8000 [Process] throw when PhpProcess::fromShellCommandLine() is used by Guikingone · Pull Request #35641 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Process] throw when PhpProcess::fromShellCommandLine() is used #35641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Symfony/Component/Process/PhpProcess.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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