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 9, 2018
1 parent d4f9ac9 commit 34b954a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
@@ -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.