diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 126d9b754fa8..22fc1b385afc 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Process; +use Symfony\Component\Process\Exception\LogicException; use Symfony\Component\Process\Exception\RuntimeException; /** @@ -49,6 +50,14 @@ public function __construct(string $script, string $cwd = null, array $env = nul 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. * diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php index b7b21ebcb160..5f1e5e670062 100644 --- a/src/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -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 @@ public function testPassingPhpExplicitly() $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(<<