Skip to content

Commit 62328c7

Browse files
committed
final touch: early return on null first argument
1 parent 7415d8d commit 62328c7

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Console/ConsoleApplication.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@ final class ConsoleApplication extends Application
2424
private const string NAME = 'Rector';
2525

2626
/**
27-
* @var array<string|null>
27+
* @var string[]
2828
*/
2929
private const array ALLOWED_COMMANDS = [
30-
// null is for example: bin/rector --version
31-
null,
32-
33-
// default commands
3430
'custom-rule',
3531
'process',
3632
'list',
@@ -75,12 +71,15 @@ public function doRun(InputInterface $input, OutputInterface $output): int
7571

7672
$commandName = $input->getFirstArgument();
7773

74+
if ($commandName === null) {
75+
return parent::doRun($input, $output);
76+
}
77+
7878
// if paths exist or if the command name is not the first argument but with --option, eg:
7979
// bin/rector src
8080
// bin/rector --only "RemovePhpVersionIdCheckRector"
8181
// file_exists() can check directory and file
82-
if (is_string($commandName) && (
83-
file_exists($commandName) || isset($_SERVER['argv'][1])
82+
if ((file_exists($commandName) || isset($_SERVER['argv'][1])
8483
&& $commandName !== $_SERVER['argv'][1]
8584
// ensure verify has parameter option, eg: --only
8685
&& $input->hasParameterOption($_SERVER['argv'][1])

0 commit comments

Comments
 (0)