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

Commit 43bcb81

Browse filesBrowse files
authored
Fix Symfony 7.3 deprecations (#55711)
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent 3c86472 commit 43bcb81
Copy full SHA for 43bcb81

File tree

Expand file treeCollapse file tree

2 files changed

+25
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+25
-5
lines changed

‎src/Illuminate/Console/Application.php

Copy file name to clipboardExpand all lines: src/Illuminate/Console/Application.php
+13-5Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
use Illuminate\Contracts\Container\Container;
99
use Illuminate\Contracts\Events\Dispatcher;
1010
use Illuminate\Support\ProcessUtils;
11+
use ReflectionClass;
1112
use Symfony\Component\Console\Application as SymfonyApplication;
13+
use Symfony\Component\Console\Attribute\AsCommand;
1214
use Symfony\Component\Console\Command\Command as SymfonyCommand;
1315
use Symfony\Component\Console\Exception\CommandNotFoundException;
1416
use Symfony\Component\Console\Input\ArrayInput;
@@ -239,12 +241,18 @@ protected function addToParent(SymfonyCommand $command)
239241
*/
240242
public function resolve($command)
241243
{
242-
if (is_subclass_of($command, SymfonyCommand::class) && ($commandName = $command::getDefaultName())) {
243-
foreach (explode('|', $commandName) as $name) {
244-
$this->commandMap[$name] = $command;
245-
}
244+
if (is_subclass_of($command, SymfonyCommand::class)) {
245+
$attribute = (new ReflectionClass($command))->getAttributes(AsCommand::class);
246+
247+
$commandName = ! empty($attribute) ? $attribute[0]->newInstance()->name : null;
246248

247-
return null;
249+
if (! is_null($commandName)) {
250+
foreach (explode('|', $commandName) as $name) {
251+
$this->commandMap[$name] = $command;
252+
}
253+
254+
return null;
255+
}
248256
}
249257

250258
if ($command instanceof Command) {

‎tests/Console/CommandMutexTest.php

Copy file name to clipboardExpand all lines: tests/Console/CommandMutexTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@
77
use Illuminate\Contracts\Console\Isolatable;
88
use Illuminate\Foundation\Application;
99
use Mockery as m;
10+
use Orchestra\Testbench\Concerns\InteractsWithMockery;
1011
use PHPUnit\Framework\TestCase;
1112
use Symfony\Component\Console\Input\ArrayInput;
1213
use Symfony\Component\Console\Output\NullOutput;
1314

1415
class CommandMutexTest extends TestCase
1516
{
17+
use InteractsWithMockery;
18+
1619
/**
1720
* @var Command
1821
*/
@@ -23,6 +26,8 @@ class CommandMutexTest extends TestCase
2326
*/
2427
protected $commandMutex;
2528

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

50+
/** {@inheritdoc} */
51+
#[\Override]
52+
protected function tearDown(): void
53+
{
54+
$this->tearDownTheTestEnvironmentUsingMockery();
55+
}
56+
4557
public function testCanRunIsolatedCommandIfNotBlocked()
4658
{
4759
$this->commandMutex->shouldReceive('create')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.