Skip to content

Commit

Permalink
refactor(Process): fromShellCommandLine
Browse files Browse the repository at this point in the history
  • Loading branch information
Guikingone committed Feb 7, 2020
1 parent cb42480 commit 7f6d71c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Symfony/Component/Process/PhpProcess.php
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Process;

use Symfony\Component\Process\Exception\LogicException;
use Symfony\Component\Process\Exception\RuntimeException;

/**
Expand Down Expand Up @@ -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.
*
Expand Down
11 changes: 11 additions & 0 deletions src/Symfony/Component/Process/Tests/PhpProcessTest.php
Expand Up @@ -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;

Expand Down Expand Up @@ -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(<<<PHP
<?php echo 'Hello World!';
PHP
);
}
}

0 comments on commit 7f6d71c

Please sign in to comment.