1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 08:32:56 +00:00

Stop relying on OS to find executables on Windows, and migrate most Process calls to array syntax (#12180)

Co-authored-by: Jordi Boggiano <j.boggiano@seld.be>
This commit is contained in:
Nicolas Grekas 2024-11-06 13:49:06 +01:00 committed by GitHub
parent 5a75d32414
commit 3dc279cf66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 714 additions and 584 deletions

View file

@ -57,16 +57,16 @@ class ProcessExecutorMock extends ProcessExecutor
}
/**
* @param array<string|array{cmd: string|list<string>, return?: int, stdout?: string, stderr?: string, callback?: callable}> $expectations
* @param array<string|non-empty-list<string>|array{cmd: string|non-empty-list<string>, return?: int, stdout?: string, stderr?: string, callback?: callable}> $expectations
* @param bool $strict set to true if you want to provide *all* expected commands, and not just a subset you are interested in testing
* @param array{return: int, stdout?: string, stderr?: string} $defaultHandler default command handler for undefined commands if not in strict mode
*/
public function expects(array $expectations, bool $strict = false, array $defaultHandler = ['return' => 0, 'stdout' => '', 'stderr' => '']): void
{
/** @var array{cmd: string|list<string>, return: int, stdout: string, stderr: string, callback: callable|null} $default */
/** @var array{cmd: string|non-empty-list<string>, return: int, stdout: string, stderr: string, callback: callable|null} $default */
$default = ['cmd' => '', 'return' => 0, 'stdout' => '', 'stderr' => '', 'callback' => null];
$this->expectations = array_map(static function ($expect) use ($default): array {
if (is_string($expect)) {
if (is_string($expect) || array_is_list($expect)) {
$command = $expect;
$expect = $default;
$expect['cmd'] = $command;