Updated Rector to commit 2e977bd3aad21113e0bb7e2aa9b102f6f1e9246d

2e977bd3aa deploy to original repository
This commit is contained in:
Tomas Votruba 2022-06-07 08:22:29 +00:00
parent 869b6f99f5
commit bdfd24339f
3052 changed files with 29920 additions and 30047 deletions

View File

@ -20,9 +20,9 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller;
\error_reporting(\E_ALL);
\ini_set('display_errors', 'stderr');
\gc_disable();
\define('__RECTOR_RUNNING__', \true);
\define('RectorPrefix20220607\\__RECTOR_RUNNING__', \true);
// Require Composer autoload.php
$autoloadIncluder = new \RectorPrefix20220607\AutoloadIncluder();
$autoloadIncluder = new AutoloadIncluder();
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
final class AutoloadIncluder
{
@ -33,7 +33,7 @@ final class AutoloadIncluder
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
{
// Rector's vendor is already loaded
if (\class_exists(\Rector\Core\Kernel\RectorKernel::class)) {
if (\class_exists(RectorKernel::class)) {
return;
}
// in Rector develop repository
@ -95,7 +95,6 @@ final class AutoloadIncluder
require_once $filePath;
}
}
\class_alias('RectorPrefix20220607\\AutoloadIncluder', 'AutoloadIncluder', \false);
if (\file_exists(__DIR__ . '/../preload.php') && \is_dir(__DIR__ . '/../vendor')) {
require_once __DIR__ . '/../preload.php';
}
@ -104,26 +103,26 @@ $autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-auto
$autoloadIncluder->autoloadProjectAutoloaderFile();
$autoloadIncluder->autoloadRectorInstalledAsGlobalDependency();
$autoloadIncluder->autoloadFromCommandLine();
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
$rectorConfigsResolver = new RectorConfigsResolver();
try {
$bootstrapConfigs = $rectorConfigsResolver->provide();
$rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory();
$rectorContainerFactory = new RectorContainerFactory();
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
} catch (\Throwable $throwable) {
// for json output
$argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput();
$outputFormat = $argvInput->getParameterOption('--' . \Rector\Core\Configuration\Option::OUTPUT_FORMAT);
$argvInput = new ArgvInput();
$outputFormat = $argvInput->getParameterOption('--' . Option::OUTPUT_FORMAT);
// report fatal error in json format
if ($outputFormat === \Rector\ChangesReporting\Output\JsonOutputFormatter::NAME) {
echo \RectorPrefix20220607\Nette\Utils\Json::encode(['fatal_errors' => [$throwable->getMessage()]]);
if ($outputFormat === JsonOutputFormatter::NAME) {
echo Json::encode(['fatal_errors' => [$throwable->getMessage()]]);
} else {
// report fatal errors in console format
$rectorConsoleOutputStyleFactory = new \Rector\Core\Console\Style\RectorConsoleOutputStyleFactory(new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller());
$rectorConsoleOutputStyleFactory = new RectorConsoleOutputStyleFactory(new PrivatesCaller());
$rectorConsoleOutputStyle = $rectorConsoleOutputStyleFactory->create();
$rectorConsoleOutputStyle->error($throwable->getMessage());
}
exit(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE);
exit(Command::FAILURE);
}
/** @var ConsoleApplication $application */
$application = $container->get(\Rector\Core\Console\ConsoleApplication::class);
$application = $container->get(ConsoleApplication::class);
exit($application->run());

View File

@ -51,9 +51,9 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard;
use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer;
use RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem;
use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
return static function (RectorConfig $rectorConfig) : void {
// make use of https://github.com/symplify/easy-parallel
$rectorConfig->import(\RectorPrefix20220607\Symplify\EasyParallel\ValueObject\EasyParallelConfig::FILE_PATH);
$rectorConfig->import(EasyParallelConfig::FILE_PATH);
$rectorConfig->paths([]);
$rectorConfig->skip([]);
$rectorConfig->autoloadPaths([]);
@ -81,17 +81,17 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
]);
// psr-4
$services->alias(\Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface::class, \Rector\PSR4\Composer\PSR4NamespaceMatcher::class);
$services->alias(PSR4AutoloadNamespaceMatcherInterface::class, PSR4NamespaceMatcher::class);
$services->load('Rector\\', __DIR__ . '/../rules')->exclude([__DIR__ . '/../rules/*/ValueObject/*', __DIR__ . '/../rules/*/Rector/*', __DIR__ . '/../rules/*/Contract/*', __DIR__ . '/../rules/*/Exception/*', __DIR__ . '/../rules/*/Enum/*', __DIR__ . '/../rules/DowngradePhp80/Reflection/SimplePhpParameterReflection.php']);
// parallel
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger::class);
$services->set(ParametersMerger::class);
// use faster in-memory cache in CI.
// CI always starts from scratch, therefore IO intensive caching is not worth it
$ciDetector = new \RectorPrefix20220607\OndraM\CiDetector\CiDetector();
$ciDetector = new CiDetector();
if ($ciDetector->isCiDetected()) {
$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\MemoryCacheStorage::class);
$rectorConfig->cacheClass(MemoryCacheStorage::class);
}
$extensionConfigResolver = new \Rector\Core\Bootstrap\ExtensionConfigResolver();
$extensionConfigResolver = new ExtensionConfigResolver();
$extensionConfigFiles = $extensionConfigResolver->provide();
foreach ($extensionConfigFiles as $extensionConfigFile) {
$rectorConfig->import($extensionConfigFile->getRealPath());
@ -99,43 +99,43 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
// require only in dev
$rectorConfig->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');
$services->load('Rector\\Core\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/Console/Style/RectorConsoleOutputStyle.php', __DIR__ . '/../src/Exception', __DIR__ . '/../src/DependencyInjection/CompilerPass', __DIR__ . '/../src/DependencyInjection/Loader', __DIR__ . '/../src/Kernel', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Bootstrap', __DIR__ . '/../src/Enum', __DIR__ . '/../src/PhpParser/Node/CustomNode', __DIR__ . '/../src/PhpParser/ValueObject', __DIR__ . '/../src/functions', __DIR__ . '/../src/constants.php']);
$services->alias(\RectorPrefix20220607\Symfony\Component\Console\Application::class, \Rector\Core\Console\ConsoleApplication::class);
$services->set(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
$services->set(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class);
$services->set(\PhpParser\BuilderFactory::class);
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
$services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class);
$services->set(\PhpParser\NodeFinder::class);
$services->set(\Rector\Core\Console\Style\RectorConsoleOutputStyle::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\Console\Style\RectorConsoleOutputStyleFactory::class), 'create']);
$services->set(\PHPStan\Parser\Parser::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createPHPStanParser']);
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createEmulativeLexer']);
$services->alias(Application::class, ConsoleApplication::class);
$services->set(EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', service('service_container'));
$services->set(SimpleCallableNodeTraverser::class);
$services->set(BuilderFactory::class);
$services->set(CloningVisitor::class);
$services->set(NodeConnectingVisitor::class);
$services->set(NodeFinder::class);
$services->set(RectorConsoleOutputStyle::class)->factory([service(RectorConsoleOutputStyleFactory::class), 'create']);
$services->set(Parser::class)->factory([service(PHPStanServicesFactory::class), 'createPHPStanParser']);
$services->set(Lexer::class)->factory([service(PHPStanServicesFactory::class), 'createEmulativeLexer']);
// symplify/package-builder
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard::class);
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer::class);
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter::class);
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class);
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem::class);
$services->set(\RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory::class);
$services->set(\RectorPrefix20220607\Doctrine\Inflector\Inflector::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory::class), 'build']);
$services->set(\RectorPrefix20220607\Composer\Semver\VersionParser::class);
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker::class);
$services->set(FileSystemGuard::class);
$services->set(PrivatesAccessor::class);
$services->set(PrivatesCaller::class);
$services->set(FinderSanitizer::class);
$services->set(FileSystemFilter::class);
$services->set(ParameterProvider::class)->arg('$container', service('service_container'));
$services->set(SmartFileSystem::class);
$services->set(JsonFileSystem::class);
$services->set(InflectorFactory::class);
$services->set(Inflector::class)->factory([service(InflectorFactory::class), 'build']);
$services->set(VersionParser::class);
$services->set(TypeChecker::class);
// phpdoc parser
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
$services->alias(\PHPStan\PhpDocParser\Parser\PhpDocParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser::class);
$services->alias(PhpDocParser::class, BetterPhpDocParser::class);
// cache
$services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']);
$services->set(\PHPStan\File\FileHelper::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createFileHelper']);
$services->set(\Rector\Caching\Cache::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\CacheFactory::class), 'create']);
$services->set(DependencyResolver::class)->factory([service(PHPStanServicesFactory::class), 'createDependencyResolver']);
$services->set(FileHelper::class)->factory([service(PHPStanServicesFactory::class), 'createFileHelper']);
$services->set(Cache::class)->factory([service(CacheFactory::class), 'create']);
// type resolving
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class);
$services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class);
$services->set(IntermediateSourceLocator::class);
$services->alias(TypeParser::class, BetterTypeParser::class);
// PHPStan services
$services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']);
$services->set(\PHPStan\Analyser\NodeScopeResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createNodeScopeResolver']);
$services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']);
$services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']);
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
$services->set(ReflectionProvider::class)->factory([service(PHPStanServicesFactory::class), 'createReflectionProvider']);
$services->set(NodeScopeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createNodeScopeResolver']);
$services->set(ScopeFactory::class)->factory([service(PHPStanServicesFactory::class), 'createScopeFactory']);
$services->set(TypeNodeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createTypeNodeResolver']);
$services->set(DynamicSourceLocatorProvider::class)->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ActionInjectionToConstructorInjectionRector::class);
};

File diff suppressed because one or more lines are too long

View File

@ -32,7 +32,7 @@ use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
$rectorConfig->rules([\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class, \Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class, \Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class, \Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class, \Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector::class, \Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector::class, \Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector::class, \Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class, \Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class, \Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class, \Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class, \Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class, \Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class, \Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class, \Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class, \Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class, \Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class, \Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class, \Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class, \Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class, \Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class, \Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class, \Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector::class, \Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector::class, \Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class, \Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class, \Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
$rectorConfig->rules([SeparateMultiUseImportsRector::class, RemoveDoubleUnderscoreInMethodNameRector::class, PostIncDecToPreIncDecRector::class, UnSpreadOperatorRector::class, NewlineAfterStatementRector::class, RemoveFinalFromConstRector::class, PHPStormVarAnnotationRector::class, NullableCompareToNullRector::class, BinarySwitchToIfElseRector::class, ConsistentImplodeRector::class, TernaryConditionVariableAssignmentRector::class, SymplifyQuoteEscapeRector::class, SplitGroupedConstantsAndPropertiesRector::class, StringClassNameToClassConstantRector::class, ConsistentPregDelimiterRector::class, CatchExceptionNameMatchingTypeRector::class, UseIncrementAssignRector::class, SplitDoubleAssignRector::class, VarConstantCommentRector::class, EncapsedStringsToSprintfRector::class, WrapEncapsedVariableInCurlyBracesRector::class, NewlineBeforeNewAssignSetRector::class, AddArrayDefaultToArrayPropertyRector::class, AddFalseDefaultToBoolPropertyRector::class, MakeInheritedMethodVisibilitySameAsParentRector::class, CallUserFuncArrayToVariadicRector::class, VersionCompareFuncCallToConstantRector::class]);
};

View File

@ -50,54 +50,54 @@ use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rules([
\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class,
\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class,
\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class,
\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class,
\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class,
\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class,
\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class,
\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class,
\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class,
\Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class,
\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class,
\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class,
\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadContinueRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class,
\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class,
\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class,
\Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class,
\Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class,
\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class,
\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class,
\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class,
\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class,
\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class,
\Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class,
\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class,
\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class,
\Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class,
\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
\Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class,
\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class,
\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class,
\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParamInRequiredAutowireRector::class,
UnwrapFutureCompatibleIfFunctionExistsRector::class,
UnwrapFutureCompatibleIfPhpVersionRector::class,
RecastingRemovalRector::class,
RemoveDeadStmtRector::class,
RemoveDuplicatedArrayKeyRector::class,
RemoveUnusedForeachKeyRector::class,
RemoveParentCallWithoutParentRector::class,
RemoveEmptyClassMethodRector::class,
RemoveDoubleAssignRector::class,
SimplifyMirrorAssignRector::class,
RemoveOverriddenValuesRector::class,
RemoveUnusedPrivatePropertyRector::class,
RemoveUnusedPrivateClassConstantRector::class,
RemoveUnusedPrivateMethodRector::class,
RemoveDeadConstructorRector::class,
RemoveDeadReturnRector::class,
RemoveDeadContinueRector::class,
RemoveDeadIfForeachForRector::class,
RemoveAndTrueRector::class,
RemoveConcatAutocastRector::class,
SimplifyUselessVariableRector::class,
RemoveDelegatingParentCallRector::class,
RemoveDuplicatedInstanceOfRector::class,
RemoveDuplicatedCaseInSwitchRector::class,
RemoveNullPropertyInitializationRector::class,
RemoveUnreachableStatementRector::class,
SimplifyIfElseWithSameContentRector::class,
TernaryToBooleanOrFalseToBooleanAndRector::class,
RemoveEmptyTestMethodRector::class,
RemoveDeadTryCatchRector::class,
RemoveUnusedVariableAssignRector::class,
RemoveDuplicatedIfReturnRector::class,
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
RemoveEmptyMethodCallRector::class,
RemoveDeadConditionAboveReturnRector::class,
RemoveUnusedConstructorParamRector::class,
RemoveDeadInstanceOfRector::class,
RemoveDeadLoopRector::class,
RemoveUnusedPrivateMethodParameterRector::class,
RemoveUnusedParamInRequiredAutowireRector::class,
// docblock
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class,
\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class,
\Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector::class,
\Rector\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignRector::class,
RemoveUselessParamTagRector::class,
RemoveUselessReturnTagRector::class,
RemoveNonExistingVarAnnotationRector::class,
RemoveUnusedPromotedPropertyRector::class,
RemoveLastReturnRector::class,
RemoveJustPropertyFetchForAssignRector::class,
]);
};

View File

@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
// @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
return static function (RectorConfig $rectorConfig) : void {
$deprecatedMessage = \sprintf('The DEFLUENT set is deprecated for high number of assumptions and reported bugs. Better use PHPStan rule "%s" to warn about these cases and refactor manually.', 'https://github.com/symplify/phpstan-rules/blob/main/docs/rules_overview.md#nochainmethodcallrule');
\trigger_error($deprecatedMessage);
\sleep(3);

View File

@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_52);
$rectorConfig->rule(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_52);
$rectorConfig->rule(DirConstToFileConstRector::class);
};

View File

@ -12,13 +12,13 @@ use Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector;
use Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector;
use Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector;
use Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_53);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Array_\ShortArrayToLongArrayRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector::class);
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeThisInClosureRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_53);
$rectorConfig->rule(ShortArrayToLongArrayRector::class);
$rectorConfig->rule(DowngradeStaticClosureRector::class);
$rectorConfig->rule(DowngradeIndirectCallByArrayRector::class);
$rectorConfig->rule(DowngradeCallableTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeBinaryNotationRector::class);
$rectorConfig->rule(DowngradeInstanceMethodCallRector::class);
$rectorConfig->rule(DowngradeThisInClosureRector::class);
};

View File

@ -9,10 +9,10 @@ use Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringR
use Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector;
use Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector;
use Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54);
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringRector::class);
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector::class);
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector::class);
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_54);
$rectorConfig->rule(DowngradeClassConstantToStringRector::class);
$rectorConfig->rule(DowngradeForeachListRector::class);
$rectorConfig->rule(DowngradeBoolvalRector::class);
$rectorConfig->rule(DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class);
};

View File

@ -10,11 +10,11 @@ use Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector;
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector;
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector;
use Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55);
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\CallLike\DowngradeArgumentUnpackingRector::class);
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector::class);
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector::class);
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector::class);
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_55);
$rectorConfig->rule(DowngradeArgumentUnpackingRector::class);
$rectorConfig->rule(DowngradeUseFunctionRector::class);
$rectorConfig->rule(DowngradeExponentialAssignmentOperatorRector::class);
$rectorConfig->rule(DowngradeExponentialOperatorRector::class);
$rectorConfig->rule(DowngradeArrayFilterUseConstantRector::class);
};

View File

@ -23,24 +23,24 @@ use Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector;
use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
use Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Instanceof_\DowngradeInstanceofThrowableRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeThrowableTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeDirnameLevelsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeUncallableValueCallToCallUserFuncRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeClosureCallRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeParentTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector::class);
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expr\DowngradeUnnecessarilyParenthesizedExpressionRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_56);
$rectorConfig->rule(DowngradeCatchThrowableRector::class);
$rectorConfig->rule(DowngradeInstanceofThrowableRector::class);
$rectorConfig->rule(DowngradeScalarTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeThrowableTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeStrictTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeSelfTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeAnonymousClassRector::class);
$rectorConfig->rule(DowngradeNullCoalesceRector::class);
$rectorConfig->rule(DowngradeSpaceshipRector::class);
$rectorConfig->rule(DowngradeDefineArrayConstantRector::class);
$rectorConfig->rule(DowngradeDirnameLevelsRector::class);
$rectorConfig->rule(DowngradeSessionStartArrayOptionsRector::class);
$rectorConfig->rule(DowngradeUncallableValueCallToCallUserFuncRector::class);
$rectorConfig->rule(SplitGroupedUseImportsRector::class);
$rectorConfig->rule(DowngradeClosureCallRector::class);
$rectorConfig->rule(DowngradeParentTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeMethodCallOnCloneRector::class);
$rectorConfig->rule(DowngradeUnnecessarilyParenthesizedExpressionRector::class);
};

View File

@ -16,17 +16,17 @@ use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector;
use Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector;
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector::class);
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\ConstFetch\DowngradePhp71JsonConstRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_70);
$rectorConfig->rule(DowngradeNullableTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeVoidTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeClassConstantVisibilityRector::class);
$rectorConfig->rule(DowngradePipeToMultiCatchExceptionRector::class);
$rectorConfig->rule(SymmetricArrayDestructuringToListRector::class);
$rectorConfig->rule(DowngradeNegativeStringOffsetToStrlenRector::class);
$rectorConfig->rule(DowngradeKeysInListRector::class);
$rectorConfig->rule(DowngradeIterablePseudoTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeIsIterableRector::class);
$rectorConfig->rule(DowngradeClosureFromCallableRector::class);
$rectorConfig->rule(DowngradePhp71JsonConstRector::class);
};

View File

@ -11,12 +11,12 @@ use Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgR
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector::class);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgRector::class);
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\ConstFetch\DowngradePhp72JsonConstRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_71);
$rectorConfig->rule(DowngradeObjectTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeParameterTypeWideningRector::class);
$rectorConfig->rule(DowngradePregUnmatchedAsNullConstantRector::class);
$rectorConfig->rule(DowngradeStreamIsattyRector::class);
$rectorConfig->rule(DowngradeJsonDecodeNullAssociativeArgRector::class);
$rectorConfig->rule(DowngradePhp72JsonConstRector::class);
};

View File

@ -12,13 +12,13 @@ use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCalls
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector::class);
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_72);
$rectorConfig->rule(DowngradeFlexibleHeredocSyntaxRector::class);
$rectorConfig->rule(DowngradeListReferenceAssignmentRector::class);
$rectorConfig->rule(DowngradeTrailingCommasInFunctionCallsRector::class);
$rectorConfig->rule(DowngradeArrayKeyFirstLastRector::class);
$rectorConfig->rule(SetCookieOptionsArrayToArgumentsRector::class);
$rectorConfig->rule(DowngradeIsCountableRector::class);
$rectorConfig->rule(DowngradePhp73JsonConstRector::class);
};

View File

@ -17,18 +17,18 @@ use Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterf
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
use Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector;
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterfaceRector::class);
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_73);
$rectorConfig->rule(DowngradeTypedPropertyRector::class);
$rectorConfig->rule(ArrowFunctionToAnonymousFunctionRector::class);
$rectorConfig->rule(DowngradeCovariantReturnTypeRector::class);
$rectorConfig->rule(DowngradeContravariantArgumentTypeRector::class);
$rectorConfig->rule(DowngradeNullCoalescingOperatorRector::class);
$rectorConfig->rule(DowngradeNumericLiteralSeparatorRector::class);
$rectorConfig->rule(DowngradeStripTagsCallWithArrayRector::class);
$rectorConfig->rule(DowngradeArraySpreadRector::class);
$rectorConfig->rule(DowngradeArrayMergeCallWithoutArgumentsRector::class);
$rectorConfig->rule(DowngradeFreadFwriteFalsyToNegationRector::class);
$rectorConfig->rule(DowngradePreviouslyImplementedInterfaceRector::class);
$rectorConfig->rule(DowngradeReflectionGetTypeRector::class);
};

View File

@ -35,43 +35,43 @@ use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
use Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector;
use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation;
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74);
$rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_74);
$rectorConfig->ruleWithConfiguration(RemoveInterfacesRector::class, [
// @see https://wiki.php.net/rfc/stringable
'Stringable',
]);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class, [
$rectorConfig->rule(DowngradeNamedArgumentRector::class);
$rectorConfig->ruleWithConfiguration(DowngradeAttributeToAnnotationRector::class, [
// Symfony
new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'),
new DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'),
// Nette
new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Nette\\DI\\Attributes\\Inject', 'inject'),
new DowngradeAttributeToAnnotation('Nette\\DI\\Attributes\\Inject', 'inject'),
]);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ArrayDimFetch\DowngradeDereferenceableOperationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\New_\DowngradeArbitraryExpressionsSupportRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Instanceof_\DowngradePhp80ResourceReturnToObjectRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeRecursiveDirectoryIteratorHasChildrenRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeNumberFormatNoFourthArgRector::class);
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStringReturnTypeOnToStringRector::class);
$rectorConfig->rule(DowngradeDereferenceableOperationRector::class);
$rectorConfig->rule(DowngradeUnionTypeTypedPropertyRector::class);
$rectorConfig->rule(DowngradeUnionTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeMixedTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeStaticTypeDeclarationRector::class);
$rectorConfig->rule(DowngradeAbstractPrivateMethodInTraitRector::class);
$rectorConfig->rule(DowngradePropertyPromotionRector::class);
$rectorConfig->rule(DowngradeNonCapturingCatchesRector::class);
$rectorConfig->rule(DowngradeStrContainsRector::class);
$rectorConfig->rule(DowngradeMatchToSwitchRector::class);
$rectorConfig->rule(DowngradeClassOnObjectToGetClassRector::class);
$rectorConfig->rule(DowngradeArbitraryExpressionsSupportRector::class);
$rectorConfig->rule(DowngradeNullsafeToTernaryOperatorRector::class);
$rectorConfig->rule(DowngradeTrailingCommasInParamUseRector::class);
$rectorConfig->rule(DowngradeStrStartsWithRector::class);
$rectorConfig->rule(DowngradeStrEndsWithRector::class);
$rectorConfig->rule(DowngradePhpTokenRector::class);
$rectorConfig->rule(DowngradeThrowExprRector::class);
$rectorConfig->rule(DowngradePhp80ResourceReturnToObjectRector::class);
$rectorConfig->rule(DowngradeReflectionGetAttributesRector::class);
$rectorConfig->rule(DowngradeRecursiveDirectoryIteratorHasChildrenRector::class);
$rectorConfig->rule(DowngradeReflectionPropertyGetDefaultValueRector::class);
$rectorConfig->rule(DowngradeReflectionClassGetConstantsFilterRector::class);
$rectorConfig->rule(DowngradeArrayFilterNullableCallbackRector::class);
$rectorConfig->rule(DowngradeNumberFormatNoFourthArgRector::class);
$rectorConfig->rule(DowngradeStringReturnTypeOnToStringRector::class);
};

View File

@ -14,15 +14,15 @@ use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector;
use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector;
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector::class);
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_80);
$rectorConfig->rule(DowngradeFinalizePublicClassConstantRector::class);
$rectorConfig->rule(DowngradeFirstClassCallableSyntaxRector::class);
$rectorConfig->rule(DowngradeNeverTypeDeclarationRector::class);
$rectorConfig->rule(DowngradePureIntersectionTypeRector::class);
$rectorConfig->rule(DowngradeNewInInitializerRector::class);
$rectorConfig->rule(DowngradePhp81ResourceReturnToObjectRector::class);
$rectorConfig->rule(DowngradeReadonlyPropertyRector::class);
$rectorConfig->rule(DowngradeArraySpreadStringKeyRector::class);
$rectorConfig->rule(DowngradeArrayIsListRector::class);
};

View File

@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81);
$rectorConfig->rule(\Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->phpVersion(PhpVersion::PHP_81);
$rectorConfig->rule(DowngradeReadonlyClassRector::class);
};

View File

@ -15,16 +15,16 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class);
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
$rectorConfig->rule(ChangeAndIfToEarlyReturnRector::class);
$rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
$rectorConfig->rule(ChangeNestedIfsToEarlyReturnRector::class);
$rectorConfig->rule(RemoveAlwaysElseRector::class);
$rectorConfig->rule(ReturnBinaryAndToEarlyReturnRector::class);
$rectorConfig->rule(ChangeOrIfReturnToEarlyReturnRector::class);
$rectorConfig->rule(ChangeOrIfContinueToMultiContinueRector::class);
$rectorConfig->rule(ReturnAfterToEarlyOnBreakRector::class);
$rectorConfig->rule(PreparedValueToEarlyReturnRector::class);
$rectorConfig->rule(ReturnBinaryOrToEarlyReturnRector::class);
};

View File

@ -6,22 +6,22 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
// Rename is now move, specific for files.
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'rename', 'move'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'rename', 'move'),
// No arbitrary abbreviations
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'),
// Writes are now deterministic
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'),
// Metadata getters are renamed
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'),
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'),
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'),
]);
};

View File

@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class);
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ReplaceSensioRouteAnnotationWithSymfonyRector::class);
$rectorConfig->rule(RemoveServiceFromSensioRouteRector::class);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(TemplateAnnotationToThisRenderRector::class);
};

File diff suppressed because one or more lines are too long

View File

@ -10,9 +10,9 @@ use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\FuncCallToMethodCall;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class, $configuration);
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')]);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]);
return static function (RectorConfig $rectorConfig) : void {
$configuration = [new FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
$rectorConfig->ruleWithConfiguration(FuncCallToMethodCallRector::class, $configuration);
$rectorConfig->ruleWithConfiguration(StaticCallToFuncCallRector::class, [new StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')]);
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_53, \Rector\Set\ValueObject\DowngradeSetList::PHP_53]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_53, DowngradeSetList::PHP_53]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_54, \Rector\Set\ValueObject\DowngradeSetList::PHP_54]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_54, DowngradeSetList::PHP_54]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_55, \Rector\Set\ValueObject\DowngradeSetList::PHP_55]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_55, DowngradeSetList::PHP_55]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_56, \Rector\Set\ValueObject\DowngradeSetList::PHP_56]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_56, DowngradeSetList::PHP_56]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_70, \Rector\Set\ValueObject\DowngradeSetList::PHP_70]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_70, DowngradeSetList::PHP_70]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_71, \Rector\Set\ValueObject\DowngradeSetList::PHP_71]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_71, DowngradeSetList::PHP_71]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_72, \Rector\Set\ValueObject\DowngradeSetList::PHP_72]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72, DowngradeSetList::PHP_72]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_73, \Rector\Set\ValueObject\DowngradeSetList::PHP_73]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_73, DowngradeSetList::PHP_73]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_74, \Rector\Set\ValueObject\DowngradeSetList::PHP_74]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_74, DowngradeSetList::PHP_74]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_80, \Rector\Set\ValueObject\DowngradeSetList::PHP_80]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_80, DowngradeSetList::PHP_80]);
};

View File

@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_81, \Rector\Set\ValueObject\DowngradeSetList::PHP_81]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_81, DowngradeSetList::PHP_81]);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeSetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeSetList::PHP_82]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([DowngradeSetList::PHP_82]);
};

View File

@ -6,8 +6,8 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_54, \Rector\Set\ValueObject\SetList::PHP_53]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_54, SetList::PHP_53]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54);
$rectorConfig->phpVersion(PhpVersion::PHP_54);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_55, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_54]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_55, LevelSetList::UP_TO_PHP_54]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55);
$rectorConfig->phpVersion(PhpVersion::PHP_55);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_56, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_55]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_56, LevelSetList::UP_TO_PHP_55]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56);
$rectorConfig->phpVersion(PhpVersion::PHP_56);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_70, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_56]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_70, LevelSetList::UP_TO_PHP_56]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70);
$rectorConfig->phpVersion(PhpVersion::PHP_70);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_71, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_70]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_71, LevelSetList::UP_TO_PHP_70]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71);
$rectorConfig->phpVersion(PhpVersion::PHP_71);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_72, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_71]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_72, LevelSetList::UP_TO_PHP_71]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72);
$rectorConfig->phpVersion(PhpVersion::PHP_72);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_73, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_72]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_73, LevelSetList::UP_TO_PHP_72]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73);
$rectorConfig->phpVersion(PhpVersion::PHP_73);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_74, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_73]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_74, LevelSetList::UP_TO_PHP_73]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74);
$rectorConfig->phpVersion(PhpVersion::PHP_74);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_80, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_74]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_80, LevelSetList::UP_TO_PHP_74]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80);
$rectorConfig->phpVersion(PhpVersion::PHP_80);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_81, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_80]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_81, LevelSetList::UP_TO_PHP_80]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81);
$rectorConfig->phpVersion(PhpVersion::PHP_81);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_82, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->sets([SetList::PHP_82, LevelSetList::UP_TO_PHP_81]);
// parameter must be defined after import, to override imported param version
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_82);
$rectorConfig->phpVersion(PhpVersion::PHP_82);
};

View File

@ -7,6 +7,6 @@ use Rector\Config\RectorConfig;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addError', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'err', 'error'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new \Rector\Renaming\ValueObject\MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')]);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('Monolog\\Logger', 'addDebug', 'debug'), new MethodCallRename('Monolog\\Logger', 'addInfo', 'info'), new MethodCallRename('Monolog\\Logger', 'addNotice', 'notice'), new MethodCallRename('Monolog\\Logger', 'addWarning', 'warning'), new MethodCallRename('Monolog\\Logger', 'addError', 'error'), new MethodCallRename('Monolog\\Logger', 'addCritical', 'critical'), new MethodCallRename('Monolog\\Logger', 'addAlert', 'alert'), new MethodCallRename('Monolog\\Logger', 'addEmergency', 'emergency'), new MethodCallRename('Monolog\\Logger', 'warn', 'warning'), new MethodCallRename('Monolog\\Logger', 'err', 'error'), new MethodCallRename('Monolog\\Logger', 'crit', 'critical'), new MethodCallRename('Monolog\\Logger', 'emerg', 'emergency')]);
};

View File

@ -14,18 +14,18 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
use Rector\Removing\ValueObject\RemoveFuncCallArg;
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
return static function (RectorConfig $rectorConfig) : void {
# https://stackoverflow.com/a/1390625/1348344
# https://github.com/philip/MySQLConverterTool/blob/master/Converter.php
# https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class, [new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)]);
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
$rectorConfig->rule(MysqlAssignToMysqliRector::class);
$rectorConfig->rule(MysqlFuncCallToMysqliRector::class);
$rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [new RemoveFuncCallArg('mysql_pconnect', 3), new RemoveFuncCallArg('mysql_connect', 3), new RemoveFuncCallArg('mysql_connect', 4)]);
$rectorConfig->rule(MysqlPConnectToMysqliConnectRector::class);
# first swap arguments, then rename
$rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class, [new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_query', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_select_db', [1, 0]), new \Rector\Arguments\ValueObject\SwapFuncCallArguments('mysql_set_charset', [1, 0])]);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']);
$rectorConfig->ruleWithConfiguration(SwapFuncCallArgumentsRector::class, [new SwapFuncCallArguments('mysql_query', [1, 0]), new SwapFuncCallArguments('mysql_real_escape_string', [1, 0]), new SwapFuncCallArguments('mysql_select_db', [1, 0]), new SwapFuncCallArguments('mysql_set_charset', [1, 0])]);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysql_connect' => 'mysqli_connect', 'mysql_data_seek' => 'mysqli_data_seek', 'mysql_fetch_array' => 'mysqli_fetch_array', 'mysql_fetch_assoc' => 'mysqli_fetch_assoc', 'mysql_fetch_lengths' => 'mysqli_fetch_lengths', 'mysql_fetch_object' => 'mysqli_fetch_object', 'mysql_fetch_row' => 'mysqli_fetch_row', 'mysql_field_seek' => 'mysqli_field_seek', 'mysql_free_result' => 'mysqli_free_result', 'mysql_get_client_info' => 'mysqli_get_client_info', 'mysql_num_fields' => 'mysqli_num_fields', 'mysql_numfields' => 'mysqli_num_fields', 'mysql_num_rows' => 'mysqli_num_rows', 'mysql_numrows' => 'mysqli_num_rows']);
# http://php.net/manual/en/mysql.constants.php → http://php.net/manual/en/mysqli.constants.php
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class, ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']);
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
$rectorConfig->ruleWithConfiguration(RenameConstantRector::class, ['MYSQL_ASSOC' => 'MYSQLI_ASSOC', 'MYSQL_BOTH' => 'MYSQLI_BOTH', 'MYSQL_CLIENT_COMPRESS' => 'MYSQLI_CLIENT_COMPRESS', 'MYSQL_CLIENT_IGNORE_SPACE' => 'MYSQLI_CLIENT_IGNORE_SPACE', 'MYSQL_CLIENT_INTERACTIVE' => 'MYSQLI_CLIENT_INTERACTIVE', 'MYSQL_CLIENT_SSL' => 'MYSQLI_CLIENT_SSL', 'MYSQL_NUM' => 'MYSQLI_NUM', 'MYSQL_PRIMARY_KEY_FLAG' => 'MYSQLI_PRI_KEY_FLAG']);
$rectorConfig->rule(MysqlQueryMysqlErrorWithLinkRector::class);
};

View File

@ -10,11 +10,11 @@ use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class);
$rectorConfig->rule(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class);
$rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class);
$rectorConfig->rule(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class);
$rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
$rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(RenameParamToMatchTypeRector::class);
$rectorConfig->rule(RenamePropertyToMatchTypeRector::class);
$rectorConfig->rule(RenameVariableToMatchNewTypeRector::class);
$rectorConfig->rule(RenameVariableToMatchMethodCallReturnTypeRector::class);
$rectorConfig->rule(RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
$rectorConfig->rule(RenameForeachValueVariableToMatchExprVariableRector::class);
};

View File

@ -8,11 +8,11 @@ use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
use Rector\Removing\ValueObject\RemoveFuncCallArg;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
$rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(VarToPublicPropertyRector::class);
$rectorConfig->rule(ContinueToBreakInSwitchRector::class);
$rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
new \Rector\Removing\ValueObject\RemoveFuncCallArg('ldap_first_attribute', 2),
new RemoveFuncCallArg('ldap_first_attribute', 2),
]);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
$rectorConfig->rule(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
$rectorConfig->rule(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(TernaryToElvisRector::class);
$rectorConfig->rule(DirNameFileConstantToDirConstantRector::class);
$rectorConfig->rule(ReplaceHttpServerVarsByServerRector::class);
};

View File

@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']);
$rectorConfig->rule(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
$rectorConfig->rule(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']);
$rectorConfig->rule(RemoveReferenceFromCallRector::class);
$rectorConfig->rule(RemoveZeroBreakContinueRector::class);
};

View File

@ -9,10 +9,10 @@ use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
use Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
$rectorConfig->rule(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class);
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector::class);
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector::class);
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
$rectorConfig->rule(ClassConstantToSelfClassRector::class);
$rectorConfig->rule(PregReplaceEModifierRector::class);
$rectorConfig->rule(GetCalledClassToSelfClassRector::class);
$rectorConfig->rule(GetCalledClassToStaticClassRector::class);
};

View File

@ -7,9 +7,9 @@ use Rector\Config\RectorConfig;
use Rector\Php56\Rector\FuncCall\PowToExpRector;
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(PowToExpRector::class);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mcrypt_generic_end' => 'mcrypt_generic_deinit', 'set_socket_blocking' => 'stream_set_blocking', 'ocibindbyname' => 'oci_bind_by_name', 'ocicancel' => 'oci_cancel', 'ocicolumnisnull' => 'oci_field_is_null', 'ocicolumnname' => 'oci_field_name', 'ocicolumnprecision' => 'oci_field_precision', 'ocicolumnscale' => 'oci_field_scale', 'ocicolumnsize' => 'oci_field_size', 'ocicolumntype' => 'oci_field_type', 'ocicolumntyperaw' => 'oci_field_type_raw', 'ocicommit' => 'oci_commit', 'ocidefinebyname' => 'oci_define_by_name', 'ocierror' => 'oci_error', 'ociexecute' => 'oci_execute', 'ocifetch' => 'oci_fetch', 'ocifetchstatement' => 'oci_fetch_all', 'ocifreecursor' => 'oci_free_statement', 'ocifreestatement' => 'oci_free_statement', 'ociinternaldebug' => 'oci_internal_debug', 'ocilogoff' => 'oci_close', 'ocilogon' => 'oci_connect', 'ocinewcollection' => 'oci_new_collection', 'ocinewcursor' => 'oci_new_cursor', 'ocinewdescriptor' => 'oci_new_descriptor', 'ocinlogon' => 'oci_new_connect', 'ocinumcols' => 'oci_num_fields', 'ociparse' => 'oci_parse', 'ociplogon' => 'oci_pconnect', 'ociresult' => 'oci_result', 'ocirollback' => 'oci_rollback', 'ocirowcount' => 'oci_num_rows', 'ociserverversion' => 'oci_server_version', 'ocisetprefetch' => 'oci_set_prefetch', 'ocistatementtype' => 'oci_statement_type']);
# inspired by level in psalm - https://github.com/vimeo/psalm/blob/82e0bcafac723fdf5007a31a7ae74af1736c9f6f/tests/FileManipulationTest.php#L1063
$rectorConfig->rule(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class);
$rectorConfig->rule(AddDefaultValueForUndefinedVariableRector::class);
};

View File

@ -23,25 +23,25 @@ use Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector;
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Assign\ListSplitStringRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\List_\EmptyListRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(Php4ConstructorRector::class);
$rectorConfig->rule(TernaryToNullCoalescingRector::class);
$rectorConfig->rule(RandomFunctionRector::class);
$rectorConfig->rule(ExceptionHandlerTypehintRector::class);
$rectorConfig->rule(MultiDirnameRector::class);
$rectorConfig->rule(ListSplitStringRector::class);
$rectorConfig->rule(EmptyListRector::class);
# be careful, run this just once, since it can keep swapping order back and forth
$rectorConfig->rule(\Rector\Php70\Rector\Assign\ListSwapArrayOrderRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class);
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class);
$rectorConfig->rule(ListSwapArrayOrderRector::class);
$rectorConfig->rule(CallUserMethodRector::class);
$rectorConfig->rule(EregToPregMatchRector::class);
$rectorConfig->rule(ReduceMultipleDefaultSwitchRector::class);
$rectorConfig->rule(TernaryToSpaceshipRector::class);
$rectorConfig->rule(WrapVariableVariableNameInCurlyBracesRector::class);
$rectorConfig->rule(IfToSpaceshipRector::class);
$rectorConfig->rule(StaticCallOnNonStaticToInstanceCallRector::class);
$rectorConfig->rule(ThisCallOnStaticMethodToStaticCallRector::class);
$rectorConfig->rule(BreakNotInLoopOrSwitchToReturnRector::class);
$rectorConfig->rule(RenameMktimeWithoutArgsToTimeRector::class);
$rectorConfig->rule(NonVariableToVariableOnFunctionCallRector::class);
};

View File

@ -12,13 +12,13 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector;
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class);
$rectorConfig->rule(\Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(IsIterableRector::class);
$rectorConfig->rule(MultiExceptionCatchRector::class);
$rectorConfig->rule(AssignArrayToStringRector::class);
$rectorConfig->rule(CountOnNullRector::class);
$rectorConfig->rule(RemoveExtraParametersRector::class);
$rectorConfig->rule(BinaryOpBetweenNumberAndStringRector::class);
$rectorConfig->rule(ListToArrayDestructRector::class);
$rectorConfig->rule(PublicConstantVisibilityRector::class);
};

View File

@ -15,12 +15,12 @@ use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector;
use Rector\Php72\Rector\Unset_\UnsetCastRector;
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\Assign\ListEachRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(WhileEachToForeachRector::class);
$rectorConfig->rule(ListEachRector::class);
$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
$rectorConfig->rule(UnsetCastRector::class);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
# and imagewbmp
'jpeg2wbmp' => 'imagecreatefromjpeg',
# or imagewbmp
@ -31,10 +31,10 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
'gmp_random' => 'gmp_random_bits',
'read_exif_data' => 'exif_read_data',
]);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class);
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
$rectorConfig->rule(GetClassOnNullRector::class);
$rectorConfig->rule(IsObjectOnIncompleteClassRector::class);
$rectorConfig->rule(ParseStrWithResultArgumentRector::class);
$rectorConfig->rule(StringsAssertNakedRector::class);
$rectorConfig->rule(CreateFunctionToAnonymousFunctionRector::class);
$rectorConfig->rule(StringifyDefineRector::class);
};

View File

@ -15,13 +15,13 @@ use Rector\Php73\Rector\FuncCall\SetCookieRector;
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(IsCountableRector::class);
$rectorConfig->rule(ArrayKeyFirstLastRector::class);
$rectorConfig->rule(SensitiveDefineRector::class);
$rectorConfig->rule(SensitiveConstantNameRector::class);
$rectorConfig->rule(SensitiveHereNowDocRector::class);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
# https://wiki.php.net/rfc/deprecations_php_7_3
'image2wbmp' => 'imagewbmp',
'mbregex_encoding' => 'mb_regex_encoding',
@ -38,9 +38,9 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
]);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);
$rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SetCookieRector::class);
$rectorConfig->rule(StringifyStrNeedlesRector::class);
$rectorConfig->rule(JsonThrowOnErrorRector::class);
$rectorConfig->rule(RegexDashEscapeRector::class);
$rectorConfig->rule(ContinueToBreakInSwitchRector::class);
$rectorConfig->rule(SetCookieRector::class);
};

View File

@ -18,9 +18,9 @@ use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(TypedPropertyRector::class);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
#the_real_type
# https://wiki.php.net/rfc/deprecations_php_7_4
'is_real' => 'is_float',
@ -28,16 +28,16 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
# https://wiki.php.net/rfc/deprecations_php_7_4
'apache_request_headers' => 'getallheaders',
]);
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
$rectorConfig->rule(\Rector\Php74\Rector\ArrayDimFetch\CurlyToSquareBracketArrayStringRector::class);
$rectorConfig->rule(ArrayKeyExistsOnPropertyRector::class);
$rectorConfig->rule(FilterVarToAddSlashesRector::class);
$rectorConfig->rule(ExportToReflectionFunctionRector::class);
$rectorConfig->rule(MbStrrposEncodingArgumentPositionRector::class);
$rectorConfig->rule(RealToFloatTypeCastRector::class);
$rectorConfig->rule(NullCoalescingOperatorRector::class);
$rectorConfig->rule(ClosureToArrowFunctionRector::class);
$rectorConfig->rule(ArraySpreadInsteadOfArrayMergeRector::class);
$rectorConfig->rule(AddLiteralSeparatorToNumberRector::class);
$rectorConfig->rule(ChangeReflectionTypeToStringToGetNameRector::class);
$rectorConfig->rule(RestoreDefaultNullToNullableTypePropertyRector::class);
$rectorConfig->rule(CurlyToSquareBracketArrayStringRector::class);
};

View File

@ -28,28 +28,28 @@ use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
use Rector\Transform\ValueObject\StaticCallToFuncCall;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class, [new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')]);
$rectorConfig->rule(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(UnionTypesRector::class);
$rectorConfig->rule(StrContainsRector::class);
$rectorConfig->rule(StrStartsWithRector::class);
$rectorConfig->rule(StrEndsWithRector::class);
$rectorConfig->ruleWithConfiguration(StaticCallToFuncCallRector::class, [new StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')]);
$rectorConfig->rule(StringableForToStringRector::class);
$rectorConfig->rule(ClassOnObjectRector::class);
$rectorConfig->rule(GetDebugTypeRector::class);
$rectorConfig->rule(TokenGetAllToObjectRector::class);
$rectorConfig->rule(RemoveUnusedVariableInCatchRector::class);
$rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class);
$rectorConfig->rule(ChangeSwitchToMatchRector::class);
// nette\utils and Strings::replace()
$rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class, [new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]);
$rectorConfig->rule(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
$rectorConfig->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]);
$rectorConfig->rule(RemoveParentCallWithoutParentRector::class);
$rectorConfig->rule(SetStateToStaticRector::class);
$rectorConfig->rule(FinalPrivateToPrivateVisibilityRector::class);
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']);
$rectorConfig->rule(\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
$rectorConfig->ruleWithConfiguration(\Rector\Arguments\Rector\FuncCall\FunctionArgumentDefaultValueReplacerRector::class, [new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new \Rector\Arguments\ValueObject\ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')]);
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class);
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class);
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['pg_clientencoding' => 'pg_client_encoding', 'pg_cmdtuples' => 'pg_affected_rows', 'pg_errormessage' => 'pg_last_error', 'pg_fieldisnull' => 'pg_field_is_null', 'pg_fieldname' => 'pg_field_name', 'pg_fieldnum' => 'pg_field_num', 'pg_fieldprtlen' => 'pg_field_prtlen', 'pg_fieldsize' => 'pg_field_size', 'pg_fieldtype' => 'pg_field_type', 'pg_freeresult' => 'pg_free_result', 'pg_getlastoid' => 'pg_last_oid', 'pg_loclose' => 'pg_lo_close', 'pg_locreate' => 'pg_lo_create', 'pg_loexport' => 'pg_lo_export', 'pg_loimport' => 'pg_lo_import', 'pg_loopen' => 'pg_lo_open', 'pg_loread' => 'pg_lo_read', 'pg_loreadall' => 'pg_lo_read_all', 'pg_lounlink' => 'pg_lo_unlink', 'pg_lowrite' => 'pg_lo_write', 'pg_numfields' => 'pg_num_fields', 'pg_numrows' => 'pg_num_rows', 'pg_result' => 'pg_fetch_result', 'pg_setclientencoding' => 'pg_set_client_encoding']);
$rectorConfig->rule(OptionalParametersAfterRequiredRector::class);
$rectorConfig->ruleWithConfiguration(FunctionArgumentDefaultValueReplacerRector::class, [new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '', '!='), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, '!', '!='), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'g', 'gt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'l', 'lt'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'gte', 'ge'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'lte', 'le'), new ReplaceFuncCallArgumentDefaultValue('version_compare', 2, 'n', 'ne')]);
$rectorConfig->rule(Php8ResourceReturnToObjectRector::class);
$rectorConfig->rule(AddParamBasedOnParentClassMethodRector::class);
};

View File

@ -14,15 +14,15 @@ use Rector\Php81\Rector\FunctionLike\IntersectionTypesRector;
use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector;
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\ClassMethod\NewInInitializerRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\FunctionLike\IntersectionTypesRector::class);
$rectorConfig->rule(\Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ReturnNeverTypeRector::class);
$rectorConfig->rule(MyCLabsClassToEnumRector::class);
$rectorConfig->rule(MyCLabsMethodCallToEnumConstRector::class);
$rectorConfig->rule(FinalizePublicClassConstantRector::class);
$rectorConfig->rule(ReadOnlyPropertyRector::class);
$rectorConfig->rule(SpatieEnumClassToEnumRector::class);
$rectorConfig->rule(Php81ResourceReturnToObjectRector::class);
$rectorConfig->rule(NewInInitializerRector::class);
$rectorConfig->rule(IntersectionTypesRector::class);
$rectorConfig->rule(NullToStrictStringFuncCallArgRector::class);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Php82\Rector\Class_\ReadOnlyClassRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ReadOnlyClassRector::class);
};

View File

@ -13,15 +13,15 @@ use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class);
$rectorConfig->rule(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(FinalizeClassesWithoutChildrenRector::class);
$rectorConfig->rule(ChangeGlobalVariablesToPropertiesRector::class);
$rectorConfig->rule(ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
$rectorConfig->rule(ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
$rectorConfig->rule(RepeatedLiteralToClassConstantRector::class);
$rectorConfig->rule(PrivatizeLocalGetterToPropertyRector::class);
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
$rectorConfig->rule(PrivatizeFinalClassMethodRector::class);
// buggy, requires more work
// $services->set(ChangeLocalPropertyToVariableRector::class);
};

View File

@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
$rectorConfig->rule(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
$rectorConfig->rule(MultipleClassFileToPsr4ClassesRector::class);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(UpgradeRectorConfigRector::class);
};

View File

@ -14,15 +14,15 @@ use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(AddClosureReturnTypeRector::class);
$rectorConfig->rule(ReturnTypeFromStrictTypedPropertyRector::class);
$rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class);
$rectorConfig->rule(ParamTypeFromStrictTypedPropertyRector::class);
$rectorConfig->rule(ReturnTypeFromStrictTypedCallRector::class);
$rectorConfig->rule(AddVoidReturnTypeWhereNoReturnRector::class);
$rectorConfig->rule(ReturnTypeFromReturnNewRector::class);
$rectorConfig->rule(TypedPropertyFromStrictGetterMethodReturnTypeRector::class);
$rectorConfig->rule(AddMethodCallBasedStrictParamTypeRector::class);
$rectorConfig->rule(ArrayShapeFromConstantArrayReturnRector::class);
};

View File

@ -16,17 +16,17 @@ use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
use Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector::class);
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(ParamTypeDeclarationRector::class);
$rectorConfig->rule(ReturnTypeDeclarationRector::class);
$rectorConfig->rule(PropertyTypeDeclarationRector::class);
$rectorConfig->rule(AddClosureReturnTypeRector::class);
$rectorConfig->rule(AddArrayParamDocTypeRector::class);
$rectorConfig->rule(AddArrayReturnDocTypeRector::class);
$rectorConfig->rule(ParamTypeByParentCallTypeRector::class);
$rectorConfig->rule(ParamTypeByMethodCallTypeRector::class);
$rectorConfig->rule(TypedPropertyFromAssignsRector::class);
$rectorConfig->rule(ReturnAnnotationIncorrectNullableRector::class);
$rectorConfig->rule(VarAnnotationIncorrectNullableRector::class);
$rectorConfig->rule(ParamAnnotationIncorrectNullableRector::class);
};

View File

@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
$rectorConfig->rule(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
return static function (RectorConfig $rectorConfig) : void {
$rectorConfig->rule(UnwrapFutureCompatibleIfFunctionExistsRector::class);
};

View File

@ -10,8 +10,8 @@ final class AttributeMirrorer
/**
* @var string[]
*/
private const ATTRIBUTES_TO_MIRROR = [\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE];
public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void
private const ATTRIBUTES_TO_MIRROR = [PhpDocAttributeKey::PARENT, PhpDocAttributeKey::START_AND_END, PhpDocAttributeKey::ORIG_NODE];
public function mirror(Node $oldNode, Node $newNode) : void
{
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
if (!$oldNode->hasAttribute($attributeToMirror)) {

View File

@ -14,14 +14,14 @@ final class CommentsMerger
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
*/
private $simpleCallableNodeTraverser;
public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
{
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
}
/**
* @param Node[] $mergedNodes
*/
public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void
public function keepComments(Node $newNode, array $mergedNodes) : void
{
$comments = $newNode->getComments();
foreach ($mergedNodes as $mergedNode) {
@ -30,25 +30,25 @@ final class CommentsMerger
if ($comments === []) {
return;
}
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
// remove so comments "win"
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null);
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, null);
}
public function keepParent(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
public function keepParent(Node $newNode, Node $oldNode) : void
{
$parent = $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
if (!$parent instanceof \PhpParser\Node) {
$parent = $oldNode->getAttribute(AttributeKey::PARENT_NODE);
if (!$parent instanceof Node) {
return;
}
$phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
$phpDocInfo = $parent->getAttribute(AttributeKey::PHP_DOC_INFO);
$comments = $parent->getComments();
if ($phpDocInfo === null && $comments === []) {
return;
}
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
}
public function keepChildren(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
public function keepChildren(Node $newNode, Node $oldNode) : void
{
$childrenComments = $this->collectChildrenComments($oldNode);
if ($childrenComments === []) {
@ -58,15 +58,15 @@ final class CommentsMerger
foreach ($childrenComments as $childComment) {
$commentContent .= $childComment->getText() . \PHP_EOL;
}
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, [new \PhpParser\Comment($commentContent)]);
$newNode->setAttribute(AttributeKey::COMMENTS, [new Comment($commentContent)]);
}
/**
* @return Comment[]
*/
private function collectChildrenComments(\PhpParser\Node $node) : array
private function collectChildrenComments(Node $node) : array
{
$childrenComments = [];
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) {
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$childrenComments) {
$comments = $node->getComments();
if ($comments !== []) {
$childrenComments = \array_merge($childrenComments, $comments);

View File

@ -4,6 +4,6 @@ declare (strict_types=1);
namespace Rector\BetterPhpDocParser\Contract;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface;
interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface
interface BasePhpDocNodeVisitorInterface extends PhpDocNodeVisitorInterface
{
}

View File

@ -7,5 +7,5 @@ use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
interface PhpDocNodeDecoratorInterface
{
public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void;
public function decorate(PhpDocNode $phpDocNode, Node $phpNode) : void;
}

View File

@ -11,14 +11,14 @@ final class CurrentTokenIteratorProvider
* @var \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator|null
*/
private $betterTokenIterator;
public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
public function setBetterTokenIterator(BetterTokenIterator $betterTokenIterator) : void
{
$this->betterTokenIterator = $betterTokenIterator;
}
public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
public function provide() : BetterTokenIterator
{
if ($this->betterTokenIterator === null) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
throw new ShouldNotHappenException();
}
return $this->betterTokenIterator;
}

View File

@ -7,7 +7,7 @@ use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Stringable;
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
{
/**
* @var \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode
@ -16,7 +16,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va
/**
* @param array<mixed, mixed> $values
*/
public function __construct(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, ?string $originalContent = null, array $values = [], ?string $silentKey = null)
public function __construct(IdentifierTypeNode $identifierTypeNode, ?string $originalContent = null, array $values = [], ?string $silentKey = null)
{
$this->identifierTypeNode = $identifierTypeNode;
$this->hasChanged = \true;
@ -59,7 +59,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va
return \true;
}
// the name is not fully qualified in the original name, look for resolved class attribute
$resolvedClass = $this->identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS);
$resolvedClass = $this->identifierTypeNode->getAttribute(PhpDocAttributeKey::RESOLVED_CLASS);
return $resolvedClass === $className;
}
}

View File

@ -9,7 +9,7 @@ use Stringable;
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
* between the @ORM\Entity and (someContent)
*/
final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
final class SpacelessPhpDocTagNode extends PhpDocTagNode
{
public function __toString() : string
{

View File

@ -39,7 +39,7 @@ final class PhpDocInfo
/**
* @var array<class-string<PhpDocTagValueNode>, string>
*/
private const TAGS_TYPES_TO_NAMES = [\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class => '@return', \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class => '@param', \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class => '@var', \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode::class => '@method', \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class => '@property'];
private const TAGS_TYPES_TO_NAMES = [ReturnTagValueNode::class => '@return', ParamTagValueNode::class => '@param', VarTagValueNode::class => '@var', MethodTagValueNode::class => '@method', PropertyTagValueNode::class => '@property'];
/**
* @var bool
*/
@ -93,7 +93,7 @@ final class PhpDocInfo
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
*/
private $phpDocNodeByTypeFinder;
public function __construct(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector, \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, CurrentNodeProvider $currentNodeProvider, RectorChangeCollector $rectorChangeCollector, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
{
$this->phpDocNode = $phpDocNode;
$this->betterTokenIterator = $betterTokenIterator;
@ -104,22 +104,22 @@ final class PhpDocInfo
$this->rectorChangeCollector = $rectorChangeCollector;
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
$this->originalPhpDocNode = clone $phpDocNode;
if (!$betterTokenIterator->containsTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) {
if (!$betterTokenIterator->containsTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
$this->isSingleLine = \true;
}
}
public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
{
$this->phpDocNode->children[] = $phpDocChildNode;
// to give node more space
$this->makeMultiLined();
$this->markAsChanged();
}
public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
public function getPhpDocNode() : PhpDocNode
{
return $this->phpDocNode;
}
public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
public function getOriginalPhpDocNode() : PhpDocNode
{
return $this->originalPhpDocNode;
}
@ -134,7 +134,7 @@ final class PhpDocInfo
{
return $this->betterTokenIterator->count();
}
public function getVarTagValueNode(string $tagName = '@var') : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode
public function getVarTagValueNode(string $tagName = '@var') : ?VarTagValueNode
{
return $this->phpDocNode->getVarTagValues($tagName)[0] ?? null;
}
@ -149,13 +149,13 @@ final class PhpDocInfo
}
$tags = $this->phpDocNode->getTags();
$name = $this->annotationNaming->normalizeName($name);
$tags = \array_filter($tags, function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($name) : bool {
$tags = \array_filter($tags, function (PhpDocTagNode $tag) use($name) : bool {
return $tag->name === $name;
});
$tags = \array_values($tags);
return \array_values($tags);
}
public function getParamType(string $name) : \PHPStan\Type\Type
public function getParamType(string $name) : Type
{
$paramTagValueNodes = $this->getParamTagValueByName($name);
return $this->getTypeOrMixed($paramTagValueNodes);
@ -167,7 +167,7 @@ final class PhpDocInfo
{
return $this->phpDocNode->getParamTagValues();
}
public function getParamTagValueNodeByName(string $parameterName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
public function getParamTagValueNodeByName(string $parameterName) : ?ParamTagValueNode
{
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
@ -177,11 +177,11 @@ final class PhpDocInfo
}
return null;
}
public function getVarType(string $tagName = '@var') : \PHPStan\Type\Type
public function getVarType(string $tagName = '@var') : Type
{
return $this->getTypeOrMixed($this->getVarTagValueNode($tagName));
}
public function getReturnType() : \PHPStan\Type\Type
public function getReturnType() : Type
{
return $this->getTypeOrMixed($this->getReturnTagValue());
}
@ -228,14 +228,14 @@ final class PhpDocInfo
{
return (bool) $this->getTagsByName($name);
}
public function getByName(string $name) : ?\PHPStan\PhpDocParser\Ast\Node
public function getByName(string $name) : ?Node
{
return $this->getTagsByName($name)[0] ?? null;
}
/**
* @param class-string[] $classes
*/
public function getByAnnotationClasses(array $classes) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
public function getByAnnotationClasses(array $classes) : ?DoctrineAnnotationTagValueNode
{
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClasses($this->phpDocNode, $classes);
return $doctrineAnnotationTagValueNodes[0] ?? null;
@ -243,7 +243,7 @@ final class PhpDocInfo
/**
* @param class-string $class
*/
public function getByAnnotationClass(string $class) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
public function getByAnnotationClass(string $class) : ?DoctrineAnnotationTagValueNode
{
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $class);
return $doctrineAnnotationTagValueNodes[0] ?? null;
@ -265,11 +265,11 @@ final class PhpDocInfo
/**
* @param string[] $desiredClasses
*/
public function findOneByAnnotationClasses(array $desiredClasses) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
public function findOneByAnnotationClasses(array $desiredClasses) : ?DoctrineAnnotationTagValueNode
{
foreach ($desiredClasses as $desiredClass) {
$doctrineAnnotationTagValueNode = $this->findOneByAnnotationClass($desiredClass);
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
continue;
}
return $doctrineAnnotationTagValueNode;
@ -279,7 +279,7 @@ final class PhpDocInfo
/**
* @param class-string $desiredClass
*/
public function findOneByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
public function findOneByAnnotationClass(string $desiredClass) : ?DoctrineAnnotationTagValueNode
{
$foundTagValueNodes = $this->findByAnnotationClass($desiredClass);
return $foundTagValueNodes[0] ?? null;
@ -298,9 +298,9 @@ final class PhpDocInfo
*/
public function removeByType(string $typeToRemove) : void
{
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use($typeToRemove) : ?int {
if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) {
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (Node $node) use($typeToRemove) : ?int {
if ($node instanceof PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) {
// keep special annotation for tools
if (\strncmp($node->name, '@psalm-', \strlen('@psalm-')) === 0) {
return null;
@ -309,13 +309,13 @@ final class PhpDocInfo
return null;
}
$this->markAsChanged();
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
return PhpDocNodeTraverser::NODE_REMOVE;
}
if (!\is_a($node, $typeToRemove, \true)) {
return null;
}
$this->markAsChanged();
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
return PhpDocNodeTraverser::NODE_REMOVE;
});
}
/**
@ -330,15 +330,15 @@ final class PhpDocInfo
}
return $paramTypesByName;
}
public function addTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : void
public function addTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : void
{
if ($phpDocTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
if ($phpDocTagValueNode->identifierTypeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode) {
if ($phpDocTagValueNode instanceof DoctrineAnnotationTagValueNode) {
if ($phpDocTagValueNode->identifierTypeNode instanceof ShortenedIdentifierTypeNode) {
$name = '@' . $phpDocTagValueNode->identifierTypeNode;
} else {
$name = '@\\' . $phpDocTagValueNode->identifierTypeNode;
}
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($name, $phpDocTagValueNode);
$spacelessPhpDocTagNode = new SpacelessPhpDocTagNode($name, $phpDocTagValueNode);
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
return;
}
@ -346,7 +346,7 @@ final class PhpDocInfo
if (!\is_string($name)) {
return;
}
$phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode);
$phpDocTagNode = new PhpDocTagNode($name, $phpDocTagValueNode);
$this->addPhpDocTagNode($phpDocTagNode);
}
public function isNewNode() : bool
@ -368,25 +368,25 @@ final class PhpDocInfo
{
// fallback for invalid tag value node
foreach ($this->phpDocNode->children as $phpDocChildNode) {
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$phpDocChildNode instanceof PhpDocTagNode) {
continue;
}
if ($phpDocChildNode->name !== $name) {
continue;
}
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) {
if (!$phpDocChildNode->value instanceof InvalidTagValueNode) {
continue;
}
return \true;
}
return \false;
}
public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode
public function getReturnTagValue() : ?ReturnTagValueNode
{
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
return $returnTagValueNodes[0] ?? null;
}
public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
public function getParamTagValueByName(string $name) : ?ParamTagValueNode
{
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
@ -410,7 +410,7 @@ final class PhpDocInfo
return \true;
}
foreach ($this->phpDocNode->children as $children) {
if (!$children instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) {
if (!$children instanceof PhpDocTextNode) {
continue;
}
if (\in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], \true)) {
@ -441,8 +441,8 @@ final class PhpDocInfo
return \true;
}
// has a single node with missing start_end
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor();
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor();
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
$phpDocNodeTraverser->traverse($this->phpDocNode);
return $changedPhpDocNodeVisitor->hasChanged();
@ -466,7 +466,7 @@ final class PhpDocInfo
{
return $this->node;
}
public function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : ?string
public function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : ?string
{
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
@ -479,10 +479,10 @@ final class PhpDocInfo
/**
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Type
*/
private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode)
private function getTypeOrMixed(?PhpDocTagValueNode $phpDocTagValueNode)
{
if ($phpDocTagValueNode === null) {
return new \PHPStan\Type\MixedType();
return new MixedType();
}
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
}

View File

@ -64,7 +64,7 @@ final class PhpDocInfoFactory
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
*/
private $phpDocNodeByTypeFinder;
public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeMapper $phpDocNodeMapper, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \PHPStan\PhpDocParser\Lexer\Lexer $lexer, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser $betterPhpDocParser, \Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\Annotation\AnnotationNaming $annotationNaming, \Rector\ChangesReporting\Collector\RectorChangeCollector $rectorChangeCollector, \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
public function __construct(PhpDocNodeMapper $phpDocNodeMapper, CurrentNodeProvider $currentNodeProvider, Lexer $lexer, BetterPhpDocParser $betterPhpDocParser, StaticTypeMapper $staticTypeMapper, AnnotationNaming $annotationNaming, RectorChangeCollector $rectorChangeCollector, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
{
$this->phpDocNodeMapper = $phpDocNodeMapper;
$this->currentNodeProvider = $currentNodeProvider;
@ -75,10 +75,10 @@ final class PhpDocInfoFactory
$this->rectorChangeCollector = $rectorChangeCollector;
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
}
public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
public function createFromNodeOrEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
{
// already added
$phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
return $phpDocInfo;
}
@ -88,7 +88,7 @@ final class PhpDocInfoFactory
}
return $this->createEmpty($node);
}
public function createFromNode(\PhpParser\Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
public function createFromNode(Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
{
$objectHash = \spl_object_hash($node);
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
@ -97,17 +97,17 @@ final class PhpDocInfoFactory
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
$this->currentNodeProvider->setNode($node);
$docComment = $node->getDocComment();
if (!$docComment instanceof \PhpParser\Comment\Doc) {
if (!$docComment instanceof Doc) {
if ($node->getComments() !== []) {
return null;
}
// create empty node
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]);
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
$tokenIterator = new BetterTokenIterator([]);
$phpDocNode = new PhpDocNode([]);
} else {
$text = $docComment->getText();
$tokens = $this->lexer->tokenize($text);
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
$tokenIterator = new BetterTokenIterator($tokens);
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
$this->setPositionOfLastToken($phpDocNode);
}
@ -115,12 +115,12 @@ final class PhpDocInfoFactory
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
return $phpDocInfo;
}
public function createEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
public function createEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
{
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
$this->currentNodeProvider->setNode($node);
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node);
$phpDocNode = new PhpDocNode([]);
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new BetterTokenIterator([]), $node);
// multiline by default
$phpDocInfo->makeMultiLined();
return $phpDocInfo;
@ -128,23 +128,23 @@ final class PhpDocInfoFactory
/**
* Needed for printing
*/
private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
private function setPositionOfLastToken(PhpDocNode $phpDocNode) : void
{
if ($phpDocNode->children === []) {
return;
}
$phpDocChildNodes = $phpDocNode->children;
$phpDocChildNode = \array_pop($phpDocChildNodes);
$startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
$startAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
if ($startAndEnd instanceof StartAndEnd) {
$phpDocNode->setAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
}
}
private function createFromPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
private function createFromPhpDocNode(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
{
$this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator);
$phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector, $this->phpDocNodeByTypeFinder);
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
$node->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
return $phpDocInfo;
}
}

View File

@ -23,23 +23,23 @@ final class TokenIteratorFactory
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
*/
private $privatesAccessor;
public function __construct(\PHPStan\PhpDocParser\Lexer\Lexer $lexer, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor)
public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor)
{
$this->lexer = $lexer;
$this->privatesAccessor = $privatesAccessor;
}
public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
public function create(string $content) : BetterTokenIterator
{
$tokens = $this->lexer->tokenize($content);
return new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
return new BetterTokenIterator($tokens);
}
public function createFromTokenIterator(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
public function createFromTokenIterator(TokenIterator $tokenIterator) : BetterTokenIterator
{
if ($tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
if ($tokenIterator instanceof BetterTokenIterator) {
return $tokenIterator;
}
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
$betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
$betterTokenIterator = new BetterTokenIterator($tokens);
// keep original position
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, self::INDEX);
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);

View File

@ -16,7 +16,7 @@ final class PhpDocClassRenamer
* @var \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher
*/
private $classAnnotationMatcher;
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher)
public function __construct(ClassAnnotationMatcher $classAnnotationMatcher)
{
$this->classAnnotationMatcher = $classAnnotationMatcher;
}
@ -26,7 +26,7 @@ final class PhpDocClassRenamer
*
* @param string[] $oldToNewClasses
*/
public function changeTypeInAnnotationTypes(\PhpParser\Node $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
{
$this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo);
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
@ -35,14 +35,14 @@ final class PhpDocClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
private function processAssertChoiceTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
{
$assertChoiceTagValueNode = $phpDocInfo->findOneByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
if (!$assertChoiceTagValueNode instanceof DoctrineAnnotationTagValueNode) {
return;
}
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
if (!$callback instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) {
if (!$callback instanceof CurlyListNode) {
return;
}
$callbackClass = $callback->getValueWithoutQuotes(0);
@ -58,10 +58,10 @@ final class PhpDocClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
private function processDoctrineRelationTagValueNode(\PhpParser\Node $node, array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
private function processDoctrineRelationTagValueNode(Node $node, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
{
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']);
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
return;
}
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
@ -69,10 +69,10 @@ final class PhpDocClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
private function processSerializerTypeTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
{
$doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
return;
}
foreach ($oldToNewClasses as $oldClass => $newClass) {
@ -82,7 +82,7 @@ final class PhpDocClassRenamer
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
continue;
}
$newContent = \RectorPrefix20220607\Nette\Utils\Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
$newContent = Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
if ($newContent === $className) {
continue;
}
@ -99,7 +99,7 @@ final class PhpDocClassRenamer
/**
* @param array<string, string> $oldToNewClasses
*/
private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node $node, array $oldToNewClasses) : void
private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Node $node, array $oldToNewClasses) : void
{
$classKey = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? 'class' : 'targetEntity';
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey);

View File

@ -10,37 +10,37 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser;
final class PhpDocTagRemover
{
public function removeByName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $name) : void
public function removeByName(PhpDocInfo $phpDocInfo, string $name) : void
{
$phpDocNode = $phpDocInfo->getPhpDocNode();
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$phpDocChildNode instanceof PhpDocTagNode) {
continue;
}
if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) {
unset($phpDocNode->children[$key]);
$phpDocInfo->markAsChanged();
}
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode && $phpDocChildNode->value->hasClassName($name)) {
if ($phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode && $phpDocChildNode->value->hasClassName($name)) {
unset($phpDocNode->children[$key]);
$phpDocInfo->markAsChanged();
}
}
}
public function removeTagValueFromNode(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\PhpDocParser\Ast\Node $desiredNode) : void
public function removeTagValueFromNode(PhpDocInfo $phpDocInfo, Node $desiredNode) : void
{
$phpDocNode = $phpDocInfo->getPhpDocNode();
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use($desiredNode, $phpDocInfo) : ?int {
if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && $node->value === $desiredNode) {
if ($node instanceof PhpDocTagNode && $node->value === $desiredNode) {
$phpDocInfo->markAsChanged();
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
return PhpDocNodeTraverser::NODE_REMOVE;
}
if ($node !== $desiredNode) {
return null;
}
$phpDocInfo->markAsChanged();
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
return PhpDocNodeTraverser::NODE_REMOVE;
});
}
private function areAnnotationNamesEqual(string $firstAnnotationName, string $secondAnnotationName) : bool

View File

@ -34,7 +34,7 @@ final class PhpDocTypeChanger
/**
* @var array<class-string<Node>>
*/
public const ALLOWED_TYPES = [\PHPStan\PhpDocParser\Ast\Type\GenericTypeNode::class, \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode::class, \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode::class, \PHPStan\PhpDocParser\Ast\Type\ArrayShapeNode::class];
public const ALLOWED_TYPES = [GenericTypeNode::class, SpacingAwareArrayTypeNode::class, SpacingAwareCallableTypeNode::class, ArrayShapeNode::class];
/**
* @var string[]
*/
@ -69,7 +69,7 @@ final class PhpDocTypeChanger
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
*/
private $phpDocInfoFactory;
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory $paramPhpDocNodeFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\Comment\CommentsMerger $commentsMerger, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory)
public function __construct(StaticTypeMapper $staticTypeMapper, TypeComparator $typeComparator, ParamPhpDocNodeFactory $paramPhpDocNodeFactory, NodeNameResolver $nodeNameResolver, CommentsMerger $commentsMerger, PhpDocInfoFactory $phpDocInfoFactory)
{
$this->staticTypeMapper = $staticTypeMapper;
$this->typeComparator = $typeComparator;
@ -78,7 +78,7 @@ final class PhpDocTypeChanger
$this->commentsMerger = $commentsMerger;
$this->phpDocInfoFactory = $phpDocInfoFactory;
}
public function changeVarType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void
public function changeVarType(PhpDocInfo $phpDocInfo, Type $newType) : void
{
// better skip, could crash hard
if ($phpDocInfo->hasInvalidTag('@var')) {
@ -89,22 +89,22 @@ final class PhpDocTypeChanger
return;
}
// prevent existing type override by mixed
if (!$phpDocInfo->getVarType() instanceof \PHPStan\Type\MixedType && $newType instanceof \PHPStan\Type\Constant\ConstantArrayType && $newType->getItemType() instanceof \PHPStan\Type\NeverType) {
if (!$phpDocInfo->getVarType() instanceof MixedType && $newType instanceof ConstantArrayType && $newType->getItemType() instanceof NeverType) {
return;
}
// override existing type
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY);
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PROPERTY);
$currentVarTagValueNode = $phpDocInfo->getVarTagValueNode();
if ($currentVarTagValueNode !== null) {
// only change type
$currentVarTagValueNode->type = $newPHPStanPhpDocType;
} else {
// add completely new one
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($newPHPStanPhpDocType, '', '');
$varTagValueNode = new VarTagValueNode($newPHPStanPhpDocType, '', '');
$phpDocInfo->addTagValueNode($varTagValueNode);
}
}
public function changeReturnType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : bool
public function changeReturnType(PhpDocInfo $phpDocInfo, Type $newType) : bool
{
// better not touch this, can crash
if ($phpDocInfo->hasInvalidTag('@return')) {
@ -115,25 +115,25 @@ final class PhpDocTypeChanger
return \false;
}
// override existing type
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN);
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::RETURN);
$currentReturnTagValueNode = $phpDocInfo->getReturnTagValue();
if ($currentReturnTagValueNode !== null) {
// only change type
$currentReturnTagValueNode->type = $newPHPStanPhpDocType;
} else {
// add completely new one
$returnTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($newPHPStanPhpDocType, '');
$returnTagValueNode = new ReturnTagValueNode($newPHPStanPhpDocType, '');
$phpDocInfo->addTagValueNode($returnTagValueNode);
}
return \true;
}
public function changeParamType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType, \PhpParser\Node\Param $param, string $paramName) : void
public function changeParamType(PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : void
{
// better skip, could crash hard
if ($phpDocInfo->hasInvalidTag('@param')) {
return;
}
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM);
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PARAM);
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
// override existing type
if ($paramTagValueNode !== null) {
@ -152,9 +152,9 @@ final class PhpDocTypeChanger
$phpDocInfo->addTagValueNode($paramTagValueNode);
}
}
public function isAllowed(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : bool
public function isAllowed(TypeNode $typeNode) : bool
{
if ($typeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) {
if ($typeNode instanceof BracketsAwareUnionTypeNode) {
foreach ($typeNode->types as $type) {
if ($this->isAllowed($type)) {
return \true;
@ -164,28 +164,28 @@ final class PhpDocTypeChanger
if (\in_array(\get_class($typeNode), self::ALLOWED_TYPES, \true)) {
return \true;
}
if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) {
if (!$typeNode instanceof IdentifierTypeNode) {
return \false;
}
return \in_array((string) $typeNode, self::ALLOWED_IDENTIFIER_TYPENODE_TYPES, \true);
}
public function copyPropertyDocToParam(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void
public function copyPropertyDocToParam(Property $property, Param $param) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($property);
if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
if (!$phpDocInfo instanceof PhpDocInfo) {
return;
}
$varTag = $phpDocInfo->getVarTagValueNode();
if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) {
if (!$varTag instanceof VarTagValueNode) {
$this->processKeepComments($property, $param);
return;
}
if ($varTag->description !== '') {
return;
}
$functionLike = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
$functionLike = $param->getAttribute(AttributeKey::PARENT_NODE);
$paramVarName = $this->nodeNameResolver->getName($param->var);
if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) {
if (!$functionLike instanceof ClassMethod) {
return;
}
if (!$this->isAllowed($varTag->type)) {
@ -194,36 +194,36 @@ final class PhpDocTypeChanger
if (!\is_string($paramVarName)) {
return;
}
$phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class);
$param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
$phpDocInfo = $functionLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
$phpDocInfo->removeByType(VarTagValueNode::class);
$param->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
$phpDocInfo = $functionLike->getAttribute(AttributeKey::PHP_DOC_INFO);
$paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTag, $property);
$this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName);
$this->processKeepComments($property, $param);
}
public function changeVarTypeNode(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : void
public function changeVarTypeNode(PhpDocInfo $phpDocInfo, TypeNode $typeNode) : void
{
// add completely new one
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($typeNode, '', '');
$varTagValueNode = new VarTagValueNode($typeNode, '', '');
$phpDocInfo->addTagValueNode($varTagValueNode);
}
private function processKeepComments(\PhpParser\Node\Stmt\Property $property, \PhpParser\Node\Param $param) : void
private function processKeepComments(Property $property, Param $param) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param);
$varTag = $phpDocInfo->getVarTagValueNode();
$toBeRemoved = !$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
$toBeRemoved = !$varTag instanceof VarTagValueNode;
$this->commentsMerger->keepComments($param, [$property]);
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param);
$varTag = $phpDocInfo->getVarTagValueNode();
if (!$toBeRemoved) {
return;
}
if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) {
if (!$varTag instanceof VarTagValueNode) {
return;
}
if ($varTag->description !== '') {
return;
}
$phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class);
$phpDocInfo->removeByType(VarTagValueNode::class);
}
}

