refactor(Process): fromShellCommandLine
This commit is contained in:
parent
cb424805f8
commit
7f6d71c2a3
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user