Skip to content

Commit 0bc0f45

Browse files
committed
Merge branch '7.3' into 7.4
* 7.3: fix test Restore Relay 8.5 test account for PHP_ZTS being a boolean value on PHP 8.4+ [Intl] Update data to ICU 78.1 [Notifier][Smsbox] Add tests for `Mode` enum [DependencyInjection] Remove unused variable [Console] Fix exception message when abbreviation matches multiple hidden commands [FrameworkBundle] Fix TypeError when traversing scalar values in debug:config [DependencyInjection] Fix loop corruption in CheckTypeDeclarationsPass [Security] Fix UserBadge validation bypass via identifier normalizer [DependencyInjection] Fix invalid PHP syntax for nullable TypedReference in PhpDumper Fix typo in comment [Translation][Routing] Fix typos [Config] Fix nullable EnumNode with BackedEnum [String] Fix normalization in trimPrefix/trimSuffix
2 parents 4155b9f + 87ca0e4 commit 0bc0f45

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Application.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,9 @@ public function find(string $name): Command
802802
}
803803
}
804804

805-
$command = $this->get(reset($commands));
805+
$command = $commands ? $this->get(reset($commands)) : null;
806806

807-
if ($command->isHidden()) {
807+
if (!$command || $command->isHidden()) {
808808
throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
809809
}
810810

Tests/ApplicationTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,21 @@ public function testOriginalHandlerRestoredAfterPop()
26272627
$this->assertSame(\SIG_DFL, pcntl_signal_get_handler(\SIGUSR1), 'OS-level handler must remain SIG_DFL after a second run.');
26282628
}
26292629

2630+
public function testFindAmbiguousHiddenCommands()
2631+
{
2632+
$application = new Application();
2633+
2634+
$application->addCommand(new Command('test:foo'));
2635+
$application->addCommand(new Command('test:foobar'));
2636+
$application->get('test:foo')->setHidden(true);
2637+
$application->get('test:foobar')->setHidden(true);
2638+
2639+
$this->expectException(CommandNotFoundException::class);
2640+
$this->expectExceptionMessage('The command "t:f" does not exist.');
2641+
2642+
$application->find('t:f');
2643+
}
2644+
26302645
#[RequiresPhpExtension('pcntl')]
26312646
#[TestWith([false])]
26322647
#[TestWith([4])]

0 commit comments

Comments
 (0)