Skip to content

Commit d55387c

Browse files
committed
Updated Rector to commit a22afd1549cd9ab88fab1e47cfcb5b0d1cd50b49
rectorphp/rector-src@a22afd1 [DX] Define list of allowed implicit commands on ConsoleApplication (#7918)
1 parent e755a28 commit d55387c

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'a68a80e072bcba690b7c55be1b854a2916c5028e';
22+
public const PACKAGE_VERSION = 'a22afd1549cd9ab88fab1e47cfcb5b0d1cd50b49';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-03-01 18:10:33';
27+
public const RELEASE_DATE = '2026-03-01 15:56:12';
2828
/**
2929
* @var int
3030
*/

src/Console/ConsoleApplication.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@
1515
use RectorPrefix202603\Symfony\Component\Console\Input\InputInterface;
1616
use RectorPrefix202603\Symfony\Component\Console\Input\InputOption;
1717
use RectorPrefix202603\Symfony\Component\Console\Output\OutputInterface;
18+
use RectorPrefix202603\Symfony\Component\Console\Style\SymfonyStyle;
1819
use RectorPrefix202603\Webmozart\Assert\Assert;
1920
final class ConsoleApplication extends Application
2021
{
22+
/**
23+
* @readonly
24+
*/
25+
private SymfonyStyle $symfonyStyle;
2126
/**
2227
* @var string
2328
*/
2429
private const NAME = 'Rector';
2530
/**
2631
* @param Command[] $commands
2732
*/
28-
public function __construct(array $commands)
33+
public function __construct(array $commands, SymfonyStyle $symfonyStyle)
2934
{
35+
$this->symfonyStyle = $symfonyStyle;
3036
parent::__construct(self::NAME, VersionResolver::PACKAGE_VERSION);
3137
Assert::notEmpty($commands);
3238
Assert::allIsInstanceOf($commands, Command::class);
@@ -48,16 +54,22 @@ public function doRun(InputInterface $input, OutputInterface $output): int
4854
$output->write(\PHP_EOL);
4955
}
5056
$commandName = $input->getFirstArgument();
57+
if ($commandName === null) {
58+
return parent::doRun($input, $output);
59+
}
5160
// if paths exist or if the command name is not the first argument but with --option, eg:
5261
// bin/rector src
5362
// bin/rector --only "RemovePhpVersionIdCheckRector"
5463
// file_exists() can check directory and file
55-
if (is_string($commandName) && (file_exists($commandName) || isset($_SERVER['argv'][1]) && $commandName !== $_SERVER['argv'][1] && $input->hasParameterOption($_SERVER['argv'][1]))) {
64+
if (file_exists($commandName) || isset($_SERVER['argv'][1]) && $commandName !== $_SERVER['argv'][1] && $input->hasParameterOption($_SERVER['argv'][1])) {
5665
// prepend command name if implicit
5766
$privatesAccessor = new PrivatesAccessor();
5867
$tokens = $privatesAccessor->getPrivateProperty($input, 'tokens');
5968
$tokens = array_merge(['process'], $tokens);
6069
$privatesAccessor->setPrivateProperty($input, 'tokens', $tokens);
70+
} elseif (!$this->has($commandName)) {
71+
$this->symfonyStyle->error(sprintf('The following given path does not match any files or directories: %s%s', "\n\n - ", $commandName));
72+
return \Rector\Console\ExitCode::FAILURE;
6173
}
6274
return parent::doRun($input, $output);
6375
}

0 commit comments

Comments
 (0)