refactor(Process): fromShellCommandLine

This commit is contained in:
Loulier Guillaume 2020-02-07 19:31:10 +01:00
parent cb424805f8
commit 7f6d71c2a3
No known key found for this signature in database
GPG Key ID: 84965059F6BAB169
2 changed files with 20 additions and 0 deletions

View File

@ -11,6 +11,7 @@
namespace Symfony\Component\Process;
use Symfony\Component\Process\Exception\LogicException;
use Symfony\Component\Process\Exception\RuntimeException;
/**
@ -49,6 +50,14 @@ class PhpProcess extends Process
parent::__construct($php, $cwd, $env, $script, $timeout);
}
/**
* {@inheritdoc}
*/
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
{
throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
}
/**
* Sets the path to the PHP binary to use.
*

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Process\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Process\Exception\LogicException;
use Symfony\Component\Process\PhpExecutableFinder;
use Symfony\Component\Process\PhpProcess;
@ -60,4 +61,14 @@ PHP;
$process->run();
$this->assertEquals($expected, $process->getOutput());
}
public function testProcessCannotBeCreatedUsingFromShellCommandLine()
{
static::expectException(LogicException::class);
static::expectExceptionMessage('The "Symfony\Component\Process\PhpProcess::fromShellCommandline()" method cannot be called when using "Symfony\Component\Process\PhpProcess".');
PhpProcess::fromShellCommandline(<<<PHP
<?php echo 'Hello World!';
PHP
);
}
}