1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-11 01:22:54 +00:00

Add parameter types to all the things

This commit is contained in:
Jordi Boggiano 2022-02-22 16:47:09 +01:00
parent c9baeda95b
commit 6da38f83a0
No known key found for this signature in database
GPG key ID: 7BBD42C429EC80BC
279 changed files with 1377 additions and 1504 deletions

View file

@ -49,7 +49,7 @@ class ProcessExecutorMock extends ProcessExecutor
*
* @return void
*/
public function expects(array $expectations, $strict = false, array $defaultHandler = array('return' => 0, 'stdout' => '', 'stderr' => '')): void
public function expects(array $expectations, bool $strict = false, array $defaultHandler = array('return' => 0, 'stdout' => '', 'stderr' => '')): void
{
/** @var array{cmd: string|list<string>, return?: int, stdout?: string, stderr?: string, callback?: callable} $default */
$default = array('cmd' => '', 'return' => 0, 'stdout' => '', 'stderr' => '', 'callback' => null);
@ -105,6 +105,7 @@ class ProcessExecutorMock extends ProcessExecutor
public function execute($command, &$output = null, $cwd = null): int
{
$cwd = $cwd ?? Platform::getCwd();
if (func_num_args() > 1) {
return $this->doExecute($command, $cwd, false, $output);
}
@ -114,6 +115,7 @@ class ProcessExecutorMock extends ProcessExecutor
public function executeTty($command, $cwd = null): int
{
$cwd = $cwd ?? Platform::getCwd();
if (Platform::isTty()) {
return $this->doExecute($command, $cwd, true);
}
@ -125,10 +127,10 @@ class ProcessExecutorMock extends ProcessExecutor
* @param string|list<string> $command
* @param string $cwd
* @param bool $tty
* @param callable $output
* @param callable|string|null $output
* @return mixed
*/
private function doExecute($command, $cwd, $tty, &$output = null)
private function doExecute($command, string $cwd, bool $tty, &$output = null)
{
$this->captureOutput = func_num_args() > 3;
$this->errorOutput = '';
@ -174,7 +176,7 @@ class ProcessExecutorMock extends ProcessExecutor
return $return;
}
public function executeAsync($command, $cwd = null): PromiseInterface
public function executeAsync($command, ?string $cwd = null): PromiseInterface
{
$resolver = function ($resolve, $reject): void {
// TODO strictly speaking this should resolve with a mock Process instance here