mirror of https://github.com/rectorphp/rector.git
Updated Rector to commit 2e977bd3aad21113e0bb7e2aa9b102f6f1e9246d
2e977bd3aa
deploy to original repository
This commit is contained in:
parent
869b6f99f5
commit
bdfd24339f
|
@ -20,9 +20,9 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||||
\error_reporting(\E_ALL);
|
\error_reporting(\E_ALL);
|
||||||
\ini_set('display_errors', 'stderr');
|
\ini_set('display_errors', 'stderr');
|
||||||
\gc_disable();
|
\gc_disable();
|
||||||
\define('__RECTOR_RUNNING__', \true);
|
\define('RectorPrefix20220607\\__RECTOR_RUNNING__', \true);
|
||||||
// Require Composer autoload.php
|
// Require Composer autoload.php
|
||||||
$autoloadIncluder = new \RectorPrefix20220607\AutoloadIncluder();
|
$autoloadIncluder = new AutoloadIncluder();
|
||||||
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
||||||
final class AutoloadIncluder
|
final class AutoloadIncluder
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ final class AutoloadIncluder
|
||||||
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
|
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
|
||||||
{
|
{
|
||||||
// Rector's vendor is already loaded
|
// Rector's vendor is already loaded
|
||||||
if (\class_exists(\Rector\Core\Kernel\RectorKernel::class)) {
|
if (\class_exists(RectorKernel::class)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// in Rector develop repository
|
// in Rector develop repository
|
||||||
|
@ -95,7 +95,6 @@ final class AutoloadIncluder
|
||||||
require_once $filePath;
|
require_once $filePath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
\class_alias('RectorPrefix20220607\\AutoloadIncluder', 'AutoloadIncluder', \false);
|
|
||||||
if (\file_exists(__DIR__ . '/../preload.php') && \is_dir(__DIR__ . '/../vendor')) {
|
if (\file_exists(__DIR__ . '/../preload.php') && \is_dir(__DIR__ . '/../vendor')) {
|
||||||
require_once __DIR__ . '/../preload.php';
|
require_once __DIR__ . '/../preload.php';
|
||||||
}
|
}
|
||||||
|
@ -104,26 +103,26 @@ $autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-auto
|
||||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||||
$autoloadIncluder->autoloadRectorInstalledAsGlobalDependency();
|
$autoloadIncluder->autoloadRectorInstalledAsGlobalDependency();
|
||||||
$autoloadIncluder->autoloadFromCommandLine();
|
$autoloadIncluder->autoloadFromCommandLine();
|
||||||
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
|
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||||
try {
|
try {
|
||||||
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
||||||
$rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory();
|
$rectorContainerFactory = new RectorContainerFactory();
|
||||||
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
||||||
} catch (\Throwable $throwable) {
|
} catch (\Throwable $throwable) {
|
||||||
// for json output
|
// for json output
|
||||||
$argvInput = new \RectorPrefix20220607\Symfony\Component\Console\Input\ArgvInput();
|
$argvInput = new ArgvInput();
|
||||||
$outputFormat = $argvInput->getParameterOption('--' . \Rector\Core\Configuration\Option::OUTPUT_FORMAT);
|
$outputFormat = $argvInput->getParameterOption('--' . Option::OUTPUT_FORMAT);
|
||||||
// report fatal error in json format
|
// report fatal error in json format
|
||||||
if ($outputFormat === \Rector\ChangesReporting\Output\JsonOutputFormatter::NAME) {
|
if ($outputFormat === JsonOutputFormatter::NAME) {
|
||||||
echo \RectorPrefix20220607\Nette\Utils\Json::encode(['fatal_errors' => [$throwable->getMessage()]]);
|
echo Json::encode(['fatal_errors' => [$throwable->getMessage()]]);
|
||||||
} else {
|
} else {
|
||||||
// report fatal errors in console format
|
// 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 = $rectorConsoleOutputStyleFactory->create();
|
||||||
$rectorConsoleOutputStyle->error($throwable->getMessage());
|
$rectorConsoleOutputStyle->error($throwable->getMessage());
|
||||||
}
|
}
|
||||||
exit(\RectorPrefix20220607\Symfony\Component\Console\Command\Command::FAILURE);
|
exit(Command::FAILURE);
|
||||||
}
|
}
|
||||||
/** @var ConsoleApplication $application */
|
/** @var ConsoleApplication $application */
|
||||||
$application = $container->get(\Rector\Core\Console\ConsoleApplication::class);
|
$application = $container->get(ConsoleApplication::class);
|
||||||
exit($application->run());
|
exit($application->run());
|
||||||
|
|
|
@ -51,9 +51,9 @@ use RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard;
|
||||||
use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
use RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||||
use RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem;
|
use RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem;
|
||||||
use RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem;
|
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
|
// 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->paths([]);
|
||||||
$rectorConfig->skip([]);
|
$rectorConfig->skip([]);
|
||||||
$rectorConfig->autoloadPaths([]);
|
$rectorConfig->autoloadPaths([]);
|
||||||
|
@ -81,17 +81,17 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
||||||
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
|
__DIR__ . '/../packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php',
|
||||||
]);
|
]);
|
||||||
// psr-4
|
// 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']);
|
$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
|
// parallel
|
||||||
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Yaml\ParametersMerger::class);
|
$services->set(ParametersMerger::class);
|
||||||
// use faster in-memory cache in CI.
|
// use faster in-memory cache in CI.
|
||||||
// CI always starts from scratch, therefore IO intensive caching is not worth it
|
// 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()) {
|
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();
|
$extensionConfigFiles = $extensionConfigResolver->provide();
|
||||||
foreach ($extensionConfigFiles as $extensionConfigFile) {
|
foreach ($extensionConfigFiles as $extensionConfigFile) {
|
||||||
$rectorConfig->import($extensionConfigFile->getRealPath());
|
$rectorConfig->import($extensionConfigFile->getRealPath());
|
||||||
|
@ -99,43 +99,43 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
||||||
// require only in dev
|
// require only in dev
|
||||||
$rectorConfig->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');
|
$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->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->alias(Application::class, ConsoleApplication::class);
|
||||||
$services->set(\Rector\Core\Validation\Collector\EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
|
$services->set(EmptyConfigurableRectorCollector::class)->arg('$containerBuilder', service('service_container'));
|
||||||
$services->set(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class);
|
$services->set(SimpleCallableNodeTraverser::class);
|
||||||
$services->set(\PhpParser\BuilderFactory::class);
|
$services->set(BuilderFactory::class);
|
||||||
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
|
$services->set(CloningVisitor::class);
|
||||||
$services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class);
|
$services->set(NodeConnectingVisitor::class);
|
||||||
$services->set(\PhpParser\NodeFinder::class);
|
$services->set(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(RectorConsoleOutputStyle::class)->factory([service(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(Parser::class)->factory([service(PHPStanServicesFactory::class), 'createPHPStanParser']);
|
||||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createEmulativeLexer']);
|
$services->set(Lexer::class)->factory([service(PHPStanServicesFactory::class), 'createEmulativeLexer']);
|
||||||
// symplify/package-builder
|
// symplify/package-builder
|
||||||
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemGuard::class);
|
$services->set(FileSystemGuard::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
|
$services->set(PrivatesAccessor::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
|
$services->set(PrivatesCaller::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Finder\FinderSanitizer::class);
|
$services->set(FinderSanitizer::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\FileSystemFilter::class);
|
$services->set(FileSystemFilter::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
|
$services->set(ParameterProvider::class)->arg('$container', service('service_container'));
|
||||||
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\SmartFileSystem::class);
|
$services->set(SmartFileSystem::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\SmartFileSystem\Json\JsonFileSystem::class);
|
$services->set(JsonFileSystem::class);
|
||||||
$services->set(\RectorPrefix20220607\Doctrine\Inflector\Rules\English\InflectorFactory::class);
|
$services->set(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(Inflector::class)->factory([service(InflectorFactory::class), 'build']);
|
||||||
$services->set(\RectorPrefix20220607\Composer\Semver\VersionParser::class);
|
$services->set(VersionParser::class);
|
||||||
$services->set(\RectorPrefix20220607\Symplify\PackageBuilder\Php\TypeChecker::class);
|
$services->set(TypeChecker::class);
|
||||||
// phpdoc parser
|
// phpdoc parser
|
||||||
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
|
$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
|
// cache
|
||||||
$services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']);
|
$services->set(DependencyResolver::class)->factory([service(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(FileHelper::class)->factory([service(PHPStanServicesFactory::class), 'createFileHelper']);
|
||||||
$services->set(\Rector\Caching\Cache::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\CacheFactory::class), 'create']);
|
$services->set(Cache::class)->factory([service(CacheFactory::class), 'create']);
|
||||||
// type resolving
|
// type resolving
|
||||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class);
|
$services->set(IntermediateSourceLocator::class);
|
||||||
$services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class);
|
$services->alias(TypeParser::class, BetterTypeParser::class);
|
||||||
// PHPStan services
|
// PHPStan services
|
||||||
$services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20220607\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']);
|
$services->set(ReflectionProvider::class)->factory([service(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(NodeScopeResolver::class)->factory([service(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(ScopeFactory::class)->factory([service(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(TypeNodeResolver::class)->factory([service(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(DynamicSourceLocatorProvider::class)->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
|
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class);
|
$rectorConfig->rule(ActionInjectionToConstructorInjectionRector::class);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -32,7 +32,7 @@ use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||||
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class, ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']);
|
$rectorConfig->ruleWithConfiguration(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]);
|
$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]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -50,54 +50,54 @@ use Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector;
|
||||||
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
|
use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
|
||||||
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
|
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
|
||||||
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
|
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rules([
|
$rectorConfig->rules([
|
||||||
\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class,
|
UnwrapFutureCompatibleIfFunctionExistsRector::class,
|
||||||
\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class,
|
UnwrapFutureCompatibleIfPhpVersionRector::class,
|
||||||
\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class,
|
RecastingRemovalRector::class,
|
||||||
\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class,
|
RemoveDeadStmtRector::class,
|
||||||
\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class,
|
RemoveDuplicatedArrayKeyRector::class,
|
||||||
\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class,
|
RemoveUnusedForeachKeyRector::class,
|
||||||
\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class,
|
RemoveParentCallWithoutParentRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class,
|
RemoveEmptyClassMethodRector::class,
|
||||||
\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class,
|
RemoveDoubleAssignRector::class,
|
||||||
\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class,
|
SimplifyMirrorAssignRector::class,
|
||||||
\Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class,
|
RemoveOverriddenValuesRector::class,
|
||||||
\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class,
|
RemoveUnusedPrivatePropertyRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class,
|
RemoveUnusedPrivateClassConstantRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class,
|
RemoveUnusedPrivateMethodRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class,
|
RemoveDeadConstructorRector::class,
|
||||||
\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class,
|
RemoveDeadReturnRector::class,
|
||||||
\Rector\DeadCode\Rector\For_\RemoveDeadContinueRector::class,
|
RemoveDeadContinueRector::class,
|
||||||
\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class,
|
RemoveDeadIfForeachForRector::class,
|
||||||
\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class,
|
RemoveAndTrueRector::class,
|
||||||
\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class,
|
RemoveConcatAutocastRector::class,
|
||||||
\Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector::class,
|
SimplifyUselessVariableRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class,
|
RemoveDelegatingParentCallRector::class,
|
||||||
\Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class,
|
RemoveDuplicatedInstanceOfRector::class,
|
||||||
\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class,
|
RemoveDuplicatedCaseInSwitchRector::class,
|
||||||
\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class,
|
RemoveNullPropertyInitializationRector::class,
|
||||||
\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class,
|
RemoveUnreachableStatementRector::class,
|
||||||
\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class,
|
SimplifyIfElseWithSameContentRector::class,
|
||||||
\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class,
|
TernaryToBooleanOrFalseToBooleanAndRector::class,
|
||||||
\Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class,
|
RemoveEmptyTestMethodRector::class,
|
||||||
\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class,
|
RemoveDeadTryCatchRector::class,
|
||||||
\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class,
|
RemoveUnusedVariableAssignRector::class,
|
||||||
\Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class,
|
RemoveDuplicatedIfReturnRector::class,
|
||||||
\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
|
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
|
||||||
\Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class,
|
RemoveEmptyMethodCallRector::class,
|
||||||
\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class,
|
RemoveDeadConditionAboveReturnRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class,
|
RemoveUnusedConstructorParamRector::class,
|
||||||
\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class,
|
RemoveDeadInstanceOfRector::class,
|
||||||
\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class,
|
RemoveDeadLoopRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class,
|
RemoveUnusedPrivateMethodParameterRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedParamInRequiredAutowireRector::class,
|
RemoveUnusedParamInRequiredAutowireRector::class,
|
||||||
// docblock
|
// docblock
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class,
|
RemoveUselessParamTagRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class,
|
RemoveUselessReturnTagRector::class,
|
||||||
\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class,
|
RemoveNonExistingVarAnnotationRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector::class,
|
RemoveUnusedPromotedPropertyRector::class,
|
||||||
\Rector\DeadCode\Rector\ClassMethod\RemoveLastReturnRector::class,
|
RemoveLastReturnRector::class,
|
||||||
\Rector\DeadCode\Rector\StmtsAwareInterface\RemoveJustPropertyFetchForAssignRector::class,
|
RemoveJustPropertyFetchForAssignRector::class,
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
|
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
|
||||||
// @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html
|
// @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');
|
$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);
|
\trigger_error($deprecatedMessage);
|
||||||
\sleep(3);
|
\sleep(3);
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
|
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_52);
|
$rectorConfig->phpVersion(PhpVersion::PHP_52);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
|
$rectorConfig->rule(DirConstToFileConstRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,13 +12,13 @@ use Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector;
|
||||||
use Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector;
|
use Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector;
|
||||||
use Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector;
|
use Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector;
|
||||||
use Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector;
|
use Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_53);
|
$rectorConfig->phpVersion(PhpVersion::PHP_53);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Array_\ShortArrayToLongArrayRector::class);
|
$rectorConfig->rule(ShortArrayToLongArrayRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeStaticClosureRector::class);
|
$rectorConfig->rule(DowngradeStaticClosureRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\FuncCall\DowngradeIndirectCallByArrayRector::class);
|
$rectorConfig->rule(DowngradeIndirectCallByArrayRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\FunctionLike\DowngradeCallableTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeCallableTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\LNumber\DowngradeBinaryNotationRector::class);
|
$rectorConfig->rule(DowngradeBinaryNotationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\MethodCall\DowngradeInstanceMethodCallRector::class);
|
$rectorConfig->rule(DowngradeInstanceMethodCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp54\Rector\Closure\DowngradeThisInClosureRector::class);
|
$rectorConfig->rule(DowngradeThisInClosureRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,10 +9,10 @@ use Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringR
|
||||||
use Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector;
|
use Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector;
|
||||||
use Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector;
|
use Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector;
|
||||||
use Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector;
|
use Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54);
|
$rectorConfig->phpVersion(PhpVersion::PHP_54);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\ClassConstFetch\DowngradeClassConstantToStringRector::class);
|
$rectorConfig->rule(DowngradeClassConstantToStringRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\Foreach_\DowngradeForeachListRector::class);
|
$rectorConfig->rule(DowngradeForeachListRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\FuncCall\DowngradeBoolvalRector::class);
|
$rectorConfig->rule(DowngradeBoolvalRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp55\Rector\Isset_\DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class);
|
$rectorConfig->rule(DowngradeArbitraryExpressionArgsToEmptyAndIssetRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,11 +10,11 @@ use Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector;
|
||||||
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector;
|
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector;
|
||||||
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector;
|
use Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector;
|
||||||
use Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector;
|
use Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55);
|
$rectorConfig->phpVersion(PhpVersion::PHP_55);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\CallLike\DowngradeArgumentUnpackingRector::class);
|
$rectorConfig->rule(DowngradeArgumentUnpackingRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Use_\DowngradeUseFunctionRector::class);
|
$rectorConfig->rule(DowngradeUseFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialAssignmentOperatorRector::class);
|
$rectorConfig->rule(DowngradeExponentialAssignmentOperatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\Pow\DowngradeExponentialOperatorRector::class);
|
$rectorConfig->rule(DowngradeExponentialOperatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp56\Rector\FuncCall\DowngradeArrayFilterUseConstantRector::class);
|
$rectorConfig->rule(DowngradeArrayFilterUseConstantRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,24 +23,24 @@ use Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector;
|
||||||
use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
|
use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
|
||||||
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
|
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
|
||||||
use Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector;
|
use Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56);
|
$rectorConfig->phpVersion(PhpVersion::PHP_56);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\TryCatch\DowngradeCatchThrowableRector::class);
|
$rectorConfig->rule(DowngradeCatchThrowableRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Instanceof_\DowngradeInstanceofThrowableRector::class);
|
$rectorConfig->rule(DowngradeInstanceofThrowableRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeScalarTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeThrowableTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeThrowableTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeStrictTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeSelfTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class);
|
$rectorConfig->rule(DowngradeAnonymousClassRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class);
|
$rectorConfig->rule(DowngradeNullCoalesceRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class);
|
$rectorConfig->rule(DowngradeSpaceshipRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class);
|
$rectorConfig->rule(DowngradeDefineArrayConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeDirnameLevelsRector::class);
|
$rectorConfig->rule(DowngradeDirnameLevelsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class);
|
$rectorConfig->rule(DowngradeSessionStartArrayOptionsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeUncallableValueCallToCallUserFuncRector::class);
|
$rectorConfig->rule(DowngradeUncallableValueCallToCallUserFuncRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class);
|
$rectorConfig->rule(SplitGroupedUseImportsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeClosureCallRector::class);
|
$rectorConfig->rule(DowngradeClosureCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\ClassMethod\DowngradeParentTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeParentTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\MethodCall\DowngradeMethodCallOnCloneRector::class);
|
$rectorConfig->rule(DowngradeMethodCallOnCloneRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp70\Rector\Expr\DowngradeUnnecessarilyParenthesizedExpressionRector::class);
|
$rectorConfig->rule(DowngradeUnnecessarilyParenthesizedExpressionRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,17 +16,17 @@ use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector;
|
||||||
use Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector;
|
use Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector;
|
||||||
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
|
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
|
||||||
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
|
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70);
|
$rectorConfig->phpVersion(PhpVersion::PHP_70);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeNullableTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeVoidTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class);
|
$rectorConfig->rule(DowngradeClassConstantVisibilityRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class);
|
$rectorConfig->rule(DowngradePipeToMultiCatchExceptionRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class);
|
$rectorConfig->rule(SymmetricArrayDestructuringToListRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class);
|
$rectorConfig->rule(DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class);
|
$rectorConfig->rule(DowngradeKeysInListRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class);
|
$rectorConfig->rule(DowngradeIsIterableRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\StaticCall\DowngradeClosureFromCallableRector::class);
|
$rectorConfig->rule(DowngradeClosureFromCallableRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp71\Rector\ConstFetch\DowngradePhp71JsonConstRector::class);
|
$rectorConfig->rule(DowngradePhp71JsonConstRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,12 +11,12 @@ use Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgR
|
||||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
|
use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector;
|
||||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71);
|
$rectorConfig->phpVersion(PhpVersion::PHP_71);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeObjectTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\ClassMethod\DowngradeParameterTypeWideningRector::class);
|
$rectorConfig->rule(DowngradeParameterTypeWideningRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
|
$rectorConfig->rule(DowngradePregUnmatchedAsNullConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
|
$rectorConfig->rule(DowngradeStreamIsattyRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeJsonDecodeNullAssociativeArgRector::class);
|
$rectorConfig->rule(DowngradeJsonDecodeNullAssociativeArgRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp72\Rector\ConstFetch\DowngradePhp72JsonConstRector::class);
|
$rectorConfig->rule(DowngradePhp72JsonConstRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,13 +12,13 @@ use Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCalls
|
||||||
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
|
use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector;
|
||||||
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
||||||
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72);
|
$rectorConfig->phpVersion(PhpVersion::PHP_72);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class);
|
$rectorConfig->rule(DowngradeFlexibleHeredocSyntaxRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class);
|
$rectorConfig->rule(DowngradeListReferenceAssignmentRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class);
|
$rectorConfig->rule(DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
|
$rectorConfig->rule(DowngradeArrayKeyFirstLastRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
|
$rectorConfig->rule(SetCookieOptionsArrayToArgumentsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeIsCountableRector::class);
|
$rectorConfig->rule(DowngradeIsCountableRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp73\Rector\ConstFetch\DowngradePhp73JsonConstRector::class);
|
$rectorConfig->rule(DowngradePhp73JsonConstRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,18 +17,18 @@ use Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterf
|
||||||
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
|
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
|
||||||
use Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector;
|
use Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector;
|
||||||
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73);
|
$rectorConfig->phpVersion(PhpVersion::PHP_73);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class);
|
$rectorConfig->rule(DowngradeTypedPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class);
|
$rectorConfig->rule(ArrowFunctionToAnonymousFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class);
|
$rectorConfig->rule(DowngradeCovariantReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class);
|
$rectorConfig->rule(DowngradeContravariantArgumentTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class);
|
$rectorConfig->rule(DowngradeNullCoalescingOperatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class);
|
$rectorConfig->rule(DowngradeNumericLiteralSeparatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class);
|
$rectorConfig->rule(DowngradeStripTagsCallWithArrayRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class);
|
$rectorConfig->rule(DowngradeArraySpreadRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
$rectorConfig->rule(DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class);
|
$rectorConfig->rule(DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\Interface_\DowngradePreviouslyImplementedInterfaceRector::class);
|
$rectorConfig->rule(DowngradePreviouslyImplementedInterfaceRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp74\Rector\MethodCall\DowngradeReflectionGetTypeRector::class);
|
$rectorConfig->rule(DowngradeReflectionGetTypeRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,43 +35,43 @@ use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
|
||||||
use Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector;
|
use Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector;
|
||||||
use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation;
|
use Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation;
|
||||||
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
|
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74);
|
$rectorConfig->phpVersion(PhpVersion::PHP_74);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class, [
|
$rectorConfig->ruleWithConfiguration(RemoveInterfacesRector::class, [
|
||||||
// @see https://wiki.php.net/rfc/stringable
|
// @see https://wiki.php.net/rfc/stringable
|
||||||
'Stringable',
|
'Stringable',
|
||||||
]);
|
]);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeNamedArgumentRector::class);
|
$rectorConfig->rule(DowngradeNamedArgumentRector::class);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\DowngradePhp80\Rector\Class_\DowngradeAttributeToAnnotationRector::class, [
|
$rectorConfig->ruleWithConfiguration(DowngradeAttributeToAnnotationRector::class, [
|
||||||
// Symfony
|
// Symfony
|
||||||
new \Rector\DowngradePhp80\ValueObject\DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'),
|
new DowngradeAttributeToAnnotation('Symfony\\Contracts\\Service\\Attribute\\Required', 'required'),
|
||||||
// Nette
|
// 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(DowngradeDereferenceableOperationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
|
$rectorConfig->rule(DowngradeUnionTypeTypedPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeUnionTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeMixedTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeStaticTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeAbstractPrivateMethodInTraitRector::class);
|
$rectorConfig->rule(DowngradeAbstractPrivateMethodInTraitRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
|
$rectorConfig->rule(DowngradePropertyPromotionRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
|
$rectorConfig->rule(DowngradeNonCapturingCatchesRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrContainsRector::class);
|
$rectorConfig->rule(DowngradeStrContainsRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class);
|
$rectorConfig->rule(DowngradeMatchToSwitchRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class);
|
$rectorConfig->rule(DowngradeClassOnObjectToGetClassRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\New_\DowngradeArbitraryExpressionsSupportRector::class);
|
$rectorConfig->rule(DowngradeArbitraryExpressionsSupportRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class);
|
$rectorConfig->rule(DowngradeNullsafeToTernaryOperatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class);
|
$rectorConfig->rule(DowngradeTrailingCommasInParamUseRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrStartsWithRector::class);
|
$rectorConfig->rule(DowngradeStrStartsWithRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeStrEndsWithRector::class);
|
$rectorConfig->rule(DowngradeStrEndsWithRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\StaticCall\DowngradePhpTokenRector::class);
|
$rectorConfig->rule(DowngradePhpTokenRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Expression\DowngradeThrowExprRector::class);
|
$rectorConfig->rule(DowngradeThrowExprRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\Instanceof_\DowngradePhp80ResourceReturnToObjectRector::class);
|
$rectorConfig->rule(DowngradePhp80ResourceReturnToObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionGetAttributesRector::class);
|
$rectorConfig->rule(DowngradeReflectionGetAttributesRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeRecursiveDirectoryIteratorHasChildrenRector::class);
|
$rectorConfig->rule(DowngradeRecursiveDirectoryIteratorHasChildrenRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionPropertyGetDefaultValueRector::class);
|
$rectorConfig->rule(DowngradeReflectionPropertyGetDefaultValueRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\MethodCall\DowngradeReflectionClassGetConstantsFilterRector::class);
|
$rectorConfig->rule(DowngradeReflectionClassGetConstantsFilterRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeArrayFilterNullableCallbackRector::class);
|
$rectorConfig->rule(DowngradeArrayFilterNullableCallbackRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\FuncCall\DowngradeNumberFormatNoFourthArgRector::class);
|
$rectorConfig->rule(DowngradeNumberFormatNoFourthArgRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStringReturnTypeOnToStringRector::class);
|
$rectorConfig->rule(DowngradeStringReturnTypeOnToStringRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,15 +14,15 @@ use Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector;
|
||||||
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector;
|
use Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector;
|
||||||
use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector;
|
use Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector;
|
||||||
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
|
use Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80);
|
$rectorConfig->phpVersion(PhpVersion::PHP_80);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\ClassConst\DowngradeFinalizePublicClassConstantRector::class);
|
$rectorConfig->rule(DowngradeFinalizePublicClassConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeFirstClassCallableSyntaxRector::class);
|
$rectorConfig->rule(DowngradeFirstClassCallableSyntaxRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNeverTypeDeclarationRector::class);
|
$rectorConfig->rule(DowngradeNeverTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradePureIntersectionTypeRector::class);
|
$rectorConfig->rule(DowngradePureIntersectionTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FunctionLike\DowngradeNewInInitializerRector::class);
|
$rectorConfig->rule(DowngradeNewInInitializerRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Instanceof_\DowngradePhp81ResourceReturnToObjectRector::class);
|
$rectorConfig->rule(DowngradePhp81ResourceReturnToObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Property\DowngradeReadonlyPropertyRector::class);
|
$rectorConfig->rule(DowngradeReadonlyPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector::class);
|
$rectorConfig->rule(DowngradeArraySpreadStringKeyRector::class);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp81\Rector\FuncCall\DowngradeArrayIsListRector::class);
|
$rectorConfig->rule(DowngradeArrayIsListRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector;
|
use Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81);
|
$rectorConfig->phpVersion(PhpVersion::PHP_81);
|
||||||
$rectorConfig->rule(\Rector\DowngradePhp82\Rector\Class_\DowngradeReadonlyClassRector::class);
|
$rectorConfig->rule(DowngradeReadonlyClassRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,16 +15,16 @@ use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
|
||||||
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
||||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
|
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
|
||||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
|
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class);
|
$rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
|
$rectorConfig->rule(ChangeAndIfToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class);
|
$rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class);
|
$rectorConfig->rule(ChangeNestedIfsToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class);
|
$rectorConfig->rule(RemoveAlwaysElseRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class);
|
$rectorConfig->rule(ReturnBinaryAndToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class);
|
$rectorConfig->rule(ChangeOrIfReturnToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class);
|
$rectorConfig->rule(ChangeOrIfContinueToMultiContinueRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class);
|
$rectorConfig->rule(ReturnAfterToEarlyOnBreakRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class);
|
$rectorConfig->rule(PreparedValueToEarlyReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class);
|
$rectorConfig->rule(ReturnBinaryOrToEarlyReturnRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,22 +6,22 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class, [
|
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
|
||||||
// Rename is now move, specific for files.
|
// 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
|
// No arbitrary abbreviations
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'createDir', 'createDirectory'),
|
||||||
// Writes are now deterministic
|
// Writes are now deterministic
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'update', 'write'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'updateStream', 'writeStream'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'put', 'write'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'putStream', 'writeStream'),
|
||||||
// Metadata getters are renamed
|
// Metadata getters are renamed
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getTimestamp', 'lastModified'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'has', 'fileExists'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getMimetype', 'mimeType'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getSize', 'fileSize'),
|
||||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'),
|
new MethodCallRename('League\\Flysystem\\FilesystemInterface', 'getVisibility', 'visibility'),
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
|
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
|
||||||
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
|
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
$rectorConfig->rule(ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class);
|
$rectorConfig->rule(RemoveServiceFromSensioRouteRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
|
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class);
|
$rectorConfig->rule(TemplateAnnotationToThisRenderRector::class);
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -10,9 +10,9 @@ use Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector;
|
||||||
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
||||||
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (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')];
|
$configuration = [new FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class, $configuration);
|
$rectorConfig->ruleWithConfiguration(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(StaticCallToFuncCallRector::class, [new StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new 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')]);
|
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [new MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_53, \Rector\Set\ValueObject\DowngradeSetList::PHP_53]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_53, DowngradeSetList::PHP_53]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_54, \Rector\Set\ValueObject\DowngradeSetList::PHP_54]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_54, DowngradeSetList::PHP_54]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_55, \Rector\Set\ValueObject\DowngradeSetList::PHP_55]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_55, DowngradeSetList::PHP_55]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_56, \Rector\Set\ValueObject\DowngradeSetList::PHP_56]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_56, DowngradeSetList::PHP_56]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_70, \Rector\Set\ValueObject\DowngradeSetList::PHP_70]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_70, DowngradeSetList::PHP_70]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_71, \Rector\Set\ValueObject\DowngradeSetList::PHP_71]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_71, DowngradeSetList::PHP_71]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_72, \Rector\Set\ValueObject\DowngradeSetList::PHP_72]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_72, DowngradeSetList::PHP_72]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_73, \Rector\Set\ValueObject\DowngradeSetList::PHP_73]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_73, DowngradeSetList::PHP_73]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_74, \Rector\Set\ValueObject\DowngradeSetList::PHP_74]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_74, DowngradeSetList::PHP_74]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_80, \Rector\Set\ValueObject\DowngradeSetList::PHP_80]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_80, DowngradeSetList::PHP_80]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,6 +6,6 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
use Rector\Set\ValueObject\DowngradeLevelSetList;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeLevelSetList::DOWN_TO_PHP_81, \Rector\Set\ValueObject\DowngradeSetList::PHP_81]);
|
$rectorConfig->sets([DowngradeLevelSetList::DOWN_TO_PHP_81, DowngradeSetList::PHP_81]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Set\ValueObject\DowngradeSetList;
|
use Rector\Set\ValueObject\DowngradeSetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\DowngradeSetList::PHP_82]);
|
$rectorConfig->sets([DowngradeSetList::PHP_82]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,8 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_54, \Rector\Set\ValueObject\SetList::PHP_53]);
|
$rectorConfig->sets([SetList::PHP_54, SetList::PHP_53]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_54);
|
$rectorConfig->phpVersion(PhpVersion::PHP_54);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_55, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_54]);
|
$rectorConfig->sets([SetList::PHP_55, LevelSetList::UP_TO_PHP_54]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_55);
|
$rectorConfig->phpVersion(PhpVersion::PHP_55);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_56, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_55]);
|
$rectorConfig->sets([SetList::PHP_56, LevelSetList::UP_TO_PHP_55]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_56);
|
$rectorConfig->phpVersion(PhpVersion::PHP_56);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_70, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_56]);
|
$rectorConfig->sets([SetList::PHP_70, LevelSetList::UP_TO_PHP_56]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_70);
|
$rectorConfig->phpVersion(PhpVersion::PHP_70);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_71, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_70]);
|
$rectorConfig->sets([SetList::PHP_71, LevelSetList::UP_TO_PHP_70]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_71);
|
$rectorConfig->phpVersion(PhpVersion::PHP_71);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_72, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_71]);
|
$rectorConfig->sets([SetList::PHP_72, LevelSetList::UP_TO_PHP_71]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_72);
|
$rectorConfig->phpVersion(PhpVersion::PHP_72);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_73, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_72]);
|
$rectorConfig->sets([SetList::PHP_73, LevelSetList::UP_TO_PHP_72]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_73);
|
$rectorConfig->phpVersion(PhpVersion::PHP_73);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_74, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_73]);
|
$rectorConfig->sets([SetList::PHP_74, LevelSetList::UP_TO_PHP_73]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_74);
|
$rectorConfig->phpVersion(PhpVersion::PHP_74);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_80, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_74]);
|
$rectorConfig->sets([SetList::PHP_80, LevelSetList::UP_TO_PHP_74]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_80);
|
$rectorConfig->phpVersion(PhpVersion::PHP_80);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_81, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_80]);
|
$rectorConfig->sets([SetList::PHP_81, LevelSetList::UP_TO_PHP_80]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_81);
|
$rectorConfig->phpVersion(PhpVersion::PHP_81);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Core\ValueObject\PhpVersion;
|
use Rector\Core\ValueObject\PhpVersion;
|
||||||
use Rector\Set\ValueObject\LevelSetList;
|
use Rector\Set\ValueObject\LevelSetList;
|
||||||
use Rector\Set\ValueObject\SetList;
|
use Rector\Set\ValueObject\SetList;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->sets([\Rector\Set\ValueObject\SetList::PHP_82, \Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_81]);
|
$rectorConfig->sets([SetList::PHP_82, LevelSetList::UP_TO_PHP_81]);
|
||||||
// parameter must be defined after import, to override imported param version
|
// parameter must be defined after import, to override imported param version
|
||||||
$rectorConfig->phpVersion(\Rector\Core\ValueObject\PhpVersion::PHP_82);
|
$rectorConfig->phpVersion(PhpVersion::PHP_82);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,6 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||||
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
|
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (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')]);
|
$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')]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,18 +14,18 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||||
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
|
use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
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://stackoverflow.com/a/1390625/1348344
|
||||||
# https://github.com/philip/MySQLConverterTool/blob/master/Converter.php
|
# 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
|
# 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(MysqlAssignToMysqliRector::class);
|
||||||
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
|
$rectorConfig->rule(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->ruleWithConfiguration(RemoveFuncCallArgRector::class, [new RemoveFuncCallArg('mysql_pconnect', 3), new RemoveFuncCallArg('mysql_connect', 3), new RemoveFuncCallArg('mysql_connect', 4)]);
|
||||||
$rectorConfig->rule(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
|
$rectorConfig->rule(MysqlPConnectToMysqliConnectRector::class);
|
||||||
# first swap arguments, then rename
|
# 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(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(\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(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
|
# 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->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(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
|
$rectorConfig->rule(MysqlQueryMysqlErrorWithLinkRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,11 +10,11 @@ use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
|
||||||
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
|
use Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector;
|
||||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
|
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
|
||||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
|
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class);
|
$rectorConfig->rule(RenameParamToMatchTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class);
|
$rectorConfig->rule(RenamePropertyToMatchTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class);
|
$rectorConfig->rule(RenameVariableToMatchNewTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class);
|
$rectorConfig->rule(RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
$rectorConfig->rule(RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class);
|
$rectorConfig->rule(RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,11 +8,11 @@ use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||||
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
use Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector;
|
||||||
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
$rectorConfig->rule(VarToPublicPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
$rectorConfig->rule(ContinueToBreakInSwitchRector::class);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class, [
|
$rectorConfig->ruleWithConfiguration(RemoveFuncCallArgRector::class, [
|
||||||
// see https://www.php.net/manual/en/function.ldap-first-attribute.php
|
// 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),
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
||||||
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
||||||
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
|
$rectorConfig->rule(TernaryToElvisRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
|
$rectorConfig->rule(DirNameFileConstantToDirConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
|
$rectorConfig->rule(ReplaceHttpServerVarsByServerRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,8 +7,8 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
||||||
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']);
|
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, ['mysqli_param_count' => 'mysqli_stmt_param_count']);
|
||||||
$rectorConfig->rule(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
|
$rectorConfig->rule(RemoveReferenceFromCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
|
$rectorConfig->rule(RemoveZeroBreakContinueRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -9,10 +9,10 @@ use Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector;
|
||||||
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
|
use Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector;
|
||||||
use Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector;
|
use Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector;
|
||||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class);
|
$rectorConfig->rule(ClassConstantToSelfClassRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\PregReplaceEModifierRector::class);
|
$rectorConfig->rule(PregReplaceEModifierRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToSelfClassRector::class);
|
$rectorConfig->rule(GetCalledClassToSelfClassRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php55\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
|
$rectorConfig->rule(GetCalledClassToStaticClassRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,9 +7,9 @@ use Rector\Config\RectorConfig;
|
||||||
use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
||||||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
|
$rectorConfig->rule(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']);
|
$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
|
# 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);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,25 +23,25 @@ use Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector;
|
||||||
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
||||||
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
|
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
|
||||||
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
|
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class);
|
$rectorConfig->rule(Php4ConstructorRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class);
|
$rectorConfig->rule(TernaryToNullCoalescingRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class);
|
$rectorConfig->rule(RandomFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class);
|
$rectorConfig->rule(ExceptionHandlerTypehintRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class);
|
$rectorConfig->rule(MultiDirnameRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Assign\ListSplitStringRector::class);
|
$rectorConfig->rule(ListSplitStringRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\List_\EmptyListRector::class);
|
$rectorConfig->rule(EmptyListRector::class);
|
||||||
# be careful, run this just once, since it can keep swapping order back and forth
|
# 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(ListSwapArrayOrderRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class);
|
$rectorConfig->rule(CallUserMethodRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class);
|
$rectorConfig->rule(EregToPregMatchRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class);
|
$rectorConfig->rule(ReduceMultipleDefaultSwitchRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class);
|
$rectorConfig->rule(TernaryToSpaceshipRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class);
|
$rectorConfig->rule(WrapVariableVariableNameInCurlyBracesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class);
|
$rectorConfig->rule(IfToSpaceshipRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class);
|
$rectorConfig->rule(StaticCallOnNonStaticToInstanceCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class);
|
$rectorConfig->rule(ThisCallOnStaticMethodToStaticCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class);
|
$rectorConfig->rule(BreakNotInLoopOrSwitchToReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class);
|
$rectorConfig->rule(RenameMktimeWithoutArgsToTimeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class);
|
$rectorConfig->rule(NonVariableToVariableOnFunctionCallRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,13 +12,13 @@ use Rector\Php71\Rector\FuncCall\CountOnNullRector;
|
||||||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||||
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
||||||
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
|
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class);
|
$rectorConfig->rule(IsIterableRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class);
|
$rectorConfig->rule(MultiExceptionCatchRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class);
|
$rectorConfig->rule(AssignArrayToStringRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class);
|
$rectorConfig->rule(CountOnNullRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
$rectorConfig->rule(RemoveExtraParametersRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class);
|
$rectorConfig->rule(BinaryOpBetweenNumberAndStringRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class);
|
$rectorConfig->rule(ListToArrayDestructRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php71\Rector\ClassConst\PublicConstantVisibilityRector::class);
|
$rectorConfig->rule(PublicConstantVisibilityRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,12 +15,12 @@ use Rector\Php72\Rector\FuncCall\StringsAssertNakedRector;
|
||||||
use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
||||||
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class);
|
$rectorConfig->rule(WhileEachToForeachRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\Assign\ListEachRector::class);
|
$rectorConfig->rule(ListEachRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
|
$rectorConfig->rule(ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
|
$rectorConfig->rule(UnsetCastRector::class);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
|
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
|
||||||
# and imagewbmp
|
# and imagewbmp
|
||||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||||
# or imagewbmp
|
# or imagewbmp
|
||||||
|
@ -31,10 +31,10 @@ return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
||||||
'gmp_random' => 'gmp_random_bits',
|
'gmp_random' => 'gmp_random_bits',
|
||||||
'read_exif_data' => 'exif_read_data',
|
'read_exif_data' => 'exif_read_data',
|
||||||
]);
|
]);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
|
$rectorConfig->rule(GetClassOnNullRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
|
$rectorConfig->rule(IsObjectOnIncompleteClassRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
|
$rectorConfig->rule(ParseStrWithResultArgumentRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class);
|
$rectorConfig->rule(StringsAssertNakedRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class);
|
$rectorConfig->rule(CreateFunctionToAnonymousFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
|
$rectorConfig->rule(StringifyDefineRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,13 +15,13 @@ use Rector\Php73\Rector\FuncCall\SetCookieRector;
|
||||||
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
||||||
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
|
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class);
|
$rectorConfig->rule(IsCountableRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class);
|
$rectorConfig->rule(ArrayKeyFirstLastRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
|
$rectorConfig->rule(SensitiveDefineRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
|
$rectorConfig->rule(SensitiveConstantNameRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
|
$rectorConfig->rule(SensitiveHereNowDocRector::class);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
|
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
|
||||||
# https://wiki.php.net/rfc/deprecations_php_7_3
|
# https://wiki.php.net/rfc/deprecations_php_7_3
|
||||||
'image2wbmp' => 'imagewbmp',
|
'image2wbmp' => 'imagewbmp',
|
||||||
'mbregex_encoding' => 'mb_regex_encoding',
|
'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_getregs' => 'mb_ereg_search_getregs',
|
||||||
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
||||||
]);
|
]);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
|
$rectorConfig->rule(StringifyStrNeedlesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
|
$rectorConfig->rule(JsonThrowOnErrorRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);
|
$rectorConfig->rule(RegexDashEscapeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
$rectorConfig->rule(ContinueToBreakInSwitchRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php73\Rector\FuncCall\SetCookieRector::class);
|
$rectorConfig->rule(SetCookieRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,9 +18,9 @@ use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
|
||||||
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||||
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
|
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
|
$rectorConfig->rule(TypedPropertyRector::class);
|
||||||
$rectorConfig->ruleWithConfiguration(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class, [
|
$rectorConfig->ruleWithConfiguration(RenameFunctionRector::class, [
|
||||||
#the_real_type
|
#the_real_type
|
||||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||||
'is_real' => 'is_float',
|
'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
|
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||||
'apache_request_headers' => 'getallheaders',
|
'apache_request_headers' => 'getallheaders',
|
||||||
]);
|
]);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
|
$rectorConfig->rule(ArrayKeyExistsOnPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
|
$rectorConfig->rule(FilterVarToAddSlashesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);
|
$rectorConfig->rule(ExportToReflectionFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class);
|
$rectorConfig->rule(MbStrrposEncodingArgumentPositionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class);
|
$rectorConfig->rule(RealToFloatTypeCastRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
|
$rectorConfig->rule(NullCoalescingOperatorRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class);
|
$rectorConfig->rule(ClosureToArrowFunctionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class);
|
$rectorConfig->rule(ArraySpreadInsteadOfArrayMergeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class);
|
$rectorConfig->rule(AddLiteralSeparatorToNumberRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class);
|
$rectorConfig->rule(ChangeReflectionTypeToStringToGetNameRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
|
$rectorConfig->rule(RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php74\Rector\ArrayDimFetch\CurlyToSquareBracketArrayStringRector::class);
|
$rectorConfig->rule(CurlyToSquareBracketArrayStringRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,28 +28,28 @@ use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
|
||||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||||
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector;
|
||||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
|
$rectorConfig->rule(UnionTypesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
|
$rectorConfig->rule(StrContainsRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
|
$rectorConfig->rule(StrStartsWithRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
|
$rectorConfig->rule(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->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(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
|
$rectorConfig->rule(StringableForToStringRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
|
$rectorConfig->rule(ClassOnObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
|
$rectorConfig->rule(GetDebugTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class);
|
$rectorConfig->rule(TokenGetAllToObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
|
$rectorConfig->rule(RemoveUnusedVariableInCatchRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
|
$rectorConfig->rule(ClassPropertyAssignToConstructorPromotionRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
|
$rectorConfig->rule(ChangeSwitchToMatchRector::class);
|
||||||
// nette\utils and Strings::replace()
|
// 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->ruleWithConfiguration(ArgumentAdderRector::class, [new ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')]);
|
||||||
$rectorConfig->rule(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
$rectorConfig->rule(RemoveParentCallWithoutParentRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
|
$rectorConfig->rule(SetStateToStaticRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
|
$rectorConfig->rule(FinalPrivateToPrivateVisibilityRector::class);
|
||||||
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
|
// @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->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(\Rector\CodeQuality\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
|
$rectorConfig->rule(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->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(\Rector\Php80\Rector\FuncCall\Php8ResourceReturnToObjectRector::class);
|
$rectorConfig->rule(Php8ResourceReturnToObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php80\Rector\ClassMethod\AddParamBasedOnParentClassMethodRector::class);
|
$rectorConfig->rule(AddParamBasedOnParentClassMethodRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,15 +14,15 @@ use Rector\Php81\Rector\FunctionLike\IntersectionTypesRector;
|
||||||
use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector;
|
use Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector;
|
||||||
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
|
use Rector\Php81\Rector\Property\ReadOnlyPropertyRector;
|
||||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
|
$rectorConfig->rule(ReturnNeverTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\Class_\MyCLabsClassToEnumRector::class);
|
$rectorConfig->rule(MyCLabsClassToEnumRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\MethodCall\MyCLabsMethodCallToEnumConstRector::class);
|
$rectorConfig->rule(MyCLabsMethodCallToEnumConstRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\ClassConst\FinalizePublicClassConstantRector::class);
|
$rectorConfig->rule(FinalizePublicClassConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\Property\ReadOnlyPropertyRector::class);
|
$rectorConfig->rule(ReadOnlyPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\Class_\SpatieEnumClassToEnumRector::class);
|
$rectorConfig->rule(SpatieEnumClassToEnumRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\FuncCall\Php81ResourceReturnToObjectRector::class);
|
$rectorConfig->rule(Php81ResourceReturnToObjectRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\ClassMethod\NewInInitializerRector::class);
|
$rectorConfig->rule(NewInInitializerRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\FunctionLike\IntersectionTypesRector::class);
|
$rectorConfig->rule(IntersectionTypesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector::class);
|
$rectorConfig->rule(NullToStrictStringFuncCallArgRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
|
use Rector\Php82\Rector\Class_\ReadOnlyClassRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Php82\Rector\Class_\ReadOnlyClassRector::class);
|
$rectorConfig->rule(ReadOnlyClassRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,15 +13,15 @@ use Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector;
|
||||||
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
|
use Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector;
|
||||||
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
|
use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector;
|
||||||
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
|
$rectorConfig->rule(FinalizeClassesWithoutChildrenRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeGlobalVariablesToPropertiesRector::class);
|
$rectorConfig->rule(ChangeGlobalVariablesToPropertiesRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
$rectorConfig->rule(ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
$rectorConfig->rule(ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
|
$rectorConfig->rule(RepeatedLiteralToClassConstantRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class);
|
$rectorConfig->rule(PrivatizeLocalGetterToPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class);
|
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class);
|
$rectorConfig->rule(PrivatizeFinalClassMethodRector::class);
|
||||||
// buggy, requires more work
|
// buggy, requires more work
|
||||||
// $services->set(ChangeLocalPropertyToVariableRector::class);
|
// $services->set(ChangeLocalPropertyToVariableRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace RectorPrefix20220607;
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
||||||
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
|
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
$rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||||
$rectorConfig->rule(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class);
|
$rectorConfig->rule(MultipleClassFileToPsr4ClassesRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector;
|
use Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\DogFood\Rector\Closure\UpgradeRectorConfigRector::class);
|
$rectorConfig->rule(UpgradeRectorConfigRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -14,15 +14,15 @@ use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
||||||
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
|
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
|
||||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
||||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
|
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
$rectorConfig->rule(AddClosureReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class);
|
$rectorConfig->rule(ReturnTypeFromStrictTypedPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
|
$rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class);
|
$rectorConfig->rule(ParamTypeFromStrictTypedPropertyRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class);
|
$rectorConfig->rule(ReturnTypeFromStrictTypedCallRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class);
|
$rectorConfig->rule(AddVoidReturnTypeWhereNoReturnRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class);
|
$rectorConfig->rule(ReturnTypeFromReturnNewRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictGetterMethodReturnTypeRector::class);
|
$rectorConfig->rule(TypedPropertyFromStrictGetterMethodReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddMethodCallBasedStrictParamTypeRector::class);
|
$rectorConfig->rule(AddMethodCallBasedStrictParamTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ArrayShapeFromConstantArrayReturnRector::class);
|
$rectorConfig->rule(ArrayShapeFromConstantArrayReturnRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,17 +16,17 @@ use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
|
||||||
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
|
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
|
||||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
|
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
|
||||||
use Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector;
|
use Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
|
$rectorConfig->rule(ParamTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
|
$rectorConfig->rule(ReturnTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
|
$rectorConfig->rule(PropertyTypeDeclarationRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
$rectorConfig->rule(AddClosureReturnTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class);
|
$rectorConfig->rule(AddArrayParamDocTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class);
|
$rectorConfig->rule(AddArrayReturnDocTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByParentCallTypeRector::class);
|
$rectorConfig->rule(ParamTypeByParentCallTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamTypeByMethodCallTypeRector::class);
|
$rectorConfig->rule(ParamTypeByMethodCallTypeRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector::class);
|
$rectorConfig->rule(TypedPropertyFromAssignsRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnAnnotationIncorrectNullableRector::class);
|
$rectorConfig->rule(ReturnAnnotationIncorrectNullableRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\Property\VarAnnotationIncorrectNullableRector::class);
|
$rectorConfig->rule(VarAnnotationIncorrectNullableRector::class);
|
||||||
$rectorConfig->rule(\Rector\TypeDeclaration\Rector\ClassMethod\ParamAnnotationIncorrectNullableRector::class);
|
$rectorConfig->rule(ParamAnnotationIncorrectNullableRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,6 +5,6 @@ namespace RectorPrefix20220607;
|
||||||
|
|
||||||
use Rector\Config\RectorConfig;
|
use Rector\Config\RectorConfig;
|
||||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
||||||
return static function (\Rector\Config\RectorConfig $rectorConfig) : void {
|
return static function (RectorConfig $rectorConfig) : void {
|
||||||
$rectorConfig->rule(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
$rectorConfig->rule(UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,8 +10,8 @@ final class AttributeMirrorer
|
||||||
/**
|
/**
|
||||||
* @var string[]
|
* @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];
|
private const ATTRIBUTES_TO_MIRROR = [PhpDocAttributeKey::PARENT, PhpDocAttributeKey::START_AND_END, PhpDocAttributeKey::ORIG_NODE];
|
||||||
public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void
|
public function mirror(Node $oldNode, Node $newNode) : void
|
||||||
{
|
{
|
||||||
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
|
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
|
||||||
if (!$oldNode->hasAttribute($attributeToMirror)) {
|
if (!$oldNode->hasAttribute($attributeToMirror)) {
|
||||||
|
|
|
@ -14,14 +14,14 @@ final class CommentsMerger
|
||||||
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
|
* @var \Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser
|
||||||
*/
|
*/
|
||||||
private $simpleCallableNodeTraverser;
|
private $simpleCallableNodeTraverser;
|
||||||
public function __construct(\RectorPrefix20220607\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||||
{
|
{
|
||||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param Node[] $mergedNodes
|
* @param Node[] $mergedNodes
|
||||||
*/
|
*/
|
||||||
public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void
|
public function keepComments(Node $newNode, array $mergedNodes) : void
|
||||||
{
|
{
|
||||||
$comments = $newNode->getComments();
|
$comments = $newNode->getComments();
|
||||||
foreach ($mergedNodes as $mergedNode) {
|
foreach ($mergedNodes as $mergedNode) {
|
||||||
|
@ -30,25 +30,25 @@ final class CommentsMerger
|
||||||
if ($comments === []) {
|
if ($comments === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
|
||||||
// remove so comments "win"
|
// 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);
|
$parent = $oldNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||||
if (!$parent instanceof \PhpParser\Node) {
|
if (!$parent instanceof Node) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
$phpDocInfo = $parent->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||||
$comments = $parent->getComments();
|
$comments = $parent->getComments();
|
||||||
if ($phpDocInfo === null && $comments === []) {
|
if ($phpDocInfo === null && $comments === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
$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);
|
$childrenComments = $this->collectChildrenComments($oldNode);
|
||||||
if ($childrenComments === []) {
|
if ($childrenComments === []) {
|
||||||
|
@ -58,15 +58,15 @@ final class CommentsMerger
|
||||||
foreach ($childrenComments as $childComment) {
|
foreach ($childrenComments as $childComment) {
|
||||||
$commentContent .= $childComment->getText() . \PHP_EOL;
|
$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[]
|
* @return Comment[]
|
||||||
*/
|
*/
|
||||||
private function collectChildrenComments(\PhpParser\Node $node) : array
|
private function collectChildrenComments(Node $node) : array
|
||||||
{
|
{
|
||||||
$childrenComments = [];
|
$childrenComments = [];
|
||||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) {
|
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$childrenComments) {
|
||||||
$comments = $node->getComments();
|
$comments = $node->getComments();
|
||||||
if ($comments !== []) {
|
if ($comments !== []) {
|
||||||
$childrenComments = \array_merge($childrenComments, $comments);
|
$childrenComments = \array_merge($childrenComments, $comments);
|
||||||
|
|
|
@ -4,6 +4,6 @@ declare (strict_types=1);
|
||||||
namespace Rector\BetterPhpDocParser\Contract;
|
namespace Rector\BetterPhpDocParser\Contract;
|
||||||
|
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
||||||
interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\Contract\PhpDocNodeVisitorInterface
|
interface BasePhpDocNodeVisitorInterface extends PhpDocNodeVisitorInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,5 @@ use PhpParser\Node;
|
||||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||||
interface PhpDocNodeDecoratorInterface
|
interface PhpDocNodeDecoratorInterface
|
||||||
{
|
{
|
||||||
public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \PhpParser\Node $phpNode) : void;
|
public function decorate(PhpDocNode $phpDocNode, Node $phpNode) : void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,14 @@ final class CurrentTokenIteratorProvider
|
||||||
* @var \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator|null
|
* @var \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator|null
|
||||||
*/
|
*/
|
||||||
private $betterTokenIterator;
|
private $betterTokenIterator;
|
||||||
public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
|
public function setBetterTokenIterator(BetterTokenIterator $betterTokenIterator) : void
|
||||||
{
|
{
|
||||||
$this->betterTokenIterator = $betterTokenIterator;
|
$this->betterTokenIterator = $betterTokenIterator;
|
||||||
}
|
}
|
||||||
public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
public function provide() : BetterTokenIterator
|
||||||
{
|
{
|
||||||
if ($this->betterTokenIterator === null) {
|
if ($this->betterTokenIterator === null) {
|
||||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
throw new ShouldNotHappenException();
|
||||||
}
|
}
|
||||||
return $this->betterTokenIterator;
|
return $this->betterTokenIterator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Stringable;
|
use Stringable;
|
||||||
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
|
final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode
|
* @var \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode
|
||||||
|
@ -16,7 +16,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va
|
||||||
/**
|
/**
|
||||||
* @param array<mixed, mixed> $values
|
* @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->identifierTypeNode = $identifierTypeNode;
|
||||||
$this->hasChanged = \true;
|
$this->hasChanged = \true;
|
||||||
|
@ -59,7 +59,7 @@ final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\Va
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
// the name is not fully qualified in the original name, look for resolved class attribute
|
// 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;
|
return $resolvedClass === $className;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use Stringable;
|
||||||
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
|
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
|
||||||
* between the @ORM\Entity and (someContent)
|
* between the @ORM\Entity and (someContent)
|
||||||
*/
|
*/
|
||||||
final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
|
final class SpacelessPhpDocTagNode extends PhpDocTagNode
|
||||||
{
|
{
|
||||||
public function __toString() : string
|
public function __toString() : string
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,7 +39,7 @@ final class PhpDocInfo
|
||||||
/**
|
/**
|
||||||
* @var array<class-string<PhpDocTagValueNode>, string>
|
* @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
|
* @var bool
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +93,7 @@ final class PhpDocInfo
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
|
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
|
||||||
*/
|
*/
|
||||||
private $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->phpDocNode = $phpDocNode;
|
||||||
$this->betterTokenIterator = $betterTokenIterator;
|
$this->betterTokenIterator = $betterTokenIterator;
|
||||||
|
@ -104,22 +104,22 @@ final class PhpDocInfo
|
||||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||||
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
|
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
|
||||||
$this->originalPhpDocNode = clone $phpDocNode;
|
$this->originalPhpDocNode = clone $phpDocNode;
|
||||||
if (!$betterTokenIterator->containsTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL)) {
|
if (!$betterTokenIterator->containsTokenType(Lexer::TOKEN_PHPDOC_EOL)) {
|
||||||
$this->isSingleLine = \true;
|
$this->isSingleLine = \true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void
|
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
|
||||||
{
|
{
|
||||||
$this->phpDocNode->children[] = $phpDocChildNode;
|
$this->phpDocNode->children[] = $phpDocChildNode;
|
||||||
// to give node more space
|
// to give node more space
|
||||||
$this->makeMultiLined();
|
$this->makeMultiLined();
|
||||||
$this->markAsChanged();
|
$this->markAsChanged();
|
||||||
}
|
}
|
||||||
public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
public function getPhpDocNode() : PhpDocNode
|
||||||
{
|
{
|
||||||
return $this->phpDocNode;
|
return $this->phpDocNode;
|
||||||
}
|
}
|
||||||
public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
public function getOriginalPhpDocNode() : PhpDocNode
|
||||||
{
|
{
|
||||||
return $this->originalPhpDocNode;
|
return $this->originalPhpDocNode;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ final class PhpDocInfo
|
||||||
{
|
{
|
||||||
return $this->betterTokenIterator->count();
|
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;
|
return $this->phpDocNode->getVarTagValues($tagName)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
@ -149,13 +149,13 @@ final class PhpDocInfo
|
||||||
}
|
}
|
||||||
$tags = $this->phpDocNode->getTags();
|
$tags = $this->phpDocNode->getTags();
|
||||||
$name = $this->annotationNaming->normalizeName($name);
|
$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;
|
return $tag->name === $name;
|
||||||
});
|
});
|
||||||
$tags = \array_values($tags);
|
$tags = \array_values($tags);
|
||||||
return \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);
|
$paramTagValueNodes = $this->getParamTagValueByName($name);
|
||||||
return $this->getTypeOrMixed($paramTagValueNodes);
|
return $this->getTypeOrMixed($paramTagValueNodes);
|
||||||
|
@ -167,7 +167,7 @@ final class PhpDocInfo
|
||||||
{
|
{
|
||||||
return $this->phpDocNode->getParamTagValues();
|
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) {
|
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||||
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
|
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
|
||||||
|
@ -177,11 +177,11 @@ final class PhpDocInfo
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public function getVarType(string $tagName = '@var') : \PHPStan\Type\Type
|
public function getVarType(string $tagName = '@var') : Type
|
||||||
{
|
{
|
||||||
return $this->getTypeOrMixed($this->getVarTagValueNode($tagName));
|
return $this->getTypeOrMixed($this->getVarTagValueNode($tagName));
|
||||||
}
|
}
|
||||||
public function getReturnType() : \PHPStan\Type\Type
|
public function getReturnType() : Type
|
||||||
{
|
{
|
||||||
return $this->getTypeOrMixed($this->getReturnTagValue());
|
return $this->getTypeOrMixed($this->getReturnTagValue());
|
||||||
}
|
}
|
||||||
|
@ -228,14 +228,14 @@ final class PhpDocInfo
|
||||||
{
|
{
|
||||||
return (bool) $this->getTagsByName($name);
|
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;
|
return $this->getTagsByName($name)[0] ?? null;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param class-string[] $classes
|
* @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);
|
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClasses($this->phpDocNode, $classes);
|
||||||
return $doctrineAnnotationTagValueNodes[0] ?? null;
|
return $doctrineAnnotationTagValueNodes[0] ?? null;
|
||||||
|
@ -243,7 +243,7 @@ final class PhpDocInfo
|
||||||
/**
|
/**
|
||||||
* @param class-string $class
|
* @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);
|
$doctrineAnnotationTagValueNodes = $this->phpDocNodeByTypeFinder->findDoctrineAnnotationsByClass($this->phpDocNode, $class);
|
||||||
return $doctrineAnnotationTagValueNodes[0] ?? null;
|
return $doctrineAnnotationTagValueNodes[0] ?? null;
|
||||||
|
@ -265,11 +265,11 @@ final class PhpDocInfo
|
||||||
/**
|
/**
|
||||||
* @param string[] $desiredClasses
|
* @param string[] $desiredClasses
|
||||||
*/
|
*/
|
||||||
public function findOneByAnnotationClasses(array $desiredClasses) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
public function findOneByAnnotationClasses(array $desiredClasses) : ?DoctrineAnnotationTagValueNode
|
||||||
{
|
{
|
||||||
foreach ($desiredClasses as $desiredClass) {
|
foreach ($desiredClasses as $desiredClass) {
|
||||||
$doctrineAnnotationTagValueNode = $this->findOneByAnnotationClass($desiredClass);
|
$doctrineAnnotationTagValueNode = $this->findOneByAnnotationClass($desiredClass);
|
||||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return $doctrineAnnotationTagValueNode;
|
return $doctrineAnnotationTagValueNode;
|
||||||
|
@ -279,7 +279,7 @@ final class PhpDocInfo
|
||||||
/**
|
/**
|
||||||
* @param class-string $desiredClass
|
* @param class-string $desiredClass
|
||||||
*/
|
*/
|
||||||
public function findOneByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
public function findOneByAnnotationClass(string $desiredClass) : ?DoctrineAnnotationTagValueNode
|
||||||
{
|
{
|
||||||
$foundTagValueNodes = $this->findByAnnotationClass($desiredClass);
|
$foundTagValueNodes = $this->findByAnnotationClass($desiredClass);
|
||||||
return $foundTagValueNodes[0] ?? null;
|
return $foundTagValueNodes[0] ?? null;
|
||||||
|
@ -298,9 +298,9 @@ final class PhpDocInfo
|
||||||
*/
|
*/
|
||||||
public function removeByType(string $typeToRemove) : void
|
public function removeByType(string $typeToRemove) : void
|
||||||
{
|
{
|
||||||
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (\PHPStan\PhpDocParser\Ast\Node $node) use($typeToRemove) : ?int {
|
$phpDocNodeTraverser->traverseWithCallable($this->phpDocNode, '', function (Node $node) use($typeToRemove) : ?int {
|
||||||
if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) {
|
if ($node instanceof PhpDocTagNode && \is_a($node->value, $typeToRemove, \true)) {
|
||||||
// keep special annotation for tools
|
// keep special annotation for tools
|
||||||
if (\strncmp($node->name, '@psalm-', \strlen('@psalm-')) === 0) {
|
if (\strncmp($node->name, '@psalm-', \strlen('@psalm-')) === 0) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -309,13 +309,13 @@ final class PhpDocInfo
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$this->markAsChanged();
|
$this->markAsChanged();
|
||||||
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
|
return PhpDocNodeTraverser::NODE_REMOVE;
|
||||||
}
|
}
|
||||||
if (!\is_a($node, $typeToRemove, \true)) {
|
if (!\is_a($node, $typeToRemove, \true)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$this->markAsChanged();
|
$this->markAsChanged();
|
||||||
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
|
return PhpDocNodeTraverser::NODE_REMOVE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -330,15 +330,15 @@ final class PhpDocInfo
|
||||||
}
|
}
|
||||||
return $paramTypesByName;
|
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 instanceof DoctrineAnnotationTagValueNode) {
|
||||||
if ($phpDocTagValueNode->identifierTypeNode instanceof \Rector\BetterPhpDocParser\ValueObject\Type\ShortenedIdentifierTypeNode) {
|
if ($phpDocTagValueNode->identifierTypeNode instanceof ShortenedIdentifierTypeNode) {
|
||||||
$name = '@' . $phpDocTagValueNode->identifierTypeNode;
|
$name = '@' . $phpDocTagValueNode->identifierTypeNode;
|
||||||
} else {
|
} else {
|
||||||
$name = '@\\' . $phpDocTagValueNode->identifierTypeNode;
|
$name = '@\\' . $phpDocTagValueNode->identifierTypeNode;
|
||||||
}
|
}
|
||||||
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($name, $phpDocTagValueNode);
|
$spacelessPhpDocTagNode = new SpacelessPhpDocTagNode($name, $phpDocTagValueNode);
|
||||||
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
|
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ final class PhpDocInfo
|
||||||
if (!\is_string($name)) {
|
if (!\is_string($name)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode);
|
$phpDocTagNode = new PhpDocTagNode($name, $phpDocTagValueNode);
|
||||||
$this->addPhpDocTagNode($phpDocTagNode);
|
$this->addPhpDocTagNode($phpDocTagNode);
|
||||||
}
|
}
|
||||||
public function isNewNode() : bool
|
public function isNewNode() : bool
|
||||||
|
@ -368,25 +368,25 @@ final class PhpDocInfo
|
||||||
{
|
{
|
||||||
// fallback for invalid tag value node
|
// fallback for invalid tag value node
|
||||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($phpDocChildNode->name !== $name) {
|
if ($phpDocChildNode->name !== $name) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) {
|
if (!$phpDocChildNode->value instanceof InvalidTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
return \false;
|
return \false;
|
||||||
}
|
}
|
||||||
public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode
|
public function getReturnTagValue() : ?ReturnTagValueNode
|
||||||
{
|
{
|
||||||
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
|
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
|
||||||
return $returnTagValueNodes[0] ?? null;
|
return $returnTagValueNodes[0] ?? null;
|
||||||
}
|
}
|
||||||
public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
public function getParamTagValueByName(string $name) : ?ParamTagValueNode
|
||||||
{
|
{
|
||||||
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
|
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
|
||||||
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
|
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
|
||||||
|
@ -410,7 +410,7 @@ final class PhpDocInfo
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
foreach ($this->phpDocNode->children as $children) {
|
foreach ($this->phpDocNode->children as $children) {
|
||||||
if (!$children instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) {
|
if (!$children instanceof PhpDocTextNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (\in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], \true)) {
|
if (\in_array($children->text, ['{@inheritdoc}', '{@inheritDoc}'], \true)) {
|
||||||
|
@ -441,8 +441,8 @@ final class PhpDocInfo
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
// has a single node with missing start_end
|
// has a single node with missing start_end
|
||||||
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor();
|
$changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor();
|
||||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
|
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
|
||||||
$phpDocNodeTraverser->traverse($this->phpDocNode);
|
$phpDocNodeTraverser->traverse($this->phpDocNode);
|
||||||
return $changedPhpDocNodeVisitor->hasChanged();
|
return $changedPhpDocNodeVisitor->hasChanged();
|
||||||
|
@ -466,7 +466,7 @@ final class PhpDocInfo
|
||||||
{
|
{
|
||||||
return $this->node;
|
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) {
|
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
|
||||||
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
|
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
|
||||||
|
@ -479,10 +479,10 @@ final class PhpDocInfo
|
||||||
/**
|
/**
|
||||||
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Type
|
* @return \PHPStan\Type\MixedType|\PHPStan\Type\Type
|
||||||
*/
|
*/
|
||||||
private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode)
|
private function getTypeOrMixed(?PhpDocTagValueNode $phpDocTagValueNode)
|
||||||
{
|
{
|
||||||
if ($phpDocTagValueNode === null) {
|
if ($phpDocTagValueNode === null) {
|
||||||
return new \PHPStan\Type\MixedType();
|
return new MixedType();
|
||||||
}
|
}
|
||||||
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
|
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ final class PhpDocInfoFactory
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
|
* @var \Rector\BetterPhpDocParser\PhpDocNodeFinder\PhpDocNodeByTypeFinder
|
||||||
*/
|
*/
|
||||||
private $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->phpDocNodeMapper = $phpDocNodeMapper;
|
||||||
$this->currentNodeProvider = $currentNodeProvider;
|
$this->currentNodeProvider = $currentNodeProvider;
|
||||||
|
@ -75,10 +75,10 @@ final class PhpDocInfoFactory
|
||||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||||
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
|
$this->phpDocNodeByTypeFinder = $phpDocNodeByTypeFinder;
|
||||||
}
|
}
|
||||||
public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
public function createFromNodeOrEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||||
{
|
{
|
||||||
// already added
|
// 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) {
|
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||||
return $phpDocInfo;
|
return $phpDocInfo;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ final class PhpDocInfoFactory
|
||||||
}
|
}
|
||||||
return $this->createEmpty($node);
|
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);
|
$objectHash = \spl_object_hash($node);
|
||||||
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
|
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
|
||||||
|
@ -97,17 +97,17 @@ final class PhpDocInfoFactory
|
||||||
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
|
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
|
||||||
$this->currentNodeProvider->setNode($node);
|
$this->currentNodeProvider->setNode($node);
|
||||||
$docComment = $node->getDocComment();
|
$docComment = $node->getDocComment();
|
||||||
if (!$docComment instanceof \PhpParser\Comment\Doc) {
|
if (!$docComment instanceof Doc) {
|
||||||
if ($node->getComments() !== []) {
|
if ($node->getComments() !== []) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// create empty node
|
// create empty node
|
||||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]);
|
$tokenIterator = new BetterTokenIterator([]);
|
||||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
$phpDocNode = new PhpDocNode([]);
|
||||||
} else {
|
} else {
|
||||||
$text = $docComment->getText();
|
$text = $docComment->getText();
|
||||||
$tokens = $this->lexer->tokenize($text);
|
$tokens = $this->lexer->tokenize($text);
|
||||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
$tokenIterator = new BetterTokenIterator($tokens);
|
||||||
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
|
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
|
||||||
$this->setPositionOfLastToken($phpDocNode);
|
$this->setPositionOfLastToken($phpDocNode);
|
||||||
}
|
}
|
||||||
|
@ -115,12 +115,12 @@ final class PhpDocInfoFactory
|
||||||
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
|
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
|
||||||
return $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() */
|
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
|
||||||
$this->currentNodeProvider->setNode($node);
|
$this->currentNodeProvider->setNode($node);
|
||||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
$phpDocNode = new PhpDocNode([]);
|
||||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node);
|
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new BetterTokenIterator([]), $node);
|
||||||
// multiline by default
|
// multiline by default
|
||||||
$phpDocInfo->makeMultiLined();
|
$phpDocInfo->makeMultiLined();
|
||||||
return $phpDocInfo;
|
return $phpDocInfo;
|
||||||
|
@ -128,23 +128,23 @@ final class PhpDocInfoFactory
|
||||||
/**
|
/**
|
||||||
* Needed for printing
|
* Needed for printing
|
||||||
*/
|
*/
|
||||||
private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
private function setPositionOfLastToken(PhpDocNode $phpDocNode) : void
|
||||||
{
|
{
|
||||||
if ($phpDocNode->children === []) {
|
if ($phpDocNode->children === []) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocChildNodes = $phpDocNode->children;
|
$phpDocChildNodes = $phpDocNode->children;
|
||||||
$phpDocChildNode = \array_pop($phpDocChildNodes);
|
$phpDocChildNode = \array_pop($phpDocChildNodes);
|
||||||
$startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
$startAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
if ($startAndEnd instanceof StartAndEnd) {
|
||||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
$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);
|
$this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator);
|
||||||
$phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector, $this->phpDocNodeByTypeFinder);
|
$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;
|
return $phpDocInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,23 +23,23 @@ final class TokenIteratorFactory
|
||||||
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
* @var \Symplify\PackageBuilder\Reflection\PrivatesAccessor
|
||||||
*/
|
*/
|
||||||
private $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->lexer = $lexer;
|
||||||
$this->privatesAccessor = $privatesAccessor;
|
$this->privatesAccessor = $privatesAccessor;
|
||||||
}
|
}
|
||||||
public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
public function create(string $content) : BetterTokenIterator
|
||||||
{
|
{
|
||||||
$tokens = $this->lexer->tokenize($content);
|
$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;
|
return $tokenIterator;
|
||||||
}
|
}
|
||||||
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
|
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
|
||||||
$betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
$betterTokenIterator = new BetterTokenIterator($tokens);
|
||||||
// keep original position
|
// keep original position
|
||||||
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, self::INDEX);
|
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, self::INDEX);
|
||||||
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);
|
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);
|
||||||
|
|
|
@ -16,7 +16,7 @@ final class PhpDocClassRenamer
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher
|
* @var \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher
|
||||||
*/
|
*/
|
||||||
private $classAnnotationMatcher;
|
private $classAnnotationMatcher;
|
||||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher)
|
public function __construct(ClassAnnotationMatcher $classAnnotationMatcher)
|
||||||
{
|
{
|
||||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ final class PhpDocClassRenamer
|
||||||
*
|
*
|
||||||
* @param string[] $oldToNewClasses
|
* @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->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||||
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
||||||
|
@ -35,14 +35,14 @@ final class PhpDocClassRenamer
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @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');
|
$assertChoiceTagValueNode = $phpDocInfo->findOneByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
|
||||||
if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
if (!$assertChoiceTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
|
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
|
||||||
if (!$callback instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode) {
|
if (!$callback instanceof CurlyListNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$callbackClass = $callback->getValueWithoutQuotes(0);
|
$callbackClass = $callback->getValueWithoutQuotes(0);
|
||||||
|
@ -58,10 +58,10 @@ final class PhpDocClassRenamer
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @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']);
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
||||||
|
@ -69,10 +69,10 @@ final class PhpDocClassRenamer
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @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');
|
$doctrineAnnotationTagValueNode = $phpDocInfo->findOneByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
|
||||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||||
|
@ -82,7 +82,7 @@ final class PhpDocClassRenamer
|
||||||
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
||||||
continue;
|
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) {
|
if ($newContent === $className) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ final class PhpDocClassRenamer
|
||||||
/**
|
/**
|
||||||
* @param array<string, string> $oldToNewClasses
|
* @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';
|
$classKey = $doctrineAnnotationTagValueNode->hasClassName('Doctrine\\ORM\\Mapping\\Embedded') ? 'class' : 'targetEntity';
|
||||||
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey);
|
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes($classKey);
|
||||||
|
|
|
@ -10,37 +10,37 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser;
|
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser;
|
||||||
final class PhpDocTagRemover
|
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();
|
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) {
|
if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) {
|
||||||
unset($phpDocNode->children[$key]);
|
unset($phpDocNode->children[$key]);
|
||||||
$phpDocInfo->markAsChanged();
|
$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]);
|
unset($phpDocNode->children[$key]);
|
||||||
$phpDocInfo->markAsChanged();
|
$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();
|
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||||
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use($desiredNode, $phpDocInfo) : ?int {
|
$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();
|
$phpDocInfo->markAsChanged();
|
||||||
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
|
return PhpDocNodeTraverser::NODE_REMOVE;
|
||||||
}
|
}
|
||||||
if ($node !== $desiredNode) {
|
if ($node !== $desiredNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$phpDocInfo->markAsChanged();
|
$phpDocInfo->markAsChanged();
|
||||||
return \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser::NODE_REMOVE;
|
return PhpDocNodeTraverser::NODE_REMOVE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private function areAnnotationNamesEqual(string $firstAnnotationName, string $secondAnnotationName) : bool
|
private function areAnnotationNamesEqual(string $firstAnnotationName, string $secondAnnotationName) : bool
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class PhpDocTypeChanger
|
||||||
/**
|
/**
|
||||||
* @var array<class-string<Node>>
|
* @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[]
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
|
@ -69,7 +69,7 @@ final class PhpDocTypeChanger
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||||
*/
|
*/
|
||||||
private $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->staticTypeMapper = $staticTypeMapper;
|
||||||
$this->typeComparator = $typeComparator;
|
$this->typeComparator = $typeComparator;
|
||||||
|
@ -78,7 +78,7 @@ final class PhpDocTypeChanger
|
||||||
$this->commentsMerger = $commentsMerger;
|
$this->commentsMerger = $commentsMerger;
|
||||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
$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
|
// better skip, could crash hard
|
||||||
if ($phpDocInfo->hasInvalidTag('@var')) {
|
if ($phpDocInfo->hasInvalidTag('@var')) {
|
||||||
|
@ -89,22 +89,22 @@ final class PhpDocTypeChanger
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// prevent existing type override by mixed
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
// override existing type
|
// override existing type
|
||||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PROPERTY);
|
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PROPERTY);
|
||||||
$currentVarTagValueNode = $phpDocInfo->getVarTagValueNode();
|
$currentVarTagValueNode = $phpDocInfo->getVarTagValueNode();
|
||||||
if ($currentVarTagValueNode !== null) {
|
if ($currentVarTagValueNode !== null) {
|
||||||
// only change type
|
// only change type
|
||||||
$currentVarTagValueNode->type = $newPHPStanPhpDocType;
|
$currentVarTagValueNode->type = $newPHPStanPhpDocType;
|
||||||
} else {
|
} else {
|
||||||
// add completely new one
|
// add completely new one
|
||||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($newPHPStanPhpDocType, '', '');
|
$varTagValueNode = new VarTagValueNode($newPHPStanPhpDocType, '', '');
|
||||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
$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
|
// better not touch this, can crash
|
||||||
if ($phpDocInfo->hasInvalidTag('@return')) {
|
if ($phpDocInfo->hasInvalidTag('@return')) {
|
||||||
|
@ -115,25 +115,25 @@ final class PhpDocTypeChanger
|
||||||
return \false;
|
return \false;
|
||||||
}
|
}
|
||||||
// override existing type
|
// override existing type
|
||||||
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::RETURN);
|
$newPHPStanPhpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::RETURN);
|
||||||
$currentReturnTagValueNode = $phpDocInfo->getReturnTagValue();
|
$currentReturnTagValueNode = $phpDocInfo->getReturnTagValue();
|
||||||
if ($currentReturnTagValueNode !== null) {
|
if ($currentReturnTagValueNode !== null) {
|
||||||
// only change type
|
// only change type
|
||||||
$currentReturnTagValueNode->type = $newPHPStanPhpDocType;
|
$currentReturnTagValueNode->type = $newPHPStanPhpDocType;
|
||||||
} else {
|
} else {
|
||||||
// add completely new one
|
// add completely new one
|
||||||
$returnTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($newPHPStanPhpDocType, '');
|
$returnTagValueNode = new ReturnTagValueNode($newPHPStanPhpDocType, '');
|
||||||
$phpDocInfo->addTagValueNode($returnTagValueNode);
|
$phpDocInfo->addTagValueNode($returnTagValueNode);
|
||||||
}
|
}
|
||||||
return \true;
|
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
|
// better skip, could crash hard
|
||||||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, \Rector\PHPStanStaticTypeMapper\Enum\TypeKind::PARAM);
|
$phpDocType = $this->staticTypeMapper->mapPHPStanTypeToPHPStanPhpDocTypeNode($newType, TypeKind::PARAM);
|
||||||
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
$paramTagValueNode = $phpDocInfo->getParamTagValueByName($paramName);
|
||||||
// override existing type
|
// override existing type
|
||||||
if ($paramTagValueNode !== null) {
|
if ($paramTagValueNode !== null) {
|
||||||
|
@ -152,9 +152,9 @@ final class PhpDocTypeChanger
|
||||||
$phpDocInfo->addTagValueNode($paramTagValueNode);
|
$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) {
|
foreach ($typeNode->types as $type) {
|
||||||
if ($this->isAllowed($type)) {
|
if ($this->isAllowed($type)) {
|
||||||
return \true;
|
return \true;
|
||||||
|
@ -164,28 +164,28 @@ final class PhpDocTypeChanger
|
||||||
if (\in_array(\get_class($typeNode), self::ALLOWED_TYPES, \true)) {
|
if (\in_array(\get_class($typeNode), self::ALLOWED_TYPES, \true)) {
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) {
|
if (!$typeNode instanceof IdentifierTypeNode) {
|
||||||
return \false;
|
return \false;
|
||||||
}
|
}
|
||||||
return \in_array((string) $typeNode, self::ALLOWED_IDENTIFIER_TYPENODE_TYPES, \true);
|
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);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($property);
|
||||||
if (!$phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
if (!$phpDocInfo instanceof PhpDocInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$varTag = $phpDocInfo->getVarTagValueNode();
|
$varTag = $phpDocInfo->getVarTagValueNode();
|
||||||
if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) {
|
if (!$varTag instanceof VarTagValueNode) {
|
||||||
$this->processKeepComments($property, $param);
|
$this->processKeepComments($property, $param);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($varTag->description !== '') {
|
if ($varTag->description !== '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$functionLike = $param->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
$functionLike = $param->getAttribute(AttributeKey::PARENT_NODE);
|
||||||
$paramVarName = $this->nodeNameResolver->getName($param->var);
|
$paramVarName = $this->nodeNameResolver->getName($param->var);
|
||||||
if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) {
|
if (!$functionLike instanceof ClassMethod) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->isAllowed($varTag->type)) {
|
if (!$this->isAllowed($varTag->type)) {
|
||||||
|
@ -194,36 +194,36 @@ final class PhpDocTypeChanger
|
||||||
if (!\is_string($paramVarName)) {
|
if (!\is_string($paramVarName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class);
|
$phpDocInfo->removeByType(VarTagValueNode::class);
|
||||||
$param->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
$param->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||||
$phpDocInfo = $functionLike->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
$phpDocInfo = $functionLike->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||||
$paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTag, $property);
|
$paramType = $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($varTag, $property);
|
||||||
$this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName);
|
$this->changeParamType($phpDocInfo, $paramType, $param, $paramVarName);
|
||||||
$this->processKeepComments($property, $param);
|
$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
|
// add completely new one
|
||||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($typeNode, '', '');
|
$varTagValueNode = new VarTagValueNode($typeNode, '', '');
|
||||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
$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);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param);
|
||||||
$varTag = $phpDocInfo->getVarTagValueNode();
|
$varTag = $phpDocInfo->getVarTagValueNode();
|
||||||
$toBeRemoved = !$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode;
|
$toBeRemoved = !$varTag instanceof VarTagValueNode;
|
||||||
$this->commentsMerger->keepComments($param, [$property]);
|
$this->commentsMerger->keepComments($param, [$property]);
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($param);
|
||||||
$varTag = $phpDocInfo->getVarTagValueNode();
|
$varTag = $phpDocInfo->getVarTagValueNode();
|
||||||
if (!$toBeRemoved) {
|
if (!$toBeRemoved) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$varTag instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode) {
|
if (!$varTag instanceof VarTagValueNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($varTag->description !== '') {
|
if ($varTag->description !== '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocInfo->removeByType(\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class);
|
$phpDocInfo->removeByType(VarTagValueNode::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,22 +15,22 @@ final class PropertyDocBlockManipulator
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
* @var \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory
|
||||||
*/
|
*/
|
||||||
private $phpDocInfoFactory;
|
private $phpDocInfoFactory;
|
||||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory)
|
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
||||||
{
|
{
|
||||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param ParamRename $renameValueObject
|
* @param ParamRename $renameValueObject
|
||||||
*/
|
*/
|
||||||
public function renameParameterNameInDocBlock(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : void
|
public function renameParameterNameInDocBlock(RenameValueObjectInterface $renameValueObject) : void
|
||||||
{
|
{
|
||||||
$functionLike = $renameValueObject->getFunctionLike();
|
$functionLike = $renameValueObject->getFunctionLike();
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
||||||
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
|
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
|
||||||
if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) {
|
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
|
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
|
||||||
$paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,36 +30,36 @@ final class VarAnnotationManipulator
|
||||||
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
* @var \Rector\Core\PhpParser\Node\BetterNodeFinder
|
||||||
*/
|
*/
|
||||||
private $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->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||||
$this->betterNodeFinder = $betterNodeFinder;
|
$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);
|
$phpDocInfo = $this->resolvePhpDocInfo($node);
|
||||||
// already done
|
// already done
|
||||||
if ($phpDocInfo->getVarTagValueNode() !== null) {
|
if ($phpDocInfo->getVarTagValueNode() !== null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
|
$fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
|
||||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
|
$varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
|
||||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||||
$phpDocInfo->makeSingleLined();
|
$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;
|
return;
|
||||||
}
|
}
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType);
|
$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);
|
$currentStmt = $this->betterNodeFinder->resolveCurrentStatement($node);
|
||||||
if ($currentStmt instanceof \PhpParser\Node\Stmt\Expression) {
|
if ($currentStmt instanceof Expression) {
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
|
||||||
} else {
|
} else {
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||||
|
|
|
@ -16,9 +16,9 @@ final class PhpDocNodeByTypeFinder
|
||||||
* @param class-string<TNode> $desiredType
|
* @param class-string<TNode> $desiredType
|
||||||
* @return array<TNode>
|
* @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 = [];
|
$foundNodes = [];
|
||||||
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use(&$foundNodes, $desiredType) : Node {
|
$phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function ($node) use(&$foundNodes, $desiredType) : Node {
|
||||||
if (!\is_a($node, $desiredType, \true)) {
|
if (!\is_a($node, $desiredType, \true)) {
|
||||||
|
@ -34,7 +34,7 @@ final class PhpDocNodeByTypeFinder
|
||||||
* @param class-string[] $classes
|
* @param class-string[] $classes
|
||||||
* @return DoctrineAnnotationTagValueNode[]
|
* @return DoctrineAnnotationTagValueNode[]
|
||||||
*/
|
*/
|
||||||
public function findDoctrineAnnotationsByClasses(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, array $classes) : array
|
public function findDoctrineAnnotationsByClasses(PhpDocNode $phpDocNode, array $classes) : array
|
||||||
{
|
{
|
||||||
$doctrineAnnotationTagValueNodes = [];
|
$doctrineAnnotationTagValueNodes = [];
|
||||||
foreach ($classes as $class) {
|
foreach ($classes as $class) {
|
||||||
|
@ -47,11 +47,11 @@ final class PhpDocNodeByTypeFinder
|
||||||
* @param class-string $desiredClass
|
* @param class-string $desiredClass
|
||||||
* @return DoctrineAnnotationTagValueNode[]
|
* @return DoctrineAnnotationTagValueNode[]
|
||||||
*/
|
*/
|
||||||
public function findDoctrineAnnotationsByClass(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, string $desiredClass) : array
|
public function findDoctrineAnnotationsByClass(PhpDocNode $phpDocNode, string $desiredClass) : array
|
||||||
{
|
{
|
||||||
$desiredDoctrineTagValueNodes = [];
|
$desiredDoctrineTagValueNodes = [];
|
||||||
/** @var DoctrineAnnotationTagValueNode[] $doctrineTagValueNodes */
|
/** @var DoctrineAnnotationTagValueNode[] $doctrineTagValueNodes */
|
||||||
$doctrineTagValueNodes = $this->findByType($phpDocNode, \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode::class);
|
$doctrineTagValueNodes = $this->findByType($phpDocNode, DoctrineAnnotationTagValueNode::class);
|
||||||
foreach ($doctrineTagValueNodes as $doctrineTagValueNode) {
|
foreach ($doctrineTagValueNodes as $doctrineTagValueNode) {
|
||||||
if ($doctrineTagValueNode->hasClassName($desiredClass)) {
|
if ($doctrineTagValueNode->hasClassName($desiredClass)) {
|
||||||
$desiredDoctrineTagValueNodes[] = $doctrineTagValueNode;
|
$desiredDoctrineTagValueNodes[] = $doctrineTagValueNode;
|
||||||
|
|
|
@ -38,23 +38,23 @@ final class PhpDocNodeMapper
|
||||||
/**
|
/**
|
||||||
* @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors
|
* @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->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||||
$this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor;
|
$this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor;
|
||||||
$this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor;
|
$this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor;
|
||||||
$this->phpDocNodeVisitors = $phpDocNodeVisitors;
|
$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);
|
$this->currentTokenIteratorProvider->setBetterTokenIterator($betterTokenIterator);
|
||||||
$parentPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$parentPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor);
|
$parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor);
|
||||||
$parentPhpDocNodeTraverser->traverse($phpDocNode);
|
$parentPhpDocNodeTraverser->traverse($phpDocNode);
|
||||||
$cloningPhpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$cloningPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
$cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor);
|
$cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor);
|
||||||
$cloningPhpDocNodeTraverser->traverse($phpDocNode);
|
$cloningPhpDocNodeTraverser->traverse($phpDocNode);
|
||||||
$phpDocNodeTraverser = new \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser();
|
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||||
foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) {
|
foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) {
|
||||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor);
|
$phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
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
|
* @readonly
|
||||||
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $attributeMirrorer;
|
private $attributeMirrorer;
|
||||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||||
{
|
{
|
||||||
$this->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;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) {
|
if ($node instanceof SpacingAwareArrayTypeNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type);
|
$spacingAwareArrayTypeNode = new SpacingAwareArrayTypeNode($node->type);
|
||||||
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
|
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
|
||||||
return $spacingAwareArrayTypeNode;
|
return $spacingAwareArrayTypeNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
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
|
* @readonly
|
||||||
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $attributeMirrorer;
|
private $attributeMirrorer;
|
||||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||||
{
|
{
|
||||||
$this->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;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode) {
|
if ($node instanceof SpacingAwareCallableTypeNode) {
|
||||||
return null;
|
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);
|
$this->attributeMirrorer->mirror($node, $spacingAwareCallableTypeNode);
|
||||||
return $spacingAwareCallableTypeNode;
|
return $spacingAwareCallableTypeNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,19 +6,19 @@ namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
|
||||||
use PHPStan\PhpDocParser\Ast\Node;
|
use PHPStan\PhpDocParser\Ast\Node;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||||
final class ChangedPhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
|
final class ChangedPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $hasChanged = \false;
|
private $hasChanged = \false;
|
||||||
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
|
public function beforeTraverse(Node $node) : void
|
||||||
{
|
{
|
||||||
$this->hasChanged = \false;
|
$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) {
|
if ($origNode === null) {
|
||||||
$this->hasChanged = \true;
|
$this->hasChanged = \true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,26 +9,26 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
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
|
* @readonly
|
||||||
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $attributeMirrorer;
|
private $attributeMirrorer;
|
||||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||||
{
|
{
|
||||||
$this->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;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode) {
|
if ($node instanceof BracketsAwareIntersectionTypeNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$bracketsAwareIntersectionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode($node->types);
|
$bracketsAwareIntersectionTypeNode = new BracketsAwareIntersectionTypeNode($node->types);
|
||||||
$this->attributeMirrorer->mirror($node, $bracketsAwareIntersectionTypeNode);
|
$this->attributeMirrorer->mirror($node, $bracketsAwareIntersectionTypeNode);
|
||||||
return $bracketsAwareIntersectionTypeNode;
|
return $bracketsAwareIntersectionTypeNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||||
use Rector\Core\Exception\ShouldNotHappenException;
|
use Rector\Core\Exception\ShouldNotHappenException;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
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
|
* @readonly
|
||||||
|
@ -27,34 +27,34 @@ final class TemplatePhpDocNodeVisitor extends \RectorPrefix20220607\Symplify\Ast
|
||||||
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $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->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||||
$this->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\PhpDoc\TemplateTagValueNode) {
|
if (!$node instanceof TemplateTagValueNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode) {
|
if ($node instanceof SpacingAwareTemplateTagValueNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$betterTokenIterator = $this->currentTokenIteratorProvider->provide();
|
$betterTokenIterator = $this->currentTokenIteratorProvider->provide();
|
||||||
$startAndEnd = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
$startAndEnd = $node->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
if (!$startAndEnd instanceof StartAndEnd) {
|
||||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
throw new ShouldNotHappenException();
|
||||||
}
|
}
|
||||||
$prepositions = $this->resolvePreposition($betterTokenIterator, $startAndEnd);
|
$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);
|
$this->attributeMirrorer->mirror($node, $spacingAwareTemplateTagValueNode);
|
||||||
return $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());
|
$partialTokens = $betterTokenIterator->partialTokens($startAndEnd->getStart(), $startAndEnd->getEnd());
|
||||||
foreach ($partialTokens as $partialToken) {
|
foreach ($partialTokens as $partialToken) {
|
||||||
if ($partialToken[1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER) {
|
if ($partialToken[1] !== Lexer::TOKEN_IDENTIFIER) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!\in_array($partialToken[0], ['as', 'of'], \true)) {
|
if (!\in_array($partialToken[0], ['as', 'of'], \true)) {
|
||||||
|
|
|
@ -14,7 +14,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||||
use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
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
|
* @readonly
|
||||||
|
@ -26,49 +26,49 @@ final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20220607\Symplif
|
||||||
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $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->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||||
$this->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\UnionTypeNode) {
|
if (!$node instanceof UnionTypeNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) {
|
if ($node instanceof BracketsAwareUnionTypeNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$startAndEnd = $this->resolveStardAndEnd($node);
|
$startAndEnd = $this->resolveStardAndEnd($node);
|
||||||
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
if (!$startAndEnd instanceof StartAndEnd) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$betterTokenProvider = $this->currentTokenIteratorProvider->provide();
|
$betterTokenProvider = $this->currentTokenIteratorProvider->provide();
|
||||||
$isWrappedInCurlyBrackets = $this->isWrappedInCurlyBrackets($betterTokenProvider, $startAndEnd);
|
$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);
|
$this->attributeMirrorer->mirror($node, $bracketsAwareUnionTypeNode);
|
||||||
return $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;
|
$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;
|
return \true;
|
||||||
}
|
}
|
||||||
// there is no + 1, as end is right at the next token
|
// 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);
|
$starAndEnd = $unionTypeNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
if ($starAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
if ($starAndEnd instanceof StartAndEnd) {
|
||||||
return $starAndEnd;
|
return $starAndEnd;
|
||||||
}
|
}
|
||||||
// unwrap with parent array type...
|
// unwrap with parent array type...
|
||||||
$parent = $unionTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT);
|
$parent = $unionTypeNode->getAttribute(PhpDocAttributeKey::PARENT);
|
||||||
if (!$parent instanceof \PHPStan\PhpDocParser\Ast\Node) {
|
if (!$parent instanceof Node) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return $parent->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
return $parent->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use RectorPrefix20220607\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||||
/**
|
/**
|
||||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest
|
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest
|
||||||
*/
|
*/
|
||||||
final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
final class BetterPhpDocParser extends PhpDocParser
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -50,76 +50,76 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||||
/**
|
/**
|
||||||
* @param PhpDocNodeDecoratorInterface[] $phpDocNodeDecorators
|
* @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->currentNodeProvider = $currentNodeProvider;
|
||||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||||
$this->phpDocNodeDecorators = $phpDocNodeDecorators;
|
$this->phpDocNodeDecorators = $phpDocNodeDecorators;
|
||||||
$this->privatesCaller = $privatesCaller;
|
$this->privatesCaller = $privatesCaller;
|
||||||
parent::__construct($typeParser, $constExprParser);
|
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->consumeTokenType(Lexer::TOKEN_OPEN_PHPDOC);
|
||||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||||
$children = [];
|
$children = [];
|
||||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) {
|
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
|
||||||
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
|
$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);
|
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// might be in the middle of annotations
|
// might be in the middle of annotations
|
||||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC);
|
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC);
|
||||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode($children);
|
$phpDocNode = new PhpDocNode($children);
|
||||||
// decorate FQN classes etc.
|
// decorate FQN classes etc.
|
||||||
$node = $this->currentNodeProvider->getNode();
|
$node = $this->currentNodeProvider->getNode();
|
||||||
if (!$node instanceof \PhpParser\Node) {
|
if (!$node instanceof Node) {
|
||||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
throw new ShouldNotHappenException();
|
||||||
}
|
}
|
||||||
foreach ($this->phpDocNodeDecorators as $phpDocNodeDecorator) {
|
foreach ($this->phpDocNodeDecorators as $phpDocNodeDecorator) {
|
||||||
$phpDocNodeDecorator->decorate($phpDocNode, $node);
|
$phpDocNodeDecorator->decorate($phpDocNode, $node);
|
||||||
}
|
}
|
||||||
return $phpDocNode;
|
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
|
// replace generic nodes with DoctrineAnnotations
|
||||||
if (!$tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
|
if (!$tokenIterator instanceof BetterTokenIterator) {
|
||||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
throw new ShouldNotHappenException();
|
||||||
}
|
}
|
||||||
$tag = $this->resolveTag($tokenIterator);
|
$tag = $this->resolveTag($tokenIterator);
|
||||||
$phpDocTagValueNode = $this->parseTagValue($tokenIterator, $tag);
|
$phpDocTagValueNode = $this->parseTagValue($tokenIterator, $tag);
|
||||||
return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($tag, $phpDocTagValueNode);
|
return new PhpDocTagNode($tag, $phpDocTagValueNode);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param BetterTokenIterator $tokenIterator
|
* @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();
|
$startPosition = $tokenIterator->currentPosition();
|
||||||
$tagValueNode = parent::parseTagValue($tokenIterator, $tag);
|
$tagValueNode = parent::parseTagValue($tokenIterator, $tag);
|
||||||
$endPosition = $tokenIterator->currentPosition();
|
$endPosition = $tokenIterator->currentPosition();
|
||||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||||
$tagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
$tagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||||
return $tagValueNode;
|
return $tagValueNode;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @return PhpDocTextNode|PhpDocTagNode
|
* @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);
|
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
|
||||||
$startPosition = $betterTokenIterator->currentPosition();
|
$startPosition = $betterTokenIterator->currentPosition();
|
||||||
/** @var PhpDocChildNode $phpDocNode */
|
/** @var PhpDocChildNode $phpDocNode */
|
||||||
$phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
|
$phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
|
||||||
$endPosition = $betterTokenIterator->currentPosition();
|
$endPosition = $betterTokenIterator->currentPosition();
|
||||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
$phpDocNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||||
return $phpDocNode;
|
return $phpDocNode;
|
||||||
}
|
}
|
||||||
private function resolveTag(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : string
|
private function resolveTag(BetterTokenIterator $tokenIterator) : string
|
||||||
{
|
{
|
||||||
$tag = $tokenIterator->currentTokenValue();
|
$tag = $tokenIterator->currentTokenValue();
|
||||||
$tokenIterator->next();
|
$tokenIterator->next();
|
||||||
|
@ -129,7 +129,7 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||||
}
|
}
|
||||||
// is not e.g "@var "
|
// is not e.g "@var "
|
||||||
// join tags like "@ORM\Column" etc.
|
// join tags like "@ORM\Column" etc.
|
||||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) {
|
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
|
||||||
return $tag;
|
return $tag;
|
||||||
}
|
}
|
||||||
// @todo use joinUntil("(")?
|
// @todo use joinUntil("(")?
|
||||||
|
|
|
@ -10,26 +10,26 @@ use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||||
use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory;
|
use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||||
final class BetterTypeParser extends \PHPStan\PhpDocParser\Parser\TypeParser
|
final class BetterTypeParser extends TypeParser
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory
|
* @var \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory
|
||||||
*/
|
*/
|
||||||
private $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;
|
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||||
parent::__construct($constExprParser);
|
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);
|
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
|
||||||
$startPosition = $betterTokenIterator->currentPosition();
|
$startPosition = $betterTokenIterator->currentPosition();
|
||||||
$typeNode = parent::parse($betterTokenIterator);
|
$typeNode = parent::parse($betterTokenIterator);
|
||||||
$endPosition = $betterTokenIterator->currentPosition();
|
$endPosition = $betterTokenIterator->currentPosition();
|
||||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||||
$typeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
$typeNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||||
return $typeNode;
|
return $typeNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,21 +36,21 @@ final class ClassAnnotationMatcher
|
||||||
* @var \PHPStan\Reflection\ReflectionProvider
|
* @var \PHPStan\Reflection\ReflectionProvider
|
||||||
*/
|
*/
|
||||||
private $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->useImportNameMatcher = $useImportNameMatcher;
|
||||||
$this->useImportsResolver = $useImportsResolver;
|
$this->useImportsResolver = $useImportsResolver;
|
||||||
$this->reflectionProvider = $reflectionProvider;
|
$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);
|
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);
|
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);
|
$uniqueHash = $tag . \spl_object_hash($node);
|
||||||
if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) {
|
if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) {
|
||||||
|
@ -71,10 +71,10 @@ final class ClassAnnotationMatcher
|
||||||
/**
|
/**
|
||||||
* @param Use_[]|GroupUse[] $uses
|
* @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);
|
$scope = $node->getAttribute(AttributeKey::SCOPE);
|
||||||
if ($scope instanceof \PHPStan\Analyser\Scope) {
|
if ($scope instanceof Scope) {
|
||||||
$namespace = $scope->getNamespace();
|
$namespace = $scope->getNamespace();
|
||||||
if ($namespace !== null) {
|
if ($namespace !== null) {
|
||||||
$namespacedTag = $namespace . '\\' . $tag;
|
$namespacedTag = $namespace . '\\' . $tag;
|
||||||
|
@ -99,9 +99,9 @@ final class ClassAnnotationMatcher
|
||||||
private function resolveAsAliased(array $uses, string $tag, bool $returnNullOnUnknownClass) : ?string
|
private function resolveAsAliased(array $uses, string $tag, bool $returnNullOnUnknownClass) : ?string
|
||||||
{
|
{
|
||||||
foreach ($uses as $use) {
|
foreach ($uses as $use) {
|
||||||
$prefix = $use instanceof \PhpParser\Node\Stmt\GroupUse ? $use->prefix . '\\' : '';
|
$prefix = $use instanceof GroupUse ? $use->prefix . '\\' : '';
|
||||||
foreach ($use->uses as $useUse) {
|
foreach ($use->uses as $useUse) {
|
||||||
if (!$useUse->alias instanceof \PhpParser\Node\Identifier) {
|
if (!$useUse->alias instanceof Identifier) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($useUse->alias->toString() === $tag) {
|
if ($useUse->alias->toString() === $tag) {
|
||||||
|
|
|
@ -16,7 +16,7 @@ use RectorPrefix20220607\Symplify\Astral\PhpDocParser\PhpDocNodeTraverser;
|
||||||
* Decorate node with fully qualified class name for const epxr,
|
* Decorate node with fully qualified class name for const epxr,
|
||||||
* e.g. Direction::*
|
* e.g. Direction::*
|
||||||
*/
|
*/
|
||||||
final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Contract\PhpDocParser\PhpDocNodeDecoratorInterface
|
final class ConstExprClassNameDecorator implements PhpDocNodeDecoratorInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -28,28 +28,28 @@ final class ConstExprClassNameDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
* @var \Symplify\Astral\PhpDocParser\PhpDocNodeTraverser
|
* @var \Symplify\Astral\PhpDocParser\PhpDocNodeTraverser
|
||||||
*/
|
*/
|
||||||
private $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->nameScopeFactory = $nameScopeFactory;
|
||||||
$this->phpDocNodeTraverser = $phpDocNodeTraverser;
|
$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) {
|
$this->phpDocNodeTraverser->traverseWithCallable($phpDocNode, '', function (Node $node) use($phpNode) {
|
||||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprNode) {
|
if (!$node instanceof ConstExprNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$className = $this->resolveFullyQualifiedClass($node, $phpNode);
|
$className = $this->resolveFullyQualifiedClass($node, $phpNode);
|
||||||
if ($className === null) {
|
if ($className === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$node->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $className);
|
$node->setAttribute(PhpDocAttributeKey::RESOLVED_CLASS, $className);
|
||||||
return $node;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
$nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($phpNode);
|
$nameScope = $this->nameScopeFactory->createNameScopeFromNodeWithoutTemplateTypes($phpNode);
|
||||||
|
|
|
@ -21,7 +21,7 @@ use Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||||
use Rector\Core\Util\StringUtils;
|
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
|
* 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
|
* @var \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer
|
||||||
*/
|
*/
|
||||||
private $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->classAnnotationMatcher = $classAnnotationMatcher;
|
||||||
$this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser;
|
$this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser;
|
||||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||||
$this->attributeMirrorer = $attributeMirrorer;
|
$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
|
// merge split doctrine nested tags
|
||||||
$this->mergeNestedDoctrineAnnotations($phpDocNode);
|
$this->mergeNestedDoctrineAnnotations($phpDocNode);
|
||||||
|
@ -74,17 +74,17 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
/**
|
/**
|
||||||
* Join token iterator with all the following nodes if nested
|
* 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 = [];
|
$removedKeys = [];
|
||||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||||
if (\in_array($key, $removedKeys, \true)) {
|
if (\in_array($key, $removedKeys, \true)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$genericTagValueNode = $phpDocChildNode->value;
|
$genericTagValueNode = $phpDocChildNode->value;
|
||||||
|
@ -95,21 +95,21 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$nextPhpDocChildNode = $phpDocNode->children[$key];
|
$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?
|
// @todo how to detect previously opened brackets?
|
||||||
// probably local property with holding count of opened brackets
|
// probably local property with holding count of opened brackets
|
||||||
$composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->text;
|
$composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->text;
|
||||||
$genericTagValueNode->value = $composedContent;
|
$genericTagValueNode->value = $composedContent;
|
||||||
$startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode);
|
$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;
|
||||||
$removedKeys[] = $key + 1;
|
$removedKeys[] = $key + 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$nextPhpDocChildNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$nextPhpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
if (!$nextPhpDocChildNode->value instanceof GenericTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($this->isClosedContent($genericTagValueNode->value)) {
|
if ($this->isClosedContent($genericTagValueNode->value)) {
|
||||||
|
@ -119,13 +119,13 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
// cleanup the next from closing
|
// cleanup the next from closing
|
||||||
$genericTagValueNode->value = $composedContent;
|
$genericTagValueNode->value = $composedContent;
|
||||||
$startAndEnd = $this->combineStartAndEnd($phpDocChildNode, $nextPhpDocChildNode);
|
$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];
|
$currentChildValueNode = $phpDocNode->children[$key];
|
||||||
if (!$currentChildValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$currentChildValueNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$currentGenericTagValueNode = $currentChildValueNode->value;
|
$currentGenericTagValueNode = $currentChildValueNode->value;
|
||||||
if (!$currentGenericTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
if (!$currentGenericTagValueNode instanceof GenericTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$removedKeys[] = $key;
|
$removedKeys[] = $key;
|
||||||
|
@ -138,22 +138,22 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
unset($phpDocNode->children[$key]);
|
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) {
|
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||||
// the @\FQN use case
|
// the @\FQN use case
|
||||||
if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) {
|
if ($phpDocChildNode instanceof PhpDocTextNode) {
|
||||||
$spacelessPhpDocTagNode = $this->resolveFqnAnnotationSpacelessPhpDocTagNode($phpDocChildNode);
|
$spacelessPhpDocTagNode = $this->resolveFqnAnnotationSpacelessPhpDocTagNode($phpDocChildNode);
|
||||||
if (!$spacelessPhpDocTagNode instanceof \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode) {
|
if (!$spacelessPhpDocTagNode instanceof SpacelessPhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$phpDocNode->children[$key] = $spacelessPhpDocTagNode;
|
$phpDocNode->children[$key] = $spacelessPhpDocTagNode;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// known doc tag to annotation class
|
// known doc tag to annotation class
|
||||||
|
@ -181,51 +181,51 @@ final class DoctrineAnnotationDecorator implements \Rector\BetterPhpDocParser\Co
|
||||||
return \true;
|
return \true;
|
||||||
}
|
}
|
||||||
do {
|
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;
|
++$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;
|
++$closeBracketCount;
|
||||||
}
|
}
|
||||||
$composedTokenIterator->next();
|
$composedTokenIterator->next();
|
||||||
} while ($composedTokenIterator->currentPosition() < $tokenCount - 1);
|
} while ($composedTokenIterator->currentPosition() < $tokenCount - 1);
|
||||||
return $openBracketCount === $closeBracketCount;
|
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);
|
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);
|
$nestedTokenIterator = $this->tokenIteratorFactory->create($annotationContent);
|
||||||
// mimics doctrine behavior just in phpdoc-parser syntax :)
|
// mimics doctrine behavior just in phpdoc-parser syntax :)
|
||||||
// https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L742
|
// https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L742
|
||||||
$values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($nestedTokenIterator);
|
$values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($nestedTokenIterator);
|
||||||
$identifierTypeNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($tagName);
|
$identifierTypeNode = new IdentifierTypeNode($tagName);
|
||||||
$identifierTypeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::RESOLVED_CLASS, $fullyQualifiedAnnotationClass);
|
$identifierTypeNode->setAttribute(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 = new DoctrineAnnotationTagValueNode($identifierTypeNode, $annotationContent, $values, SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null);
|
||||||
$doctrineAnnotationTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
$doctrineAnnotationTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||||
return new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($tagName, $doctrineAnnotationTagValueNode);
|
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 */
|
/** @var StartAndEnd $currentStartAndEnd */
|
||||||
$currentStartAndEnd = $startPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
$currentStartAndEnd = $startPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
/** @var StartAndEnd $nextStartAndEnd */
|
/** @var StartAndEnd $nextStartAndEnd */
|
||||||
$nextStartAndEnd = $endPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
$nextStartAndEnd = $endPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||||
return new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd());
|
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;
|
$fullyQualifiedAnnotationClass = $match['class_name'] ?? null;
|
||||||
if ($fullyQualifiedAnnotationClass === null) {
|
if ($fullyQualifiedAnnotationClass === null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$annotationContent = $match['annotation_content'] ?? null;
|
$annotationContent = $match['annotation_content'] ?? null;
|
||||||
$tagName = '@\\' . $fullyQualifiedAnnotationClass;
|
$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);
|
return $this->createDoctrineSpacelessPhpDocTagNode($annotationContent, $tagName, $fullyQualifiedAnnotationClass, $formerStartEnd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer;
|
||||||
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
use Rector\PhpAttribute\NodeFactory\PhpAttributeGroupFactory;
|
||||||
use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper;
|
use Rector\PHPStanStaticTypeMapper\Utils\TypeUnwrapper;
|
||||||
use Rector\StaticTypeMapper\StaticTypeMapper;
|
use Rector\StaticTypeMapper\StaticTypeMapper;
|
||||||
use RectorPrefix20220607\ReturnTypeWillChange;
|
use ReturnTypeWillChange;
|
||||||
/**
|
/**
|
||||||
* @see https://wiki.php.net/rfc/internal_method_return_types#proposal
|
* @see https://wiki.php.net/rfc/internal_method_return_types#proposal
|
||||||
*/
|
*/
|
||||||
|
@ -79,7 +79,7 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
|
* @var \Rector\Php80\NodeAnalyzer\PhpAttributeAnalyzer
|
||||||
*/
|
*/
|
||||||
private $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->staticTypeMapper = $staticTypeMapper;
|
||||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||||
|
@ -102,11 +102,11 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
||||||
$this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type);
|
$this->phpDocTypeChanger->changeReturnType($phpDocInfo, $type);
|
||||||
$functionLike->returnType = null;
|
$functionLike->returnType = null;
|
||||||
if (!$functionLike instanceof \PhpParser\Node\Stmt\ClassMethod) {
|
if (!$functionLike instanceof ClassMethod) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [\PhpParser\Node\Stmt\Class_::class, \PhpParser\Node\Stmt\Interface_::class]);
|
$classLike = $this->betterNodeFinder->findParentByTypes($functionLike, [Class_::class, Interface_::class]);
|
||||||
if (!$classLike instanceof \PhpParser\Node\Stmt\ClassLike) {
|
if (!$classLike instanceof ClassLike) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!$this->isRequireReturnTypeWillChange(\get_class($type), $classLike, $functionLike)) {
|
if (!$this->isRequireReturnTypeWillChange(\get_class($type), $classLike, $functionLike)) {
|
||||||
|
@ -119,7 +119,7 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
* @param array<class-string<Type>> $requiredTypes
|
* @param array<class-string<Type>> $requiredTypes
|
||||||
* @param \PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Expr\ArrowFunction $functionLike
|
* @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) {
|
if ($param->type === null) {
|
||||||
return;
|
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
|
* @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) {
|
if ($param->type === null) {
|
||||||
return;
|
return;
|
||||||
|
@ -148,7 +148,7 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
* @return bool True if node was changed
|
* @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
|
* @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) {
|
if ($functionLike->returnType === null) {
|
||||||
return \false;
|
return \false;
|
||||||
|
@ -159,16 +159,16 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
$this->decorate($functionLike);
|
$this->decorate($functionLike);
|
||||||
return \true;
|
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)) {
|
if (!\array_key_exists($type, self::ADD_RETURN_TYPE_WILL_CHANGE)) {
|
||||||
return \false;
|
return \false;
|
||||||
}
|
}
|
||||||
$className = (string) $this->nodeNameResolver->getName($classLike);
|
$className = (string) $this->nodeNameResolver->getName($classLike);
|
||||||
$objectClass = new \PHPStan\Type\ObjectType($className);
|
$objectClass = new ObjectType($className);
|
||||||
$methodName = $this->nodeNameResolver->getName($classMethod);
|
$methodName = $this->nodeNameResolver->getName($classMethod);
|
||||||
foreach (self::ADD_RETURN_TYPE_WILL_CHANGE[$type] as $class => $methods) {
|
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()) {
|
if (!$objectClassConfig->isSuperTypeOf($objectClass)->yes()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,14 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
/**
|
/**
|
||||||
* @param \PhpParser\Node\ComplexType|\PhpParser\Node\Identifier|\PhpParser\Node\Name $typeNode
|
* @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);
|
$returnType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($typeNode);
|
||||||
// cover nullable union types
|
// cover nullable union types
|
||||||
if ($returnType instanceof \PHPStan\Type\UnionType) {
|
if ($returnType instanceof UnionType) {
|
||||||
$returnType = $this->typeUnwrapper->unwrapNullableType($returnType);
|
$returnType = $this->typeUnwrapper->unwrapNullableType($returnType);
|
||||||
}
|
}
|
||||||
if ($returnType instanceof \PHPStan\Type\ObjectType) {
|
if ($returnType instanceof ObjectType) {
|
||||||
return $returnType->equals($requireType);
|
return $returnType->equals($requireType);
|
||||||
}
|
}
|
||||||
return \get_class($returnType) === \get_class($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
|
* @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);
|
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
||||||
$paramName = $this->nodeNameResolver->getName($param);
|
$paramName = $this->nodeNameResolver->getName($param);
|
||||||
|
@ -210,7 +210,7 @@ final class PhpDocFromTypeDeclarationDecorator
|
||||||
/**
|
/**
|
||||||
* @param array<class-string<Type>> $requiredTypes
|
* @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);
|
return \in_array(\get_class($type), $requiredTypes, \true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ final class StaticDoctrineAnnotationParser
|
||||||
* @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
|
* @var \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser
|
||||||
*/
|
*/
|
||||||
private $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->plainValueParser = $plainValueParser;
|
||||||
$this->arrayParser = $arrayParser;
|
$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
|
* mimics: https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1024-L1041
|
||||||
* @return array<mixed, mixed>
|
* @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 [];
|
return [];
|
||||||
}
|
}
|
||||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES);
|
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES);
|
||||||
// empty ()
|
// empty ()
|
||||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return $this->resolveAnnotationValues($tokenIterator);
|
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
|
* @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
|
* @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
|
// skips dummy tokens like newlines
|
||||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||||
// no assign
|
// 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
|
// 1. plain value - mimics https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1234-L1282
|
||||||
return $this->parseValue($tokenIterator);
|
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
|
// 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303
|
||||||
/** @var int $key */
|
/** @var int $key */
|
||||||
$key = $this->parseValue($tokenIterator);
|
$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
|
// mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238
|
||||||
$value = $this->parseValue($tokenIterator);
|
$value = $this->parseValue($tokenIterator);
|
||||||
return [
|
return [
|
||||||
|
@ -75,7 +75,7 @@ final class StaticDoctrineAnnotationParser
|
||||||
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079
|
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079
|
||||||
* @return array<mixed>
|
* @return array<mixed>
|
||||||
*/
|
*/
|
||||||
private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
|
private function resolveAnnotationValues(BetterTokenIterator $tokenIterator) : array
|
||||||
{
|
{
|
||||||
$values = [];
|
$values = [];
|
||||||
$resolvedValue = $this->resolveAnnotationValue($tokenIterator);
|
$resolvedValue = $this->resolveAnnotationValue($tokenIterator);
|
||||||
|
@ -84,10 +84,10 @@ final class StaticDoctrineAnnotationParser
|
||||||
} else {
|
} else {
|
||||||
$values[] = $resolvedValue;
|
$values[] = $resolvedValue;
|
||||||
}
|
}
|
||||||
while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) {
|
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) {
|
||||||
$tokenIterator->next();
|
$tokenIterator->next();
|
||||||
// if is next item just closing brackets
|
// 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;
|
continue;
|
||||||
}
|
}
|
||||||
$nestedValues = $this->resolveAnnotationValue($tokenIterator);
|
$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
|
* @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);
|
$items = $this->arrayParser->parseCurlyArray($tokenIterator);
|
||||||
return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode($items);
|
return new CurlyListNode($items);
|
||||||
}
|
}
|
||||||
return $this->plainValueParser->parseValue($tokenIterator);
|
return $this->plainValueParser->parseValue($tokenIterator);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue