Skip to content

Commit 8b13301

Browse files
bug symfony#52427 [Console][Process] do not let context classes extend the message classes (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [Console][Process] do not let context classes extend the message classes | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT Commits ------- d96479d do not let context classes extend the message classes
2 parents 6c3d377 + d96479d commit 8b13301

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

src/Symfony/Component/Console/Messenger/RunCommandContext.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
/**
1515
* @author Kevin Bond <kevinbond@gmail.com>
1616
*/
17-
final class RunCommandContext extends RunCommandMessage
17+
final class RunCommandContext
1818
{
19-
public function __construct(RunCommandMessage $message, public readonly int $exitCode, public readonly string $output)
20-
{
21-
parent::__construct($message->input, $message->throwOnFailure, $message->catchExceptions);
19+
public function __construct(
20+
public readonly RunCommandMessage $message,
21+
public readonly int $exitCode,
22+
public readonly string $output,
23+
) {
2224
}
2325
}

src/Symfony/Component/Process/Messenger/RunProcessContext.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@
1616
/**
1717
* @author Kevin Bond <kevinbond@gmail.com>
1818
*/
19-
final class RunProcessContext extends RunProcessMessage
19+
final class RunProcessContext
2020
{
2121
public readonly ?int $exitCode;
2222
public readonly ?string $output;
2323
public readonly ?string $errorOutput;
2424

25-
public function __construct(RunProcessMessage $message, Process $process)
26-
{
27-
parent::__construct($message->command, $message->cwd, $message->env, $message->input, $message->timeout);
28-
25+
public function __construct(
26+
public readonly RunProcessMessage $message,
27+
Process $process,
28+
) {
2929
$this->exitCode = $process->getExitCode();
3030
$this->output = $process->isOutputDisabled() ? null : $process->getOutput();
3131
$this->errorOutput = $process->isOutputDisabled() ? null : $process->getErrorOutput();

src/Symfony/Component/Process/Tests/Messenger/RunProcessMessageHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testRunSuccessfulProcess()
2222
{
2323
$context = (new RunProcessMessageHandler())(new RunProcessMessage(['ls'], cwd: __DIR__));
2424

25-
$this->assertSame(['ls'], $context->command);
25+
$this->assertSame(['ls'], $context->message->command);
2626
$this->assertSame(0, $context->exitCode);
2727
$this->assertStringContainsString(basename(__FILE__), $context->output);
2828
}
@@ -32,7 +32,7 @@ public function testRunFailedProcess()
3232
try {
3333
(new RunProcessMessageHandler())(new RunProcessMessage(['invalid']));
3434
} catch (RunProcessFailedException $e) {
35-
$this->assertSame(['invalid'], $e->context->command);
35+
$this->assertSame(['invalid'], $e->context->message->command);
3636
$this->assertSame('\\' === \DIRECTORY_SEPARATOR ? 1 : 127, $e->context->exitCode);
3737

3838
return;

0 commit comments

Comments
 (0)