10000 bug #35641 [Process] throw when PhpProcess::fromShellCommandLine() is… · symfony/symfony@2d89ed1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d89ed1

Browse files
committed
bug #35641 [Process] throw when PhpProcess::fromShellCommandLine() is used (Guikingone)
This PR was merged into the 4.4 branch. Discussion ---------- [Process] throw when PhpProcess::fromShellCommandLine() is used | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #35637 | License | MIT | Doc PR | None Close #35638 Final PR (rebased and tests added) Commits ------- 7f6d71c refactor(Process): fromShellCommandLine
2 parents 138439a + 7f6d71c commit 2d89ed1

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Symfony/Component/Process/PhpProcess.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Process;
1313

14+
use Symfony\Component\Process\Exception\LogicException;
1415
use Symfony\Component\Process\Exception\RuntimeException;
1516

1617
/**
@@ -49,6 +50,14 @@ public function __construct(string $script, string $cwd = null, array $env = nul
4950
parent::__construct($php, $cwd, $env, $script, $timeout);
5051
}
5152

53+
/**
54+
* {@inheritdoc}
55+
*/
56+
public static function fromShellCommandline(string $command, string $cwd = null, array $env = null, $input = null, ?float $timeout = 60)
57+
{
58+
throw new LogicException(sprintf('The "%s()" method cannot be called when using "%s".', __METHOD__, self::class));
59+
}
60+
5261
/**
5362
* Sets the path to the PHP binary to use.
5463
*

src/Symfony/Component/Process/Tests/PhpProcessTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\Process\Tests;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Process\Exception\LogicException;
1516
use Symfony\Component\Process\PhpExecutableFinder;
1617
use Symfony\Component\Process\PhpProcess;
1718

@@ -60,4 +61,14 @@ public function testPassingPhpExplicitly()
6061
$process->run();
6162
$this->assertEquals($expected, $process->getOutput());
6263
}
64+
65+
public function testProcessCannotBeCreatedUsingFromShellCommandLine()
66+
{
67+
static::expectException(LogicException::class);
68+
static::expectExceptionMessage('The "Symfony\Component\Process\PhpProcess::fromShellCommandline()" method cannot be called when using "Symfony\Component\Process\PhpProcess".');
69+
PhpProcess::fromShellCommandline(<<<PHP
70+
<?php echo 'Hello World!';
71+
PHP
72+
);
73+
}
6374
}

0 commit comments

Comments
 (0)
0