mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-12 22:22:24 +00:00
[Core] Replace deprecated ShellCode:: with Symfony Command:: for status (#737)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
974d5ee347
commit
b422a9d747
|
@ -10,7 +10,8 @@ use Rector\Core\Console\ConsoleApplication;
|
|||
use Rector\Core\Console\Style\SymfonyStyleFactory;
|
||||
use Rector\Core\DependencyInjection\RectorContainerFactory;
|
||||
use Rector\Core\HttpKernel\RectorKernel;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
|
||||
// @ intentionally: continue anyway
|
||||
|
@ -57,7 +58,7 @@ try {
|
|||
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
||||
} catch (Throwable $throwable) {
|
||||
// for json output
|
||||
$argvInput = new \Symfony\Component\Console\Input\ArgvInput();
|
||||
$argvInput = new ArgvInput();
|
||||
$outputFormat = $argvInput->getParameterOption('--' . Option::OUTPUT_FORMAT);
|
||||
|
||||
// report fatal error in json format
|
||||
|
@ -72,7 +73,7 @@ try {
|
|||
$symfonyStyle->error($throwable->getMessage());
|
||||
}
|
||||
|
||||
exit(ShellCode::ERROR);
|
||||
exit(Command::FAILURE);
|
||||
}
|
||||
|
||||
/** @var ConsoleApplication $application */
|
||||
|
|
|
@ -101,8 +101,7 @@ final class ClassMethodParameterTypeManipulator
|
|||
Param $param,
|
||||
ClassMethod $classMethod,
|
||||
array $methodsReturningClassInstance
|
||||
): void
|
||||
{
|
||||
): void {
|
||||
if ($classMethod->stmts === null) {
|
||||
return;
|
||||
}
|
||||
|
@ -126,8 +125,7 @@ final class ClassMethodParameterTypeManipulator
|
|||
Param $param,
|
||||
MethodCall $methodCall,
|
||||
array $methodsReturningClassInstance
|
||||
): void
|
||||
{
|
||||
): void {
|
||||
$paramName = $this->nodeNameResolver->getName($param->var);
|
||||
if ($paramName === null) {
|
||||
return;
|
||||
|
@ -159,8 +157,7 @@ final class ClassMethodParameterTypeManipulator
|
|||
string $paramName,
|
||||
MethodCall $methodCall,
|
||||
array $methodsReturningClassInstance
|
||||
): bool
|
||||
{
|
||||
): bool {
|
||||
if (! $this->nodeNameResolver->isName($methodCall->var, $paramName)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -115,21 +115,22 @@ CODE_SAMPLE
|
|||
return true;
|
||||
}
|
||||
|
||||
/** @var Scope $scope */
|
||||
$scope = $foreach->expr->getAttribute(AttributeKey::SCOPE);
|
||||
|
||||
if (! $scope instanceof Scope) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
$type = $scope->getType($foreach->expr);
|
||||
|
||||
if ($type instanceof ObjectType) {
|
||||
return $type->isIterable()->yes();
|
||||
return $type->isIterable()
|
||||
->yes();
|
||||
}
|
||||
|
||||
if ($type instanceof ThisType) {
|
||||
return $type->isIterable()->yes();
|
||||
return $type->isIterable()
|
||||
->yes();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -195,8 +195,7 @@ CODE_SAMPLE
|
|||
private function resolveParentReflectionMethod(
|
||||
ClassReflection $classReflection,
|
||||
string $methodName
|
||||
): ?ReflectionMethod
|
||||
{
|
||||
): ?ReflectionMethod {
|
||||
if (! $classReflection->hasMethod($methodName)) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -73,10 +73,7 @@ CODE_SAMPLE
|
|||
*/
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
if ($node->returnType instanceof Name && $this->nodeNameResolver->isName(
|
||||
$node->returnType,
|
||||
'self'
|
||||
)) {
|
||||
if ($node->returnType instanceof Name && $this->nodeNameResolver->isName($node->returnType, 'self')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -195,7 +195,10 @@ final class PromotedPropertyCandidateResolver
|
|||
}
|
||||
|
||||
// different types, not a good to fit
|
||||
return ! $isAllFullyQualifiedObjectType && ! $this->typeComparator->areTypesEqual($propertyType, $matchedParamType);
|
||||
return ! $isAllFullyQualifiedObjectType && ! $this->typeComparator->areTypesEqual(
|
||||
$propertyType,
|
||||
$matchedParamType
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,8 +6,8 @@ namespace Rector\Core\Application;
|
|||
|
||||
use DateTime;
|
||||
use Rector\Core\Exception\VersionException;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
/**
|
||||
* Inspired by https://github.com/composer/composer/blob/master/src/Composer/Composer.php
|
||||
|
@ -28,7 +28,7 @@ final class VersionResolver
|
|||
public static function resolvePackageVersion(): string
|
||||
{
|
||||
$process = new Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
if ($process->run() !== ShellCode::SUCCESS) {
|
||||
if ($process->run() !== Command::SUCCESS) {
|
||||
throw new VersionException(
|
||||
'You must ensure to run compile from composer git repository clone and that git binary is available.'
|
||||
);
|
||||
|
@ -41,7 +41,7 @@ final class VersionResolver
|
|||
public static function resolverReleaseDateTime(): DateTime
|
||||
{
|
||||
$process = new Process(['git', 'log', '-n1', '--pretty=%ci', 'HEAD'], __DIR__);
|
||||
if ($process->run() !== ShellCode::SUCCESS) {
|
||||
if ($process->run() !== Command::SUCCESS) {
|
||||
throw new VersionException(
|
||||
'You must ensure to run compile from composer git repository clone and that git binary is available.'
|
||||
);
|
||||
|
|
|
@ -14,7 +14,6 @@ use Symfony\Component\Console\Input\InputInterface;
|
|||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
use Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use Symplify\SmartFileSystem\SmartFileSystem;
|
||||
|
||||
|
@ -63,7 +62,7 @@ final class InitCommand extends Command
|
|||
$this->symfonyStyle->success('"rector.php" config file was added');
|
||||
}
|
||||
|
||||
return ShellCode::SUCCESS;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function resolveTemplateFilePathByType(string $templateType): string
|
||||
|
|
|
@ -29,7 +29,6 @@ use Symfony\Component\Console\Input\InputArgument;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class ProcessCommand extends Command
|
||||
{
|
||||
|
@ -185,15 +184,15 @@ final class ProcessCommand extends Command
|
|||
{
|
||||
// some errors were found → fail
|
||||
if ($processResult->getErrors() !== []) {
|
||||
return ShellCode::ERROR;
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
// inverse error code for CI dry-run
|
||||
if (! $configuration->isDryRun()) {
|
||||
return ShellCode::SUCCESS;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
return $processResult->getFileDiffs() === [] ? ShellCode::SUCCESS : ShellCode::ERROR;
|
||||
return $processResult->getFileDiffs() === [] ? Command::SUCCESS : Command::FAILURE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -15,7 +15,6 @@ use Symfony\Component\Console\Command\Command;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class ShowCommand extends Command
|
||||
{
|
||||
|
@ -52,7 +51,7 @@ final class ShowCommand extends Command
|
|||
|
||||
$this->reportLoadedRectors($outputFormat);
|
||||
|
||||
return ShellCode::SUCCESS;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
private function reportLoadedRectors(string $outputFormat): void
|
||||
|
|
|
@ -7,8 +7,8 @@ namespace Rector\Core\Reporting;
|
|||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
|
||||
use Rector\PostRector\Contract\Rector\PostRectorInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class MissingRectorRulesReporter
|
||||
{
|
||||
|
@ -40,7 +40,7 @@ final class MissingRectorRulesReporter
|
|||
|
||||
$this->report();
|
||||
|
||||
return ShellCode::ERROR;
|
||||
return Command::FAILURE;
|
||||
}
|
||||
|
||||
public function report(): void
|
||||
|
|
|
@ -8,7 +8,6 @@ use Symfony\Component\Console\Command\Command;
|
|||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Symplify\PackageBuilder\Console\ShellCode;
|
||||
|
||||
final class DowngradePathsCommand extends Command
|
||||
{
|
||||
|
@ -76,7 +75,7 @@ final class DowngradePathsCommand extends Command
|
|||
$downgradePathsLine = implode(';', $downgradePaths);
|
||||
echo $downgradePathsLine . PHP_EOL;
|
||||
|
||||
return ShellCode::SUCCESS;
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user