diff --git a/.github/workflows/databases.yml b/.github/workflows/databases.yml index 41bb82da9666..754b43b8df99 100644 --- a/.github/workflows/databases.yml +++ b/.github/workflows/databases.yml @@ -29,8 +29,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -40,6 +38,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -74,8 +75,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -85,6 +84,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -119,8 +121,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -130,6 +130,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -165,8 +168,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -176,6 +177,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -209,8 +213,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -220,6 +222,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: diff --git a/.github/workflows/facades.yml b/.github/workflows/facades.yml index af8eb9b60223..93772d1427c7 100644 --- a/.github/workflows/facades.yml +++ b/.github/workflows/facades.yml @@ -19,8 +19,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/queues.yml b/.github/workflows/queues.yml index ef08a648a1fe..1856f6b5b194 100644 --- a/.github/workflows/queues.yml +++ b/.github/workflows/queues.yml @@ -19,8 +19,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -30,6 +28,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -53,8 +54,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -64,6 +63,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -95,8 +97,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -106,6 +106,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: @@ -126,8 +129,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Download & Extract beanstalkd run: curl -L https://github.com/beanstalkd/beanstalkd/archive/refs/tags/v1.13.tar.gz | tar xz @@ -144,6 +145,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 76a0be9b42e5..9fb6fdfcf74f 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,8 +21,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -31,6 +29,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Install dependencies uses: nick-fields/retry@v3 with: diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1a4feecb7ce0..079f71a40337 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -47,8 +47,6 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -62,6 +60,9 @@ jobs: REDIS_CONFIGURE_OPTS: --enable-redis --enable-redis-igbinary --enable-redis-msgpack --enable-redis-lzf --with-liblzf --enable-redis-zstd --with-libzstd --enable-redis-lz4 --with-liblz4 REDIS_LIBS: liblz4-dev, liblzf-dev, libzstd-dev + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Set minimum PHP 8.1 versions uses: nick-fields/retry@v3 with: @@ -121,8 +122,6 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - with: - fetch-depth: 0 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -132,6 +131,9 @@ jobs: tools: composer:v2 coverage: none + - name: Set Framework version + run: composer config version "10.x-dev" + - name: Set Minimum PHP 8.1 Versions uses: nick-fields/retry@v3 with: diff --git a/src/Illuminate/Console/Application.php b/src/Illuminate/Console/Application.php index 98536ce41eec..d880f8df63d3 100755 --- a/src/Illuminate/Console/Application.php +++ b/src/Illuminate/Console/Application.php @@ -237,7 +237,9 @@ protected function addToParent(SymfonyCommand $command) public function resolve($command) { if (is_subclass_of($command, SymfonyCommand::class) && ($commandName = $command::getDefaultName())) { - $this->commandMap[$commandName] = $command; + foreach (explode('|', $commandName) as $name) { + $this->commandMap[$name] = $command; + } return null; } diff --git a/tests/Integration/Console/ConsoleApplicationTest.php b/tests/Integration/Console/ConsoleApplicationTest.php index 9daafb57c89a..bd54013c0649 100644 --- a/tests/Integration/Console/ConsoleApplicationTest.php +++ b/tests/Integration/Console/ConsoleApplicationTest.php @@ -2,20 +2,27 @@ namespace Illuminate\Tests\Integration\Console; +use Illuminate\Console\Application as Artisan; use Illuminate\Console\Command; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Console\QueuedCommand; use Illuminate\Support\Facades\Queue; use Orchestra\Testbench\TestCase; +use Symfony\Component\Console\Attribute\AsCommand; class ConsoleApplicationTest extends TestCase { protected function setUp(): void { - parent::setUp(); + Artisan::starting(function ($artisan) { + $artisan->resolveCommands([ + FooCommandStub::class, + ZondaCommandStub::class, + ]); + }); - $this->app[Kernel::class]->registerCommand(new FooCommandStub); + parent::setUp(); } public function testArtisanCallUsingCommandName() @@ -25,6 +32,13 @@ public function testArtisanCallUsingCommandName() ])->assertExitCode(0); } + public function testArtisanCallUsingCommandNameAliases() + { + $this->artisan('app:foobar', [ + 'id' => 1, + ])->assertExitCode(0); + } + public function testArtisanCallUsingCommandClass() { $this->artisan(FooCommandStub::class, [ @@ -32,6 +46,20 @@ public function testArtisanCallUsingCommandClass() ])->assertExitCode(0); } + public function testArtisanCallUsingCommandNameUsingAsCommandAttribute() + { + $this->artisan('zonda', [ + 'id' => 1, + ])->assertExitCode(0); + } + + public function testArtisanCallUsingCommandNameAliasesUsingAsCommandAttribute() + { + $this->artisan('app:zonda', [ + 'id' => 1, + ])->assertExitCode(0); + } + public function testArtisanCallNow() { $exitCode = $this->artisan('foo:bar', [ @@ -86,6 +114,21 @@ class FooCommandStub extends Command { protected $signature = 'foo:bar {id}'; + protected $aliases = ['app:foobar']; + + public function handle() + { + // + } +} + +#[AsCommand(name: 'zonda', aliases: ['app:zonda'])] +class ZondaCommandStub extends Command +{ + protected $signature = 'zonda {id}'; + + protected $aliases = ['app:zonda']; + public function handle() { //