View File

@ -15,22 +15,22 @@ final class PropertyDocBlockManipulator
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
*/
private $phpDocInfoFactory;
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory)
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
}
/**
* @param ParamRename $renameValueObject
*/
public function renameParameterNameInDocBlock(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : void
public function renameParameterNameInDocBlock(RenameValueObjectInterface $renameValueObject) : void
{
$functionLike = $renameValueObject->getFunctionLike();
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) {
if (!$paramTagValueNode instanceof ParamTagValueNode) {
return;
}
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
$paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
}
}

View File

@ -30,36 +30,36 @@ final class VarAnnotationManipulator
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
*/
private $betterNodeFinder;
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder)
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, BetterNodeFinder $betterNodeFinder)
{
$this->phpDocInfoFactory = $phpDocInfoFactory;
$this->phpDocTypeChanger = $phpDocTypeChanger;
$this->betterNodeFinder = $betterNodeFinder;
}
public function decorateNodeWithInlineVarType(\PhpParser\Node $node, \PHPStan\Type\TypeWithClassName $typeWithClassName, string $variableName) : void
public function decorateNodeWithInlineVarType(Node $node, TypeWithClassName $typeWithClassName, string $variableName) : void
{
$phpDocInfo = $this->resolvePhpDocInfo($node);
// already done
if ($phpDocInfo->getVarTagValueNode() !== null) {
return;
}
$fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
$fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
$varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
$phpDocInfo->addTagValueNode($varTagValueNode);
$phpDocInfo->makeSingleLined();
}
public function decorateNodeWithType(\PhpParser\Node $node, \PHPStan\Type\Type $staticType) : void
public function decorateNodeWithType(Node $node, Type $staticType) : void
{
if ($staticType instanceof \PHPStan\Type\MixedType) {
if ($staticType instanceof MixedType) {
return;
}
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType);
}
private function resolvePhpDocInfo(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
private function resolvePhpDocInfo(Node $node) : PhpDocInfo
{
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node);
if ($currentStmt instanceof \PhpParser\Node\Stmt\Expression) {
if ($currentStmt instanceof Expression) {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
} else {
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);

View File

@ -16,9 +16,9 @@ final class PhpDocNodeByTypeFinder
* @param class-string<TNode> $desiredType
* @return array<TNode>
*/
public function findByType(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, string $desiredType) : array
public function findByType(PhpDocNode $phpDocNode, string $desiredType) : array
{
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$phpDocNodeTraverser = new PhpDocNodeTraverser();
$foundNodes = [];
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use(&$foundNodes, $desiredType) : Node {
if (!\is_a($node, $desiredType, \true)) {
@ -34,7 +34,7 @@ final class PhpDocNodeByTypeFinder
* @param class-string[] $classes
* @return DoctrineAnnotationTagValueNode[]
*/
public function findDoctrineAnnotationsByClasses(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, array $classes) : array
public function findDoctrineAnnotationsByClasses(PhpDocNode $phpDocNode, array $classes) : array
{
$doctrineAnnotationTagValueNodes = [];
foreach ($classes as $class) {
@ -47,11 +47,11 @@ final class PhpDocNodeByTypeFinder
* @param class-string $desiredClass
* @return DoctrineAnnotationTagValueNode[]
*/
public function findDoctrineAnnotationsByClass(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, string $desiredClass) : array
public function findDoctrineAnnotationsByClass(PhpDocNode $phpDocNode, string $desiredClass) : array
{
$desiredDoctrineTagValueNodes = [];
/** @var DoctrineAnnotationTagValueNode[] $doctrineTagValueNodes */
$doctrineTagValueNodes = $this->findByType($phpDocNode, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode::class);
$doctrineTagValueNodes = $this->findByType($phpDocNode, DoctrineAnnotationTagValueNode::class);
foreach ($doctrineTagValueNodes as $doctrineTagValueNode) {
if ($doctrineTagValueNode->hasClassName($desiredClass)) {
$desiredDoctrineTagValueNodes[] = $doctrineTagValueNode;

View File

@ -38,23 +38,23 @@ final class PhpDocNodeMapper
/**
* @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors
*/
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors)
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors)
{
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
$this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor;
$this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor;
$this->phpDocNodeVisitors = $phpDocNodeVisitors;
}
public function transform(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
public function transform(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator) : void
{
$this->currentTokenIteratorProvider->setBetterTokenIterator($betterTokenIterator);
$parentPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$parentPhpDocNodeTraverser = new PhpDocNodeTraverser();
$parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor);
$parentPhpDocNodeTraverser->traverse($phpDocNode);
$cloningPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$cloningPhpDocNodeTraverser = new PhpDocNodeTraverser();
$cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor);
$cloningPhpDocNodeTraverser->traverse($phpDocNode);
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
$phpDocNodeTraverser = new PhpDocNodeTraverser();
foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) {
$phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor);
}

View File

@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class ArrayTypePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
final class ArrayTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
{
/**
* @readonly
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(AttributeMirrorer $attributeMirrorer)
{
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) {
if (!$node instanceof ArrayTypeNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) {
if ($node instanceof SpacingAwareArrayTypeNode) {
return null;
}
$spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type);
$spacingAwareArrayTypeNode = new SpacingAwareArrayTypeNode($node->type);
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
return $spacingAwareArrayTypeNode;
}

View File

@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class CallableTypePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
final class CallableTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
{
/**
* @readonly
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(AttributeMirrorer $attributeMirrorer)
{
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode) {
if (!$node instanceof CallableTypeNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode) {
if ($node instanceof SpacingAwareCallableTypeNode) {
return null;
}
$spacingAwareCallableTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType);
$spacingAwareCallableTypeNode = new SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType);
$this->attributeMirrorer->mirror($node, $spacingAwareCallableTypeNode);
return $spacingAwareCallableTypeNode;
}

View File

@ -6,19 +6,19 @@ namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
use PHPStan\PhpDocParser\Ast\Node;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class ChangedPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
final class ChangedPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
{
/**
* @var bool
*/
private $hasChanged = \false;
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
public function beforeTraverse(Node $node) : void
{
$this->hasChanged = \false;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
$origNode = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE);
$origNode = $node->getAttribute(PhpDocAttributeKey::ORIG_NODE);
if ($origNode === null) {
$this->hasChanged = \true;
}

View File

@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class IntersectionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
final class IntersectionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
{
/**
* @readonly
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(AttributeMirrorer $attributeMirrorer)
{
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode) {
if (!$node instanceof IntersectionTypeNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode) {
if ($node instanceof BracketsAwareIntersectionTypeNode) {
return null;
}
$bracketsAwareIntersectionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode($node->types);
$bracketsAwareIntersectionTypeNode = new BracketsAwareIntersectionTypeNode($node->types);
$this->attributeMirrorer->mirror($node, $bracketsAwareIntersectionTypeNode);
return $bracketsAwareIntersectionTypeNode;
}

View File

@ -15,7 +15,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
use Rector\Core\Exception\ShouldNotHappenException;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class TemplatePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
final class TemplatePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
{
/**
* @readonly
@ -27,34 +27,34 @@ final class TemplatePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Ast
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer)
{
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) {
if (!$node instanceof TemplateTagValueNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode) {
if ($node instanceof SpacingAwareTemplateTagValueNode) {
return null;
}
$betterTokenIterator = $this->currentTokenIteratorProvider->provide();
$startAndEnd = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
$startAndEnd = $node->getAttribute(PhpDocAttributeKey::START_AND_END);
if (!$startAndEnd instanceof StartAndEnd) {
throw new ShouldNotHappenException();
}
$prepositions = $this->resolvePreposition($betterTokenIterator, $startAndEnd);
$spacingAwareTemplateTagValueNode = new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions);
$spacingAwareTemplateTagValueNode = new SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions);
$this->attributeMirrorer->mirror($node, $spacingAwareTemplateTagValueNode);
return $spacingAwareTemplateTagValueNode;
}
private function resolvePreposition(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : string
private function resolvePreposition(BetterTokenIterator $betterTokenIterator, StartAndEnd $startAndEnd) : string
{
$partialTokens = $betterTokenIterator->partialTokens($startAndEnd->getStart(), $startAndEnd->getEnd());
foreach ($partialTokens as $partialToken) {
if ($partialToken[1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER) {
if ($partialToken[1] !== Lexer::TOKEN_IDENTIFIER) {
continue;
}
if (!\in_array($partialToken[0], ['as', 'of'], \true)) {

View File

@ -14,7 +14,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
final class UnionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
{
/**
* @readonly
@ -26,49 +26,49 @@ final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplif
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer)
{
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
$this->attributeMirrorer = $attributeMirrorer;
}
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
public function enterNode(Node $node) : ?Node
{
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) {
if (!$node instanceof UnionTypeNode) {
return null;
}
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) {
if ($node instanceof BracketsAwareUnionTypeNode) {
return null;
}
$startAndEnd = $this->resolveStardAndEnd($node);
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
if (!$startAndEnd instanceof StartAndEnd) {
return null;
}
$betterTokenProvider = $this->currentTokenIteratorProvider->provide();
$isWrappedInCurlyBrackets = $this->isWrappedInCurlyBrackets($betterTokenProvider, $startAndEnd);
$bracketsAwareUnionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets);
$bracketsAwareUnionTypeNode = new BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets);
$this->attributeMirrorer->mirror($node, $bracketsAwareUnionTypeNode);
return $bracketsAwareUnionTypeNode;
}
private function isWrappedInCurlyBrackets(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenProvider, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : bool
private function isWrappedInCurlyBrackets(BetterTokenIterator $betterTokenProvider, StartAndEnd $startAndEnd) : bool
{
$previousPosition = $startAndEnd->getStart() - 1;
if ($betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) {
if ($betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) {
return \true;
}
// there is no + 1, as end is right at the next token
return $betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd());
return $betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd());
}
private function resolveStardAndEnd(\PHPStan\PhpDocParser\Ast\Type\UnionTypeNode $unionTypeNode) : ?\Rector\BetterPhpDocParser\ValueObject\StartAndEnd
private function resolveStardAndEnd(UnionTypeNode $unionTypeNode) : ?StartAndEnd
{
$starAndEnd = $unionTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
if ($starAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
$starAndEnd = $unionTypeNode->getAttribute(PhpDocAttributeKey::START_AND_END);
if ($starAndEnd instanceof StartAndEnd) {
return $starAndEnd;
}
// unwrap with parent array type...
$parent = $unionTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT);
if (!$parent instanceof \PHPStan\PhpDocParser\Ast\Node) {
$parent = $unionTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
if (!$parent instanceof Node) {
return null;
}
return $parent->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
return $parent->getAttribute(PhpDocAttributeKey::START_AND_END);
}
}

View File

@ -25,7 +25,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller;
/**
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest
*/
final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
final class BetterPhpDocParser extends PhpDocParser
{
/**
* @readonly
@ -50,76 +50,76 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
/**
* @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators
*/
public function __construct(\PHPStan\PhpDocParser\Parser\TypeParser $typeParser, \PHPStan\PhpDocParser\Parser\ConstExprParser $constExprParser, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller $privatesCaller = null)
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, CurrentNodeProvider $currentNodeProvider, TokenIteratorFactory $tokenIteratorFactory, array $phpDocNodeDecorators, PrivatesCaller $privatesCaller = null)
{
$privatesCaller = $privatesCaller ?? new \RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller();
$privatesCaller = $privatesCaller ?? new PrivatesCaller();
$this->currentNodeProvider = $currentNodeProvider;
$this->tokenIteratorFactory = $tokenIteratorFactory;
$this->phpDocNodeDecorators = $phpDocNodeDecorators;
$this->privatesCaller = $privatesCaller;
parent::__construct($typeParser, $constExprParser);
}
public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
public function parse(TokenIterator $tokenIterator) : PhpDocNode
{
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PHPDOC);
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PHPDOC);
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
$children = [];
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) {
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
while ($tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) {
while ($tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
}
}
// might be in the middle of annotations
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC);
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode($children);
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC);
$phpDocNode = new PhpDocNode($children);
// decorate FQN classes etc.
$node = $this->currentNodeProvider->getNode();
if (!$node instanceof \PhpParser\Node) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
if (!$node instanceof Node) {
throw new ShouldNotHappenException();
}
foreach ($this->phpDocNodeDecorators as $phpDocNodeDecorator) {
$phpDocNodeDecorator->decorate($phpDocNode, $node);
}
return $phpDocNode;
}
public function parseTag(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
public function parseTag(TokenIterator $tokenIterator) : PhpDocTagNode
{
// replace generic nodes with DoctrineAnnotations
if (!$tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
throw new \Rector\Core\Exception\ShouldNotHappenException();
if (!$tokenIterator instanceof BetterTokenIterator) {
throw new ShouldNotHappenException();
}
$tag = $this->resolveTag($tokenIterator);
$phpDocTagValueNode = $this->parseTagValue($tokenIterator, $tag);
return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($tag, $phpDocTagValueNode);
return new PhpDocTagNode($tag, $phpDocTagValueNode);
}
/**
* @param BetterTokenIterator $tokenIterator
*/
public function parseTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator, string $tag) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode
public function parseTagValue(TokenIterator $tokenIterator, string $tag) : PhpDocTagValueNode
{
$startPosition = $tokenIterator->currentPosition();
$tagValueNode = parent::parseTagValue($tokenIterator, $tag);
$endPosition = $tokenIterator->currentPosition();
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
$tagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
$tagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
return $tagValueNode;
}
/**
* @return PhpDocTextNode|PhpDocTagNode
*/
private function parseChildAndStoreItsPositions(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode
private function parseChildAndStoreItsPositions(TokenIterator $tokenIterator) : PhpDocChildNode
{
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
$startPosition = $betterTokenIterator->currentPosition();
/** @var PhpDocChildNode $phpDocNode */
$phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
$endPosition = $betterTokenIterator->currentPosition();
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
$phpDocNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
return $phpDocNode;
}
private function resolveTag(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : string
private function resolveTag(BetterTokenIterator $tokenIterator) : string
{
$tag = $tokenIterator->currentTokenValue();
$tokenIterator->next();
@ -129,7 +129,7 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
}
// is not e.g "@var "
// join tags like "@ORM\Column" etc.
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) {
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
return $tag;
}
// @todo use joinUntil("(")?

View File

@ -10,26 +10,26 @@ use PHPStan\PhpDocParser\Parser\TypeParser;
use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
final class BetterTypeParser extends \PHPStan\PhpDocParser\Parser\TypeParser
final class BetterTypeParser extends TypeParser
{
/**
* @readonly
* @var \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory
*/
private $tokenIteratorFactory;
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, ?\PHPStan\PhpDocParser\Parser\ConstExprParser $constExprParser = null)
public function __construct(TokenIteratorFactory $tokenIteratorFactory, ?ConstExprParser $constExprParser = null)
{
$this->tokenIteratorFactory = $tokenIteratorFactory;
parent::__construct($constExprParser);
}
public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
public function parse(TokenIterator $tokenIterator) : TypeNode
{
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
$startPosition = $betterTokenIterator->currentPosition();
$typeNode = parent::parse($betterTokenIterator);
$endPosition = $betterTokenIterator->currentPosition();
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
$typeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
$typeNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
return $typeNode;
}
}

View File

@ -36,21 +36,21 @@ final class ClassAnnotationMatcher
* @var \PHPStan\Reflection\ReflectionProvider
*/
private $reflectionProvider;
public function __construct(\Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher $useImportNameMatcher, \Rector\Naming\Naming\UseImportsResolver $useImportsResolver, \PHPStan\Reflection\ReflectionProvider $reflectionProvider)
public function __construct(UseImportNameMatcher $useImportNameMatcher, UseImportsResolver $useImportsResolver, ReflectionProvider $reflectionProvider)
{
$this->useImportNameMatcher = $useImportNameMatcher;
$this->useImportsResolver = $useImportsResolver;
$this->reflectionProvider = $reflectionProvider;
}
public function resolveTagToKnownFullyQualifiedName(string $tag, \PhpParser\Node $node) : ?string
public function resolveTagToKnownFullyQualifiedName(string $tag, Node $node) : ?string
{
return $this->_resolveTagFullyQualifiedName($tag, $node, \true);
}
public function resolveTagFullyQualifiedName(string $tag, \PhpParser\Node $node) : ?string
public function resolveTagFullyQualifiedName(string $tag, Node $node) : ?string
{
return $this->_resolveTagFullyQualifiedName($tag, $node, \false);
}
private function _resolveTagFullyQualifiedName(string $tag, \PhpParser\Node $node, bool $returnNullOnUnknownClass) : ?string
private function _resolveTagFullyQualifiedName(string $tag, Node $node, bool $returnNullOnUnknownClass) : ?string
{
$uniqueHash = $tag . \spl_object_hash($node);
if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) {
@ -71,10 +71,10 @@ final class ClassAnnotationMatcher
/**
* @param Use_[]|GroupUse[] $uses
*/
private function resolveFullyQualifiedClass(array $uses, \PhpParser\Node $node, string $tag, bool $returnNullOnUnknownClass) : ?string
private function resolveFullyQualifiedClass(array $uses, Node $node, string $tag, bool $returnNullOnUnknownClass) : ?string
{
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
if ($scope instanceof \PHPStan\Analyser\Scope) {
$scope = $node->getAttribute(AttributeKey::SCOPE);
if ($scope instanceof Scope) {
$namespace = $scope->getNamespace();
if ($namespace !== null) {
$namespacedTag = $namespace . '\\' . $tag;
@ -99,9 +99,9 @@ final class ClassAnnotationMatcher
private function resolveAsAliased(array $uses, string $tag, bool $returnNullOnUnknownClass) : ?string
{
foreach ($uses as $use) {
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
$prefix = $use instanceof GroupUse ? $use->prefix . '\\' : '';
foreach ($use->uses as $useUse) {
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
if (!$useUse->alias instanceof Identifier) {
continue;
}
if ($useUse->alias->toString() === $tag) {

View File

@ -16,7 +16,7 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser;
* Decorate node with fully qualified class name for const epxr,
* e.g. Direction::*
*/
final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface
final class ConstExprClassNameDecorator implements PhpDocNodeDecoratorInterface
{
/**
* @readonly
@ -28,28 +28,28 @@ final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Co
* @var \Symplify\Astral\PhpDocParser\PhpDocNodeTraverser
*/
private $phpDocNodeTraverser;
public function __construct(\Rector\StaticTypeMapper\Naming\NameScopeFactory $nameScopeFactory, \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser $phpDocNodeTraverser)
public function __construct(NameScopeFactory $nameScopeFactory, PhpDocNodeTraverser $phpDocNodeTraverser)
{
$this->nameScopeFactory = $nameScopeFactory;
$this->phpDocNodeTraverser = $phpDocNodeTraverser;
}
public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void
public function decorate(PhpDocNode $phpDocNode, PhpNode $phpNode) : void
{
$this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use($phpNode) {
if (!$node instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode) {
$this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function (Node $node) use($phpNode) {
if (!$node instanceof ConstExprNode) {
return null;
}
$className = $this->resolveFullyQualifiedClass($node, $phpNode);
if ($className === null) {
return null;
}
$node->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $className);
$node->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $className);
return $node;
});
}
private function resolveFullyQualifiedClass(\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode $constExprNode, \PhpParser\Node $phpNode) : ?string
private function resolveFullyQualifiedClass(ConstExprNode $constExprNode, PhpNode $phpNode) : ?string
{
if (!$constExprNode instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode) {
if (!$constExprNode instanceof ConstFetchNode) {
return null;
}
$nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($phpNode);

View File

@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap;
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
use Rector\Core\Util\StringUtils;
final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface
final class DoctrineAnnotationDecorator implements PhpDocNodeDecoratorInterface
{
/**
* Special short annotations, that are resolved as FQN by Doctrine annotation parser
@ -58,14 +58,14 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
*/
private $attributeMirrorer;
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, TokenIteratorFactory $tokenIteratorFactory, AttributeMirrorer $attributeMirrorer)
{
$this->classAnnotationMatcher = $classAnnotationMatcher;
$this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser;
$this->tokenIteratorFactory = $tokenIteratorFactory;
$this->attributeMirrorer = $attributeMirrorer;
}
public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void
public function decorate(PhpDocNode $phpDocNode, Node $phpNode) : void
{
// merge split doctrine nested tags
$this->mergeNestedDoctrineAnnotations($phpDocNode);
@ -74,17 +74,17 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
/**
* Join token iterator with all the following nodes if nested
*/
private function mergeNestedDoctrineAnnotations(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
private function mergeNestedDoctrineAnnotations(PhpDocNode $phpDocNode) : void
{
$removedKeys = [];
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
if (\in_array($key, $removedKeys, \true)) {
continue;
}
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$phpDocChildNode instanceof PhpDocTagNode) {
continue;
}
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
continue;
}
$genericTagValueNode = $phpDocChildNode->value;
@ -95,21 +95,21 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
break;
}
$nextPhpDocChildNode = $phpDocNode->children[$key];
if ($nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode && \Rector\Core\Util\StringUtils::isMatch($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) {
if ($nextPhpDocChildNode instanceof PhpDocTextNode && StringUtils::isMatch($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) {
// @todo how to detect previously opened brackets?
// probably local property with holding count of opened brackets
$composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->text;
$genericTagValueNode->value = $composedContent;
$startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode);
$phpDocChildNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
$phpDocChildNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
$removedKeys[] = $key;
$removedKeys[] = $key + 1;
continue;
}
if (!$nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$nextPhpDocChildNode instanceof PhpDocTagNode) {
continue;
}
if (!$nextPhpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
if (!$nextPhpDocChildNode->value instanceof GenericTagValueNode) {
continue;
}
if ($this->isClosedContent($genericTagValueNode->value)) {
@ -119,13 +119,13 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
// cleanup the next from closing
$genericTagValueNode->value = $composedContent;
$startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode);
$phpDocChildNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
$phpDocChildNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
$currentChildValueNode = $phpDocNode->children[$key];
if (!$currentChildValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$currentChildValueNode instanceof PhpDocTagNode) {
continue;
}
$currentGenericTagValueNode = $currentChildValueNode->value;
if (!$currentGenericTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
if (!$currentGenericTagValueNode instanceof GenericTagValueNode) {
continue;
}
$removedKeys[] = $key;
@ -138,22 +138,22 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
unset($phpDocNode->children[$key]);
}
}
private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $currentPhpNode) : void
private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes(PhpDocNode $phpDocNode, Node $currentPhpNode) : void
{
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
// the @\FQN use case
if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) {
if ($phpDocChildNode instanceof PhpDocTextNode) {
$spacelessPhpDocTagNode = $this->resolveFqnAnnotationSpacelessPhpDocTagNode($phpDocChildNode);
if (!$spacelessPhpDocTagNode instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) {
if (!$spacelessPhpDocTagNode instanceof SpacelessPhpDocTagNode) {
continue;
}
$phpDocNode->children[$key] = $spacelessPhpDocTagNode;
continue;
}
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
if (!$phpDocChildNode instanceof PhpDocTagNode) {
continue;
}
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
continue;
}
// known doc tag to annotation class
@ -181,51 +181,51 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
return \true;
}
do {
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), '(') !== \false) {
if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_OPEN_CURLY_BRACKET, Lexer::TOKEN_OPEN_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), '(') !== \false) {
++$openBracketCount;
}
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), ')') !== \false) {
if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_CLOSE_CURLY_BRACKET, Lexer::TOKEN_CLOSE_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), ')') !== \false) {
++$closeBracketCount;
}
$composedTokenIterator->next();
} while ($composedTokenIterator->currentPosition() < $tokenCount - 1);
return $openBracketCount === $closeBracketCount;
}
private function createSpacelessPhpDocTagNode(string $tagName, \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode $genericTagValueNode, string $fullyQualifiedAnnotationClass) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode
private function createSpacelessPhpDocTagNode(string $tagName, GenericTagValueNode $genericTagValueNode, string $fullyQualifiedAnnotationClass) : SpacelessPhpDocTagNode
{
$formerStartEnd = $genericTagValueNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
$formerStartEnd = $genericTagValueNode->getAttribute(PhpDocAttributeKey::START_AND_END);
return $this->createDoctrineSpacelessPhpDocTagNode($genericTagValueNode->value, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd);
}
private function createDoctrineSpacelessPhpDocTagNode(string $annotationContent, string $tagName, string $fullyQualifiedAnnotationClass, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode
private function createDoctrineSpacelessPhpDocTagNode(string $annotationContent, string $tagName, string $fullyQualifiedAnnotationClass, StartAndEnd $startAndEnd) : SpacelessPhpDocTagNode
{
$nestedTokenIterator = $this->tokenIteratorFactory->create($annotationContent);
// mimics doctrine behavior just in phpdoc-parser syntax :)
// https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L742
$values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($nestedTokenIterator);
$identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tagName);
$identifierTypeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass);
$doctrineAnnotationTagValueNode = new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationContent, $values, \Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null);
$doctrineAnnotationTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
return new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($tagName, $doctrineAnnotationTagValueNode);
$identifierTypeNode = new IdentifierTypeNode($tagName);
$identifierTypeNode->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass);
$doctrineAnnotationTagValueNode = new DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationContent, $values, SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null);
$doctrineAnnotationTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
return new SpacelessPhpDocTagNode($tagName, $doctrineAnnotationTagValueNode);
}
private function combineStartAndEnd(\PHPStan\PhpDocParser\Ast\Node $startPhpDocChildNode, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $endPhpDocChildNode) : \Rector\BetterPhpDocParser\ValueObject\StartAndEnd
private function combineStartAndEnd(\PHPStan\PhpDocParser\Ast\Node $startPhpDocChildNode, PhpDocChildNode $endPhpDocChildNode) : StartAndEnd
{
/** @var StartAndEnd $currentStartAndEnd */
$currentStartAndEnd = $startPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
$currentStartAndEnd = $startPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
/** @var StartAndEnd $nextStartAndEnd */
$nextStartAndEnd = $endPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
return new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd());
$nextStartAndEnd = $endPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
return new StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd());
}
private function resolveFqnAnnotationSpacelessPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode $phpDocTextNode) : ?\Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode
private function resolveFqnAnnotationSpacelessPhpDocTagNode(PhpDocTextNode $phpDocTextNode) : ?SpacelessPhpDocTagNode
{
$match = \RectorPrefix20220607\Nette\Utils\Strings::match($phpDocTextNode->text, self::LONG_ANNOTATION_REGEX);
$match = Strings::match($phpDocTextNode->text, self::LONG_ANNOTATION_REGEX);
$fullyQualifiedAnnotationClass = $match['class_name'] ?? null;
if ($fullyQualifiedAnnotationClass === null) {
return null;
}
$annotationContent = $match['annotation_content'] ?? null;
$tagName = '@\\' . $fullyQualifiedAnnotationClass;
$formerStartEnd = $phpDocTextNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
$formerStartEnd = $phpDocTextNode->getAttribute(PhpDocAttributeKey::START_AND_END);
return $this->createDoctrineSpacelessPhpDocTagNode($annotationContent, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd);
}
}

View File

@ -25,7 +25,7 @@ use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper;
use Rector\StaticTypeMapper\StaticTypeMapper;
use RectorPrefix20220607\ReturnTypeWillChange;
use ReturnTypeWillChange;
/**
* @see https://wiki.php.net/rfc/internal_method_return_types#proposal
*/
@ -79,7 +79,7 @@ final class PhpDocFromTypeDeclarationDecorator
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
*/
private $phpAttributeAnalyzer;
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\NodeNameResolver\NodeNameResolver $nodeNameResolver, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger, \Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper $typeUnwrapper, \Rector\Core\PhpParser\Node\BetterNodeFinder $betterNodeFinder, \Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory $phpAttributeGroupFactory, \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer $phpAttributeAnalyzer)
public function __construct(StaticTypeMapper $staticTypeMapper, PhpDocInfoFactory $phpDocInfoFactory, NodeNameResolver $nodeNameResolver, PhpDocTypeChanger $phpDocTypeChanger, TypeUnwrapper $typeUnwrapper, BetterNodeFinder $betterNodeFinder, PhpAttributeGroupFactory $phpAttributeGroupFactory, PhpAttributeAnalyzer $phpAttributeAnalyzer)
{
$this->staticTypeMapper = $staticTypeMapper;
$this->phpDocInfoFactory = $phpDocInfoFactory;
@ -102,11 +102,11 @@ final class PhpDocFromTypeDeclarationDecorator
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type);
$functionLike->returnType = null;
if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) {
if (!$functionLike instanceof ClassMethod) {
return;
}
$classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]);
if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) {
$classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [Class_::class, Interface_::class]);
if (!$classLike instanceof ClassLike) {
return;
}
if (!$this->isRequireReturnTypeWillChange(\get_class($type), $classLike, $functionLike)) {
@ -119,7 +119,7 @@ final class PhpDocFromTypeDeclarationDecorator
* @param array<class-string<Type>> $requiredTypes
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
*/
public function decorateParam(\PhpParser\Node\Param $param, $functionLike, array $requiredTypes) : void
public function decorateParam(Param $param, $functionLike, array $requiredTypes) : void
{
if ($param->type === null) {
return;
@ -133,7 +133,7 @@ final class PhpDocFromTypeDeclarationDecorator
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
*/
public function decorateParamWithSpecificType(\PhpParser\Node\Param $param, $functionLike, \PHPStan\Type\Type $requireType) : void
public function decorateParamWithSpecificType(Param $param, $functionLike, Type $requireType) : void
{
if ($param->type === null) {
return;
@ -148,7 +148,7 @@ final class PhpDocFromTypeDeclarationDecorator
* @return bool True if node was changed
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
*/
public function decorateReturnWithSpecificType($functionLike, \PHPStan\Type\Type $requireType) : bool
public function decorateReturnWithSpecificType($functionLike, Type $requireType) : bool
{
if ($functionLike->returnType === null) {
return \false;
@ -159,16 +159,16 @@ final class PhpDocFromTypeDeclarationDecorator
$this->decorate($functionLike);
return \true;
}
private function isRequireReturnTypeWillChange(string $type, \PhpParser\Node\Stmt\ClassLike $classLike, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool
private function isRequireReturnTypeWillChange(string $type, ClassLike $classLike, ClassMethod $classMethod) : bool
{
if (!\array_key_exists($type, self::ADD_RETURN_TYPE_WILL_CHANGE)) {
return \false;
}
$className = (string) $this->nodeNameResolver->getName($classLike);
$objectClass = new \PHPStan\Type\ObjectType($className);
$objectClass = new ObjectType($className);
$methodName = $this->nodeNameResolver->getName($classMethod);
foreach (self::ADD_RETURN_TYPE_WILL_CHANGE[$type] as $class => $methods) {
$objectClassConfig = new \PHPStan\Type\ObjectType($class);
$objectClassConfig = new ObjectType($class);
if (!$objectClassConfig->isSuperTypeOf($objectClass)->yes()) {
continue;
}
@ -185,14 +185,14 @@ final class PhpDocFromTypeDeclarationDecorator
/**
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode
*/
private function isTypeMatch($typeNode, \PHPStan\Type\Type $requireType) : bool
private function isTypeMatch($typeNode, Type $requireType) : bool
{
$returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($typeNode);
// cover nullable union types
if ($returnType instanceof \PHPStan\Type\UnionType) {
if ($returnType instanceof UnionType) {
$returnType = $this->typeUnwrapper->unwrapNullableType($returnType);
}
if ($returnType instanceof \PHPStan\Type\ObjectType) {
if ($returnType instanceof ObjectType) {
return $returnType->equals($requireType);
}
return \get_class($returnType) === \get_class($requireType);
@ -200,7 +200,7 @@ final class PhpDocFromTypeDeclarationDecorator
/**
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
*/
private function moveParamTypeToParamDoc($functionLike, \PhpParser\Node\Param $param, \PHPStan\Type\Type $type) : void
private function moveParamTypeToParamDoc($functionLike, Param $param, Type $type) : void
{
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
$paramName = $this->nodeNameResolver->getName($param);
@ -210,7 +210,7 @@ final class PhpDocFromTypeDeclarationDecorator
/**
* @param array<class-string<Type>> $requiredTypes
*/
private function isMatchingType(\PHPStan\Type\Type $type, array $requiredTypes) : bool
private function isMatchingType(Type $type, array $requiredTypes) : bool
{
return \in_array(\get_class($type), $requiredTypes, \true);
}

View File

@ -26,7 +26,7 @@ final class StaticDoctrineAnnotationParser
* @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
*/
private $arrayParser;
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser $plainValueParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser)
public function __construct(PlainValueParser $plainValueParser, ArrayParser $arrayParser)
{
$this->plainValueParser = $plainValueParser;
$this->arrayParser = $arrayParser;
@ -35,14 +35,14 @@ final class StaticDoctrineAnnotationParser
* mimics: https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1024-L1041
* @return array<mixed, mixed>
*/
public function resolveAnnotationMethodCall(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
public function resolveAnnotationMethodCall(BetterTokenIterator $tokenIterator) : array
{
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) {
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) {
return [];
}
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES);
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES);
// empty ()
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) {
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) {
return [];
}
return $this->resolveAnnotationValues($tokenIterator);
@ -51,19 +51,19 @@ final class StaticDoctrineAnnotationParser
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224
* @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/
public function resolveAnnotationValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
public function resolveAnnotationValue(BetterTokenIterator $tokenIterator)
{
// skips dummy tokens like newlines
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
// no assign
if (!$tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL)) {
if (!$tokenIterator->isNextTokenType(Lexer::TOKEN_EQUAL)) {
// 1. plain value - mimics https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1234-L1282
return $this->parseValue($tokenIterator);
}
// 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303
/** @var int $key */
$key = $this->parseValue($tokenIterator);
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL);
$tokenIterator->consumeTokenType(Lexer::TOKEN_EQUAL);
// mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238
$value = $this->parseValue($tokenIterator);
return [
@ -75,7 +75,7 @@ final class StaticDoctrineAnnotationParser
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079
* @return array<mixed>
*/
private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
private function resolveAnnotationValues(BetterTokenIterator $tokenIterator) : array
{
$values = [];
$resolvedValue = $this->resolveAnnotationValue($tokenIterator);
@ -84,10 +84,10 @@ final class StaticDoctrineAnnotationParser
} else {
$values[] = $resolvedValue;
}
while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) {
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) {
$tokenIterator->next();
// if is next item just closing brackets
if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) {
if ($tokenIterator->isNextTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) {
continue;
}
$nestedValues = $this->resolveAnnotationValue($tokenIterator);
@ -102,11 +102,11 @@ final class StaticDoctrineAnnotationParser
/**
* @return \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode|string|mixed[]|\PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode|\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
*/
private function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
private function parseValue(BetterTokenIterator $tokenIterator)
{
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET)) {
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET)) {
$items = $this->arrayParser->parseCurlyArray($tokenIterator);
return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode($items);
return new CurlyListNode($items);
}
return $this->plainValueParser->parseValue($tokenIterator);
}

Some files were not shown because too many files have changed in this diff Show More