1 | <?php |
||
7 | final class GitCommand |
||
8 | { |
||
9 | /** |
||
10 | * Path to the directory containing the working copy. If this variable is |
||
11 | * set, then the process will change into this directory while the Git |
||
12 | * command is being run. |
||
13 | * |
||
14 | * @var string|null |
||
15 | */ |
||
16 | private $directory; |
||
17 | |||
18 | /** |
||
19 | * The command being run, e.g. "clone", "commit", etc. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | private $command = ''; |
||
24 | |||
25 | /** |
||
26 | * Whether command execution should be bypassed. |
||
27 | * |
||
28 | * @var bool |
||
29 | */ |
||
30 | private $bypass = false; |
||
31 | |||
32 | /** |
||
33 | * Whether to execute the raw command without escaping it. This is useful |
||
34 | * for executing arbitrary commands, e.g. "status -s". If this is true, |
||
35 | * any options and arguments are ignored. |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $executeRaw = false; |
||
40 | |||
41 | /** |
||
42 | * @var mixed[] |
||
43 | */ |
||
44 | private $options = []; |
||
45 | |||
46 | /** |
||
47 | * @var mixed[] |
||
48 | */ |
||
49 | private $args = []; |
||
50 | |||
51 | /** |
||
52 | * @param mixed ...$argsAndOptions |
||
53 | */ |
||
54 | public function __construct(string $command = '', ...$argsAndOptions) |
||
68 | |||
69 | /** |
||
70 | * Returns Git command being run, e.g. "clone", "commit", etc. |
||
71 | * @api |
||
72 | */ |
||
73 | public function getCommand(): string |
||
77 | |||
78 | public function setDirectory(?string $directory): void |
||
82 | |||
83 | public function getDirectory(): ?string |
||
87 | |||
88 | /** |
||
89 | * A bool flagging whether to skip running the command. |
||
90 | */ |
||
91 | public function bypass(bool $bypass = true): void |
||
95 | |||
96 | /** |
||
97 | * Set whether to execute the command as-is without escaping it. |
||
98 | */ |
||
99 | public function executeRaw(bool $executeRaw = true): void |
||
103 | |||
104 | /** |
||
105 | * Returns true if the Git command should be run. |
||
106 | */ |
||
107 | public function notBypassed(): bool |
||
111 | |||
112 | /** |
||
113 | * @param mixed[]|string|true $value The option's value, pass true if the options is a flag. |
||
114 | */ |
||
115 | public function setOption(string $option, $value): void |
||
119 | |||
120 | /** |
||
121 | * @api |
||
122 | * @param mixed[] $options |
||
123 | */ |
||
124 | public function setOptions(array $options): void |
||
130 | |||
131 | public function setFlag(string $option): void |
||
135 | |||
136 | /** |
||
137 | * @api |
||
138 | */ |
||
139 | public function getOption(string $option, $default = null) |
||
143 | |||
144 | public function addArgument(string $arg): void |
||
148 | |||
149 | /** |
||
150 | * Renders the arguments and options for the Git command. |
||
151 | * |
||
152 | * @return string|string[] |
||
153 | */ |
||
154 | public function getCommandLine() |
||
172 | |||
173 | /** |
||
174 | * Builds the command line options for use in the Git command. |
||
175 | * |
||
176 | * @return mixed[] |
||
177 | */ |
||
178 | private function buildOptions(): array |
||
196 | } |
||
197 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: