Skip to content
Permalink
Browse files

Clean up the php process command builder

* Gets rid of the need for eval-stdin.php in phpdbg with the s option
* Only include the args separator when a file is not given
  • Loading branch information
kabel authored and sebastianbergmann committed Jul 8, 2018
1 parent d4f9ac9 commit 34b954a2326d60cdf59566aaef51b7c670fa59d1
Showing with 10 additions and 14 deletions.
  1. +9 −12 src/Util/PHP/AbstractPhpProcess.php
  2. +1 −2 tests/Util/PHP/AbstractPhpProcessTest.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;
}

@@ -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);

0 comments on commit 34b954a

Please sign in to comment.
You can’t perform that action at this time.