Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[11.x] Fix Symfony 7.3 deprecations #55711

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
May 12, 2025
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
18 changes: 13 additions & 5 deletions 18 src/Illuminate/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Support\ProcessUtils;
use ReflectionClass;
use Symfony\Component\Console\Application as SymfonyApplication;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command as SymfonyCommand;
use Symfony\Component\Console\Exception\CommandNotFoundException;
use Symfony\Component\Console\Input\ArrayInput;
Expand Down Expand Up @@ -239,12 +241,18 @@ protected function addToParent(SymfonyCommand $command)
*/
public function resolve($command)
{
if (is_subclass_of($command, SymfonyCommand::class) && ($commandName = $command::getDefaultName())) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overriding Command::getDefaultName() will trigger a deprecation in Symfony 7.3. And the method will be removed in Symfony 8.0

foreach (explode('|', $commandName) as $name) {
$this->commandMap[$name] = $command;
}
if (is_subclass_of($command, SymfonyCommand::class)) {
$attribute = (new ReflectionClass($command))->getAttributes(AsCommand::class);

$commandName = ! empty($attribute) ? $attribute[0]->newInstance()->name : null;

return null;
if (! is_null($commandName)) {
foreach (explode('|', $commandName) as $name) {
$this->commandMap[$name] = $command;
}

return null;
}
}

if ($command instanceof Command) {
Expand Down
12 changes: 12 additions & 0 deletions 12 tests/Console/CommandMutexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
use Illuminate\Contracts\Console\Isolatable;
use Illuminate\Foundation\Application;
use Mockery as m;
use Orchestra\Testbench\Concerns\InteractsWithMockery;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;

class CommandMutexTest extends TestCase
{
use InteractsWithMockery;

/**
* @var Command
*/
Expand All @@ -23,6 +26,8 @@ class CommandMutexTest extends TestCase
*/
protected $commandMutex;

/** {@inheritdoc} */
#[\Override]
protected function setUp(): void
{
$this->command = new class extends Command implements Isolatable
Expand All @@ -42,6 +47,13 @@ public function __invoke()
$this->command->setLaravel($app);
}

/** {@inheritdoc} */
#[\Override]
protected function tearDown(): void
{
$this->tearDownTheTestEnvironmentUsingMockery();
}
Copy link
Member Author

@crynobone crynobone May 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test uses Mockery but doesn't close on teardown.


public function testCanRunIsolatedCommandIfNotBlocked()
{
$this->commandMutex->shouldReceive('create')
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.