diff --git a/src/Util/PHP/AbstractPhpProcess.php b/src/Util/PHP/AbstractPhpProcess.php index bacc3eee532..fba0b9600b8 100644 --- a/src/Util/PHP/AbstractPhpProcess.php +++ b/src/Util/PHP/AbstractPhpProcess.php @@ -180,24 +180,21 @@ public function getCommand(array $settings, string $file = null): string $command .= $this->settingsToParameters($settings); if (\PHP_SAPI === 'phpdbg') { - $command .= ' -qrr '; + $command .= ' -qrr'; - if ($file) { - $command .= '-e ' . \escapeshellarg($file); - } else { - $command .= \escapeshellarg(__DIR__ . '/eval-stdin.php'); - } - } else { - if ($file) { - $command .= ' -f ' . \escapeshellarg($file); + if (!$file) { + $command .= 's='; } + } - if ($this->args) { - $command .= ' --'; - } + if ($file) { + $command .= ' ' . \escapeshellarg($file); } if ($this->args) { + if (!$file) { + $command .= ' --'; + } $command .= ' ' . $this->args; } diff --git a/tests/Util/PHP/AbstractPhpProcessTest.php b/tests/Util/PHP/AbstractPhpProcessTest.php index c5a8721e255..862d5ea2dbd 100644 --- a/tests/Util/PHP/AbstractPhpProcessTest.php +++ b/tests/Util/PHP/AbstractPhpProcessTest.php @@ -83,8 +83,7 @@ public function testShouldUseArgsToCreateCommand(): void public function testShouldHaveFileToCreateCommand(): void { - $argumentEscapingCharacter = \DIRECTORY_SEPARATOR === '\\' ? '"' : '\''; - $expectedCommandFormat = \sprintf('%%s -%%c %1$sfile.php%1$s', $argumentEscapingCharacter); + $expectedCommandFormat = '%s %cfile.php%c'; $actualCommand = $this->phpProcess->getCommand([], 'file.php'); $this->assertStringMatchesFormat($expectedCommandFormat, $actualCommand);