1 | <?php |
||
26 | final class GitWrapper |
||
27 | { |
||
28 | /** |
||
29 | * Path to the Git binary. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | private $gitBinary; |
||
34 | |||
35 | /** |
||
36 | * The timeout of the Git command in seconds. |
||
37 | * |
||
38 | * @var int |
||
39 | */ |
||
40 | private $timeout = 60; |
||
41 | |||
42 | /** |
||
43 | * Environment variables defined in the scope of the Git command. |
||
44 | * |
||
45 | * @var string[] |
||
46 | */ |
||
47 | private $env = []; |
||
48 | |||
49 | /** |
||
50 | * @var AbstractOutputEventSubscriber |
||
51 | */ |
||
52 | private $outputEventSubscriber; |
||
53 | |||
54 | /** |
||
55 | * @var EventDispatcherInterface |
||
56 | */ |
||
57 | private $eventDispatcher; |
||
58 | |||
59 | public function __construct(?string $gitBinary = null) |
||
73 | |||
74 | public function getDispatcher(): EventDispatcherInterface |
||
78 | |||
79 | public function setDispatcher(EventDispatcherInterface $eventDispatcher): void |
||
83 | |||
84 | public function setGitBinary(string $gitBinary): void |
||
88 | |||
89 | public function getGitBinary(): string |
||
93 | |||
94 | public function setEnvVar(string $var, $value): void |
||
98 | |||
99 | public function unsetEnvVar(string $var): void |
||
103 | |||
104 | /** |
||
105 | * Returns an environment variable that is defined only in the scope of the |
||
106 | * Git command. |
||
107 | * |
||
108 | * @param string $var The name of the environment variable, e.g. "HOME", "GIT_SSH". |
||
109 | * @param mixed $default The value returned if the environment variable is not set, defaults to |
||
110 | * null. |
||
111 | */ |
||
112 | public function getEnvVar(string $var, $default = null) |
||
116 | |||
117 | /** |
||
118 | * @return string[] |
||
119 | */ |
||
120 | public function getEnvVars(): array |
||
124 | |||
125 | public function setTimeout(int $timeout): void |
||
129 | |||
130 | public function getTimeout(): int |
||
134 | |||
135 | /** |
||
136 | * Set an alternate private key used to connect to the repository. |
||
137 | * |
||
138 | * This method sets the GIT_SSH environment variable to use the wrapper |
||
139 | * script included with this library. It also sets the custom GIT_SSH_KEY |
||
140 | * and GIT_SSH_PORT environment variables that are used by the script. |
||
141 | * |
||
142 | * @param string|null $wrapper Path the the GIT_SSH wrapper script, defaults to null which uses the |
||
143 | * script included with this library. |
||
144 | */ |
||
145 | public function setPrivateKey(string $privateKey, int $port = 22, ?string $wrapper = null): void |
||
163 | |||
164 | /** |
||
165 | * Unsets the private key by removing the appropriate environment variables. |
||
166 | */ |
||
167 | public function unsetPrivateKey(): void |
||
173 | |||
174 | /** |
||
175 | * @api |
||
176 | */ |
||
177 | public function addOutputEventSubscriber(AbstractOutputEventSubscriber $gitOutputEventSubscriber): void |
||
181 | |||
182 | public function addLoggerEventSubscriber(GitLoggerEventSubscriber $gitLoggerEventSubscriber): void |
||
186 | |||
187 | /** |
||
188 | * @api |
||
189 | */ |
||
190 | public function removeOutputEventSubscriber(AbstractOutputEventSubscriber $gitOutputEventSubscriber): void |
||
194 | |||
195 | /** |
||
196 | * @api |
||
197 | * Set whether or not to stream real-time output to STDOUT and STDERR. |
||
198 | */ |
||
199 | public function streamOutput(bool $streamOutput = true): void |
||
211 | |||
212 | /** |
||
213 | * Returns an object that interacts with a working copy. |
||
214 | * |
||
215 | * @param string $directory Path to the directory containing the working copy. |
||
216 | */ |
||
217 | public function workingCopy(string $directory): GitWorkingCopy |
||
221 | |||
222 | /** |
||
223 | * Returns the version of the installed Git client. |
||
224 | */ |
||
225 | public function version(): string |
||
229 | |||
230 | /** |
||
231 | * Executes a `git init` command. |
||
232 | * |
||
233 | * Create an empty git repository or reinitialize an existing one. |
||
234 | * |
||
235 | * @param mixed[] $options An associative array of command line options. |
||
236 | */ |
||
237 | public function init(string $directory, array $options = []): GitWorkingCopy |
||
245 | |||
246 | /** |
||
247 | * Executes a `git clone` command and returns a working copy object. |
||
248 | * |
||
249 | * Clone a repository into a new directory. Use @see GitWorkingCopy::cloneRepository() |
||
250 | * instead for more readable code. |
||
251 | * |
||
252 | * @param string $directory The directory that the repository will be cloned into. If null is |
||
253 | * passed, the directory will be generated from the URL with @see GitStrings::parseRepositoryName(). |
||
254 | * @param mixed[] $options |
||
255 | */ |
||
256 | public function cloneRepository(string $repository, ?string $directory = null, array $options = []): GitWorkingCopy |
||
267 | |||
268 | /** |
||
269 | * The command is simply a raw command line entry for everything after the Git binary. |
||
270 | * For example, a `git config -l` command would be passed as `config -l` via the first argument of this method. |
||
271 | * |
||
272 | * @return string The STDOUT returned by the Git command. |
||
273 | */ |
||
274 | public function git(string $commandLine, ?string $cwd = null): string |
||
281 | |||
282 | /** |
||
283 | * @return string The STDOUT returned by the Git command. |
||
284 | */ |
||
285 | public function run(GitCommand $gitCommand, ?string $cwd = null): string |
||
295 | } |
||
296 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..