Skip to content
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
6 changes: 3 additions & 3 deletions src/Symfony/Component/Console/Command/TraceableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@
public function setCode(callable $code): static
{
if ($code instanceof InvokableCommand) {
$r = new \ReflectionFunction(\Closure::bind(function () {
return $this->code;
}, $code, InvokableCommand::class)());
$r = \Closure::bind(function () {
return $this->invokable;

Check failure on line 173 in src/Symfony/Component/Console/Command/TraceableCommand.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedThisPropertyFetch

src/Symfony/Component/Console/Command/TraceableCommand.php:173:24: UndefinedThisPropertyFetch: Instance property Symfony\Component\Console\Command\TraceableCommand::$invokable is not defined (see https://psalm.dev/041)

Check failure on line 173 in src/Symfony/Component/Console/Command/TraceableCommand.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedThisPropertyFetch

src/Symfony/Component/Console/Command/TraceableCommand.php:173:24: UndefinedThisPropertyFetch: Instance property Symfony\Component\Console\Command\TraceableCommand::$invokable is not defined (see https://psalm.dev/041)
}, $code, InvokableCommand::class)();

$this->invokableCommandInfo = [
'class' => $r->getClosureScopeClass()->name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\TraceableCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Tests\Fixtures\InvokableTestCommand;
use Symfony\Component\Console\Tests\Fixtures\LoopExampleCommand;
use Symfony\Component\Stopwatch\Stopwatch;

Expand All @@ -26,6 +27,7 @@ protected function setUp(): void
{
$this->application = new Application();
$this->application->addCommand(new LoopExampleCommand());
$this->application->addCommand(new InvokableTestCommand());
}

public function testRunIsOverriddenWithoutProfile()
Expand Down Expand Up @@ -57,6 +59,16 @@ public function testRunIsNotOverriddenWithProfile()
$this->assertLoopOutputCorrectness($output);
}

public function testRunOnInvokableCommand()
{
$command = $this->application->find('invokable:test');
$traceableCommand = new TraceableCommand($command, new Stopwatch());

$commandTester = new CommandTester($traceableCommand);
$commandTester->execute([]);
$commandTester->assertCommandIsSuccessful();
}

public function assertLoopOutputCorrectness(string $output)
{
$completeChar = '\\' !== \DIRECTORY_SEPARATOR ? '▓' : '=';
Expand Down
Loading