mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Updated Rector to commit a7db1ad94df4879885b9106773d2f8335cb40e49
a7db1ad94d
use scoper 0.15
This commit is contained in:
parent
32bd3e59d8
commit
363a910cf7
@ -18,29 +18,29 @@ use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
\gc_disable();
|
||||
\define('__RECTOR_RUNNING__', \true);
|
||||
// Require Composer autoload.php
|
||||
$autoloadIncluder = new \RectorPrefix20210510\AutoloadIncluder();
|
||||
$autoloadIncluder = new AutoloadIncluder();
|
||||
$autoloadIncluder->includeDependencyOrRepositoryVendorAutoloadIfExists();
|
||||
// load extracted PHPStan with its own preload.php
|
||||
$extractedPhpstanAutoload = __DIR__ . '/../vendor/phpstan/phpstan-extracted/vendor/autoload.php';
|
||||
if (\file_exists($extractedPhpstanAutoload)) {
|
||||
require_once $extractedPhpstanAutoload;
|
||||
} elseif (\RectorPrefix20210510\should_include_preload()) {
|
||||
} elseif (should_include_preload()) {
|
||||
require_once __DIR__ . '/../preload.php';
|
||||
}
|
||||
require_once __DIR__ . '/../src/constants.php';
|
||||
$autoloadIncluder->loadIfExistsAndNotLoadedYet(__DIR__ . '/../vendor/scoper-autoload.php');
|
||||
$autoloadIncluder->autoloadProjectAutoloaderFile();
|
||||
$autoloadIncluder->autoloadFromCommandLine();
|
||||
$symfonyStyleFactory = new \Rector\Core\Console\Style\SymfonyStyleFactory(new \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller());
|
||||
$symfonyStyleFactory = new SymfonyStyleFactory(new PrivatesCaller());
|
||||
$symfonyStyle = $symfonyStyleFactory->create();
|
||||
$rectorConfigsResolver = new \Rector\Core\Bootstrap\RectorConfigsResolver();
|
||||
$rectorConfigsResolver = new RectorConfigsResolver();
|
||||
try {
|
||||
$bootstrapConfigs = $rectorConfigsResolver->provide();
|
||||
$rectorContainerFactory = new \Rector\Core\DependencyInjection\RectorContainerFactory();
|
||||
$rectorContainerFactory = new RectorContainerFactory();
|
||||
$container = $rectorContainerFactory->createFromBootstrapConfigs($bootstrapConfigs);
|
||||
} catch (\Throwable $throwable) {
|
||||
$symfonyStyle->error($throwable->getMessage());
|
||||
exit(\RectorPrefix20210510\Symplify\PackageBuilder\Console\ShellCode::ERROR);
|
||||
exit(ShellCode::ERROR);
|
||||
}
|
||||
// preload local InstalledVersions.php - to fix incorrect version by same-named class in phpstan
|
||||
$currentlyInstalledVersions = __DIR__ . '/../../../../vendor/composer/InstalledVersions.php';
|
||||
@ -48,7 +48,7 @@ if (\file_exists($currentlyInstalledVersions)) {
|
||||
require_once $currentlyInstalledVersions;
|
||||
}
|
||||
/** @var ConsoleApplication $application */
|
||||
$application = $container->get(\Rector\Core\Console\ConsoleApplication::class);
|
||||
$application = $container->get(ConsoleApplication::class);
|
||||
exit($application->run());
|
||||
final class AutoloadIncluder
|
||||
{
|
||||
@ -59,7 +59,7 @@ final class AutoloadIncluder
|
||||
public function includeDependencyOrRepositoryVendorAutoloadIfExists() : void
|
||||
{
|
||||
// Rector's vendor is already loaded
|
||||
if (\class_exists(\Rector\Core\HttpKernel\RectorKernel::class)) {
|
||||
if (\class_exists(RectorKernel::class)) {
|
||||
return;
|
||||
}
|
||||
// in Rector develop repository
|
||||
|
@ -6,12 +6,12 @@ namespace RectorPrefix20210510;
|
||||
use Rector\Core\Bootstrap\ExtensionConfigResolver;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/services.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-rules.php');
|
||||
$containerConfigurator->import(__DIR__ . '/services-packages.php');
|
||||
$containerConfigurator->import(__DIR__ . '/parameters.php');
|
||||
$extensionConfigResolver = new \Rector\Core\Bootstrap\ExtensionConfigResolver();
|
||||
$extensionConfigResolver = new ExtensionConfigResolver();
|
||||
$extensionConfigFiles = $extensionConfigResolver->provide();
|
||||
foreach ($extensionConfigFiles as $extensionConfigFile) {
|
||||
$containerConfigurator->import($extensionConfigFile->getRealPath());
|
||||
@ -20,5 +20,5 @@ return static function (\RectorPrefix20210510\Symfony\Component\DependencyInject
|
||||
$containerConfigurator->import(__DIR__ . '/../utils/compiler/config/config.php', null, 'not_found');
|
||||
// to override extension-loaded config
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHPSTAN_FOR_RECTOR_PATH, \getcwd() . '/phpstan-for-rector.neon');
|
||||
$parameters->set(Option::PHPSTAN_FOR_RECTOR_PATH, \getcwd() . '/phpstan-for-rector.neon');
|
||||
};
|
||||
|
@ -6,23 +6,23 @@ namespace RectorPrefix20210510;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\ProjectType;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
// paths and extensions
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PATHS, []);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::FILE_EXTENSIONS, ['php']);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTOLOAD_PATHS, []);
|
||||
$parameters->set(Option::PATHS, []);
|
||||
$parameters->set(Option::FILE_EXTENSIONS, ['php']);
|
||||
$parameters->set(Option::AUTOLOAD_PATHS, []);
|
||||
// these files will be executed, useful e.g. for constant definitions
|
||||
$parameters->set(\Rector\Core\Configuration\Option::BOOTSTRAP_FILES, []);
|
||||
$parameters->set(Option::BOOTSTRAP_FILES, []);
|
||||
// FQN class importing
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_SHORT_CLASSES, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::IMPORT_DOC_BLOCKS, \true);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, null);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PROJECT_TYPE, \Rector\Core\ValueObject\ProjectType::PROPRIETARY);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::SKIP, []);
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, \false);
|
||||
$parameters->set(Option::IMPORT_SHORT_CLASSES, \true);
|
||||
$parameters->set(Option::IMPORT_DOC_BLOCKS, \true);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, null);
|
||||
$parameters->set(Option::PROJECT_TYPE, ProjectType::PROPRIETARY);
|
||||
$parameters->set(Option::NESTED_CHAIN_METHOD_CALL_LIMIT, 30);
|
||||
$parameters->set(Option::SKIP, []);
|
||||
// cache
|
||||
$parameters->set(\Rector\Core\Configuration\Option::ENABLE_CACHE, \false);
|
||||
$parameters->set(\Rector\Core\Configuration\Option::CACHE_DIR, \sys_get_temp_dir() . '/rector_cached_files');
|
||||
$parameters->set(Option::ENABLE_CACHE, \false);
|
||||
$parameters->set(Option::CACHE_DIR, \sys_get_temp_dir() . '/rector_cached_files');
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ declare (strict_types=1);
|
||||
namespace RectorPrefix20210510;
|
||||
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\', __DIR__ . '/../packages')->exclude([
|
||||
|
@ -7,12 +7,12 @@ use Rector\Core\Configuration\Option;
|
||||
use Rector\PSR4\Composer\PSR4NamespaceMatcher;
|
||||
use Rector\PSR4\Contract\PSR4AutoloadNamespaceMatcherInterface;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::TYPES_TO_REMOVE_STATIC_FROM, []);
|
||||
$parameters->set(Option::TYPES_TO_REMOVE_STATIC_FROM, []);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
// 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,Rector,Contract,Exception}']);
|
||||
};
|
||||
|
@ -54,55 +54,55 @@ use RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemGuard;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\Finder\FinderSanitizer;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\Json\JsonFileSystem;
|
||||
use RectorPrefix20210510\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->defaults()->public()->autowire()->autoconfigure();
|
||||
$services->load('Rector\\Core\\', __DIR__ . '/../src')->exclude([__DIR__ . '/../src/Rector', __DIR__ . '/../src/Exception', __DIR__ . '/../src/DependencyInjection/CompilerPass', __DIR__ . '/../src/DependencyInjection/Loader', __DIR__ . '/../src/HttpKernel', __DIR__ . '/../src/ValueObject', __DIR__ . '/../src/Bootstrap', __DIR__ . '/../src/PhpParser/Node/CustomNode', __DIR__ . '/../src/functions', __DIR__ . '/../src/constants.php']);
|
||||
$services->alias(\RectorPrefix20210510\Symfony\Component\Console\Application::class, \Rector\Core\Console\ConsoleApplication::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemGuard::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser::class);
|
||||
$services->set(\PhpParser\ParserFactory::class);
|
||||
$services->set(\PhpParser\BuilderFactory::class);
|
||||
$services->set(\PhpParser\NodeVisitor\CloningVisitor::class);
|
||||
$services->set(\PhpParser\NodeFinder::class);
|
||||
$services->set(\PhpParser\Parser::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(\PhpParser\Lexer::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Core\PhpParser\Parser\PhpParserLexerFactory::class), 'create']);
|
||||
$services->alias(SymfonyApplication::class, ConsoleApplication::class);
|
||||
$services->set(FileSystemGuard::class);
|
||||
$services->set(SimpleCallableNodeTraverser::class);
|
||||
$services->set(ParserFactory::class);
|
||||
$services->set(BuilderFactory::class);
|
||||
$services->set(CloningVisitor::class);
|
||||
$services->set(NodeFinder::class);
|
||||
$services->set(Parser::class)->factory([service(NikicPhpParserFactory::class), 'create']);
|
||||
$services->set(Lexer::class)->factory([service(PhpParserLexerFactory::class), 'create']);
|
||||
// symplify/package-builder
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\Finder\FinderSanitizer::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\FileSystemFilter::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Parameter\ParameterProvider::class)->arg('$container', \RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service('service_container'));
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Command\CommandNaming::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\SmartFileSystem::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Strings\StringFormatConverter::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class);
|
||||
$services->set(\RectorPrefix20210510\Symfony\Component\Console\Style\SymfonyStyle::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210510\Symplify\PackageBuilder\Console\Style\SymfonyStyleFactory::class), 'create']);
|
||||
$services->set(\RectorPrefix20210510\Symplify\SmartFileSystem\Json\JsonFileSystem::class);
|
||||
$services->set(\PhpParser\NodeVisitor\NodeConnectingVisitor::class);
|
||||
$services->set(\RectorPrefix20210510\Doctrine\Inflector\Rules\English\InflectorFactory::class);
|
||||
$services->set(\RectorPrefix20210510\Doctrine\Inflector\Inflector::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\RectorPrefix20210510\Doctrine\Inflector\Rules\English\InflectorFactory::class), 'build']);
|
||||
$services->set(\RectorPrefix20210510\Composer\Semver\VersionParser::class);
|
||||
$services->set(\RectorPrefix20210510\Symplify\PackageBuilder\Php\TypeChecker::class);
|
||||
$services->set(PrivatesAccessor::class);
|
||||
$services->set(PrivatesCaller::class);
|
||||
$services->set(FinderSanitizer::class);
|
||||
$services->set(FileSystemFilter::class);
|
||||
$services->set(ParameterProvider::class)->arg('$container', service('service_container'));
|
||||
$services->set(CommandNaming::class);
|
||||
$services->set(SmartFileSystem::class);
|
||||
$services->set(StringFormatConverter::class);
|
||||
$services->set(SymfonyStyleFactory::class);
|
||||
$services->set(SymfonyStyle::class)->factory([service(SymfonyStyleFactory::class), 'create']);
|
||||
$services->set(JsonFileSystem::class);
|
||||
$services->set(NodeConnectingVisitor::class);
|
||||
$services->set(InflectorFactory::class);
|
||||
$services->set(Inflector::class)->factory([service(InflectorFactory::class), 'build']);
|
||||
$services->set(VersionParser::class);
|
||||
$services->set(TypeChecker::class);
|
||||
// phpdoc parser
|
||||
$services->set(\PHPStan\PhpDocParser\Lexer\Lexer::class);
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\PhpDocParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterPhpDocParser::class);
|
||||
$services->alias(PhpDocParser::class, BetterPhpDocParser::class);
|
||||
// cache
|
||||
$services->set(\PHPStan\Dependency\DependencyResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDependencyResolver']);
|
||||
$services->set(\PHPStan\File\FileHelper::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createFileHelper']);
|
||||
$services->set(\RectorPrefix20210510\Nette\Caching\Cache::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\Caching\Cache\NetteCacheFactory::class), 'create']);
|
||||
$services->set(DependencyResolver::class)->factory([service(PHPStanServicesFactory::class), 'createDependencyResolver']);
|
||||
$services->set(FileHelper::class)->factory([service(PHPStanServicesFactory::class), 'createFileHelper']);
|
||||
$services->set(Cache::class)->factory([service(NetteCacheFactory::class), 'create']);
|
||||
// type resolving
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocator\IntermediateSourceLocator::class);
|
||||
$services->alias(\PHPStan\PhpDocParser\Parser\TypeParser::class, \Rector\BetterPhpDocParser\PhpDocParser\BetterTypeParser::class);
|
||||
$services->set(IntermediateSourceLocator::class);
|
||||
$services->alias(TypeParser::class, BetterTypeParser::class);
|
||||
// PHPStan services
|
||||
$services->set(\PHPStan\Reflection\ReflectionProvider::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createReflectionProvider']);
|
||||
$services->set(\PHPStan\Analyser\NodeScopeResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
||||
$services->set(\PHPStan\Analyser\ScopeFactory::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createScopeFactory']);
|
||||
$services->set(\PHPStan\PhpDoc\TypeNodeResolver::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
||||
$services->set(\Rector\NodeTypeResolver\Reflection\BetterReflection\SourceLocatorProvider\DynamicSourceLocatorProvider::class)->factory([\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\service(\Rector\NodeTypeResolver\DependencyInjection\PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||
$services->set(\RectorPrefix20210510\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->alias(\RectorPrefix20210510\Ergebnis\Json\Printer\PrinterInterface::class, \RectorPrefix20210510\Ergebnis\Json\Printer\Printer::class);
|
||||
$services->set(\RectorPrefix20210510\PrettyXml\Formatter::class);
|
||||
$services->set(\RectorPrefix20210510\Idiosyncratic\EditorConfig\EditorConfig::class);
|
||||
$services->alias(\Rector\FileFormatter\Contract\EditorConfig\EditorConfigParserInterface::class, \Rector\FileFormatter\EditorConfig\EditorConfigIdiosyncraticParser::class);
|
||||
$services->set(ReflectionProvider::class)->factory([service(PHPStanServicesFactory::class), 'createReflectionProvider']);
|
||||
$services->set(NodeScopeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createNodeScopeResolver']);
|
||||
$services->set(ScopeFactory::class)->factory([service(PHPStanServicesFactory::class), 'createScopeFactory']);
|
||||
$services->set(TypeNodeResolver::class)->factory([service(PHPStanServicesFactory::class), 'createTypeNodeResolver']);
|
||||
$services->set(DynamicSourceLocatorProvider::class)->factory([service(PHPStanServicesFactory::class), 'createDynamicSourceLocatorProvider']);
|
||||
$services->set(Printer::class);
|
||||
$services->alias(PrinterInterface::class, Printer::class);
|
||||
$services->set(Formatter::class);
|
||||
$services->set(EditorConfig::class);
|
||||
$services->alias(EditorConfigParserInterface::class, EditorConfigIdiosyncraticParser::class);
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ namespace RectorPrefix20210510;
|
||||
use Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector;
|
||||
use Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DependencyInjection\Rector\Class_\ActionInjectionToConstructorInjectionRector::class);
|
||||
$services->set(\Rector\DependencyInjection\Rector\Variable\ReplaceVariableByPropertyFetchRector::class);
|
||||
$services->set(ActionInjectionToConstructorInjectionRector::class);
|
||||
$services->set(ReplaceVariableByPropertyFetchRector::class);
|
||||
};
|
||||
|
@ -7,8 +7,8 @@ use Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector
|
||||
use Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# source: https://carbon.nesbot.com/docs/#api-carbon-2
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeDiffForHumansArgsRector::class);
|
||||
$services->set(\Rector\Carbon\Rector\MethodCall\ChangeCarbonSingularMethodCallToPluralRector::class);
|
||||
$services->set(ChangeDiffForHumansArgsRector::class);
|
||||
$services->set(ChangeCarbonSingularMethodCallToPluralRector::class);
|
||||
};
|
||||
|
@ -9,11 +9,11 @@ use Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenc
|
||||
use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\If_\MoveOutMethodCallInsideIfConditionRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(\Rector\CodeQualityStrict\Rector\Variable\MoveVariableDeclarationNearReferenceRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
$services->set(MoveOutMethodCallInsideIfConditionRector::class);
|
||||
$services->set(CountArrayToEmptyArrayComparisonRector::class);
|
||||
$services->set(MoveVariableDeclarationNearReferenceRector::class);
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(FlipTypeControlToUseExclusiveTypeRector::class);
|
||||
};
|
||||
|
@ -76,65 +76,65 @@ use Rector\Php52\Rector\Property\VarToPublicPropertyRector;
|
||||
use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\CombinedAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachToInArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\InArrayAndArrayKeysToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyFuncGetArgsCountRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyInArrayValuesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\GetClassToInstanceOfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyArraySearchRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNotNullReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyTautologyTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\SimplifyForeachToArrayFilterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SingleInArrayToCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Concat\JoinStringConcatRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfIssetToNullCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\CombineIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Equal\UseIdenticalOverEqualWithSameTypeRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SimplifyDuplicatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\BooleanNotIdenticalToNotIdenticalRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\AndAssignsToSeparateLinesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForToForeachRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CompactToVariablesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IsAWithStringWithThirdArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Identical\StrlenZeroToIdenticalEmptyStringRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FunctionLike\RemoveAlwaysTrueConditionSetInConstructorRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Catch_\ThrowWithPreviousExceptionRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\RemoveSoleValueSprintfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\ShortenElseIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayMergeOfNonArraysToSimpleArrayRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\IntvalToTypeCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\ArrayKeyExistsTernaryThenValueToCoalescingRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Include_\AbsolutizeRequireAndIncludePathRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\For_\ForRepeatedCountToOwnVariableRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\ForeachItemsAssignToEmptyArrayToAssignRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\ArrayKeysAndInArrayToArrayKeyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Assign\SplitListAssignToSeparateLineRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\NotEqual\CommonNotEqualRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
$services->set(CombinedAssignRector::class);
|
||||
$services->set(SimplifyEmptyArrayCheckRector::class);
|
||||
$services->set(ForeachToInArrayRector::class);
|
||||
$services->set(SimplifyForeachToCoalescingRector::class);
|
||||
$services->set(InArrayAndArrayKeysToArrayKeyExistsRector::class);
|
||||
$services->set(SimplifyFuncGetArgsCountRector::class);
|
||||
$services->set(SimplifyInArrayValuesRector::class);
|
||||
$services->set(SimplifyStrposLowerRector::class);
|
||||
$services->set(GetClassToInstanceOfRector::class);
|
||||
$services->set(SimplifyArraySearchRector::class);
|
||||
$services->set(SimplifyConditionsRector::class);
|
||||
$services->set(SimplifyIfNotNullReturnRector::class);
|
||||
$services->set(SimplifyIfReturnBoolRector::class);
|
||||
$services->set(SimplifyUselessVariableRector::class);
|
||||
$services->set(UnnecessaryTernaryExpressionRector::class);
|
||||
$services->set(RemoveExtraParametersRector::class);
|
||||
$services->set(SimplifyDeMorganBinaryRector::class);
|
||||
$services->set(SimplifyTautologyTernaryRector::class);
|
||||
$services->set(SimplifyForeachToArrayFilterRector::class);
|
||||
$services->set(SingleInArrayToCompareRector::class);
|
||||
$services->set(SimplifyIfElseToTernaryRector::class);
|
||||
$services->set(JoinStringConcatRector::class);
|
||||
$services->set(ConsecutiveNullCompareReturnsToNullCoalesceQueueRector::class);
|
||||
$services->set(SimplifyIfIssetToNullCoalescingRector::class);
|
||||
$services->set(ExplicitBoolCompareRector::class);
|
||||
$services->set(CombineIfRector::class);
|
||||
$services->set(UseIdenticalOverEqualWithSameTypeRector::class);
|
||||
$services->set(SimplifyDuplicatedTernaryRector::class);
|
||||
$services->set(SimplifyBoolIdenticalTrueRector::class);
|
||||
$services->set(SimplifyRegexPatternRector::class);
|
||||
$services->set(BooleanNotIdenticalToNotIdenticalRector::class);
|
||||
$services->set(CallableThisArrayToAnonymousFunctionRector::class);
|
||||
$services->set(AndAssignsToSeparateLinesRector::class);
|
||||
$services->set(ForToForeachRector::class);
|
||||
$services->set(CompactToVariablesRector::class);
|
||||
$services->set(CompleteDynamicPropertiesRector::class);
|
||||
$services->set(IsAWithStringWithThirdArgumentRector::class);
|
||||
$services->set(StrlenZeroToIdenticalEmptyStringRector::class);
|
||||
$services->set(RemoveAlwaysTrueConditionSetInConstructorRector::class);
|
||||
$services->set(ThrowWithPreviousExceptionRector::class);
|
||||
$services->set(RemoveSoleValueSprintfRector::class);
|
||||
$services->set(ShortenElseIfRector::class);
|
||||
$services->set(AddPregQuoteDelimiterRector::class);
|
||||
$services->set(ArrayMergeOfNonArraysToSimpleArrayRector::class);
|
||||
$services->set(IntvalToTypeCastRector::class);
|
||||
$services->set(ArrayKeyExistsTernaryThenValueToCoalescingRector::class);
|
||||
$services->set(AbsolutizeRequireAndIncludePathRector::class);
|
||||
$services->set(ChangeArrayPushToArrayAssignRector::class);
|
||||
$services->set(ForRepeatedCountToOwnVariableRector::class);
|
||||
$services->set(ForeachItemsAssignToEmptyArrayToAssignRector::class);
|
||||
$services->set(InlineIfToExplicitIfRector::class);
|
||||
$services->set(ArrayKeysAndInArrayToArrayKeyExistsRector::class);
|
||||
$services->set(SplitListAssignToSeparateLineRector::class);
|
||||
$services->set(UnusedForeachValueToArrayKeysRector::class);
|
||||
$services->set(ArrayThisCallToThisMethodCallRector::class);
|
||||
$services->set(CommonNotEqualRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
'split' => 'explode',
|
||||
'join' => 'implode',
|
||||
'sizeof' => 'count',
|
||||
@ -159,19 +159,19 @@ return static function (\RectorPrefix20210510\Symfony\Component\DependencyInject
|
||||
'mbstrrpos' => 'mb_strrpos',
|
||||
'mbsubstr' => 'mb_substr',
|
||||
]]]);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\SetTypeToCastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Name\FixClassCaseSensitivityNameRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Isset_\IssetOnPropertyObjectToPropertyExistsRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\New_\NewStaticToNewSelfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\DateTimeToDateTimeInterfaceRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\UnwrapSprintfOneArgumentRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Ternary\SwitchNegatedTernaryRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Switch_\SingularSwitchToIfRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\If_\SimplifyIfNullableReturnRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\ClassMethod\NarrowUnionTypeDocRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncToMethodCallRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\FuncCall\CallUserFuncWithArrowFunctionToInlineRector::class);
|
||||
$services->set(SetTypeToCastRector::class);
|
||||
$services->set(LogicalToBooleanRector::class);
|
||||
$services->set(VarToPublicPropertyRector::class);
|
||||
$services->set(FixClassCaseSensitivityNameRector::class);
|
||||
$services->set(IssetOnPropertyObjectToPropertyExistsRector::class);
|
||||
$services->set(NewStaticToNewSelfRector::class);
|
||||
$services->set(DateTimeToDateTimeInterfaceRector::class);
|
||||
$services->set(UnwrapSprintfOneArgumentRector::class);
|
||||
$services->set(SwitchNegatedTernaryRector::class);
|
||||
$services->set(SingularSwitchToIfRector::class);
|
||||
$services->set(SimplifyIfNullableReturnRector::class);
|
||||
$services->set(NarrowUnionTypeDocRector::class);
|
||||
$services->set(FuncGetArgsToVariadicParamRector::class);
|
||||
$services->set(CallUserFuncToMethodCallRector::class);
|
||||
$services->set(CallUserFuncWithArrowFunctionToInlineRector::class);
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
};
|
||||
|
@ -35,37 +35,37 @@ use Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\PHPStormVarAnnotationRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\If_\NullableCompareToNullRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Switch_\BinarySwitchToIfElseRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Ternary\TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\RemoveUnusedAliasRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\String_\SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\ConsistentPregDelimiterRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Include_\FollowRequireByDirRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Plus\UseIncrementAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\SplitDoubleAssignRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassConst\VarConstantCommentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\NewlineBeforeNewAssignSetRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Assign\ManualJsonStringToJsonEncodeArrayRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Class_\AddArrayDefaultToArrayPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\Property\AddFalseDefaultToBoolPropertyRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\CallUserFuncArrayToVariadicRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\FuncCall\VersionCompareFuncCallToConstantRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\MethodCall\UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']]]);
|
||||
$services->set(\Rector\CodingStyle\Rector\Use_\SeparateMultiUseImportsRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\PostInc\PostIncDecToPreIncDecRector::class);
|
||||
$services->set(\Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector::class);
|
||||
$services->set(PHPStormVarAnnotationRector::class);
|
||||
$services->set(NullableCompareToNullRector::class);
|
||||
$services->set(BinarySwitchToIfElseRector::class);
|
||||
$services->set(ConsistentImplodeRector::class);
|
||||
$services->set(TernaryConditionVariableAssignmentRector::class);
|
||||
$services->set(RemoveUnusedAliasRector::class);
|
||||
$services->set(SymplifyQuoteEscapeRector::class);
|
||||
$services->set(SplitGroupedConstantsAndPropertiesRector::class);
|
||||
$services->set(SplitStringClassConstantToClassConstFetchRector::class);
|
||||
$services->set(StringClassNameToClassConstantRector::class);
|
||||
$services->set(ConsistentPregDelimiterRector::class);
|
||||
$services->set(FollowRequireByDirRector::class);
|
||||
$services->set(CatchExceptionNameMatchingTypeRector::class);
|
||||
$services->set(UseIncrementAssignRector::class);
|
||||
$services->set(SplitDoubleAssignRector::class);
|
||||
$services->set(VarConstantCommentRector::class);
|
||||
$services->set(EncapsedStringsToSprintfRector::class);
|
||||
$services->set(WrapEncapsedVariableInCurlyBracesRector::class);
|
||||
$services->set(NewlineBeforeNewAssignSetRector::class);
|
||||
$services->set(ManualJsonStringToJsonEncodeArrayRector::class);
|
||||
$services->set(AddArrayDefaultToArrayPropertyRector::class);
|
||||
$services->set(AddFalseDefaultToBoolPropertyRector::class);
|
||||
$services->set(MakeInheritedMethodVisibilitySameAsParentRector::class);
|
||||
$services->set(CallUserFuncArrayToVariadicRector::class);
|
||||
$services->set(VersionCompareFuncCallToConstantRector::class);
|
||||
$services->set(UseMessageVariableForSprintfInSymfonyStyleRector::class);
|
||||
$services->set(FuncCallToConstFetchRector::class)->call('configure', [[FuncCallToConstFetchRector::FUNCTIONS_TO_CONSTANTS => ['php_sapi_name' => 'PHP_SAPI', 'pi' => 'M_PI']]]);
|
||||
$services->set(SeparateMultiUseImportsRector::class);
|
||||
$services->set(RemoveDoubleUnderscoreInMethodNameRector::class);
|
||||
$services->set(PostIncDecToPreIncDecRector::class);
|
||||
$services->set(UnSpreadOperatorRector::class);
|
||||
};
|
||||
|
@ -48,51 +48,51 @@ use Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector;
|
||||
use Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector;
|
||||
use Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfPhpVersionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Cast\RecastingRemovalRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\RemoveDeadStmtRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Foreach_\RemoveUnusedForeachKeyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveEmptyClassMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Expression\SimplifyMirrorAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveOverriddenValuesRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveUnusedPrivatePropertyRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveCodeAfterReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDeadConstructorRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDeadReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadIfForeachForRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Concat\RemoveConcatAutocastRector::class);
|
||||
$services->set(\Rector\CodeQuality\Rector\Return_\SimplifyUselessVariableRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveDelegatingParentCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\BinaryOp\RemoveDuplicatedInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Switch_\RemoveDuplicatedCaseInSwitchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Property\RemoveSetterOnlyPropertyAndMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\PropertyProperty\RemoveNullPropertyInitializationRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Stmt\RemoveUnreachableStatementRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\SimplifyIfElseWithSameContentRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Ternary\TernaryToBooleanOrFalseToBooleanAndRector::class);
|
||||
$services->set(\Rector\PHPUnit\Rector\ClassMethod\RemoveEmptyTestMethodRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\TryCatch\RemoveDeadTryCatchRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\FunctionLike\RemoveDuplicatedIfReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveUnusedNonEmptyArrayBeforeForeachRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Assign\RemoveAssignOfVoidReturnFunctionRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Return_\RemoveDeadConditionAboveReturnRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedConstructorParamRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\If_\RemoveDeadInstanceOfRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\For_\RemoveDeadLoopRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodParameterRector::class);
|
||||
$services->set(UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(UnwrapFutureCompatibleIfPhpVersionRector::class);
|
||||
$services->set(RecastingRemovalRector::class);
|
||||
$services->set(RemoveDeadStmtRector::class);
|
||||
$services->set(RemoveDuplicatedArrayKeyRector::class);
|
||||
$services->set(RemoveUnusedForeachKeyRector::class);
|
||||
$services->set(RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(RemoveEmptyClassMethodRector::class);
|
||||
$services->set(RemoveDoubleAssignRector::class);
|
||||
$services->set(SimplifyMirrorAssignRector::class);
|
||||
$services->set(RemoveOverriddenValuesRector::class);
|
||||
$services->set(RemoveUnusedPrivatePropertyRector::class);
|
||||
$services->set(RemoveUnusedPrivateClassConstantRector::class);
|
||||
$services->set(RemoveUnusedPrivateMethodRector::class);
|
||||
$services->set(RemoveCodeAfterReturnRector::class);
|
||||
$services->set(RemoveDeadConstructorRector::class);
|
||||
$services->set(RemoveDeadReturnRector::class);
|
||||
$services->set(RemoveDeadIfForeachForRector::class);
|
||||
$services->set(RemoveAndTrueRector::class);
|
||||
$services->set(RemoveConcatAutocastRector::class);
|
||||
$services->set(SimplifyUselessVariableRector::class);
|
||||
$services->set(RemoveDelegatingParentCallRector::class);
|
||||
$services->set(RemoveDuplicatedInstanceOfRector::class);
|
||||
$services->set(RemoveDuplicatedCaseInSwitchRector::class);
|
||||
$services->set(RemoveSetterOnlyPropertyAndMethodCallRector::class);
|
||||
$services->set(RemoveNullPropertyInitializationRector::class);
|
||||
$services->set(RemoveUnreachableStatementRector::class);
|
||||
$services->set(SimplifyIfElseWithSameContentRector::class);
|
||||
$services->set(TernaryToBooleanOrFalseToBooleanAndRector::class);
|
||||
$services->set(RemoveEmptyTestMethodRector::class);
|
||||
$services->set(RemoveDeadTryCatchRector::class);
|
||||
$services->set(RemoveUnusedVariableAssignRector::class);
|
||||
$services->set(RemoveDuplicatedIfReturnRector::class);
|
||||
$services->set(RemoveUnusedNonEmptyArrayBeforeForeachRector::class);
|
||||
$services->set(RemoveAssignOfVoidReturnFunctionRector::class);
|
||||
$services->set(RemoveEmptyMethodCallRector::class);
|
||||
$services->set(RemoveDeadConditionAboveReturnRector::class);
|
||||
$services->set(RemoveUnusedConstructorParamRector::class);
|
||||
$services->set(RemoveDeadInstanceOfRector::class);
|
||||
$services->set(RemoveDeadLoopRector::class);
|
||||
$services->set(RemoveUnusedPrivateMethodParameterRector::class);
|
||||
// docblock
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessParamTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector::class);
|
||||
$services->set(\Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector::class);
|
||||
$services->set(RemoveUselessParamTagRector::class);
|
||||
$services->set(RemoveUselessReturnTagRector::class);
|
||||
$services->set(RemoveNonExistingVarAnnotationRector::class);
|
||||
};
|
||||
|
@ -14,16 +14,16 @@ use Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRect
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
// @see https://ocramius.github.io/blog/fluent-interfaces-are-evil/
|
||||
// @see https://www.yegor256.com/2018/03/13/fluent-interfaces.html
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
// variable/property
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnFluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$services->set(ReturnFluentChainMethodCallToNormalMethodCallRector::class);
|
||||
// new
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\NewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\ReturnNewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\ClassMethod\ReturnThisRemoveRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\Return_\DefluentReturnMethodCallRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\MethodCallOnSetterMethodCallToStandaloneAssignRector::class);
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\InArgFluentChainMethodCallToStandaloneMethodCallRector::class);
|
||||
$services->set(NewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(ReturnNewFluentChainMethodCallToNonFluentRector::class);
|
||||
$services->set(ReturnThisRemoveRector::class);
|
||||
$services->set(DefluentReturnMethodCallRector::class);
|
||||
$services->set(MethodCallOnSetterMethodCallToStandaloneAssignRector::class);
|
||||
$services->set(InArgFluentChainMethodCallToStandaloneMethodCallRector::class);
|
||||
};
|
||||
|
@ -7,9 +7,9 @@ use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_53);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_53);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp53\Rector\Dir\DirConstToFileConstRector::class);
|
||||
$services->set(DirConstToFileConstRector::class);
|
||||
};
|
||||
|
@ -15,17 +15,17 @@ use Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector;
|
||||
use Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector;
|
||||
use Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_56);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_56);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FunctionLike\DowngradeScalarTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Declare_\DowngradeStrictTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\New_\DowngradeAnonymousClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Coalesce\DowngradeNullCoalesceRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Spaceship\DowngradeSpaceshipRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\Expression\DowngradeDefineArrayConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\FuncCall\DowngradeSessionStartArrayOptionsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\GroupUse\SplitGroupedUseImportsRector::class);
|
||||
$services->set(\Rector\DowngradePhp70\Rector\String_\DowngradeGeneratedScalarTypesRector::class);
|
||||
$services->set(DowngradeScalarTypeDeclarationRector::class);
|
||||
$services->set(DowngradeStrictTypeDeclarationRector::class);
|
||||
$services->set(DowngradeAnonymousClassRector::class);
|
||||
$services->set(DowngradeNullCoalesceRector::class);
|
||||
$services->set(DowngradeSpaceshipRector::class);
|
||||
$services->set(DowngradeDefineArrayConstantRector::class);
|
||||
$services->set(DowngradeSessionStartArrayOptionsRector::class);
|
||||
$services->set(SplitGroupedUseImportsRector::class);
|
||||
$services->set(DowngradeGeneratedScalarTypesRector::class);
|
||||
};
|
||||
|
@ -15,17 +15,17 @@ use Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector;
|
||||
use Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector;
|
||||
use Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_70);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_70);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeNullableTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeVoidTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\ClassConst\DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\TryCatch\DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\Array_\SymmetricArrayDestructuringToListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\String_\DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\List_\DowngradeKeysInListRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FunctionLike\DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp71\Rector\FuncCall\DowngradeIsIterableRector::class);
|
||||
$services->set(DowngradeNullableTypeDeclarationRector::class);
|
||||
$services->set(DowngradeVoidTypeDeclarationRector::class);
|
||||
$services->set(DowngradeClassConstantVisibilityRector::class);
|
||||
$services->set(DowngradePipeToMultiCatchExceptionRector::class);
|
||||
$services->set(SymmetricArrayDestructuringToListRector::class);
|
||||
$services->set(DowngradeNegativeStringOffsetToStrlenRector::class);
|
||||
$services->set(DowngradeKeysInListRector::class);
|
||||
$services->set(DowngradeIterablePseudoTypeDeclarationRector::class);
|
||||
$services->set(DowngradeIsIterableRector::class);
|
||||
};
|
||||
|
@ -10,12 +10,12 @@ use Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRe
|
||||
use Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector;
|
||||
use Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_71);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_71);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FunctionLike\DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\Class_\DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(\Rector\DowngradePhp72\Rector\FuncCall\DowngradeStreamIsattyRector::class);
|
||||
$services->set(DowngradeObjectTypeDeclarationRector::class);
|
||||
$services->set(DowngradeParameterTypeWideningRector::class);
|
||||
$services->set(DowngradePregUnmatchedAsNullConstantRector::class);
|
||||
$services->set(DowngradeStreamIsattyRector::class);
|
||||
};
|
||||
|
@ -11,13 +11,13 @@ use Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector
|
||||
use Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector;
|
||||
use Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_72);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_72);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp73\Rector\String_\DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\List_\DowngradeListReferenceAssignmentRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\DowngradeArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\DowngradePhp73\Rector\FuncCall\SetCookieOptionsArrayToArgumentsRector::class);
|
||||
$services->set(DowngradeFlexibleHeredocSyntaxRector::class);
|
||||
$services->set(DowngradeListReferenceAssignmentRector::class);
|
||||
$services->set(DowngradeTrailingCommasInFunctionCallsRector::class);
|
||||
$services->set(DowngradeArrayKeyFirstLastRector::class);
|
||||
$services->set(SetCookieOptionsArrayToArgumentsRector::class);
|
||||
};
|
||||
|
@ -17,19 +17,19 @@ use Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRe
|
||||
use Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector;
|
||||
use Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_73);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_73);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Property\DowngradeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeCovariantReturnTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeContravariantArgumentTypeRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Coalesce\DowngradeNullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\LNumber\DowngradeNumericLiteralSeparatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeStripTagsCallWithArrayRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Array_\DowngradeArraySpreadRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\FuncCall\DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\Identical\DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(\Rector\DowngradePhp74\Rector\ClassMethod\DowngradeSelfTypeDeclarationRector::class);
|
||||
$services->set(DowngradeTypedPropertyRector::class);
|
||||
$services->set(ArrowFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(DowngradeCovariantReturnTypeRector::class);
|
||||
$services->set(DowngradeContravariantArgumentTypeRector::class);
|
||||
$services->set(DowngradeNullCoalescingOperatorRector::class);
|
||||
$services->set(DowngradeNumericLiteralSeparatorRector::class);
|
||||
$services->set(DowngradeStripTagsCallWithArrayRector::class);
|
||||
$services->set(DowngradeArraySpreadRector::class);
|
||||
$services->set(DowngradeArrayMergeCallWithoutArgumentsRector::class);
|
||||
$services->set(DowngradeFreadFwriteFalsyToNegationRector::class);
|
||||
$services->set(DowngradeSelfTypeDeclarationRector::class);
|
||||
};
|
||||
|
@ -16,18 +16,18 @@ use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRecto
|
||||
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
|
||||
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
|
||||
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_74);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeStaticTypeDeclarationRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Class_\DowngradePropertyPromotionRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Catch_\DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassConstFetch\DowngradeClassOnObjectToGetClassRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector::class);
|
||||
$services->set(\Rector\DowngradePhp80\Rector\ClassMethod\DowngradeTrailingCommasInParamUseRector::class);
|
||||
$services->set(DowngradeUnionTypeTypedPropertyRector::class);
|
||||
$services->set(DowngradeUnionTypeDeclarationRector::class);
|
||||
$services->set(DowngradeMixedTypeDeclarationRector::class);
|
||||
$services->set(DowngradeStaticTypeDeclarationRector::class);
|
||||
$services->set(DowngradePropertyPromotionRector::class);
|
||||
$services->set(DowngradeNonCapturingCatchesRector::class);
|
||||
$services->set(DowngradeMatchToSwitchRector::class);
|
||||
$services->set(DowngradeClassOnObjectToGetClassRector::class);
|
||||
$services->set(DowngradeNullsafeToTernaryOperatorRector::class);
|
||||
$services->set(DowngradeTrailingCommasInParamUseRector::class);
|
||||
};
|
||||
|
@ -15,17 +15,17 @@ use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector;
|
||||
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeNestedIfsToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryAndToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfReturnToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Foreach_\ReturnAfterToEarlyOnBreakRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector::class);
|
||||
$services->set(\Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector::class);
|
||||
$services->set(ChangeNestedForeachIfsToEarlyContinueRector::class);
|
||||
$services->set(ChangeAndIfToEarlyReturnRector::class);
|
||||
$services->set(ChangeIfElseValueAssignToEarlyReturnRector::class);
|
||||
$services->set(ChangeNestedIfsToEarlyReturnRector::class);
|
||||
$services->set(RemoveAlwaysElseRector::class);
|
||||
$services->set(ReturnBinaryAndToEarlyReturnRector::class);
|
||||
$services->set(ChangeOrIfReturnToEarlyReturnRector::class);
|
||||
$services->set(ChangeOrIfContinueToMultiContinueRector::class);
|
||||
$services->set(ReturnAfterToEarlyOnBreakRector::class);
|
||||
$services->set(PreparedValueToEarlyReturnRector::class);
|
||||
$services->set(ReturnBinaryOrToEarlyReturnRector::class);
|
||||
};
|
||||
|
@ -7,23 +7,23 @@ use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
// Rename is now move, specific for files.
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'rename', 'move'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'rename', 'move'),
|
||||
// No arbitrary abbreviations
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'createDir', 'createDirectory'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'createDir', 'createDirectory'),
|
||||
// Writes are now deterministic
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'update', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'updateStream', 'writeStream'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'put', 'write'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'putStream', 'writeStream'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'update', 'write'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'updateStream', 'writeStream'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'put', 'write'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'putStream', 'writeStream'),
|
||||
// Metadata getters are renamed
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getTimestamp', 'lastModified'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'has', 'fileExists'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getMimetype', 'mimeType'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getSize', 'fileSize'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('League\\Flysystem\\Filesystem', 'getVisibility', 'visibility'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'getTimestamp', 'lastModified'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'has', 'fileExists'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'getMimetype', 'mimeType'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'getSize', 'fileSize'),
|
||||
new MethodCallRename('League\\Flysystem\\Filesystem', 'getVisibility', 'visibility'),
|
||||
])]]);
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ namespace RectorPrefix20210510;
|
||||
use Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector;
|
||||
use Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\RemoveServiceFromSensioRouteRector::class);
|
||||
$services->set(ReplaceSensioRouteAnnotationWithSymfonyRector::class);
|
||||
$services->set(RemoveServiceFromSensioRouteRector::class);
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Symfony\Rector\ClassMethod\TemplateAnnotationToThisRenderRector::class);
|
||||
$services->set(TemplateAnnotationToThisRenderRector::class);
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,12 +12,12 @@ use Rector\Transform\ValueObject\FuncCallToMethodCall;
|
||||
use Rector\Transform\ValueObject\StaticCallToFuncCall;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# both uses "%classes_to_defluent%
|
||||
$services->set(\Rector\Defluent\Rector\MethodCall\FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$configuration = [new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new \Rector\Transform\ValueObject\FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
|
||||
$services->set(\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::class)->call('configure', [[\Rector\Transform\Rector\FuncCall\FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline($configuration)]]);
|
||||
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')])]]);
|
||||
$services->set(FluentChainMethodCallToNormalMethodCallRector::class);
|
||||
$configuration = [new FuncCallToMethodCall('GuzzleHttp\\json_decode', 'GuzzleHttp\\Utils', 'jsonDecode'), new FuncCallToMethodCall('GuzzleHttp\\get_path', 'GuzzleHttp\\Utils', 'getPath')];
|
||||
$services->set(FuncCallToMethodCallRector::class)->call('configure', [[FuncCallToMethodCallRector::FUNC_CALL_TO_CLASS_METHOD_CALL => ValueObjectInliner::inline($configuration)]]);
|
||||
$services->set(StaticCallToFuncCallRector::class)->call('configure', [[StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => ValueObjectInliner::inline([new StaticCallToFuncCall('GuzzleHttp\\Utils', 'setPath', 'GuzzleHttp\\set_path'), new StaticCallToFuncCall('GuzzleHttp\\Pool', 'batch', 'GuzzleHttp\\Pool\\batch')])]]);
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([new MethodCallRename('GuzzleHttp\\Message\\MessageInterface', 'getHeaderLines', 'getHeaderAsArray')])]]);
|
||||
};
|
||||
|
@ -12,10 +12,10 @@ use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
|
||||
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::class)->call('configure', [[\Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector::METHOD_VISIBILITIES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Visibility\ValueObject\ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', \Rector\Core\ValueObject\Visibility::STATIC)])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans'), new \Rector\Renaming\ValueObject\MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface', 'Kdyby\\Monolog\\Logger' => 'Psr\\Log\\LoggerInterface', 'Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Translation\\Translator' => 'Symfony\\Contracts\\Translation\\TranslatorInterface']]]);
|
||||
$services->set(\Rector\NetteToSymfony\Rector\MethodCall\WrapTransParameterNameRector::class);
|
||||
$services->set(ChangeMethodVisibilityRector::class)->call('configure', [[ChangeMethodVisibilityRector::METHOD_VISIBILITIES => ValueObjectInliner::inline([new ChangeMethodVisibility('Kdyby\\Events\\Subscriber', 'getSubscribedEvents', Visibility::STATIC)])]]);
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([new MethodCallRename('Kdyby\\Translation\\Translator', 'translate', 'trans'), new MethodCallRename('Kdyby\\RabbitMq\\IConsumer', 'process', 'execute')])]]);
|
||||
$services->set(RenameClassRector::class)->call('configure', [[RenameClassRector::OLD_TO_NEW_CLASSES => ['Kdyby\\RabbitMq\\IConsumer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ConsumerInterface', 'Kdyby\\RabbitMq\\IProducer' => 'OldSound\\RabbitMqBundle\\RabbitMq\\ProducerInterface', 'Kdyby\\Monolog\\Logger' => 'Psr\\Log\\LoggerInterface', 'Kdyby\\Events\\Subscriber' => 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface', 'Kdyby\\Translation\\Translator' => 'Symfony\\Contracts\\Translation\\TranslatorInterface']]]);
|
||||
$services->set(WrapTransParameterNameRector::class);
|
||||
};
|
||||
|
@ -22,17 +22,17 @@ use Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$parameters = $containerConfigurator->parameters();
|
||||
$parameters->set(\Rector\Core\Configuration\Option::AUTO_IMPORT_NAMES, \true);
|
||||
$parameters->set(Option::AUTO_IMPORT_NAMES, \true);
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Composer\Rector\ChangePackageVersionComposerRector::class)->call('configure', [[\Rector\Composer\Rector\ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Composer\ValueObject\PackageAndVersion('league/event', '^3.0')])]]);
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EventInterface', 'getName', 'eventName'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'emit', 'dispatch'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addListener', 'subscribeTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'addOneTimeListener', 'subscribeOneTo'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\EmitterInterface', 'useListenerProvider', 'subscribeListenersFrom'), new \Rector\Renaming\ValueObject\MethodCallRename('League\\Event\\ListenerInterface', 'handle', '__invoke')])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddParamTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', 0, new \PHPStan\Type\ObjectWithoutClassType())])]]);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\EventInterface', 'eventName', new \PHPStan\Type\StringType()), new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', new \PHPStan\Type\VoidType())])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['League\\Event\\Emitter' => 'League\\Event\\EventDispatcher', 'League\\Event\\ListenerInterface' => 'League\\Event\\Listener', 'League\\Event\\GeneratorInterface' => 'League\\Event\\EventGenerator', 'League\\Event\\ListenerProviderInterface' => 'League\\Event\\ListenerSubscriber', 'League\\Event\\ListenerAcceptorInterface' => 'League\\Event\\ListenerRegistry']]]);
|
||||
$services->set(\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::class)->call('configure', [[\Rector\Transform\Rector\Class_\AddInterfaceByParentRector::INTERFACE_BY_PARENT => ['League\\Event\\Event' => 'League\\Event\\HasEventName', 'League\\Event\\AbstractListener' => 'League\\Event\\Listener']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['League\\Event\\EventInterface']]]);
|
||||
$services->set(\Rector\Removing\Rector\Class_\RemoveParentRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveParentRector::PARENT_TYPES_TO_REMOVE => ['League\\Event\\AbstractEvent', 'League\\Event\\Event', 'League\\Event\\AbstractListener']]]);
|
||||
$services->set(\Rector\LeagueEvent\Rector\MethodCall\DispatchStringToObjectRector::class);
|
||||
$services->set(ChangePackageVersionComposerRector::class)->call('configure', [[ChangePackageVersionComposerRector::PACKAGES_AND_VERSIONS => ValueObjectInliner::inline([new PackageAndVersion('league/event', '^3.0')])]]);
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([new MethodCallRename('League\\Event\\EventInterface', 'getName', 'eventName'), new MethodCallRename('League\\Event\\EmitterInterface', 'emit', 'dispatch'), new MethodCallRename('League\\Event\\EmitterInterface', 'addListener', 'subscribeTo'), new MethodCallRename('League\\Event\\EmitterInterface', 'addOneTimeListener', 'subscribeOneTo'), new MethodCallRename('League\\Event\\EmitterInterface', 'useListenerProvider', 'subscribeListenersFrom'), new MethodCallRename('League\\Event\\ListenerInterface', 'handle', '__invoke')])]]);
|
||||
$services->set(AddParamTypeDeclarationRector::class)->call('configure', [[AddParamTypeDeclarationRector::PARAMETER_TYPEHINTS => ValueObjectInliner::inline([new AddParamTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', 0, new ObjectWithoutClassType())])]]);
|
||||
$services->set(AddReturnTypeDeclarationRector::class)->call('configure', [[AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([new AddReturnTypeDeclaration('League\\Event\\EventInterface', 'eventName', new StringType()), new AddReturnTypeDeclaration('League\\Event\\ListenerInterface', '__invoke', new VoidType())])]]);
|
||||
$services->set(RenameClassRector::class)->call('configure', [[RenameClassRector::OLD_TO_NEW_CLASSES => ['League\\Event\\Emitter' => 'League\\Event\\EventDispatcher', 'League\\Event\\ListenerInterface' => 'League\\Event\\Listener', 'League\\Event\\GeneratorInterface' => 'League\\Event\\EventGenerator', 'League\\Event\\ListenerProviderInterface' => 'League\\Event\\ListenerSubscriber', 'League\\Event\\ListenerAcceptorInterface' => 'League\\Event\\ListenerRegistry']]]);
|
||||
$services->set(AddInterfaceByParentRector::class)->call('configure', [[AddInterfaceByParentRector::INTERFACE_BY_PARENT => ['League\\Event\\Event' => 'League\\Event\\HasEventName', 'League\\Event\\AbstractListener' => 'League\\Event\\Listener']]]);
|
||||
$services->set(RemoveInterfacesRector::class)->call('configure', [[RemoveInterfacesRector::INTERFACES_TO_REMOVE => ['League\\Event\\EventInterface']]]);
|
||||
$services->set(RemoveParentRector::class)->call('configure', [[RemoveParentRector::PARENT_TYPES_TO_REMOVE => ['League\\Event\\AbstractEvent', 'League\\Event\\Event', 'League\\Event\\AbstractListener']]]);
|
||||
$services->set(DispatchStringToObjectRector::class);
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
# https://github.com/Seldaek/monolog/commit/39f8a20e6dadc0194e846b254c5f23d1c732290b#diff-dce565f403e044caa5e6a0d988339430
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([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')])]]);
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([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')])]]);
|
||||
};
|
||||
|
@ -15,19 +15,19 @@ use Rector\Renaming\Rector\ConstFetch\RenameConstantRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# https://stackoverflow.com/a/1390625/1348344
|
||||
# https://github.com/philip/MySQLConverterTool/blob/master/Converter.php
|
||||
# https://www.phpclasses.org/blog/package/9199/post/3-Smoothly-Migrate-your-PHP-Code-using-the-Old-MySQL-extension-to-MySQLi.html
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\Assign\MysqlAssignToMysqliRector::class);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlFuncCallToMysqliRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_pconnect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 3), new \Rector\Removing\ValueObject\RemoveFuncCallArg('mysql_connect', 4)])]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlPConnectToMysqliConnectRector::class);
|
||||
$services->set(MysqlAssignToMysqliRector::class);
|
||||
$services->set(MysqlFuncCallToMysqliRector::class);
|
||||
$services->set(RemoveFuncCallArgRector::class)->call('configure', [[RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([new RemoveFuncCallArg('mysql_pconnect', 3), new RemoveFuncCallArg('mysql_connect', 3), new RemoveFuncCallArg('mysql_connect', 4)])]]);
|
||||
$services->set(MysqlPConnectToMysqliConnectRector::class);
|
||||
# first swap arguments, then rename
|
||||
$services->set(\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::class)->call('configure', [[\Rector\Arguments\Rector\FuncCall\SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([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])])]]);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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']]]);
|
||||
$services->set(SwapFuncCallArgumentsRector::class)->call('configure', [[SwapFuncCallArgumentsRector::FUNCTION_ARGUMENT_SWAPS => ValueObjectInliner::inline([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])])]]);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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
|
||||
$services->set(\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::class)->call('configure', [[\Rector\Renaming\Rector\ConstFetch\RenameConstantRector::OLD_TO_NEW_CONSTANTS => ['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']]]);
|
||||
$services->set(\Rector\MysqlToMysqli\Rector\FuncCall\MysqlQueryMysqlErrorWithLinkRector::class);
|
||||
$services->set(RenameConstantRector::class)->call('configure', [[RenameConstantRector::OLD_TO_NEW_CONSTANTS => ['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']]]);
|
||||
$services->set(MysqlQueryMysqlErrorWithLinkRector::class);
|
||||
};
|
||||
|
@ -13,15 +13,15 @@ use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableR
|
||||
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector;
|
||||
use Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Class_\RenamePropertyToMatchTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\RenameVariableToMatchNewTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeGetterClassMethodNameStartWithGetRector::class);
|
||||
$services->set(\Rector\Naming\Rector\ClassMethod\MakeIsserClassMethodNameStartWithIsRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Property\MakeBoolPropertyRespectIsHasWasMethodNamingRector::class);
|
||||
$services->set(\Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||
$services->set(RenameParamToMatchTypeRector::class);
|
||||
$services->set(RenamePropertyToMatchTypeRector::class);
|
||||
$services->set(RenameVariableToMatchNewTypeRector::class);
|
||||
$services->set(RenameVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(MakeGetterClassMethodNameStartWithGetRector::class);
|
||||
$services->set(MakeIsserClassMethodNameStartWithIsRector::class);
|
||||
$services->set(RenameForeachValueVariableToMatchMethodCallReturnTypeRector::class);
|
||||
$services->set(MakeBoolPropertyRespectIsHasWasMethodNamingRector::class);
|
||||
$services->set(RenameForeachValueVariableToMatchExprVariableRector::class);
|
||||
};
|
||||
|
@ -9,11 +9,11 @@ use Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector;
|
||||
use Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector;
|
||||
use Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPrivateMethodsByUseRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderClassConstantsByIntegerValueRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderMethodsByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderPropertiesByVisibilityRector::class);
|
||||
$services->set(\Rector\Order\Rector\Class_\OrderConstantsByVisibilityRector::class);
|
||||
$services->set(OrderPrivateMethodsByUseRector::class);
|
||||
$services->set(OrderClassConstantsByIntegerValueRector::class);
|
||||
$services->set(OrderMethodsByVisibilityRector::class);
|
||||
$services->set(OrderPropertiesByVisibilityRector::class);
|
||||
$services->set(OrderConstantsByVisibilityRector::class);
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -9,12 +9,12 @@ use Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector;
|
||||
use Rector\Removing\ValueObject\RemoveFuncCallArg;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php52\Rector\Property\VarToPublicPropertyRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
$services->set(\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::class)->call('configure', [[\Rector\Removing\Rector\FuncCall\RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
$services->set(VarToPublicPropertyRector::class);
|
||||
$services->set(ContinueToBreakInSwitchRector::class);
|
||||
$services->set(RemoveFuncCallArgRector::class)->call('configure', [[RemoveFuncCallArgRector::REMOVED_FUNCTION_ARGUMENTS => ValueObjectInliner::inline([
|
||||
// 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),
|
||||
])]]);
|
||||
};
|
||||
|
@ -8,10 +8,10 @@ use Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector;
|
||||
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
|
||||
use Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php53\Rector\Ternary\TernaryToElvisRector::class);
|
||||
$services->set(\Rector\Php53\Rector\FuncCall\DirNameFileConstantToDirConstantRector::class);
|
||||
$services->set(\Rector\Php53\Rector\AssignRef\ClearReturnNewByReferenceRector::class);
|
||||
$services->set(\Rector\Php53\Rector\Variable\ReplaceHttpServerVarsByServerRector::class);
|
||||
$services->set(TernaryToElvisRector::class);
|
||||
$services->set(DirNameFileConstantToDirConstantRector::class);
|
||||
$services->set(ClearReturnNewByReferenceRector::class);
|
||||
$services->set(ReplaceHttpServerVarsByServerRector::class);
|
||||
};
|
||||
|
@ -7,9 +7,9 @@ use Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector;
|
||||
use Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysqli_param_count' => 'mysqli_stmt_param_count']]]);
|
||||
$services->set(\Rector\Php54\Rector\FuncCall\RemoveReferenceFromCallRector::class);
|
||||
$services->set(\Rector\Php54\Rector\Break_\RemoveZeroBreakContinueRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['mysqli_param_count' => 'mysqli_stmt_param_count']]]);
|
||||
$services->set(RemoveReferenceFromCallRector::class);
|
||||
$services->set(RemoveZeroBreakContinueRector::class);
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ namespace RectorPrefix20210510;
|
||||
use Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector;
|
||||
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php55\Rector\String_\StringClassNameToClassConstantRector::class);
|
||||
$services->set(\Rector\Php55\Rector\Class_\ClassConstantToSelfClassRector::class);
|
||||
$services->set(StringClassNameToClassConstantRector::class);
|
||||
$services->set(ClassConstantToSelfClassRector::class);
|
||||
};
|
||||
|
@ -7,10 +7,10 @@ use Rector\Php56\Rector\FuncCall\PowToExpRector;
|
||||
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php56\Rector\FuncCall\PowToExpRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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']]]);
|
||||
$services->set(PowToExpRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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
|
||||
$services->set(\Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector::class);
|
||||
$services->set(AddDefaultValueForUndefinedVariableRector::class);
|
||||
};
|
||||
|
@ -23,27 +23,27 @@ use Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector;
|
||||
use Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector;
|
||||
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$containerConfigurator->import(__DIR__ . '/mysql-to-mysqli.php');
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php70\Rector\ClassMethod\Php4ConstructorRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToNullCoalescingRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RandomFunctionRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\MultiDirnameRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSplitStringRector::class);
|
||||
$services->set(\Rector\Php70\Rector\List_\EmptyListRector::class);
|
||||
$services->set(Php4ConstructorRector::class);
|
||||
$services->set(TernaryToNullCoalescingRector::class);
|
||||
$services->set(RandomFunctionRector::class);
|
||||
$services->set(ExceptionHandlerTypehintRector::class);
|
||||
$services->set(MultiDirnameRector::class);
|
||||
$services->set(ListSplitStringRector::class);
|
||||
$services->set(EmptyListRector::class);
|
||||
# be careful, run this just once, since it can keep swapping order back and forth
|
||||
$services->set(\Rector\Php70\Rector\Assign\ListSwapArrayOrderRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\CallUserMethodRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\EregToPregMatchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Switch_\ReduceMultipleDefaultSwitchRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Ternary\TernaryToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector::class);
|
||||
$services->set(\Rector\Php70\Rector\If_\IfToSpaceshipRector::class);
|
||||
$services->set(\Rector\Php70\Rector\StaticCall\StaticCallOnNonStaticToInstanceCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\MethodCall\ThisCallOnStaticMethodToStaticCallRector::class);
|
||||
$services->set(\Rector\Php70\Rector\Break_\BreakNotInLoopOrSwitchToReturnRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector::class);
|
||||
$services->set(\Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector::class);
|
||||
$services->set(ListSwapArrayOrderRector::class);
|
||||
$services->set(CallUserMethodRector::class);
|
||||
$services->set(EregToPregMatchRector::class);
|
||||
$services->set(ReduceMultipleDefaultSwitchRector::class);
|
||||
$services->set(TernaryToSpaceshipRector::class);
|
||||
$services->set(WrapVariableVariableNameInCurlyBracesRector::class);
|
||||
$services->set(IfToSpaceshipRector::class);
|
||||
$services->set(StaticCallOnNonStaticToInstanceCallRector::class);
|
||||
$services->set(ThisCallOnStaticMethodToStaticCallRector::class);
|
||||
$services->set(BreakNotInLoopOrSwitchToReturnRector::class);
|
||||
$services->set(RenameMktimeWithoutArgsToTimeRector::class);
|
||||
$services->set(NonVariableToVariableOnFunctionCallRector::class);
|
||||
};
|
||||
|
@ -11,13 +11,13 @@ use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
||||
use Rector\Php71\Rector\List_\ListToArrayDestructRector;
|
||||
use Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php71\Rector\BooleanOr\IsIterableRector::class);
|
||||
$services->set(\Rector\Php71\Rector\TryCatch\MultiExceptionCatchRector::class);
|
||||
$services->set(\Rector\Php71\Rector\Assign\AssignArrayToStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\CountOnNullRector::class);
|
||||
$services->set(\Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector::class);
|
||||
$services->set(\Rector\Php71\Rector\BinaryOp\BinaryOpBetweenNumberAndStringRector::class);
|
||||
$services->set(\Rector\Php71\Rector\List_\ListToArrayDestructRector::class);
|
||||
$services->set(IsIterableRector::class);
|
||||
$services->set(MultiExceptionCatchRector::class);
|
||||
$services->set(AssignArrayToStringRector::class);
|
||||
$services->set(CountOnNullRector::class);
|
||||
$services->set(RemoveExtraParametersRector::class);
|
||||
$services->set(BinaryOpBetweenNumberAndStringRector::class);
|
||||
$services->set(ListToArrayDestructRector::class);
|
||||
};
|
||||
|
@ -15,13 +15,13 @@ use Rector\Php72\Rector\Unset_\UnsetCastRector;
|
||||
use Rector\Php72\Rector\While_\WhileEachToForeachRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php72\Rector\While_\WhileEachToForeachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ListEachRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Assign\ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\Unset_\UnsetCastRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
$services->set(WhileEachToForeachRector::class);
|
||||
$services->set(ListEachRector::class);
|
||||
$services->set(ReplaceEachAssignmentWithKeyCurrentRector::class);
|
||||
$services->set(UnsetCastRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# and imagewbmp
|
||||
'jpeg2wbmp' => 'imagecreatefromjpeg',
|
||||
# or imagewbmp
|
||||
@ -32,10 +32,10 @@ return static function (\RectorPrefix20210510\Symfony\Component\DependencyInject
|
||||
'gmp_random' => 'gmp_random_bits',
|
||||
'read_exif_data' => 'exif_read_data',
|
||||
]]]);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\GetClassOnNullRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\IsObjectOnIncompleteClassRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\ParseStrWithResultArgumentRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringsAssertNakedRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(\Rector\Php72\Rector\FuncCall\StringifyDefineRector::class);
|
||||
$services->set(GetClassOnNullRector::class);
|
||||
$services->set(IsObjectOnIncompleteClassRector::class);
|
||||
$services->set(ParseStrWithResultArgumentRector::class);
|
||||
$services->set(StringsAssertNakedRector::class);
|
||||
$services->set(CreateFunctionToAnonymousFunctionRector::class);
|
||||
$services->set(StringifyDefineRector::class);
|
||||
};
|
||||
|
@ -14,14 +14,14 @@ use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
||||
use Rector\Php73\Rector\String_\SensitiveHereNowDocRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php73\Rector\BooleanOr\IsCountableRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\ArrayKeyFirstLastRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\SensitiveDefineRector::class);
|
||||
$services->set(\Rector\Php73\Rector\ConstFetch\SensitiveConstantNameRector::class);
|
||||
$services->set(\Rector\Php73\Rector\String_\SensitiveHereNowDocRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
$services->set(IsCountableRector::class);
|
||||
$services->set(ArrayKeyFirstLastRector::class);
|
||||
$services->set(SensitiveDefineRector::class);
|
||||
$services->set(SensitiveConstantNameRector::class);
|
||||
$services->set(SensitiveHereNowDocRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_3
|
||||
'image2wbmp' => 'imagewbmp',
|
||||
'mbregex_encoding' => 'mb_regex_encoding',
|
||||
@ -38,8 +38,8 @@ return static function (\RectorPrefix20210510\Symfony\Component\DependencyInject
|
||||
'mbereg_search_getregs' => 'mb_ereg_search_getregs',
|
||||
'mbereg_search_getpos' => 'mb_ereg_search_getpos',
|
||||
]]]);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector::class);
|
||||
$services->set(\Rector\Php73\Rector\FuncCall\RegexDashEscapeRector::class);
|
||||
$services->set(\Rector\Php52\Rector\Switch_\ContinueToBreakInSwitchRector::class);
|
||||
$services->set(StringifyStrNeedlesRector::class);
|
||||
$services->set(JsonThrowOnErrorRector::class);
|
||||
$services->set(RegexDashEscapeRector::class);
|
||||
$services->set(ContinueToBreakInSwitchRector::class);
|
||||
};
|
||||
|
@ -19,10 +19,10 @@ use Rector\Php74\Rector\Property\TypedPropertyRector;
|
||||
use Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php74\Rector\Property\TypedPropertyRector::class);
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
$services->set(TypedPropertyRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => [
|
||||
#the_real_type
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'is_real' => 'is_float',
|
||||
@ -30,17 +30,17 @@ return static function (\RectorPrefix20210510\Symfony\Component\DependencyInject
|
||||
# https://wiki.php.net/rfc/deprecations_php_7_4
|
||||
'apache_request_headers' => 'getallheaders',
|
||||
]]]);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArrayKeyExistsOnPropertyRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\FilterVarToAddSlashesRector::class);
|
||||
$services->set(\Rector\Php74\Rector\StaticCall\ExportToReflectionFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\GetCalledClassToStaticClassRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\MbStrrposEncodingArgumentPositionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Double\RealToFloatTypeCastRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Assign\NullCoalescingOperatorRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Function_\ReservedFnFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector::class);
|
||||
$services->set(\Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector::class);
|
||||
$services->set(\Rector\Php74\Rector\LNumber\AddLiteralSeparatorToNumberRector::class);
|
||||
$services->set(\Rector\Php74\Rector\MethodCall\ChangeReflectionTypeToStringToGetNameRector::class);
|
||||
$services->set(\Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||
$services->set(ArrayKeyExistsOnPropertyRector::class);
|
||||
$services->set(FilterVarToAddSlashesRector::class);
|
||||
$services->set(ExportToReflectionFunctionRector::class);
|
||||
$services->set(GetCalledClassToStaticClassRector::class);
|
||||
$services->set(MbStrrposEncodingArgumentPositionRector::class);
|
||||
$services->set(RealToFloatTypeCastRector::class);
|
||||
$services->set(NullCoalescingOperatorRector::class);
|
||||
$services->set(ReservedFnFunctionRector::class);
|
||||
$services->set(ClosureToArrowFunctionRector::class);
|
||||
$services->set(ArraySpreadInsteadOfArrayMergeRector::class);
|
||||
$services->set(AddLiteralSeparatorToNumberRector::class);
|
||||
$services->set(ChangeReflectionTypeToStringToGetNameRector::class);
|
||||
$services->set(RestoreDefaultNullToNullableTypePropertyRector::class);
|
||||
};
|
||||
|
@ -24,26 +24,26 @@ use Rector\Php80\Rector\Ternary\GetDebugTypeRector;
|
||||
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Php80\Rector\FunctionLike\UnionTypesRector::class);
|
||||
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
|
||||
$services->set(\Rector\Php80\Rector\FuncCall\TokenGetAllToObjectRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Catch_\RemoveUnusedVariableInCatchRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$services->set(\Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector::class);
|
||||
$services->set(UnionTypesRector::class);
|
||||
$services->set(StrContainsRector::class);
|
||||
$services->set(StrStartsWithRector::class);
|
||||
$services->set(StrEndsWithRector::class);
|
||||
$services->set(StringableForToStringRector::class);
|
||||
$services->set(AnnotationToAttributeRector::class);
|
||||
$services->set(ClassOnObjectRector::class);
|
||||
$services->set(GetDebugTypeRector::class);
|
||||
$services->set(TokenGetAllToObjectRector::class);
|
||||
$services->set(RemoveUnusedVariableInCatchRector::class);
|
||||
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
|
||||
$services->set(ChangeSwitchToMatchRector::class);
|
||||
// nette\utils and Strings::replace()
|
||||
$services->set(\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::class)->call('configure', [[\Rector\Arguments\Rector\ClassMethod\ArgumentAdderRector::ADDED_ARGUMENTS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Arguments\ValueObject\ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')])]]);
|
||||
$services->set(\Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\SetStateToStaticRector::class);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\FinalPrivateToPrivateVisibilityRector::class);
|
||||
$services->set(ArgumentAdderRector::class)->call('configure', [[ArgumentAdderRector::ADDED_ARGUMENTS => ValueObjectInliner::inline([new ArgumentAdder('Nette\\Utils\\Strings', 'replace', 2, 'replacement', '')])]]);
|
||||
$services->set(RemoveParentCallWithoutParentRector::class);
|
||||
$services->set(SetStateToStaticRector::class);
|
||||
$services->set(FinalPrivateToPrivateVisibilityRector::class);
|
||||
// @see https://php.watch/versions/8.0/pgsql-aliases-deprecated
|
||||
$services->set(\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::class)->call('configure', [[\Rector\Renaming\Rector\FuncCall\RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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']]]);
|
||||
$services->set(\Rector\Php80\Rector\ClassMethod\OptionalParametersAfterRequiredRector::class);
|
||||
$services->set(RenameFunctionRector::class)->call('configure', [[RenameFunctionRector::OLD_FUNCTION_TO_NEW_FUNCTION => ['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']]]);
|
||||
$services->set(OptionalParametersAfterRequiredRector::class);
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnNeverTypeRector::class);
|
||||
$services->set(ReturnNeverTypeRector::class);
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,16 +12,16 @@ use Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRect
|
||||
use Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
# see: https://gnugat.github.io/2015/09/23/phpunit-with-phpspec.html
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
# 1. first convert mocks
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecMocksToPHPUnitMocksRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\MethodCall\PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
$services->set(PhpSpecMocksToPHPUnitMocksRector::class);
|
||||
$services->set(PhpSpecPromisesToPHPUnitAssertRector::class);
|
||||
# 2. then methods
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\ClassMethod\PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
$services->set(PhpSpecMethodToPHPUnitMethodRector::class);
|
||||
# 3. then the class itself
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\PhpSpecClassToPHPUnitClassRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\AddMockPropertiesRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Variable\MockVariableToPropertyFetchRector::class);
|
||||
$services->set(\Rector\PhpSpecToPHPUnit\Rector\Class_\RenameSpecFileToTestFileRector::class);
|
||||
$services->set(PhpSpecClassToPHPUnitClassRector::class);
|
||||
$services->set(AddMockPropertiesRector::class);
|
||||
$services->set(MockVariableToPropertyFetchRector::class);
|
||||
$services->set(RenameSpecFileToTestFileRector::class);
|
||||
};
|
||||
|
@ -8,12 +8,12 @@ use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Renaming\Rector\MethodCall\RenameMethodRector::class)->call('configure', [[\Rector\Renaming\Rector\MethodCall\RenameMethodRector::METHOD_CALL_RENAMES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([
|
||||
$services->set(RenameMethodRector::class)->call('configure', [[RenameMethodRector::METHOD_CALL_RENAMES => ValueObjectInliner::inline([
|
||||
// @see http://www.phpspec.net/en/stable/manual/upgrading-to-phpspec-3.html
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'set', 'define'),
|
||||
new \Rector\Renaming\ValueObject\MethodCallRename('PhpSpec\\ServiceContainer', 'setShared', 'define'),
|
||||
new MethodCallRename('PhpSpec\\ServiceContainer', 'set', 'define'),
|
||||
new MethodCallRename('PhpSpec\\ServiceContainer', 'setShared', 'define'),
|
||||
])]]);
|
||||
$services->set(\Rector\Renaming\Rector\Name\RenameClassRector::class)->call('configure', [[\Rector\Renaming\Rector\Name\RenameClassRector::OLD_TO_NEW_CLASSES => ['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']]]);
|
||||
$services->set(RenameClassRector::class)->call('configure', [[RenameClassRector::OLD_TO_NEW_CLASSES => ['PhpSpec\\Console\\IO' => 'PhpSpec\\Console\\ConsoleIO', 'PhpSpec\\IO\\IOInterface' => 'PhpSpec\\IO\\IO', 'PhpSpec\\Locator\\ResourceInterface' => 'PhpSpec\\Locator\\Resource', 'PhpSpec\\Locator\\ResourceLocatorInterface' => 'PhpSpec\\Locator\\ResourceLocator', 'PhpSpec\\Formatter\\Presenter\\PresenterInterface' => 'PhpSpec\\Formatter\\Presenter\\Presenter', 'PhpSpec\\CodeGenerator\\Generator\\GeneratorInterface' => 'PhpSpec\\CodeGenerator\\Generator\\Generator', 'PhpSpec\\Extension\\ExtensionInterface' => 'PhpSpec\\Extension', 'Phpspec\\CodeAnalysis\\AccessInspectorInterface' => 'Phpspec\\CodeAnalysis\\AccessInspector', 'Phpspec\\Event\\EventInterface' => 'Phpspec\\Event\\PhpSpecEvent', 'PhpSpec\\Formatter\\Presenter\\Differ\\EngineInterface' => 'PhpSpec\\Formatter\\Presenter\\Differ\\DifferEngine', 'PhpSpec\\Matcher\\MatcherInterface' => 'PhpSpec\\Matcher\\Matcher', 'PhpSpec\\Matcher\\MatchersProviderInterface' => 'PhpSpec\\Matcher\\MatchersProvider', 'PhpSpec\\SpecificationInterface' => 'PhpSpec\\Specification', 'PhpSpec\\Runner\\Maintainer\\MaintainerInterface' => 'PhpSpec\\Runner\\Maintainer\\Maintainer']]]);
|
||||
};
|
||||
|
@ -9,8 +9,8 @@ use Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$arrayType = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \PHPStan\Type\MixedType());
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::class)->call('configure', [[\Rector\TypeDeclaration\Rector\ClassMethod\AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\TypeDeclaration\ValueObject\AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)])]]);
|
||||
$arrayType = new ArrayType(new MixedType(), new MixedType());
|
||||
$services->set(AddReturnTypeDeclarationRector::class)->call('configure', [[AddReturnTypeDeclarationRector::METHOD_RETURN_TYPES => ValueObjectInliner::inline([new AddReturnTypeDeclaration('PhpSpec\\ObjectBehavior', 'getMatchers', $arrayType)])]]);
|
||||
};
|
||||
|
@ -14,17 +14,17 @@ use Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueT
|
||||
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
|
||||
use Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\ChangeGlobalVariablesToPropertiesRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Class_\RepeatedLiteralToClassConstantRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\MethodCall\PrivatizeLocalGetterToPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeLocalPropertyToPrivatePropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector::class);
|
||||
$services->set(\Rector\Privatization\Rector\ClassMethod\PrivatizeFinalClassMethodRector::class);
|
||||
$services->set(FinalizeClassesWithoutChildrenRector::class);
|
||||
$services->set(ChangeGlobalVariablesToPropertiesRector::class);
|
||||
$services->set(ChangeReadOnlyPropertyWithDefaultValueToConstantRector::class);
|
||||
$services->set(ChangeReadOnlyVariableWithDefaultValueToConstantRector::class);
|
||||
$services->set(RepeatedLiteralToClassConstantRector::class);
|
||||
$services->set(PrivatizeLocalGetterToPropertyRector::class);
|
||||
$services->set(PrivatizeLocalPropertyToPrivatePropertyRector::class);
|
||||
$services->set(PrivatizeFinalClassPropertyRector::class);
|
||||
$services->set(PrivatizeFinalClassMethodRector::class);
|
||||
// buggy, requires more work
|
||||
// $services->set(ChangeLocalPropertyToVariableRector::class);
|
||||
};
|
||||
|
@ -6,8 +6,8 @@ namespace RectorPrefix20210510;
|
||||
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
||||
use Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||
$services->set(\Rector\PSR4\Rector\Namespace_\MultipleClassFileToPsr4ClassesRector::class);
|
||||
$services->set(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
||||
$services->set(MultipleClassFileToPsr4ClassesRector::class);
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -12,14 +12,14 @@ use Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector;
|
||||
use Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Param\ParamTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictTypedCallRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector::class);
|
||||
$services->set(AddClosureReturnTypeRector::class);
|
||||
$services->set(ReturnTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(TypedPropertyFromStrictConstructorRector::class);
|
||||
$services->set(ParamTypeFromStrictTypedPropertyRector::class);
|
||||
$services->set(ReturnTypeFromStrictTypedCallRector::class);
|
||||
$services->set(AddVoidReturnTypeWhereNoReturnRector::class);
|
||||
// $services->set(AddMethodCallBasedStrictParamTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromReturnNewRector::class);
|
||||
$services->set(ReturnTypeFromReturnNewRector::class);
|
||||
};
|
||||
|
@ -11,13 +11,13 @@ use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector;
|
||||
use Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\FunctionLike\ReturnTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Property\PropertyTypeDeclarationRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\Closure\AddClosureReturnTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayParamDocTypeRector::class);
|
||||
$services->set(\Rector\TypeDeclaration\Rector\ClassMethod\AddArrayReturnDocTypeRector::class);
|
||||
$services->set(ParamTypeDeclarationRector::class);
|
||||
$services->set(ReturnTypeDeclarationRector::class);
|
||||
$services->set(PropertyTypeDeclarationRector::class);
|
||||
$services->set(AddClosureReturnTypeRector::class);
|
||||
$services->set(AddArrayParamDocTypeRector::class);
|
||||
$services->set(AddArrayReturnDocTypeRector::class);
|
||||
// $services->set(AddParamTypeFromCallersRector::class);
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ namespace RectorPrefix20210510;
|
||||
|
||||
use Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector;
|
||||
use RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
|
||||
return static function (\RectorPrefix20210510\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
|
||||
return static function (ContainerConfigurator $containerConfigurator) : void {
|
||||
$services = $containerConfigurator->services();
|
||||
$services->set(\Rector\DeadCode\Rector\If_\UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
$services->set(UnwrapFutureCompatibleIfFunctionExistsRector::class);
|
||||
};
|
||||
|
@ -10,8 +10,8 @@ final class AttributeMirrorer
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private const ATTRIBUTES_TO_MIRROR = [\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, \Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE];
|
||||
public function mirror(\PHPStan\PhpDocParser\Ast\Node $oldNode, \PHPStan\PhpDocParser\Ast\Node $newNode) : void
|
||||
private const ATTRIBUTES_TO_MIRROR = [PhpDocAttributeKey::PARENT, PhpDocAttributeKey::START_AND_END, PhpDocAttributeKey::ORIG_NODE];
|
||||
public function mirror(Node $oldNode, Node $newNode) : void
|
||||
{
|
||||
foreach (self::ATTRIBUTES_TO_MIRROR as $attributeToMirror) {
|
||||
if (!$oldNode->hasAttribute($attributeToMirror)) {
|
||||
|
@ -13,14 +13,14 @@ final class CommentsMerger
|
||||
* @var SimpleCallableNodeTraverser
|
||||
*/
|
||||
private $simpleCallableNodeTraverser;
|
||||
public function __construct(\RectorPrefix20210510\Symplify\Astral\NodeTraverser\SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
public function __construct(SimpleCallableNodeTraverser $simpleCallableNodeTraverser)
|
||||
{
|
||||
$this->simpleCallableNodeTraverser = $simpleCallableNodeTraverser;
|
||||
}
|
||||
/**
|
||||
* @param Node[] $mergedNodes
|
||||
*/
|
||||
public function keepComments(\PhpParser\Node $newNode, array $mergedNodes) : void
|
||||
public function keepComments(Node $newNode, array $mergedNodes) : void
|
||||
{
|
||||
$comments = $newNode->getComments();
|
||||
foreach ($mergedNodes as $mergedNode) {
|
||||
@ -29,25 +29,25 @@ final class CommentsMerger
|
||||
if ($comments === []) {
|
||||
return;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
|
||||
// remove so comments "win"
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, null);
|
||||
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, null);
|
||||
}
|
||||
public function keepParent(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
public function keepParent(Node $newNode, Node $oldNode) : void
|
||||
{
|
||||
$parent = $oldNode->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);
|
||||
if (!$parent instanceof \PhpParser\Node) {
|
||||
$parent = $oldNode->getAttribute(AttributeKey::PARENT_NODE);
|
||||
if (!$parent instanceof Node) {
|
||||
return;
|
||||
}
|
||||
$phpDocInfo = $parent->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
$phpDocInfo = $parent->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
$comments = $parent->getComments();
|
||||
if ($phpDocInfo === null && $comments === []) {
|
||||
return;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, $comments);
|
||||
$newNode->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, $comments);
|
||||
}
|
||||
public function keepChildren(\PhpParser\Node $newNode, \PhpParser\Node $oldNode) : void
|
||||
public function keepChildren(Node $newNode, Node $oldNode) : void
|
||||
{
|
||||
$childrenComments = $this->collectChildrenComments($oldNode);
|
||||
if ($childrenComments === []) {
|
||||
@ -57,15 +57,15 @@ final class CommentsMerger
|
||||
foreach ($childrenComments as $childComment) {
|
||||
$commentContent .= $childComment->getText() . \PHP_EOL;
|
||||
}
|
||||
$newNode->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::COMMENTS, [new \PhpParser\Comment($commentContent)]);
|
||||
$newNode->setAttribute(AttributeKey::COMMENTS, [new Comment($commentContent)]);
|
||||
}
|
||||
/**
|
||||
* @return Comment[]
|
||||
*/
|
||||
private function collectChildrenComments(\PhpParser\Node $node) : array
|
||||
private function collectChildrenComments(Node $node) : array
|
||||
{
|
||||
$childrenComments = [];
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (\PhpParser\Node $node) use(&$childrenComments) : void {
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($node, function (Node $node) use(&$childrenComments) : void {
|
||||
$comments = $node->getComments();
|
||||
if ($comments !== []) {
|
||||
$childrenComments = \array_merge($childrenComments, $comments);
|
||||
|
@ -4,6 +4,6 @@ declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\Contract;
|
||||
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface;
|
||||
interface BasePhpDocNodeVisitorInterface extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\Contract\PhpDocNodeVisitorInterface
|
||||
interface BasePhpDocNodeVisitorInterface extends PhpDocNodeVisitorInterface
|
||||
{
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ final class CurrentTokenIteratorProvider
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
public function setBetterTokenIterator(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
|
||||
public function setBetterTokenIterator(BetterTokenIterator $betterTokenIterator) : void
|
||||
{
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
}
|
||||
public function provide() : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
public function provide() : BetterTokenIterator
|
||||
{
|
||||
return $this->betterTokenIterator;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\PhpDoc;
|
||||
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
|
||||
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
|
||||
final class DoctrineAnnotationTagValueNode extends AbstractValuesAwareNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
|
@ -8,7 +8,7 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
|
||||
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
|
||||
* between the @ORM\Entity and (someContent)
|
||||
*/
|
||||
final class SpacelessPhpDocTagNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
|
||||
final class SpacelessPhpDocTagNode extends PhpDocTagNode
|
||||
{
|
||||
public function __toString() : string
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ final class PhpDocInfo
|
||||
/**
|
||||
* @var array<class-string<PhpDocTagValueNode>, string>
|
||||
*/
|
||||
private const TAGS_TYPES_TO_NAMES = [\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class => '@return', \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class => '@param', \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class => '@var', \PHPStan\PhpDocParser\Ast\PhpDoc\MethodTagValueNode::class => '@method', \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class => '@property'];
|
||||
private const TAGS_TYPES_TO_NAMES = [ReturnTagValueNode::class => '@return', ParamTagValueNode::class => '@param', VarTagValueNode::class => '@var', MethodTagValueNode::class => '@method', PropertyTagValueNode::class => '@property'];
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
@ -79,12 +79,12 @@ final class PhpDocInfo
|
||||
* @var BetterTokenIterator
|
||||
*/
|
||||
private $betterTokenIterator;
|
||||
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)
|
||||
public function __construct(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, StaticTypeMapper $staticTypeMapper, \PhpParser\Node $node, AnnotationNaming $annotationNaming, CurrentNodeProvider $currentNodeProvider, RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->phpDocNode = $phpDocNode;
|
||||
$this->betterTokenIterator = $betterTokenIterator;
|
||||
$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->staticTypeMapper = $staticTypeMapper;
|
||||
@ -93,18 +93,18 @@ final class PhpDocInfo
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
public function addPhpDocTagNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : void
|
||||
public function addPhpDocTagNode(PhpDocChildNode $phpDocChildNode) : void
|
||||
{
|
||||
$this->phpDocNode->children[] = $phpDocChildNode;
|
||||
// to give node more space
|
||||
$this->makeMultiLined();
|
||||
$this->markAsChanged();
|
||||
}
|
||||
public function getPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
public function getPhpDocNode() : PhpDocNode
|
||||
{
|
||||
return $this->phpDocNode;
|
||||
}
|
||||
public function getOriginalPhpDocNode() : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
public function getOriginalPhpDocNode() : PhpDocNode
|
||||
{
|
||||
return $this->originalPhpDocNode;
|
||||
}
|
||||
@ -119,7 +119,7 @@ final class PhpDocInfo
|
||||
{
|
||||
return $this->betterTokenIterator->count();
|
||||
}
|
||||
public function getVarTagValueNode() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode
|
||||
public function getVarTagValueNode() : ?VarTagValueNode
|
||||
{
|
||||
return $this->phpDocNode->getVarTagValues()[0] ?? null;
|
||||
}
|
||||
@ -130,13 +130,13 @@ final class PhpDocInfo
|
||||
{
|
||||
$name = $this->annotationNaming->normalizeName($name);
|
||||
$tags = $this->phpDocNode->getTags();
|
||||
$tags = \array_filter($tags, function (\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode $tag) use($name) : bool {
|
||||
$tags = \array_filter($tags, function (PhpDocTagNode $tag) use($name) : bool {
|
||||
return $tag->name === $name;
|
||||
});
|
||||
$tags = \array_values($tags);
|
||||
return \array_values($tags);
|
||||
}
|
||||
public function getParamType(string $name) : \PHPStan\Type\Type
|
||||
public function getParamType(string $name) : Type
|
||||
{
|
||||
$paramTagValueNodes = $this->getParamTagValueByName($name);
|
||||
return $this->getTypeOrMixed($paramTagValueNodes);
|
||||
@ -148,7 +148,7 @@ final class PhpDocInfo
|
||||
{
|
||||
return $this->phpDocNode->getParamTagValues();
|
||||
}
|
||||
public function getParamTagValueNodeByName(string $parameterName) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
public function getParamTagValueNodeByName(string $parameterName) : ?ParamTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->getParamTagValues() as $paramTagValueNode) {
|
||||
if ($paramTagValueNode->parameterName !== '$' . $parameterName) {
|
||||
@ -158,11 +158,11 @@ final class PhpDocInfo
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public function getVarType() : \PHPStan\Type\Type
|
||||
public function getVarType() : Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getVarTagValueNode());
|
||||
}
|
||||
public function getReturnType() : \PHPStan\Type\Type
|
||||
public function getReturnType() : Type
|
||||
{
|
||||
return $this->getTypeOrMixed($this->getReturnTagValue());
|
||||
}
|
||||
@ -201,18 +201,18 @@ final class PhpDocInfo
|
||||
{
|
||||
return (bool) $this->getTagsByName($name);
|
||||
}
|
||||
public function getByName(string $name) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function getByName(string $name) : ?Node
|
||||
{
|
||||
return $this->getTagsByName($name)[0] ?? null;
|
||||
}
|
||||
/**
|
||||
* @param string[] $classes
|
||||
*/
|
||||
public function getByAnnotationClasses(array $classes) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
public function getByAnnotationClasses(array $classes) : ?DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($classes as $class) {
|
||||
$tagValueNode = $this->getByAnnotationClass($class);
|
||||
if ($tagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if ($tagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
return $tagValueNode;
|
||||
}
|
||||
}
|
||||
@ -229,14 +229,14 @@ final class PhpDocInfo
|
||||
{
|
||||
return $this->getByAnnotationClasses($annotationsClasses) !== null;
|
||||
}
|
||||
public function getByAnnotationClass(string $desiredClass) : ?\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
public function getByAnnotationClass(string $desiredClass) : ?DoctrineAnnotationTagValueNode
|
||||
{
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
// new approach
|
||||
if (!$phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$annotationClass = $phpDocChildNode->value->getAnnotationClass();
|
||||
@ -260,7 +260,7 @@ final class PhpDocInfo
|
||||
if (\is_a($phpDocChildNode, $type, \true)) {
|
||||
return $phpDocChildNode;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
@ -282,7 +282,7 @@ final class PhpDocInfo
|
||||
unset($this->phpDocNode->children[$key]);
|
||||
$this->markAsChanged();
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!\is_a($phpDocChildNode->value, $type, \true)) {
|
||||
@ -304,15 +304,15 @@ final class PhpDocInfo
|
||||
}
|
||||
return $paramTypesByName;
|
||||
}
|
||||
public function addTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : void
|
||||
public function addTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : void
|
||||
{
|
||||
if ($phpDocTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode('@\\' . $phpDocTagValueNode->getAnnotationClass(), $phpDocTagValueNode);
|
||||
if ($phpDocTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
$spacelessPhpDocTagNode = new SpacelessPhpDocTagNode('@\\' . $phpDocTagValueNode->getAnnotationClass(), $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($spacelessPhpDocTagNode);
|
||||
return;
|
||||
}
|
||||
$name = $this->resolveNameForPhpDocTagValueNode($phpDocTagValueNode);
|
||||
$phpDocTagNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($name, $phpDocTagValueNode);
|
||||
$phpDocTagNode = new PhpDocTagNode($name, $phpDocTagValueNode);
|
||||
$this->addPhpDocTagNode($phpDocTagNode);
|
||||
}
|
||||
public function isNewNode() : bool
|
||||
@ -334,25 +334,25 @@ final class PhpDocInfo
|
||||
{
|
||||
// fallback for invalid tag value node
|
||||
foreach ($this->phpDocNode->children as $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($phpDocChildNode->name !== $name) {
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\InvalidTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof InvalidTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function getReturnTagValue() : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode
|
||||
public function getReturnTagValue() : ?ReturnTagValueNode
|
||||
{
|
||||
$returnTagValueNodes = $this->phpDocNode->getReturnTagValues();
|
||||
return $returnTagValueNodes[0] ?? null;
|
||||
}
|
||||
public function getParamTagValueByName(string $name) : ?\PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
public function getParamTagValueByName(string $name) : ?ParamTagValueNode
|
||||
{
|
||||
$desiredParamNameWithDollar = '$' . \ltrim($name, '$');
|
||||
foreach ($this->getParamTagValueNodes() as $paramTagValueNode) {
|
||||
@ -396,8 +396,8 @@ final class PhpDocInfo
|
||||
return \true;
|
||||
}
|
||||
// has a single node with missing start_end
|
||||
$phpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeVisitor = new \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor();
|
||||
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeVisitor = new ChangedPhpDocNodeVisitor();
|
||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($changedPhpDocNodeVisitor);
|
||||
$phpDocNodeTraverser->traverse($this->phpDocNode);
|
||||
return $changedPhpDocNodeVisitor->hasChanged();
|
||||
@ -417,14 +417,14 @@ final class PhpDocInfo
|
||||
{
|
||||
$this->isSingleLine = \false;
|
||||
}
|
||||
private function getTypeOrMixed(?\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : \PHPStan\Type\Type
|
||||
private function getTypeOrMixed(?PhpDocTagValueNode $phpDocTagValueNode) : Type
|
||||
{
|
||||
if ($phpDocTagValueNode === null) {
|
||||
return new \PHPStan\Type\MixedType();
|
||||
return new MixedType();
|
||||
}
|
||||
return $this->staticTypeMapper->mapPHPStanPhpDocTypeToPHPStanType($phpDocTagValueNode, $this->node);
|
||||
}
|
||||
private function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode $phpDocTagValueNode) : string
|
||||
private function resolveNameForPhpDocTagValueNode(PhpDocTagValueNode $phpDocTagValueNode) : string
|
||||
{
|
||||
foreach (self::TAGS_TYPES_TO_NAMES as $tagValueNodeType => $name) {
|
||||
/** @var class-string<PhpDocTagNode> $tagValueNodeType */
|
||||
@ -432,11 +432,11 @@ final class PhpDocInfo
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
throw new \Rector\Core\Exception\NotImplementedYetException(\get_class($phpDocTagValueNode));
|
||||
throw new NotImplementedYetException(\get_class($phpDocTagValueNode));
|
||||
}
|
||||
private function isFnmatch(string $currentValue, string $desiredValue) : bool
|
||||
{
|
||||
if (!\RectorPrefix20210510\Nette\Utils\Strings::contains($desiredValue, '*')) {
|
||||
if (!Strings::contains($desiredValue, '*')) {
|
||||
return \false;
|
||||
}
|
||||
return \fnmatch($desiredValue, $currentValue, \FNM_NOESCAPE);
|
||||
|
@ -53,7 +53,7 @@ final class PhpDocInfoFactory
|
||||
* @var array<string, PhpDocInfo>
|
||||
*/
|
||||
private $phpDocInfosByObjectHash = [];
|
||||
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)
|
||||
public function __construct(PhpDocNodeMapper $phpDocNodeMapper, CurrentNodeProvider $currentNodeProvider, Lexer $lexer, BetterPhpDocParser $betterPhpDocParser, StaticTypeMapper $staticTypeMapper, AnnotationNaming $annotationNaming, RectorChangeCollector $rectorChangeCollector)
|
||||
{
|
||||
$this->betterPhpDocParser = $betterPhpDocParser;
|
||||
$this->lexer = $lexer;
|
||||
@ -63,10 +63,10 @@ final class PhpDocInfoFactory
|
||||
$this->annotationNaming = $annotationNaming;
|
||||
$this->rectorChangeCollector = $rectorChangeCollector;
|
||||
}
|
||||
public function createFromNodeOrEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
public function createFromNodeOrEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
// already added
|
||||
$phpDocInfo = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO);
|
||||
$phpDocInfo = $node->getAttribute(AttributeKey::PHP_DOC_INFO);
|
||||
if ($phpDocInfo instanceof \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo) {
|
||||
return $phpDocInfo;
|
||||
}
|
||||
@ -76,7 +76,7 @@ final class PhpDocInfoFactory
|
||||
}
|
||||
return $this->createEmpty($node);
|
||||
}
|
||||
public function createFromNode(\PhpParser\Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
public function createFromNode(Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$objectHash = \spl_object_hash($node);
|
||||
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
|
||||
@ -85,18 +85,18 @@ final class PhpDocInfoFactory
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
$docComment = $node->getDocComment();
|
||||
if (!$docComment instanceof \PhpParser\Comment\Doc) {
|
||||
if (!$docComment instanceof Doc) {
|
||||
if ($node->getComments() !== []) {
|
||||
return null;
|
||||
}
|
||||
// create empty node
|
||||
$content = '';
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
$tokenIterator = new BetterTokenIterator([]);
|
||||
$phpDocNode = new PhpDocNode([]);
|
||||
} else {
|
||||
$content = $docComment->getText();
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
$tokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
$tokenIterator = new BetterTokenIterator($tokens);
|
||||
$phpDocNode = $this->betterPhpDocParser->parse($tokenIterator);
|
||||
$this->setPositionOfLastToken($phpDocNode);
|
||||
}
|
||||
@ -104,12 +104,12 @@ final class PhpDocInfoFactory
|
||||
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
|
||||
return $phpDocInfo;
|
||||
}
|
||||
public function createEmpty(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
public function createEmpty(Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
/** needed for @see PhpDocNodeFactoryInterface */
|
||||
$this->currentNodeProvider->setNode($node);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode([]);
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator([]), $node);
|
||||
$phpDocNode = new PhpDocNode([]);
|
||||
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, new BetterTokenIterator([]), $node);
|
||||
// multiline by default
|
||||
$phpDocInfo->makeMultiLined();
|
||||
return $phpDocInfo;
|
||||
@ -117,23 +117,23 @@ final class PhpDocInfoFactory
|
||||
/**
|
||||
* Needed for printing
|
||||
*/
|
||||
private function setPositionOfLastToken(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
||||
private function setPositionOfLastToken(PhpDocNode $phpDocNode) : void
|
||||
{
|
||||
if ($phpDocNode->children === []) {
|
||||
return;
|
||||
}
|
||||
$phpDocChildNodes = $phpDocNode->children;
|
||||
$lastChildNode = \array_pop($phpDocChildNodes);
|
||||
$startAndEnd = $lastChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
||||
$startAndEnd = $lastChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof StartAndEnd) {
|
||||
$phpDocNode->setAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION, $startAndEnd->getEnd());
|
||||
}
|
||||
}
|
||||
private function createFromPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
private function createFromPhpDocNode(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator, Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
{
|
||||
$this->phpDocNodeMapper->transform($phpDocNode, $betterTokenIterator);
|
||||
$phpDocInfo = new \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo($phpDocNode, $betterTokenIterator, $this->staticTypeMapper, $node, $this->annotationNaming, $this->currentNodeProvider, $this->rectorChangeCollector);
|
||||
$node->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
$node->setAttribute(AttributeKey::PHP_DOC_INFO, $phpDocInfo);
|
||||
return $phpDocInfo;
|
||||
}
|
||||
}
|
||||
|
@ -21,23 +21,23 @@ final class TokenIteratorFactory
|
||||
* @var PrivatesAccessor
|
||||
*/
|
||||
private $privatesAccessor;
|
||||
public function __construct(\PHPStan\PhpDocParser\Lexer\Lexer $lexer, \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor $privatesAccessor)
|
||||
public function __construct(Lexer $lexer, PrivatesAccessor $privatesAccessor)
|
||||
{
|
||||
$this->lexer = $lexer;
|
||||
$this->privatesAccessor = $privatesAccessor;
|
||||
}
|
||||
public function create(string $content) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
public function create(string $content) : BetterTokenIterator
|
||||
{
|
||||
$tokens = $this->lexer->tokenize($content);
|
||||
return new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
return new BetterTokenIterator($tokens);
|
||||
}
|
||||
public function createFromTokenIterator(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator
|
||||
public function createFromTokenIterator(TokenIterator $tokenIterator) : BetterTokenIterator
|
||||
{
|
||||
if ($tokenIterator instanceof \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator) {
|
||||
if ($tokenIterator instanceof BetterTokenIterator) {
|
||||
return $tokenIterator;
|
||||
}
|
||||
$tokens = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'tokens');
|
||||
$betterTokenIterator = new \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator($tokens);
|
||||
$betterTokenIterator = new BetterTokenIterator($tokens);
|
||||
// keep original position
|
||||
$currentIndex = $this->privatesAccessor->getPrivateProperty($tokenIterator, 'index');
|
||||
$this->privatesAccessor->setPrivateProperty($betterTokenIterator, self::INDEX, $currentIndex);
|
||||
|
@ -14,7 +14,7 @@ final class PhpDocClassRenamer
|
||||
* @var ClassAnnotationMatcher
|
||||
*/
|
||||
private $classAnnotationMatcher;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher)
|
||||
public function __construct(ClassAnnotationMatcher $classAnnotationMatcher)
|
||||
{
|
||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||
}
|
||||
@ -24,7 +24,7 @@ final class PhpDocClassRenamer
|
||||
*
|
||||
* @param string[] $oldToNewClasses
|
||||
*/
|
||||
public function changeTypeInAnnotationTypes(\PhpParser\Node $node, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
|
||||
public function changeTypeInAnnotationTypes(Node $node, PhpDocInfo $phpDocInfo, array $oldToNewClasses) : void
|
||||
{
|
||||
$this->processAssertChoiceTagValueNode($oldToNewClasses, $phpDocInfo);
|
||||
$this->processDoctrineRelationTagValueNode($node, $oldToNewClasses, $phpDocInfo);
|
||||
@ -33,10 +33,10 @@ final class PhpDocClassRenamer
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processAssertChoiceTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
private function processAssertChoiceTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$assertChoiceTagValueNode = $phpDocInfo->getByAnnotationClass('Symfony\\Component\\Validator\\Constraints\\Choice');
|
||||
if (!$assertChoiceTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if (!$assertChoiceTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$callback = $assertChoiceTagValueNode->getValueWithoutQuotes('callback');
|
||||
@ -55,10 +55,10 @@ final class PhpDocClassRenamer
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineRelationTagValueNode(\PhpParser\Node $node, array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
private function processDoctrineRelationTagValueNode(Node $node, array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClasses(['Doctrine\\ORM\\Mapping\\OneToMany', 'Doctrine\\ORM\\Mapping\\ManyToMany', 'Doctrine\\ORM\\Mapping\\Embedded']);
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$this->processDoctrineToMany($doctrineAnnotationTagValueNode, $node, $oldToNewClasses);
|
||||
@ -66,10 +66,10 @@ final class PhpDocClassRenamer
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processSerializerTypeTagValueNode(array $oldToNewClasses, \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : void
|
||||
private function processSerializerTypeTagValueNode(array $oldToNewClasses, PhpDocInfo $phpDocInfo) : void
|
||||
{
|
||||
$doctrineAnnotationTagValueNode = $phpDocInfo->getByAnnotationClass('JMS\\Serializer\\Annotation\\Type');
|
||||
if (!$doctrineAnnotationTagValueNode instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if (!$doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
return;
|
||||
}
|
||||
foreach ($oldToNewClasses as $oldClass => $newClass) {
|
||||
@ -79,7 +79,7 @@ final class PhpDocClassRenamer
|
||||
$doctrineAnnotationTagValueNode->changeSilentValue($newClass);
|
||||
continue;
|
||||
}
|
||||
$newContent = \RectorPrefix20210510\Nette\Utils\Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
||||
$newContent = Strings::replace($className, '#\\b' . \preg_quote($oldClass, '#') . '\\b#', $newClass);
|
||||
if ($newContent === $className) {
|
||||
continue;
|
||||
}
|
||||
@ -96,7 +96,7 @@ final class PhpDocClassRenamer
|
||||
/**
|
||||
* @param array<string, string> $oldToNewClasses
|
||||
*/
|
||||
private function processDoctrineToMany(\Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, \PhpParser\Node $node, array $oldToNewClasses) : void
|
||||
private function processDoctrineToMany(DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, Node $node, array $oldToNewClasses) : void
|
||||
{
|
||||
if ($doctrineAnnotationTagValueNode->getAnnotationClass() === 'Doctrine\\ORM\\Mapping\\Embedded') {
|
||||
$classKey = 'class';
|
||||
|
@ -9,18 +9,18 @@ use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
final class PhpDocTagRemover
|
||||
{
|
||||
public function removeByName(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, string $name) : void
|
||||
public function removeByName(PhpDocInfo $phpDocInfo, string $name) : void
|
||||
{
|
||||
$phpDocNode = $phpDocInfo->getPhpDocNode();
|
||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($this->areAnnotationNamesEqual($name, $phpDocChildNode->name)) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
$phpDocInfo->markAsChanged();
|
||||
}
|
||||
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode) {
|
||||
if ($phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode) {
|
||||
$tagClass = $phpDocChildNode->value->getAnnotationClass();
|
||||
if ($tagClass === $name) {
|
||||
unset($phpDocNode->children[$key]);
|
||||
@ -29,7 +29,7 @@ final class PhpDocTagRemover
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||
@ -38,7 +38,7 @@ final class PhpDocTagRemover
|
||||
$phpDocInfo->markAsChanged();
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if ($phpDocChildNode->value !== $desiredNode) {
|
||||
|
@ -28,13 +28,13 @@ final class PhpDocTypeChanger
|
||||
* @var ParamPhpDocNodeFactory
|
||||
*/
|
||||
private $paramPhpDocNodeFactory;
|
||||
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \Rector\NodeTypeResolver\TypeComparator\TypeComparator $typeComparator, \Rector\TypeDeclaration\PhpDocParser\ParamPhpDocNodeFactory $paramPhpDocNodeFactory)
|
||||
public function __construct(StaticTypeMapper $staticTypeMapper, TypeComparator $typeComparator, ParamPhpDocNodeFactory $paramPhpDocNodeFactory)
|
||||
{
|
||||
$this->typeComparator = $typeComparator;
|
||||
$this->staticTypeMapper = $staticTypeMapper;
|
||||
$this->paramPhpDocNodeFactory = $paramPhpDocNodeFactory;
|
||||
}
|
||||
public function changeVarType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void
|
||||
public function changeVarType(PhpDocInfo $phpDocInfo, Type $newType) : void
|
||||
{
|
||||
// better skip, could crash hard
|
||||
if ($phpDocInfo->hasInvalidTag('@var')) {
|
||||
@ -45,7 +45,7 @@ final class PhpDocTypeChanger
|
||||
return;
|
||||
}
|
||||
// prevent existing type override by mixed
|
||||
if (!$phpDocInfo->getVarType() instanceof \PHPStan\Type\MixedType && $newType instanceof \PHPStan\Type\Constant\ConstantArrayType && $newType->getItemType() instanceof \PHPStan\Type\NeverType) {
|
||||
if (!$phpDocInfo->getVarType() instanceof MixedType && $newType instanceof ConstantArrayType && $newType->getItemType() instanceof NeverType) {
|
||||
return;
|
||||
}
|
||||
// override existing type
|
||||
@ -56,11 +56,11 @@ final class PhpDocTypeChanger
|
||||
$currentVarTagValueNode->type = $newPHPStanPhpDocType;
|
||||
} else {
|
||||
// add completely new one
|
||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($newPHPStanPhpDocType, '', '');
|
||||
$varTagValueNode = new VarTagValueNode($newPHPStanPhpDocType, '', '');
|
||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||
}
|
||||
}
|
||||
public function changeReturnType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType) : void
|
||||
public function changeReturnType(PhpDocInfo $phpDocInfo, Type $newType) : void
|
||||
{
|
||||
// better not touch this, can crash
|
||||
if ($phpDocInfo->hasInvalidTag('@return')) {
|
||||
@ -78,11 +78,11 @@ final class PhpDocTypeChanger
|
||||
$currentReturnTagValueNode->type = $newPHPStanPhpDocType;
|
||||
} else {
|
||||
// add completely new one
|
||||
$returnTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode($newPHPStanPhpDocType, '');
|
||||
$returnTagValueNode = new ReturnTagValueNode($newPHPStanPhpDocType, '');
|
||||
$phpDocInfo->addTagValueNode($returnTagValueNode);
|
||||
}
|
||||
}
|
||||
public function changeParamType(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo, \PHPStan\Type\Type $newType, \PhpParser\Node\Param $param, string $paramName) : void
|
||||
public function changeParamType(PhpDocInfo $phpDocInfo, Type $newType, Param $param, string $paramName) : void
|
||||
{
|
||||
// better skip, could crash hard
|
||||
if ($phpDocInfo->hasInvalidTag('@param')) {
|
||||
|
@ -14,22 +14,22 @@ final class PropertyDocBlockManipulator
|
||||
* @var PhpDocInfoFactory
|
||||
*/
|
||||
private $phpDocInfoFactory;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory)
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
}
|
||||
/**
|
||||
* @param ParamRename $renameValueObject
|
||||
*/
|
||||
public function renameParameterNameInDocBlock(\Rector\Naming\Contract\RenameValueObjectInterface $renameValueObject) : void
|
||||
public function renameParameterNameInDocBlock(RenameValueObjectInterface $renameValueObject) : void
|
||||
{
|
||||
$functionLike = $renameValueObject->getFunctionLike();
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($functionLike);
|
||||
$paramTagValueNode = $phpDocInfo->getParamTagValueNodeByName($renameValueObject->getCurrentName());
|
||||
if (!$paramTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) {
|
||||
if (!$paramTagValueNode instanceof ParamTagValueNode) {
|
||||
return;
|
||||
}
|
||||
$paramTagValueNode->parameterName = '$' . $renameValueObject->getExpectedName();
|
||||
$paramTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
||||
$paramTagValueNode->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||
}
|
||||
}
|
||||
|
@ -23,35 +23,35 @@ final class VarAnnotationManipulator
|
||||
* @var PhpDocTypeChanger
|
||||
*/
|
||||
private $phpDocTypeChanger;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger)
|
||||
public function __construct(PhpDocInfoFactory $phpDocInfoFactory, \Rector\BetterPhpDocParser\PhpDocManipulator\PhpDocTypeChanger $phpDocTypeChanger)
|
||||
{
|
||||
$this->phpDocInfoFactory = $phpDocInfoFactory;
|
||||
$this->phpDocTypeChanger = $phpDocTypeChanger;
|
||||
}
|
||||
public function decorateNodeWithInlineVarType(\PhpParser\Node $node, \PHPStan\Type\TypeWithClassName $typeWithClassName, string $variableName) : void
|
||||
public function decorateNodeWithInlineVarType(Node $node, TypeWithClassName $typeWithClassName, string $variableName) : void
|
||||
{
|
||||
$phpDocInfo = $this->resolvePhpDocInfo($node);
|
||||
// already done
|
||||
if ($phpDocInfo->getVarTagValueNode() !== null) {
|
||||
return;
|
||||
}
|
||||
$fullyQualifiedIdentifierTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
|
||||
$varTagValueNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
|
||||
$fullyQualifiedIdentifierTypeNode = new FullyQualifiedIdentifierTypeNode($typeWithClassName->getClassName());
|
||||
$varTagValueNode = new VarTagValueNode($fullyQualifiedIdentifierTypeNode, '$' . $variableName, '');
|
||||
$phpDocInfo->addTagValueNode($varTagValueNode);
|
||||
$phpDocInfo->makeSingleLined();
|
||||
}
|
||||
public function decorateNodeWithType(\PhpParser\Node $node, \PHPStan\Type\Type $staticType) : void
|
||||
public function decorateNodeWithType(Node $node, Type $staticType) : void
|
||||
{
|
||||
if ($staticType instanceof \PHPStan\Type\MixedType) {
|
||||
if ($staticType instanceof MixedType) {
|
||||
return;
|
||||
}
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
$this->phpDocTypeChanger->changeVarType($phpDocInfo, $staticType);
|
||||
}
|
||||
private function resolvePhpDocInfo(\PhpParser\Node $node) : \Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
|
||||
private function resolvePhpDocInfo(Node $node) : PhpDocInfo
|
||||
{
|
||||
$currentStmt = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::CURRENT_STATEMENT);
|
||||
if ($currentStmt instanceof \PhpParser\Node\Stmt\Expression) {
|
||||
$currentStmt = $node->getAttribute(AttributeKey::CURRENT_STATEMENT);
|
||||
if ($currentStmt instanceof Expression) {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($currentStmt);
|
||||
} else {
|
||||
$phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node);
|
||||
|
@ -35,23 +35,23 @@ final class PhpDocNodeMapper
|
||||
/**
|
||||
* @param BasePhpDocNodeVisitorInterface[] $phpDocNodeVisitors
|
||||
*/
|
||||
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors)
|
||||
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, ParentConnectingPhpDocNodeVisitor $parentConnectingPhpDocNodeVisitor, CloningPhpDocNodeVisitor $cloningPhpDocNodeVisitor, array $phpDocNodeVisitors)
|
||||
{
|
||||
$this->phpDocNodeVisitors = $phpDocNodeVisitors;
|
||||
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||
$this->parentConnectingPhpDocNodeVisitor = $parentConnectingPhpDocNodeVisitor;
|
||||
$this->cloningPhpDocNodeVisitor = $cloningPhpDocNodeVisitor;
|
||||
}
|
||||
public function transform(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator) : void
|
||||
public function transform(PhpDocNode $phpDocNode, BetterTokenIterator $betterTokenIterator) : void
|
||||
{
|
||||
$this->currentTokenIteratorProvider->setBetterTokenIterator($betterTokenIterator);
|
||||
$parentPhpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$parentPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
$parentPhpDocNodeTraverser->addPhpDocNodeVisitor($this->parentConnectingPhpDocNodeVisitor);
|
||||
$parentPhpDocNodeTraverser->traverse($phpDocNode);
|
||||
$cloningPhpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$cloningPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
$cloningPhpDocNodeTraverser->addPhpDocNodeVisitor($this->cloningPhpDocNodeVisitor);
|
||||
$cloningPhpDocNodeTraverser->traverse($phpDocNode);
|
||||
$phpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$phpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
foreach ($this->phpDocNodeVisitors as $phpDocNodeVisitor) {
|
||||
$phpDocNodeTraverser->addPhpDocNodeVisitor($phpDocNodeVisitor);
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ final class ChangedPhpDocNodeTraverserFactory
|
||||
* @var ChangedPhpDocNodeVisitor
|
||||
*/
|
||||
private $changedPhpDocNodeVisitor;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor)
|
||||
public function __construct(ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor)
|
||||
{
|
||||
$this->changedPhpDocNodeVisitor = $changedPhpDocNodeVisitor;
|
||||
}
|
||||
public function create() : \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser
|
||||
public function create() : PhpDocNodeTraverser
|
||||
{
|
||||
$changedPhpDocNodeTraverser = new \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeTraverser = new PhpDocNodeTraverser();
|
||||
$changedPhpDocNodeTraverser->addPhpDocNodeVisitor($this->changedPhpDocNodeVisitor);
|
||||
return $changedPhpDocNodeTraverser;
|
||||
}
|
||||
|
@ -9,25 +9,25 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class ArrayTypePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class ArrayTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode) {
|
||||
if (!$node instanceof ArrayTypeNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode) {
|
||||
if ($node instanceof SpacingAwareArrayTypeNode) {
|
||||
return null;
|
||||
}
|
||||
$spacingAwareArrayTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareArrayTypeNode($node->type);
|
||||
$spacingAwareArrayTypeNode = new SpacingAwareArrayTypeNode($node->type);
|
||||
$this->attributeMirrorer->mirror($node, $spacingAwareArrayTypeNode);
|
||||
return $spacingAwareArrayTypeNode;
|
||||
}
|
||||
|
@ -9,25 +9,25 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class CallableTypePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class CallableTypePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode) {
|
||||
if (!$node instanceof CallableTypeNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode) {
|
||||
if ($node instanceof SpacingAwareCallableTypeNode) {
|
||||
return null;
|
||||
}
|
||||
$spacingAwareCallableTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType);
|
||||
$spacingAwareCallableTypeNode = new SpacingAwareCallableTypeNode($node->identifier, $node->parameters, $node->returnType);
|
||||
$this->attributeMirrorer->mirror($node, $spacingAwareCallableTypeNode);
|
||||
return $spacingAwareCallableTypeNode;
|
||||
}
|
||||
|
@ -6,19 +6,19 @@ namespace Rector\BetterPhpDocParser\PhpDocNodeVisitor;
|
||||
use PHPStan\PhpDocParser\Ast\Node;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class ChangedPhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor
|
||||
final class ChangedPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor
|
||||
{
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $hasChanged = \false;
|
||||
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
|
||||
public function beforeTraverse(Node $node) : void
|
||||
{
|
||||
$this->hasChanged = \false;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
$origNode = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE);
|
||||
$origNode = $node->getAttribute(PhpDocAttributeKey::ORIG_NODE);
|
||||
if ($origNode === null) {
|
||||
$this->hasChanged = \true;
|
||||
}
|
||||
|
@ -9,25 +9,25 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class IntersectionTypeNodePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class IntersectionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode) {
|
||||
if (!$node instanceof IntersectionTypeNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode) {
|
||||
if ($node instanceof BracketsAwareIntersectionTypeNode) {
|
||||
return null;
|
||||
}
|
||||
$bracketsAwareIntersectionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareIntersectionTypeNode($node->types);
|
||||
$bracketsAwareIntersectionTypeNode = new BracketsAwareIntersectionTypeNode($node->types);
|
||||
$this->attributeMirrorer->mirror($node, $bracketsAwareIntersectionTypeNode);
|
||||
return $bracketsAwareIntersectionTypeNode;
|
||||
}
|
||||
|
@ -9,25 +9,25 @@ use Rector\BetterPhpDocParser\Attributes\AttributeMirrorer;
|
||||
use Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDoc\VariadicAwareParamTagValueNode;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class ParamPhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class ParamPhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode) {
|
||||
if (!$node instanceof ParamTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\VariadicAwareParamTagValueNode) {
|
||||
if ($node instanceof VariadicAwareParamTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
$variadicAwareParamTagValueNode = new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\VariadicAwareParamTagValueNode($node->type, $node->isVariadic, $node->parameterName, $node->description);
|
||||
$variadicAwareParamTagValueNode = new VariadicAwareParamTagValueNode($node->type, $node->isVariadic, $node->parameterName, $node->description);
|
||||
$this->attributeMirrorer->mirror($node, $variadicAwareParamTagValueNode);
|
||||
return $variadicAwareParamTagValueNode;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class TemplatePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class TemplatePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var CurrentTokenIteratorProvider
|
||||
@ -25,34 +25,34 @@ final class TemplatePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\Sim
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) {
|
||||
if (!$node instanceof TemplateTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode) {
|
||||
if ($node instanceof SpacingAwareTemplateTagValueNode) {
|
||||
return null;
|
||||
}
|
||||
$betterTokenIterator = $this->currentTokenIteratorProvider->provide();
|
||||
$startAndEnd = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
$startAndEnd = $node->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
if (!$startAndEnd instanceof StartAndEnd) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$prepositions = $this->resolvePreposition($betterTokenIterator, $startAndEnd);
|
||||
$spacingAwareTemplateTagValueNode = new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions);
|
||||
$spacingAwareTemplateTagValueNode = new SpacingAwareTemplateTagValueNode($node->name, $node->bound, $node->description, $prepositions);
|
||||
$this->attributeMirrorer->mirror($node, $spacingAwareTemplateTagValueNode);
|
||||
return $spacingAwareTemplateTagValueNode;
|
||||
}
|
||||
private function resolvePreposition(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenIterator, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : string
|
||||
private function resolvePreposition(BetterTokenIterator $betterTokenIterator, StartAndEnd $startAndEnd) : string
|
||||
{
|
||||
$partialTokens = $betterTokenIterator->partialTokens($startAndEnd->getStart(), $startAndEnd->getEnd());
|
||||
foreach ($partialTokens as $partialToken) {
|
||||
if ($partialToken[1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER) {
|
||||
if ($partialToken[1] !== Lexer::TOKEN_IDENTIFIER) {
|
||||
continue;
|
||||
}
|
||||
if (!\in_array($partialToken[0], ['as', 'of'], \true)) {
|
||||
|
@ -15,7 +15,7 @@ use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor;
|
||||
final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20210510\Symplify\SimplePhpDocParser\PhpDocNodeVisitor\AbstractPhpDocNodeVisitor implements \Rector\BetterPhpDocParser\Contract\BasePhpDocNodeVisitorInterface
|
||||
final class UnionTypeNodePhpDocNodeVisitor extends AbstractPhpDocNodeVisitor implements BasePhpDocNodeVisitorInterface
|
||||
{
|
||||
/**
|
||||
* @var CurrentTokenIteratorProvider
|
||||
@ -25,37 +25,37 @@ final class UnionTypeNodePhpDocNodeVisitor extends \RectorPrefix20210510\Symplif
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\BetterPhpDocParser\DataProvider\CurrentTokenIteratorProvider $currentTokenIteratorProvider, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(CurrentTokenIteratorProvider $currentTokenIteratorProvider, AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->currentTokenIteratorProvider = $currentTokenIteratorProvider;
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function enterNode(\PHPStan\PhpDocParser\Ast\Node $node) : ?\PHPStan\PhpDocParser\Ast\Node
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if (!$node instanceof \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode) {
|
||||
if (!$node instanceof UnionTypeNode) {
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode) {
|
||||
if ($node instanceof BracketsAwareUnionTypeNode) {
|
||||
return null;
|
||||
}
|
||||
// unwrap with parent array type...
|
||||
$startAndEnd = $node->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if (!$startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
$startAndEnd = $node->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
if (!$startAndEnd instanceof StartAndEnd) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$betterTokenProvider = $this->currentTokenIteratorProvider->provide();
|
||||
$isWrappedInCurlyBrackets = $this->isWrappedInCurlyBrackets($betterTokenProvider, $startAndEnd);
|
||||
$bracketsAwareUnionTypeNode = new \Rector\BetterPhpDocParser\ValueObject\Type\BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets);
|
||||
$bracketsAwareUnionTypeNode = new BracketsAwareUnionTypeNode($node->types, $isWrappedInCurlyBrackets);
|
||||
$this->attributeMirrorer->mirror($node, $bracketsAwareUnionTypeNode);
|
||||
return $bracketsAwareUnionTypeNode;
|
||||
}
|
||||
private function isWrappedInCurlyBrackets(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $betterTokenProvider, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : bool
|
||||
private function isWrappedInCurlyBrackets(BetterTokenIterator $betterTokenProvider, StartAndEnd $startAndEnd) : bool
|
||||
{
|
||||
$previousPosition = $startAndEnd->getStart() - 1;
|
||||
if ($betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) {
|
||||
if ($betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_OPEN_PARENTHESES, $previousPosition)) {
|
||||
return \true;
|
||||
}
|
||||
// there is no + 1, as end is right at the next token
|
||||
return $betterTokenProvider->isTokenTypeOnPosition(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd());
|
||||
return $betterTokenProvider->isTokenTypeOnPosition(Lexer::TOKEN_CLOSE_PARENTHESES, $startAndEnd->getEnd());
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller;
|
||||
/**
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocParser\TagValueNodeReprint\TagValueNodeReprintTest
|
||||
*/
|
||||
final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||
final class BetterPhpDocParser extends PhpDocParser
|
||||
{
|
||||
/**
|
||||
* @var PrivatesCaller
|
||||
@ -35,27 +35,27 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||
* @var TokenIteratorFactory
|
||||
*/
|
||||
private $tokenIteratorFactory;
|
||||
public function __construct(\PHPStan\PhpDocParser\Parser\TypeParser $typeParser, \PHPStan\PhpDocParser\Parser\ConstExprParser $constExprParser, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator $doctrineAnnotationDecorator)
|
||||
public function __construct(TypeParser $typeParser, ConstExprParser $constExprParser, TokenIteratorFactory $tokenIteratorFactory, \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator $doctrineAnnotationDecorator)
|
||||
{
|
||||
parent::__construct($typeParser, $constExprParser);
|
||||
$this->privatesCaller = new \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesCaller();
|
||||
$this->privatesCaller = new PrivatesCaller();
|
||||
$this->doctrineAnnotationDecorator = $doctrineAnnotationDecorator;
|
||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||
}
|
||||
public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode
|
||||
public function parse(TokenIterator $tokenIterator) : PhpDocNode
|
||||
{
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PHPDOC);
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PHPDOC);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$children = [];
|
||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) {
|
||||
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
|
||||
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
|
||||
while ($tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC)) {
|
||||
while ($tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL) && !$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PHPDOC)) {
|
||||
$children[] = $this->parseChildAndStoreItsPositions($tokenIterator);
|
||||
}
|
||||
}
|
||||
// might be in the middle of annotations
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PHPDOC);
|
||||
$phpDocNode = new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode($children);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_CLOSE_PHPDOC);
|
||||
$phpDocNode = new PhpDocNode($children);
|
||||
// replace generic nodes with DoctrineAnnotations
|
||||
$this->doctrineAnnotationDecorator->decorate($phpDocNode);
|
||||
return $phpDocNode;
|
||||
@ -63,36 +63,36 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||
/**
|
||||
* @param BetterTokenIterator $tokenIterator
|
||||
*/
|
||||
public function parseTag(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode
|
||||
public function parseTag(TokenIterator $tokenIterator) : PhpDocTagNode
|
||||
{
|
||||
$tag = $this->resolveTag($tokenIterator);
|
||||
$phpDocTagValueNode = $this->parseTagValue($tokenIterator, $tag);
|
||||
return new \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode($tag, $phpDocTagValueNode);
|
||||
return new PhpDocTagNode($tag, $phpDocTagValueNode);
|
||||
}
|
||||
/**
|
||||
* @param BetterTokenIterator $tokenIterator
|
||||
*/
|
||||
public function parseTagValue(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator, string $tag) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode
|
||||
public function parseTagValue(TokenIterator $tokenIterator, string $tag) : PhpDocTagValueNode
|
||||
{
|
||||
$startPosition = $tokenIterator->currentPosition();
|
||||
$tagValueNode = parent::parseTagValue($tokenIterator, $tag);
|
||||
$endPosition = $tokenIterator->currentPosition();
|
||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
||||
$tagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||
$tagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
return $tagValueNode;
|
||||
}
|
||||
private function parseChildAndStoreItsPositions(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode
|
||||
private function parseChildAndStoreItsPositions(TokenIterator $tokenIterator) : PhpDocChildNode
|
||||
{
|
||||
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
|
||||
$startPosition = $betterTokenIterator->currentPosition();
|
||||
/** @var PhpDocTagNode|PhpDocTextNode $phpDocNode */
|
||||
$phpDocNode = $this->privatesCaller->callPrivateMethod($this, 'parseChild', [$betterTokenIterator]);
|
||||
$endPosition = $betterTokenIterator->currentPosition();
|
||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
||||
$phpDocNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||
$phpDocNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
return $phpDocNode;
|
||||
}
|
||||
private function resolveTag(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : string
|
||||
private function resolveTag(BetterTokenIterator $tokenIterator) : string
|
||||
{
|
||||
$tag = $tokenIterator->currentTokenValue();
|
||||
$tokenIterator->next();
|
||||
@ -102,7 +102,7 @@ final class BetterPhpDocParser extends \PHPStan\PhpDocParser\Parser\PhpDocParser
|
||||
}
|
||||
// is not e.g "@var "
|
||||
// join tags like "@ORM\Column" etc.
|
||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) {
|
||||
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
|
||||
return $tag;
|
||||
}
|
||||
// @todo use joinUntil("(")?
|
||||
|
@ -10,25 +10,25 @@ use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
final class BetterTypeParser extends \PHPStan\PhpDocParser\Parser\TypeParser
|
||||
final class BetterTypeParser extends TypeParser
|
||||
{
|
||||
/**
|
||||
* @var 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)
|
||||
{
|
||||
parent::__construct($constExprParser);
|
||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||
}
|
||||
public function parse(\PHPStan\PhpDocParser\Parser\TokenIterator $tokenIterator) : \PHPStan\PhpDocParser\Ast\Type\TypeNode
|
||||
public function parse(TokenIterator $tokenIterator) : TypeNode
|
||||
{
|
||||
$betterTokenIterator = $this->tokenIteratorFactory->createFromTokenIterator($tokenIterator);
|
||||
$startPosition = $betterTokenIterator->currentPosition();
|
||||
$typeNode = parent::parse($betterTokenIterator);
|
||||
$endPosition = $betterTokenIterator->currentPosition();
|
||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($startPosition, $endPosition);
|
||||
$typeNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
$startAndEnd = new StartAndEnd($startPosition, $endPosition);
|
||||
$typeNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
return $typeNode;
|
||||
}
|
||||
}
|
||||
|
@ -23,11 +23,11 @@ final class ClassAnnotationMatcher
|
||||
* @var ReflectionProvider
|
||||
*/
|
||||
private $reflectionProvider;
|
||||
public function __construct(\PHPStan\Reflection\ReflectionProvider $reflectionProvider)
|
||||
public function __construct(ReflectionProvider $reflectionProvider)
|
||||
{
|
||||
$this->reflectionProvider = $reflectionProvider;
|
||||
}
|
||||
public function resolveTagFullyQualifiedName(string $tag, \PhpParser\Node $node) : string
|
||||
public function resolveTagFullyQualifiedName(string $tag, Node $node) : string
|
||||
{
|
||||
$uniqueHash = $tag . \spl_object_hash($node);
|
||||
if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) {
|
||||
@ -35,7 +35,7 @@ final class ClassAnnotationMatcher
|
||||
}
|
||||
$tag = \ltrim($tag, '@');
|
||||
/** @var Use_[] $uses */
|
||||
$uses = (array) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES);
|
||||
$uses = (array) $node->getAttribute(AttributeKey::USE_NODES);
|
||||
$fullyQualifiedClass = $this->resolveFullyQualifiedClass($uses, $node, $tag);
|
||||
$this->fullyQualifiedNameByHash[$uniqueHash] = $fullyQualifiedClass;
|
||||
return $fullyQualifiedClass;
|
||||
@ -43,10 +43,10 @@ final class ClassAnnotationMatcher
|
||||
/**
|
||||
* @param Use_[] $uses
|
||||
*/
|
||||
private function resolveFullyQualifiedClass(array $uses, \PhpParser\Node $node, string $tag) : string
|
||||
private function resolveFullyQualifiedClass(array $uses, Node $node, string $tag) : string
|
||||
{
|
||||
$scope = $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE);
|
||||
if ($scope instanceof \PHPStan\Analyser\Scope) {
|
||||
$scope = $node->getAttribute(AttributeKey::SCOPE);
|
||||
if ($scope instanceof Scope) {
|
||||
$namespace = $scope->getNamespace();
|
||||
if ($namespace !== null) {
|
||||
$namespacedTag = $namespace . '\\' . $tag;
|
||||
@ -72,19 +72,19 @@ final class ClassAnnotationMatcher
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function isUseMatchingName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : bool
|
||||
private function isUseMatchingName(string $tag, UseUse $useUse) : bool
|
||||
{
|
||||
$shortName = $useUse->alias !== null ? $useUse->alias->name : $useUse->name->getLast();
|
||||
$shortNamePattern = \preg_quote($shortName, '#');
|
||||
return (bool) \RectorPrefix20210510\Nette\Utils\Strings::match($tag, '#' . $shortNamePattern . '(\\\\[\\w]+)?#i');
|
||||
return (bool) Strings::match($tag, '#' . $shortNamePattern . '(\\\\[\\w]+)?#i');
|
||||
}
|
||||
private function resolveName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : string
|
||||
private function resolveName(string $tag, UseUse $useUse) : string
|
||||
{
|
||||
if ($useUse->alias === null) {
|
||||
return $useUse->name->toString();
|
||||
}
|
||||
$unaliasedShortClass = \RectorPrefix20210510\Nette\Utils\Strings::substring($tag, \RectorPrefix20210510\Nette\Utils\Strings::length($useUse->alias->toString()));
|
||||
if (\RectorPrefix20210510\Nette\Utils\Strings::startsWith($unaliasedShortClass, '\\')) {
|
||||
$unaliasedShortClass = Strings::substring($tag, Strings::length($useUse->alias->toString()));
|
||||
if (Strings::startsWith($unaliasedShortClass, '\\')) {
|
||||
return $useUse->name . $unaliasedShortClass;
|
||||
}
|
||||
return $useUse->name . '\\' . $unaliasedShortClass;
|
||||
|
@ -40,7 +40,7 @@ final class DoctrineAnnotationDecorator
|
||||
* @var AttributeMirrorer
|
||||
*/
|
||||
private $attributeMirrorer;
|
||||
public function __construct(\Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider, \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocInfo\TokenIteratorFactory $tokenIteratorFactory, \Rector\BetterPhpDocParser\Attributes\AttributeMirrorer $attributeMirrorer)
|
||||
public function __construct(CurrentNodeProvider $currentNodeProvider, \Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, TokenIteratorFactory $tokenIteratorFactory, AttributeMirrorer $attributeMirrorer)
|
||||
{
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||
@ -48,11 +48,11 @@ final class DoctrineAnnotationDecorator
|
||||
$this->tokenIteratorFactory = $tokenIteratorFactory;
|
||||
$this->attributeMirrorer = $attributeMirrorer;
|
||||
}
|
||||
public function decorate(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
||||
public function decorate(PhpDocNode $phpDocNode) : void
|
||||
{
|
||||
$currentPhpNode = $this->currentNodeProvider->getNode();
|
||||
if (!$currentPhpNode instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
if (!$currentPhpNode instanceof Node) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
// merge split doctrine nested tags
|
||||
$this->mergeNestedDoctrineAnnotations($phpDocNode);
|
||||
@ -61,17 +61,17 @@ final class DoctrineAnnotationDecorator
|
||||
/**
|
||||
* Join token iterator with all the following nodes if nested
|
||||
*/
|
||||
private function mergeNestedDoctrineAnnotations(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : void
|
||||
private function mergeNestedDoctrineAnnotations(PhpDocNode $phpDocNode) : void
|
||||
{
|
||||
$removedKeys = [];
|
||||
foreach ($phpDocNode->children as $key => $phpDocChildNode) {
|
||||
if (\in_array($key, $removedKeys, \true)) {
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$genericTagValueNode = $phpDocChildNode->value;
|
||||
@ -82,10 +82,10 @@ final class DoctrineAnnotationDecorator
|
||||
break;
|
||||
}
|
||||
$nextPhpDocChildNode = $phpDocNode->children[$key];
|
||||
if (!$nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$nextPhpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!$nextPhpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
||||
if (!$nextPhpDocChildNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
if ($this->isClosedContent($genericTagValueNode->value)) {
|
||||
@ -94,17 +94,17 @@ final class DoctrineAnnotationDecorator
|
||||
$composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->name . $nextPhpDocChildNode->value;
|
||||
$genericTagValueNode->value = $composedContent;
|
||||
/** @var StartAndEnd $currentStartAndEnd */
|
||||
$currentStartAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
$currentStartAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
/** @var StartAndEnd $nextStartAndEnd */
|
||||
$nextStartAndEnd = $nextPhpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
$startAndEnd = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd());
|
||||
$phpDocChildNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
$nextStartAndEnd = $nextPhpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
$startAndEnd = new StartAndEnd($currentStartAndEnd->getStart(), $nextStartAndEnd->getEnd());
|
||||
$phpDocChildNode->setAttribute(PhpDocAttributeKey::START_AND_END, $startAndEnd);
|
||||
$currentChildValueNode = $phpDocNode->children[$key];
|
||||
if (!$currentChildValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$currentChildValueNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
$currentGenericTagValueNode = $currentChildValueNode->value;
|
||||
if (!$currentGenericTagValueNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
||||
if (!$currentGenericTagValueNode instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
$removedKeys[] = $key;
|
||||
@ -117,19 +117,19 @@ final class DoctrineAnnotationDecorator
|
||||
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) {
|
||||
if (!$phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if (!$phpDocChildNode instanceof PhpDocTagNode) {
|
||||
continue;
|
||||
}
|
||||
if (!$phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode) {
|
||||
if (!$phpDocChildNode->value instanceof GenericTagValueNode) {
|
||||
continue;
|
||||
}
|
||||
// known doc tag to annotation class
|
||||
$fullyQualifiedAnnotationClass = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($phpDocChildNode->name, $currentPhpNode);
|
||||
// not an annotations class
|
||||
if (!\RectorPrefix20210510\Nette\Utils\Strings::contains($fullyQualifiedAnnotationClass, '\\')) {
|
||||
if (!Strings::contains($fullyQualifiedAnnotationClass, '\\')) {
|
||||
continue;
|
||||
}
|
||||
$genericTagValueNode = $phpDocChildNode->value;
|
||||
@ -137,10 +137,10 @@ final class DoctrineAnnotationDecorator
|
||||
// mimics doctrine behavior just in phpdoc-parser syntax :)
|
||||
// https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L742
|
||||
$values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($nestedTokenIterator);
|
||||
$formerStartEnd = $genericTagValueNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
$doctrineAnnotationTagValueNode = new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($fullyQualifiedAnnotationClass, $genericTagValueNode->value, $values, \Rector\BetterPhpDocParser\ValueObject\DoctrineAnnotation\SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null);
|
||||
$doctrineAnnotationTagValueNode->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END, $formerStartEnd);
|
||||
$spacelessPhpDocTagNode = new \Rector\BetterPhpDocParser\PhpDoc\SpacelessPhpDocTagNode($phpDocChildNode->name, $doctrineAnnotationTagValueNode);
|
||||
$formerStartEnd = $genericTagValueNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
$doctrineAnnotationTagValueNode = new DoctrineAnnotationTagValueNode($fullyQualifiedAnnotationClass, $genericTagValueNode->value, $values, SilentKeyMap::CLASS_NAMES_TO_SILENT_KEYS[$fullyQualifiedAnnotationClass] ?? null);
|
||||
$doctrineAnnotationTagValueNode->setAttribute(PhpDocAttributeKey::START_AND_END, $formerStartEnd);
|
||||
$spacelessPhpDocTagNode = new SpacelessPhpDocTagNode($phpDocChildNode->name, $doctrineAnnotationTagValueNode);
|
||||
$this->attributeMirrorer->mirror($phpDocChildNode, $spacelessPhpDocTagNode);
|
||||
$phpDocNode->children[$key] = $spacelessPhpDocTagNode;
|
||||
}
|
||||
@ -159,10 +159,10 @@ final class DoctrineAnnotationDecorator
|
||||
return \true;
|
||||
}
|
||||
do {
|
||||
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES]) || \RectorPrefix20210510\Nette\Utils\Strings::contains($composedTokenIterator->currentTokenValue(), '(')) {
|
||||
if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_OPEN_CURLY_BRACKET, Lexer::TOKEN_OPEN_PARENTHESES]) || Strings::contains($composedTokenIterator->currentTokenValue(), '(')) {
|
||||
++$openBracketCount;
|
||||
}
|
||||
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES]) || \RectorPrefix20210510\Nette\Utils\Strings::contains($composedTokenIterator->currentTokenValue(), ')')) {
|
||||
if ($composedTokenIterator->isCurrentTokenTypes([Lexer::TOKEN_CLOSE_CURLY_BRACKET, Lexer::TOKEN_CLOSE_PARENTHESES]) || Strings::contains($composedTokenIterator->currentTokenValue(), ')')) {
|
||||
++$closeBracketCount;
|
||||
}
|
||||
$composedTokenIterator->next();
|
||||
|
@ -22,7 +22,7 @@ final class StaticDoctrineAnnotationParser
|
||||
* @var ArrayParser
|
||||
*/
|
||||
private $arrayParser;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\PlainValueParser $plainValueParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser)
|
||||
public function __construct(PlainValueParser $plainValueParser, ArrayParser $arrayParser)
|
||||
{
|
||||
$this->plainValueParser = $plainValueParser;
|
||||
$this->arrayParser = $arrayParser;
|
||||
@ -31,14 +31,14 @@ final class StaticDoctrineAnnotationParser
|
||||
* mimics: https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1024-L1041
|
||||
* @return array<mixed, mixed>
|
||||
*/
|
||||
public function resolveAnnotationMethodCall(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
|
||||
public function resolveAnnotationMethodCall(BetterTokenIterator $tokenIterator) : array
|
||||
{
|
||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) {
|
||||
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) {
|
||||
return [];
|
||||
}
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_PARENTHESES);
|
||||
// empty ()
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
||||
return [];
|
||||
}
|
||||
return $this->resolveAnnotationValues($tokenIterator);
|
||||
@ -47,18 +47,18 @@ final class StaticDoctrineAnnotationParser
|
||||
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1215-L1224
|
||||
* @return mixed|mixed[]
|
||||
*/
|
||||
public function resolveAnnotationValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
|
||||
public function resolveAnnotationValue(BetterTokenIterator $tokenIterator)
|
||||
{
|
||||
// skips dummy tokens like newlines
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
// no assign
|
||||
if (!$tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL)) {
|
||||
if (!$tokenIterator->isNextTokenType(Lexer::TOKEN_EQUAL)) {
|
||||
// 1. plain value - mimics https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1234-L1282
|
||||
return $this->parseValue($tokenIterator);
|
||||
}
|
||||
// 2. assign key = value - mimics FieldAssignment() https://github.com/doctrine/annotations/blob/0cb0cd2950a5c6cdbf22adbe2bfd5fd1ea68588f/lib/Doctrine/Common/Annotations/DocParser.php#L1291-L1303
|
||||
$key = $this->parseValue($tokenIterator);
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_EQUAL);
|
||||
// mimics https://github.com/doctrine/annotations/blob/1.13.x/lib/Doctrine/Common/Annotations/DocParser.php#L1236-L1238
|
||||
$value = $this->parseValue($tokenIterator);
|
||||
return [
|
||||
@ -70,7 +70,7 @@ final class StaticDoctrineAnnotationParser
|
||||
* @see https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1051-L1079
|
||||
* @return array<mixed, mixed>
|
||||
*/
|
||||
private function resolveAnnotationValues(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
|
||||
private function resolveAnnotationValues(BetterTokenIterator $tokenIterator) : array
|
||||
{
|
||||
$values = [];
|
||||
$resolvedValue = $this->resolveAnnotationValue($tokenIterator);
|
||||
@ -79,7 +79,7 @@ final class StaticDoctrineAnnotationParser
|
||||
} else {
|
||||
$values[] = $resolvedValue;
|
||||
}
|
||||
while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) {
|
||||
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) {
|
||||
$tokenIterator->next();
|
||||
$nestedValues = $this->resolveAnnotationValue($tokenIterator);
|
||||
if (\is_array($nestedValues)) {
|
||||
@ -93,11 +93,11 @@ final class StaticDoctrineAnnotationParser
|
||||
/**
|
||||
* @return bool|int|mixed|mixed[]|string
|
||||
*/
|
||||
private function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
|
||||
private function parseValue(BetterTokenIterator $tokenIterator)
|
||||
{
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET)) {
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET)) {
|
||||
$items = $this->arrayParser->parseCurlyArray($tokenIterator);
|
||||
return new \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\CurlyListNode($items);
|
||||
return new CurlyListNode($items);
|
||||
}
|
||||
return $this->plainValueParser->parseValue($tokenIterator);
|
||||
}
|
||||
|
@ -22,36 +22,36 @@ final class ArrayParser
|
||||
* Mimics https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1305-L1352
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function parseCurlyArray(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
|
||||
public function parseCurlyArray(BetterTokenIterator $tokenIterator) : array
|
||||
{
|
||||
$values = [];
|
||||
// nothing
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
return [];
|
||||
}
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET);
|
||||
// If the array is empty, stop parsing and return.
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET);
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET);
|
||||
return [];
|
||||
}
|
||||
// first item
|
||||
$values[] = $this->resolveArrayItem($tokenIterator);
|
||||
// 2nd+ item
|
||||
while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA)) {
|
||||
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_COMMA)) {
|
||||
// optional trailing comma
|
||||
if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
if ($tokenIterator->isNextTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET)) {
|
||||
break;
|
||||
}
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_COMMA);
|
||||
$values[] = $this->resolveArrayItem($tokenIterator);
|
||||
// skip newlines
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
}
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
// special case for nested doctrine annotations
|
||||
if (!$tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET);
|
||||
if (!$tokenIterator->isCurrentTokenType(Lexer::TOKEN_CLOSE_PARENTHESES)) {
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_CURLY_BRACKET);
|
||||
}
|
||||
return $this->createArrayFromValues($values);
|
||||
}
|
||||
@ -59,21 +59,21 @@ final class ArrayParser
|
||||
* Mimics https://github.com/doctrine/annotations/blob/c66f06b7c83e9a2a7523351a9d5a4b55f885e574/lib/Doctrine/Common/Annotations/DocParser.php#L1354-L1385
|
||||
* @return array<null|mixed, mixed>
|
||||
*/
|
||||
private function resolveArrayItem(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : array
|
||||
private function resolveArrayItem(BetterTokenIterator $tokenIterator) : array
|
||||
{
|
||||
// skip newlines
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
if ($tokenIterator->isNextTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON])) {
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL);
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON);
|
||||
if ($tokenIterator->isNextTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) {
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
if ($tokenIterator->isNextTokenTypes([Lexer::TOKEN_EQUAL, Lexer::TOKEN_COLON])) {
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_EQUAL);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COLON);
|
||||
if ($tokenIterator->isNextTokenType(Lexer::TOKEN_IDENTIFIER)) {
|
||||
$key = $this->plainValueParser->parseValue($tokenIterator);
|
||||
} else {
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COMMA);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COMMA);
|
||||
$key = $this->plainValueParser->parseValue($tokenIterator);
|
||||
}
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_EQUAL);
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_COLON);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_EQUAL);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_COLON);
|
||||
return [$key, $this->plainValueParser->parseValue($tokenIterator)];
|
||||
}
|
||||
return [null, $this->plainValueParser->parseValue($tokenIterator)];
|
||||
|
@ -32,7 +32,7 @@ final class PlainValueParser
|
||||
* @var ArrayParser
|
||||
*/
|
||||
private $arrayParser;
|
||||
public function __construct(\Rector\BetterPhpDocParser\PhpDocParser\ClassAnnotationMatcher $classAnnotationMatcher, \Rector\Core\Configuration\CurrentNodeProvider $currentNodeProvider)
|
||||
public function __construct(ClassAnnotationMatcher $classAnnotationMatcher, CurrentNodeProvider $currentNodeProvider)
|
||||
{
|
||||
$this->classAnnotationMatcher = $classAnnotationMatcher;
|
||||
$this->currentNodeProvider = $currentNodeProvider;
|
||||
@ -40,7 +40,7 @@ final class PlainValueParser
|
||||
/**
|
||||
* @required
|
||||
*/
|
||||
public function autowirePlainValueParser(\Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser) : void
|
||||
public function autowirePlainValueParser(StaticDoctrineAnnotationParser $staticDoctrineAnnotationParser, \Rector\BetterPhpDocParser\PhpDocParser\StaticDoctrineAnnotationParser\ArrayParser $arrayParser) : void
|
||||
{
|
||||
$this->staticDoctrineAnnotationParser = $staticDoctrineAnnotationParser;
|
||||
$this->arrayParser = $arrayParser;
|
||||
@ -48,52 +48,52 @@ final class PlainValueParser
|
||||
/**
|
||||
* @return bool|int|mixed|string
|
||||
*/
|
||||
public function parseValue(\Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator)
|
||||
public function parseValue(BetterTokenIterator $tokenIterator)
|
||||
{
|
||||
$currentTokenValue = $tokenIterator->currentTokenValue();
|
||||
// temporary hackaround multi-line doctrine annotations
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_END)) {
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_END)) {
|
||||
return $currentTokenValue;
|
||||
}
|
||||
// consume the token
|
||||
$isOpenCurlyArray = $tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET);
|
||||
$isOpenCurlyArray = $tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_CURLY_BRACKET);
|
||||
if ($isOpenCurlyArray) {
|
||||
return $this->arrayParser->parseCurlyArray($tokenIterator);
|
||||
}
|
||||
$tokenIterator->next();
|
||||
// normalize value
|
||||
if ($currentTokenValue === 'false') {
|
||||
return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprFalseNode();
|
||||
return new ConstExprFalseNode();
|
||||
}
|
||||
if ($currentTokenValue === 'true') {
|
||||
return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprTrueNode();
|
||||
return new ConstExprTrueNode();
|
||||
}
|
||||
if (\is_numeric($currentTokenValue) && (string) (int) $currentTokenValue === $currentTokenValue) {
|
||||
return new \PHPStan\PhpDocParser\Ast\ConstExpr\ConstExprIntegerNode($currentTokenValue);
|
||||
return new ConstExprIntegerNode($currentTokenValue);
|
||||
}
|
||||
while ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_IDENTIFIER)) {
|
||||
while ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_DOUBLE_COLON) || $tokenIterator->isCurrentTokenType(Lexer::TOKEN_IDENTIFIER)) {
|
||||
$currentTokenValue .= $tokenIterator->currentTokenValue();
|
||||
$tokenIterator->next();
|
||||
}
|
||||
// nested entity!
|
||||
if ($tokenIterator->isCurrentTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES)) {
|
||||
if ($tokenIterator->isCurrentTokenType(Lexer::TOKEN_OPEN_PARENTHESES)) {
|
||||
return $this->parseNestedDoctrineAnnotationTagValueNode($currentTokenValue, $tokenIterator);
|
||||
}
|
||||
return $currentTokenValue;
|
||||
}
|
||||
private function parseNestedDoctrineAnnotationTagValueNode(string $currentTokenValue, \Rector\BetterPhpDocParser\ValueObject\Parser\BetterTokenIterator $tokenIterator) : \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode
|
||||
private function parseNestedDoctrineAnnotationTagValueNode(string $currentTokenValue, BetterTokenIterator $tokenIterator) : DoctrineAnnotationTagValueNode
|
||||
{
|
||||
// @todo
|
||||
$annotationShortName = $currentTokenValue;
|
||||
$values = $this->staticDoctrineAnnotationParser->resolveAnnotationMethodCall($tokenIterator);
|
||||
$currentNode = $this->currentNodeProvider->getNode();
|
||||
if (!$currentNode instanceof \PhpParser\Node) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
if (!$currentNode instanceof Node) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$fullyQualifiedAnnotationClass = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($annotationShortName, $currentNode);
|
||||
// keep the last ")"
|
||||
$tokenIterator->tryConsumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->consumeTokenType(\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES);
|
||||
return new \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode($fullyQualifiedAnnotationClass, $annotationShortName, $values);
|
||||
$tokenIterator->tryConsumeTokenType(Lexer::TOKEN_PHPDOC_EOL);
|
||||
$tokenIterator->consumeTokenType(Lexer::TOKEN_CLOSE_PARENTHESES);
|
||||
return new DoctrineAnnotationTagValueNode($fullyQualifiedAnnotationClass, $annotationShortName, $values);
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,13 @@ use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
*/
|
||||
final class TypeNodeAnalyzer
|
||||
{
|
||||
public function isIntersectionAndNotNullable(\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode) : bool
|
||||
public function isIntersectionAndNotNullable(TypeNode $typeNode) : bool
|
||||
{
|
||||
if (!$typeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode) {
|
||||
if (!$typeNode instanceof IntersectionTypeNode) {
|
||||
return \false;
|
||||
}
|
||||
foreach ($typeNode->types as $subType) {
|
||||
if ($subType instanceof \PHPStan\PhpDocParser\Ast\Type\NullableTypeNode) {
|
||||
if ($subType instanceof NullableTypeNode) {
|
||||
return \false;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ final class DocBlockInliner
|
||||
private const NEWLINE_MIDDLE_DOC_REGEX = "#\n \\* #";
|
||||
public function inline(string $docContent) : string
|
||||
{
|
||||
$docContent = \RectorPrefix20210510\Nette\Utils\Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' ');
|
||||
return \RectorPrefix20210510\Nette\Utils\Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */');
|
||||
$docContent = Strings::replace($docContent, self::NEWLINE_MIDDLE_DOC_REGEX, ' ');
|
||||
return Strings::replace($docContent, self::NEWLINE_CLOSING_DOC_REGEX, ' */');
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,13 @@ use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode;
|
||||
final class EmptyPhpDocDetector
|
||||
{
|
||||
public function isPhpDocNodeEmpty(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : bool
|
||||
public function isPhpDocNodeEmpty(PhpDocNode $phpDocNode) : bool
|
||||
{
|
||||
if ($phpDocNode->children === []) {
|
||||
return \true;
|
||||
}
|
||||
foreach ($phpDocNode->children as $phpDocChildNode) {
|
||||
if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode) {
|
||||
if ($phpDocChildNode instanceof PhpDocTextNode) {
|
||||
if ($phpDocChildNode->text !== '') {
|
||||
return \false;
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ final class PhpDocInfoPrinter
|
||||
* @var PhpDocNodeTraverser
|
||||
*/
|
||||
private $changedPhpDocNodeTraverser;
|
||||
public function __construct(\Rector\BetterPhpDocParser\Printer\EmptyPhpDocDetector $emptyPhpDocDetector, \Rector\BetterPhpDocParser\Printer\DocBlockInliner $docBlockInliner, \Rector\BetterPhpDocParser\Printer\RemoveNodesStartAndEndResolver $removeNodesStartAndEndResolver, \Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor, \Rector\BetterPhpDocParser\PhpDocNodeTraverser\ChangedPhpDocNodeTraverserFactory $changedPhpDocNodeTraverserFactory)
|
||||
public function __construct(\Rector\BetterPhpDocParser\Printer\EmptyPhpDocDetector $emptyPhpDocDetector, \Rector\BetterPhpDocParser\Printer\DocBlockInliner $docBlockInliner, \Rector\BetterPhpDocParser\Printer\RemoveNodesStartAndEndResolver $removeNodesStartAndEndResolver, ChangedPhpDocNodeVisitor $changedPhpDocNodeVisitor, ChangedPhpDocNodeTraverserFactory $changedPhpDocNodeTraverserFactory)
|
||||
{
|
||||
$this->emptyPhpDocDetector = $emptyPhpDocDetector;
|
||||
$this->docBlockInliner = $docBlockInliner;
|
||||
@ -107,11 +107,11 @@ final class PhpDocInfoPrinter
|
||||
$this->changedPhpDocNodeVisitor = $changedPhpDocNodeVisitor;
|
||||
$this->changedPhpDocNodeTraverser = $changedPhpDocNodeTraverserFactory->create();
|
||||
}
|
||||
public function printNew(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : string
|
||||
public function printNew(PhpDocInfo $phpDocInfo) : string
|
||||
{
|
||||
$docContent = (string) $phpDocInfo->getPhpDocNode();
|
||||
// fix missing newline in the end of docblock - keep BC compatible for both cases until phpstan with phpdoc-parser 0.5.2 is released
|
||||
$docContent = \RectorPrefix20210510\Nette\Utils\Strings::replace($docContent, self::MISSING_NEWLINE_REGEX, "\$1\n */");
|
||||
$docContent = Strings::replace($docContent, self::MISSING_NEWLINE_REGEX, "\$1\n */");
|
||||
if ($phpDocInfo->isSingleLine()) {
|
||||
return $this->docBlockInliner->inline($docContent);
|
||||
}
|
||||
@ -127,7 +127,7 @@ final class PhpDocInfoPrinter
|
||||
* - Print(subnode2)
|
||||
* - Tokens[subnode2.endPos .. node.endPos]
|
||||
*/
|
||||
public function printFormatPreserving(\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo $phpDocInfo) : string
|
||||
public function printFormatPreserving(PhpDocInfo $phpDocInfo) : string
|
||||
{
|
||||
if ($phpDocInfo->getTokens() === []) {
|
||||
// completely new one, just print string version of it
|
||||
@ -143,9 +143,9 @@ final class PhpDocInfoPrinter
|
||||
$this->currentTokenPosition = 0;
|
||||
$phpDocString = $this->printPhpDocNode($this->phpDocNode);
|
||||
// hotfix of extra space with callable ()
|
||||
return \RectorPrefix20210510\Nette\Utils\Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable(');
|
||||
return Strings::replace($phpDocString, self::CALLABLE_REGEX, 'callable(');
|
||||
}
|
||||
private function printPhpDocNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $phpDocNode) : string
|
||||
private function printPhpDocNode(PhpDocNode $phpDocNode) : string
|
||||
{
|
||||
// no nodes were, so empty doc
|
||||
if ($this->emptyPhpDocDetector->isPhpDocNodeEmpty($phpDocNode)) {
|
||||
@ -159,39 +159,39 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
$output = $this->printEnd($output);
|
||||
// fix missing start
|
||||
if (!\RectorPrefix20210510\Nette\Utils\Strings::match($output, self::DOCBLOCK_START_REGEX) && $output) {
|
||||
if (!Strings::match($output, self::DOCBLOCK_START_REGEX) && $output) {
|
||||
$output = '/**' . $output;
|
||||
}
|
||||
// fix missing end
|
||||
if (\RectorPrefix20210510\Nette\Utils\Strings::match($output, self::OPENING_DOCBLOCK_REGEX) && $output && !\RectorPrefix20210510\Nette\Utils\Strings::match($output, self::CLOSING_DOCBLOCK_REGEX)) {
|
||||
if (Strings::match($output, self::OPENING_DOCBLOCK_REGEX) && $output && !Strings::match($output, self::CLOSING_DOCBLOCK_REGEX)) {
|
||||
$output .= ' */';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
private function printDocChildNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode, int $key = 0, int $nodeCount = 0) : string
|
||||
private function printDocChildNode(PhpDocChildNode $phpDocChildNode, int $key = 0, int $nodeCount = 0) : string
|
||||
{
|
||||
$output = '';
|
||||
$shouldReprintChildNode = $this->shouldReprint($phpDocChildNode);
|
||||
if ($phpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
if ($shouldReprintChildNode && ($phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode || $phpDocChildNode->value instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode)) {
|
||||
if ($phpDocChildNode instanceof PhpDocTagNode) {
|
||||
if ($shouldReprintChildNode && ($phpDocChildNode->value instanceof ParamTagValueNode || $phpDocChildNode->value instanceof ThrowsTagValueNode || $phpDocChildNode->value instanceof VarTagValueNode || $phpDocChildNode->value instanceof ReturnTagValueNode || $phpDocChildNode->value instanceof PropertyTagValueNode)) {
|
||||
// the type has changed → reprint
|
||||
$phpDocChildNodeStartEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
$phpDocChildNodeStartEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
// bump the last position of token after just printed node
|
||||
if ($phpDocChildNodeStartEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
if ($phpDocChildNodeStartEnd instanceof StartAndEnd) {
|
||||
$this->currentTokenPosition = $phpDocChildNodeStartEnd->getEnd();
|
||||
}
|
||||
return $this->standardPrintPhpDocChildNode($phpDocChildNode);
|
||||
}
|
||||
if ($phpDocChildNode->value instanceof \Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode && $shouldReprintChildNode) {
|
||||
if ($phpDocChildNode->value instanceof DoctrineAnnotationTagValueNode && $shouldReprintChildNode) {
|
||||
$printedNode = (string) $phpDocChildNode;
|
||||
// remove extra space between tags
|
||||
$printedNode = \RectorPrefix20210510\Nette\Utils\Strings::replace($printedNode, self::TAG_AND_SPACE_REGEX, '$1(');
|
||||
$printedNode = Strings::replace($printedNode, self::TAG_AND_SPACE_REGEX, '$1(');
|
||||
return self::NEWLINE_WITH_ASTERISK . $printedNode;
|
||||
}
|
||||
}
|
||||
/** @var StartAndEnd|null $startAndEnd */
|
||||
$startAndEnd = $phpDocChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd && !$shouldReprintChildNode) {
|
||||
$startAndEnd = $phpDocChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
if ($startAndEnd instanceof StartAndEnd && !$shouldReprintChildNode) {
|
||||
$isLastToken = $nodeCount === $key;
|
||||
// correct previously changed node
|
||||
$this->correctPreviouslyReprintedFirstNode($key, $startAndEnd);
|
||||
@ -199,7 +199,7 @@ final class PhpDocInfoPrinter
|
||||
$this->currentTokenPosition = $startAndEnd->getEnd();
|
||||
return \rtrim($output);
|
||||
}
|
||||
if ($startAndEnd instanceof \Rector\BetterPhpDocParser\ValueObject\StartAndEnd) {
|
||||
if ($startAndEnd instanceof StartAndEnd) {
|
||||
$this->currentTokenPosition = $startAndEnd->getEnd();
|
||||
}
|
||||
$standardPrintedPhpDocChildNode = $this->standardPrintPhpDocChildNode($phpDocChildNode);
|
||||
@ -207,7 +207,7 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
private function printEnd(string $output) : string
|
||||
{
|
||||
$lastTokenPosition = $this->phpDocNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION) ?: $this->currentTokenPosition;
|
||||
$lastTokenPosition = $this->phpDocNode->getAttribute(PhpDocAttributeKey::LAST_PHP_DOC_TOKEN_POSITION) ?: $this->currentTokenPosition;
|
||||
if ($lastTokenPosition === 0) {
|
||||
$lastTokenPosition = 1;
|
||||
}
|
||||
@ -222,11 +222,11 @@ final class PhpDocInfoPrinter
|
||||
$positionJumpSet[$removedStartAndEnd->getStart()] = $removedStartAndEnd->getEnd();
|
||||
}
|
||||
// include also space before, in case of inlined docs
|
||||
if (isset($this->tokens[$from - 1]) && $this->tokens[$from - 1][1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) {
|
||||
if (isset($this->tokens[$from - 1]) && $this->tokens[$from - 1][1] === Lexer::TOKEN_HORIZONTAL_WS) {
|
||||
--$from;
|
||||
}
|
||||
// skip extra empty lines above if this is the last one
|
||||
if ($shouldSkipEmptyLinesAbove && \RectorPrefix20210510\Nette\Utils\Strings::contains($this->tokens[$from][0], \PHP_EOL) && \RectorPrefix20210510\Nette\Utils\Strings::contains($this->tokens[$from + 1][0], \PHP_EOL)) {
|
||||
if ($shouldSkipEmptyLinesAbove && Strings::contains($this->tokens[$from][0], \PHP_EOL) && Strings::contains($this->tokens[$from + 1][0], \PHP_EOL)) {
|
||||
++$from;
|
||||
}
|
||||
return $this->appendToOutput($output, $from, $to, $positionJumpSet);
|
||||
@ -245,7 +245,7 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
private function correctPreviouslyReprintedFirstNode(int $key, \Rector\BetterPhpDocParser\ValueObject\StartAndEnd $startAndEnd) : void
|
||||
private function correctPreviouslyReprintedFirstNode(int $key, StartAndEnd $startAndEnd) : void
|
||||
{
|
||||
if ($this->currentTokenPosition !== 0) {
|
||||
return;
|
||||
@ -259,17 +259,17 @@ final class PhpDocInfoPrinter
|
||||
return;
|
||||
}
|
||||
$previousToken = $tokens[$startTokenPosition - 1];
|
||||
if ($previousToken[1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) {
|
||||
if ($previousToken[1] === Lexer::TOKEN_PHPDOC_EOL) {
|
||||
--$startTokenPosition;
|
||||
}
|
||||
$this->currentTokenPosition = $startTokenPosition;
|
||||
}
|
||||
private function shouldReprint(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : bool
|
||||
private function shouldReprint(PhpDocChildNode $phpDocChildNode) : bool
|
||||
{
|
||||
$this->changedPhpDocNodeTraverser->traverse($phpDocChildNode);
|
||||
return $this->changedPhpDocNodeVisitor->hasChanged();
|
||||
}
|
||||
private function standardPrintPhpDocChildNode(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocChildNode $phpDocChildNode) : string
|
||||
private function standardPrintPhpDocChildNode(PhpDocChildNode $phpDocChildNode) : string
|
||||
{
|
||||
if ($this->phpDocInfo->isSingleLine()) {
|
||||
return ' ' . $phpDocChildNode;
|
||||
|
@ -14,7 +14,7 @@ final class RemoveNodesStartAndEndResolver
|
||||
* @param mixed[] $tokens
|
||||
* @return StartAndEnd[]
|
||||
*/
|
||||
public function resolve(\PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $originalPhpDocNode, \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode $currentPhpDocNode, array $tokens) : array
|
||||
public function resolve(PhpDocNode $originalPhpDocNode, PhpDocNode $currentPhpDocNode, array $tokens) : array
|
||||
{
|
||||
$removedNodePositions = [];
|
||||
/** @var PhpDocChildNode[] $removedChildNodes */
|
||||
@ -22,11 +22,11 @@ final class RemoveNodesStartAndEndResolver
|
||||
$lastEndPosition = null;
|
||||
foreach ($removedChildNodes as $removedChildNode) {
|
||||
/** @var StartAndEnd $removedPhpDocNodeInfo */
|
||||
$removedPhpDocNodeInfo = $removedChildNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::START_AND_END);
|
||||
$removedPhpDocNodeInfo = $removedChildNode->getAttribute(PhpDocAttributeKey::START_AND_END);
|
||||
// change start position to start of the line, so the whole line is removed
|
||||
$seekPosition = $removedPhpDocNodeInfo->getStart();
|
||||
while ($seekPosition >= 0 && $tokens[$seekPosition][1] !== \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_HORIZONTAL_WS) {
|
||||
if ($tokens[$seekPosition][1] === \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_PHPDOC_EOL) {
|
||||
while ($seekPosition >= 0 && $tokens[$seekPosition][1] !== Lexer::TOKEN_HORIZONTAL_WS) {
|
||||
if ($tokens[$seekPosition][1] === Lexer::TOKEN_PHPDOC_EOL) {
|
||||
break;
|
||||
}
|
||||
// do not colide
|
||||
@ -36,7 +36,7 @@ final class RemoveNodesStartAndEndResolver
|
||||
--$seekPosition;
|
||||
}
|
||||
$lastEndPosition = $removedPhpDocNodeInfo->getEnd();
|
||||
$removedNodePositions[] = new \Rector\BetterPhpDocParser\ValueObject\StartAndEnd(\max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd());
|
||||
$removedNodePositions[] = new StartAndEnd(\max(0, $seekPosition - 1), $removedPhpDocNodeInfo->getEnd());
|
||||
}
|
||||
return $removedNodePositions;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ final class NodeTypes
|
||||
/**
|
||||
* @var array<class-string<PhpDocTagValueNode>>
|
||||
*/
|
||||
public const TYPE_AWARE_NODES = [\PHPStan\PhpDocParser\Ast\PhpDoc\VarTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ReturnTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\ThrowsTagValueNode::class, \PHPStan\PhpDocParser\Ast\PhpDoc\PropertyTagValueNode::class];
|
||||
public const TYPE_AWARE_NODES = [VarTagValueNode::class, ParamTagValueNode::class, ReturnTagValueNode::class, ThrowsTagValueNode::class, PropertyTagValueNode::class];
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@ namespace Rector\BetterPhpDocParser\ValueObject\Parser;
|
||||
use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterator
|
||||
final class BetterTokenIterator extends TokenIterator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
@ -25,7 +25,7 @@ final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterat
|
||||
*/
|
||||
public function __construct(array $tokens, int $index = 0)
|
||||
{
|
||||
$this->privatesAccessor = new \RectorPrefix20210510\Symplify\PackageBuilder\Reflection\PrivatesAccessor();
|
||||
$this->privatesAccessor = new PrivatesAccessor();
|
||||
if ($tokens === []) {
|
||||
$this->privatesAccessor->setPrivateProperty($this, self::TOKENS, []);
|
||||
$this->privatesAccessor->setPrivateProperty($this, self::INDEX, 0);
|
||||
@ -76,7 +76,7 @@ final class BetterTokenIterator extends \PHPStan\PhpDocParser\Parser\TokenIterat
|
||||
public function printFromTo(int $from, int $to) : string
|
||||
{
|
||||
if ($to < $from) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException('Arguments are flipped');
|
||||
throw new ShouldNotHappenException('Arguments are flipped');
|
||||
}
|
||||
$tokens = $this->getTokens();
|
||||
$content = '';
|
||||
|
@ -8,7 +8,7 @@ use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\NodeAttributes;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode
|
||||
abstract class AbstractValuesAwareNode implements PhpDocTagValueNode
|
||||
{
|
||||
use NodeAttributes;
|
||||
/**
|
||||
@ -51,7 +51,7 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
unset($this->values[$key]);
|
||||
unset($this->values[$quotedKey]);
|
||||
// invoke reprint
|
||||
$this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
||||
$this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||
}
|
||||
/**
|
||||
* @return mixed[]
|
||||
@ -79,14 +79,14 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
{
|
||||
// is quoted?
|
||||
if (isset($this->values[$key])) {
|
||||
$isQuoted = (bool) \RectorPrefix20210510\Nette\Utils\Strings::match($this->values[$key], self::UNQUOTED_VALUE_REGEX);
|
||||
$isQuoted = (bool) Strings::match($this->values[$key], self::UNQUOTED_VALUE_REGEX);
|
||||
if ($isQuoted) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
}
|
||||
$this->values[$key] = $value;
|
||||
// invoke reprint
|
||||
$this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
||||
$this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||
}
|
||||
/**
|
||||
* @param string|int $key
|
||||
@ -106,14 +106,14 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
public function changeSilentValue($value) : void
|
||||
{
|
||||
// is quoted?
|
||||
$isQuoted = (bool) \RectorPrefix20210510\Nette\Utils\Strings::match($this->values[0], self::UNQUOTED_VALUE_REGEX);
|
||||
$isQuoted = (bool) Strings::match($this->values[0], self::UNQUOTED_VALUE_REGEX);
|
||||
if ($isQuoted) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
$this->values[0] = $value;
|
||||
$this->hasChanged = \true;
|
||||
// invoke reprint
|
||||
$this->setAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE, null);
|
||||
$this->setAttribute(PhpDocAttributeKey::ORIG_NODE, null);
|
||||
}
|
||||
/**
|
||||
* @return mixed|null
|
||||
@ -152,7 +152,7 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
if (!\is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
$matches = \RectorPrefix20210510\Nette\Utils\Strings::match($value, self::UNQUOTED_VALUE_REGEX);
|
||||
$matches = Strings::match($value, self::UNQUOTED_VALUE_REGEX);
|
||||
if ($matches === null) {
|
||||
return $value;
|
||||
}
|
||||
|
@ -5,13 +5,13 @@ namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
|
||||
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
|
||||
final class SpacingAwareTemplateTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode
|
||||
final class SpacingAwareTemplateTagValueNode extends TemplateTagValueNode
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $preposition;
|
||||
public function __construct(string $name, ?\PHPStan\PhpDocParser\Ast\Type\TypeNode $typeNode, string $description, string $preposition)
|
||||
public function __construct(string $name, ?TypeNode $typeNode, string $description, string $preposition)
|
||||
{
|
||||
parent::__construct($name, $typeNode, $description);
|
||||
$this->preposition = $preposition;
|
||||
|
@ -4,7 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
|
||||
final class VariadicAwareParamTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
|
||||
final class VariadicAwareParamTagValueNode extends ParamTagValueNode
|
||||
{
|
||||
public function __toString() : string
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ final class PhpDocAttributeKey
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PARENT = \RectorPrefix20210510\Symplify\SimplePhpDocParser\ValueObject\PhpDocAttributeKey::PARENT;
|
||||
public const PARENT = NativePhpDocAttributeKey::PARENT;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -21,5 +21,5 @@ final class PhpDocAttributeKey
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const ORIG_NODE = \RectorPrefix20210510\Symplify\SimplePhpDocParser\ValueObject\PhpDocAttributeKey::ORIG_NODE;
|
||||
public const ORIG_NODE = NativePhpDocAttributeKey::ORIG_NODE;
|
||||
}
|
||||
|
@ -10,11 +10,11 @@ use Rector\Core\Exception\ShouldNotHappenException;
|
||||
* @deprecated
|
||||
* Just for back compatibility
|
||||
*/
|
||||
abstract class AbstractTagValueNode implements \PHPStan\PhpDocParser\Ast\Node
|
||||
abstract class AbstractTagValueNode implements Node
|
||||
{
|
||||
use NodeAttributes;
|
||||
public function __toString() : string
|
||||
{
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException('Implement in child class');
|
||||
throw new ShouldNotHappenException('Implement in child class');
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ final class StartAndEnd
|
||||
public function __construct(int $start, int $end)
|
||||
{
|
||||
if ($end < $start) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
$this->start = $start;
|
||||
$this->end = $end;
|
||||
|
@ -4,7 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\BetterPhpDocParser\ValueObject\Type;
|
||||
|
||||
use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
|
||||
final class BracketsAwareIntersectionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode
|
||||
final class BracketsAwareIntersectionTypeNode extends IntersectionTypeNode
|
||||
{
|
||||
public function __toString() : string
|
||||
{
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user