mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-04 02:10:51 +00:00
Updated Rector to commit e1188e9bff
e1188e9bff
[DeadCode] Skip has return reassign Coalesce Op on RemoveUnusedPrivatePropertyRector (#2477)
This commit is contained in:
parent
dd31e833a9
commit
7800c7ad15
|
@ -75,7 +75,8 @@ final class ComplexNodeRemover
|
|||
{
|
||||
$propertyName = $this->nodeNameResolver->getName($property);
|
||||
$totalPropertyFetch = $this->propertyFetchAnalyzer->countLocalPropertyFetchName($class, $propertyName);
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (Node $node) use($removeAssignSideEffect, $propertyName, &$totalPropertyFetch) : ?Node {
|
||||
$expressions = [];
|
||||
$this->simpleCallableNodeTraverser->traverseNodesWithCallable($class->stmts, function (Node $node) use($removeAssignSideEffect, $propertyName, &$totalPropertyFetch, &$expressions) : ?Node {
|
||||
// here should be checked all expr like stmts that can hold assign, e.f. if, foreach etc. etc.
|
||||
if (!$node instanceof Expression) {
|
||||
return null;
|
||||
|
@ -108,8 +109,7 @@ final class ComplexNodeRemover
|
|||
}
|
||||
}
|
||||
if ($totalPropertyFetch < $currentTotalPropertyFetch) {
|
||||
$this->nodeRemover->removeNode($node);
|
||||
return $node;
|
||||
$expressions[] = $node;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
@ -118,6 +118,7 @@ final class ComplexNodeRemover
|
|||
return \false;
|
||||
}
|
||||
$this->removeConstructorDependency($class, $propertyName);
|
||||
$this->nodeRemover->removeNodes($expressions);
|
||||
$this->nodeRemover->removeNode($property);
|
||||
return \true;
|
||||
}
|
||||
|
|
|
@ -16,11 +16,11 @@ final class VersionResolver
|
|||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'ce1c29184d943c5626b4461b6314f18701898b82';
|
||||
public const PACKAGE_VERSION = 'e1188e9bffd33b902b51de71a3c2cf06ce48b9e2';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2022-06-11 14:21:30';
|
||||
public const RELEASE_DATE = '2022-06-11 15:58:17';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) {
|
|||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27::getLoader();
|
||||
return ComposerAutoloaderInit376f3b17c6c2bb014736d4c6d3cb06cf::getLoader();
|
||||
|
|
6
vendor/composer/autoload_classmap.php
vendored
6
vendor/composer/autoload_classmap.php
vendored
|
@ -2770,8 +2770,10 @@ return array(
|
|||
'Rector\\Symfony\\Exception\\XmlContainerNotExistsException' => $vendorDir . '/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php',
|
||||
'Rector\\Symfony\\FormHelper\\FormTypeStringToTypeProvider' => $vendorDir . '/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php',
|
||||
'Rector\\Symfony\\Helper\\TemplateGuesser' => $vendorDir . '/rector/rector-symfony/src/Helper/TemplateGuesser.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\ClassAnnotationAssertResolver' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/ClassAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\MethodCallAnnotationAssertResolver' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/MethodCallAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\PropertyAnnotationAssertResolver' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/PropertyAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\StmtMethodCallMatcher' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/StmtMethodCallMatcher.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\DependencyInjectionMethodCallAnalyzer' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\FormAddMethodCallAnalyzer' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\FormCollectionAnalyzer' => $vendorDir . '/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php',
|
||||
|
@ -2879,20 +2881,20 @@ return array(
|
|||
'Rector\\Symfony\\TypeAnalyzer\\JMSDITypeResolver' => $vendorDir . '/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php',
|
||||
'Rector\\Symfony\\TypeDeclaration\\ReturnTypeDeclarationUpdater' => $vendorDir . '/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php',
|
||||
'Rector\\Symfony\\ValueObjectFactory\\ServiceMapFactory' => $vendorDir . '/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php',
|
||||
'Rector\\Symfony\\ValueObject\\ClassMethodAndAnnotation' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ClassMethodAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyRequestConstantMap' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyResponseConstantMap' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventNameToClassAndConstant' => $vendorDir . '/rector/rector-symfony/src/ValueObject/EventNameToClassAndConstant.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventReferenceToMethodName' => $vendorDir . '/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventReferenceToMethodNameWithPriority' => $vendorDir . '/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php',
|
||||
'Rector\\Symfony\\ValueObject\\InvokableController\\ActiveClassElements' => $vendorDir . '/rector/rector-symfony/src/ValueObject/InvokableController/ActiveClassElements.php',
|
||||
'Rector\\Symfony\\ValueObject\\PropertyAndAnnotation' => $vendorDir . '/rector/rector-symfony/src/ValueObject/PropertyAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ReplaceServiceArgument' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php',
|
||||
'Rector\\Symfony\\ValueObject\\ServiceDefinition' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ServiceDefinition.php',
|
||||
'Rector\\Symfony\\ValueObject\\ServiceMap\\ServiceMap' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\SymfonyRouteMetadata' => $vendorDir . '/rector/rector-symfony/src/ValueObject/SymfonyRouteMetadata.php',
|
||||
'Rector\\Symfony\\ValueObject\\Tag' => $vendorDir . '/rector/rector-symfony/src/ValueObject/Tag.php',
|
||||
'Rector\\Symfony\\ValueObject\\Tag\\EventListenerTag' => $vendorDir . '/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php',
|
||||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\ClassMethodAndAnnotation' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/ClassMethodAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\PropertyAndAnnotation' => $vendorDir . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/PropertyAndAnnotation.php',
|
||||
'Rector\\Testing\\Contract\\RectorTestInterface' => $baseDir . '/packages/Testing/Contract/RectorTestInterface.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => $baseDir . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractTestCase' => $baseDir . '/packages/Testing/PHPUnit/AbstractTestCase.php',
|
||||
|
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27
|
||||
class ComposerAutoloaderInit376f3b17c6c2bb014736d4c6d3cb06cf
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -22,19 +22,19 @@ class ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit376f3b17c6c2bb014736d4c6d3cb06cf', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit376f3b17c6c2bb014736d4c6d3cb06cf', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27::$files;
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequirebefe56bb1d3fefbcab50ce5415e9cd27($fileIdentifier, $file);
|
||||
composerRequire376f3b17c6c2bb014736d4c6d3cb06cf($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
|
@ -46,7 +46,7 @@ class ComposerAutoloaderInitbefe56bb1d3fefbcab50ce5415e9cd27
|
|||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequirebefe56bb1d3fefbcab50ce5415e9cd27($fileIdentifier, $file)
|
||||
function composerRequire376f3b17c6c2bb014736d4c6d3cb06cf($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
|
14
vendor/composer/autoload_static.php
vendored
14
vendor/composer/autoload_static.php
vendored
|
@ -4,7 +4,7 @@
|
|||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27
|
||||
class ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf
|
||||
{
|
||||
public static $files = array (
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
|
@ -3071,8 +3071,10 @@ class ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27
|
|||
'Rector\\Symfony\\Exception\\XmlContainerNotExistsException' => __DIR__ . '/..' . '/rector/rector-symfony/src/Exception/XmlContainerNotExistsException.php',
|
||||
'Rector\\Symfony\\FormHelper\\FormTypeStringToTypeProvider' => __DIR__ . '/..' . '/rector/rector-symfony/src/FormHelper/FormTypeStringToTypeProvider.php',
|
||||
'Rector\\Symfony\\Helper\\TemplateGuesser' => __DIR__ . '/..' . '/rector/rector-symfony/src/Helper/TemplateGuesser.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\ClassAnnotationAssertResolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/ClassAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\MethodCallAnnotationAssertResolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/MethodCallAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\PropertyAnnotationAssertResolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/PropertyAnnotationAssertResolver.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\Annotations\\StmtMethodCallMatcher' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/Annotations/StmtMethodCallMatcher.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\DependencyInjectionMethodCallAnalyzer' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/DependencyInjectionMethodCallAnalyzer.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\FormAddMethodCallAnalyzer' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/FormAddMethodCallAnalyzer.php',
|
||||
'Rector\\Symfony\\NodeAnalyzer\\FormCollectionAnalyzer' => __DIR__ . '/..' . '/rector/rector-symfony/src/NodeAnalyzer/FormCollectionAnalyzer.php',
|
||||
|
@ -3180,20 +3182,20 @@ class ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27
|
|||
'Rector\\Symfony\\TypeAnalyzer\\JMSDITypeResolver' => __DIR__ . '/..' . '/rector/rector-symfony/src/TypeAnalyzer/JMSDITypeResolver.php',
|
||||
'Rector\\Symfony\\TypeDeclaration\\ReturnTypeDeclarationUpdater' => __DIR__ . '/..' . '/rector/rector-symfony/src/TypeDeclaration/ReturnTypeDeclarationUpdater.php',
|
||||
'Rector\\Symfony\\ValueObjectFactory\\ServiceMapFactory' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObjectFactory/ServiceMapFactory.php',
|
||||
'Rector\\Symfony\\ValueObject\\ClassMethodAndAnnotation' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ClassMethodAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyRequestConstantMap' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyRequestConstantMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\ConstantMap\\SymfonyResponseConstantMap' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ConstantMap/SymfonyResponseConstantMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventNameToClassAndConstant' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/EventNameToClassAndConstant.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventReferenceToMethodName' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/EventReferenceToMethodName.php',
|
||||
'Rector\\Symfony\\ValueObject\\EventReferenceToMethodNameWithPriority' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/EventReferenceToMethodNameWithPriority.php',
|
||||
'Rector\\Symfony\\ValueObject\\InvokableController\\ActiveClassElements' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/InvokableController/ActiveClassElements.php',
|
||||
'Rector\\Symfony\\ValueObject\\PropertyAndAnnotation' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/PropertyAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ReplaceServiceArgument' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ReplaceServiceArgument.php',
|
||||
'Rector\\Symfony\\ValueObject\\ServiceDefinition' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ServiceDefinition.php',
|
||||
'Rector\\Symfony\\ValueObject\\ServiceMap\\ServiceMap' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ServiceMap/ServiceMap.php',
|
||||
'Rector\\Symfony\\ValueObject\\SymfonyRouteMetadata' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/SymfonyRouteMetadata.php',
|
||||
'Rector\\Symfony\\ValueObject\\Tag' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/Tag.php',
|
||||
'Rector\\Symfony\\ValueObject\\Tag\\EventListenerTag' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/Tag/EventListenerTag.php',
|
||||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\ClassMethodAndAnnotation' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/ClassMethodAndAnnotation.php',
|
||||
'Rector\\Symfony\\ValueObject\\ValidatorAssert\\PropertyAndAnnotation' => __DIR__ . '/..' . '/rector/rector-symfony/src/ValueObject/ValidatorAssert/PropertyAndAnnotation.php',
|
||||
'Rector\\Testing\\Contract\\RectorTestInterface' => __DIR__ . '/../..' . '/packages/Testing/Contract/RectorTestInterface.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractRectorTestCase' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/AbstractRectorTestCase.php',
|
||||
'Rector\\Testing\\PHPUnit\\AbstractTestCase' => __DIR__ . '/../..' . '/packages/Testing/PHPUnit/AbstractTestCase.php',
|
||||
|
@ -3393,9 +3395,9 @@ class ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27
|
|||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInitbefe56bb1d3fefbcab50ce5415e9cd27::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit376f3b17c6c2bb014736d4c6d3cb06cf::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
|
@ -2347,12 +2347,12 @@
|
|||
"source": {
|
||||
"type": "git",
|
||||
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
|
||||
"reference": "86505d3316684056b2c91abcaa547b2caf15d2c0"
|
||||
"reference": "b77392f892061519caeb3c533a957bcfb08bf440"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/86505d3316684056b2c91abcaa547b2caf15d2c0",
|
||||
"reference": "86505d3316684056b2c91abcaa547b2caf15d2c0",
|
||||
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/b77392f892061519caeb3c533a957bcfb08bf440",
|
||||
"reference": "b77392f892061519caeb3c533a957bcfb08bf440",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -2381,7 +2381,7 @@
|
|||
"symplify\/rule-doc-generator": "^10.2",
|
||||
"symplify\/vendor-patches": "^10.2"
|
||||
},
|
||||
"time": "2022-06-11T12:14:45+00:00",
|
||||
"time": "2022-06-11T13:01:13+00:00",
|
||||
"default-branch": true,
|
||||
"type": "rector-extension",
|
||||
"extra": {
|
||||
|
|
2
vendor/composer/installed.php
vendored
2
vendor/composer/installed.php
vendored
File diff suppressed because one or more lines are too long
|
@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
|
|||
*/
|
||||
final class GeneratedConfig
|
||||
{
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f84ea17'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b695bf6'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 623c9e2'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1194b1b'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f29fa56'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 15ee440'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b220a7f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 86505d3'));
|
||||
public const EXTENSIONS = array('rector/rector-cakephp' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-cakephp', 'relative_install_path' => '../../rector-cakephp', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f84ea17'), 'rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b695bf6'), 'rector/rector-generator' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-generator', 'relative_install_path' => '../../rector-generator', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 623c9e2'), 'rector/rector-laravel' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-laravel', 'relative_install_path' => '../../rector-laravel', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 1194b1b'), 'rector/rector-nette' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-nette', 'relative_install_path' => '../../rector-nette', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main f29fa56'), 'rector/rector-phpoffice' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpoffice', 'relative_install_path' => '../../rector-phpoffice', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main 15ee440'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b220a7f'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => array('includes' => array(0 => 'config/config.php')), 'version' => 'dev-main b77392f'));
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
|
42
vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ClassAnnotationAssertResolver.php
vendored
Normal file
42
vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/ClassAnnotationAssertResolver.php
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\NodeAnalyzer\Annotations;
|
||||
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\Core\Exception\NotImplementedYetException;
|
||||
use Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory;
|
||||
final class ClassAnnotationAssertResolver
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher
|
||||
*/
|
||||
private $stmtMethodCallMatcher;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory
|
||||
*/
|
||||
private $doctrineAnnotationFromNewFactory;
|
||||
public function __construct(\Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher $stmtMethodCallMatcher, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory)
|
||||
{
|
||||
$this->stmtMethodCallMatcher = $stmtMethodCallMatcher;
|
||||
$this->doctrineAnnotationFromNewFactory = $doctrineAnnotationFromNewFactory;
|
||||
}
|
||||
public function resolve(Stmt $stmt) : ?DoctrineAnnotationTagValueNode
|
||||
{
|
||||
$methodCall = $this->stmtMethodCallMatcher->match($stmt, 'addConstraint');
|
||||
if (!$methodCall instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$args = $methodCall->getArgs();
|
||||
$firstArgValue = $args[0]->value;
|
||||
if (!$firstArgValue instanceof New_) {
|
||||
throw new NotImplementedYetException();
|
||||
}
|
||||
return $this->doctrineAnnotationFromNewFactory->create($firstArgValue);
|
||||
}
|
||||
}
|
|
@ -6,18 +6,11 @@ namespace Rector\Symfony\NodeAnalyzer\Annotations;
|
|||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory;
|
||||
use Rector\Symfony\ValueObject\ClassMethodAndAnnotation;
|
||||
use Rector\Symfony\ValueObject\ValidatorAssert\ClassMethodAndAnnotation;
|
||||
final class MethodCallAnnotationAssertResolver
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Core\PhpParser\Node\Value\ValueResolver
|
||||
|
@ -28,22 +21,21 @@ final class MethodCallAnnotationAssertResolver
|
|||
* @var \Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory
|
||||
*/
|
||||
private $doctrineAnnotationFromNewFactory;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver, ValueResolver $valueResolver, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher
|
||||
*/
|
||||
private $stmtMethodCallMatcher;
|
||||
public function __construct(ValueResolver $valueResolver, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory, \Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher $stmtMethodCallMatcher)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->doctrineAnnotationFromNewFactory = $doctrineAnnotationFromNewFactory;
|
||||
$this->stmtMethodCallMatcher = $stmtMethodCallMatcher;
|
||||
}
|
||||
public function resolve(Stmt $stmt) : ?ClassMethodAndAnnotation
|
||||
{
|
||||
if (!$stmt instanceof Expression) {
|
||||
return null;
|
||||
}
|
||||
if (!$stmt->expr instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$methodCall = $stmt->expr;
|
||||
if (!$this->nodeNameResolver->isName($methodCall->name, 'addGetterConstraint')) {
|
||||
$methodCall = $this->stmtMethodCallMatcher->match($stmt, 'addGetterConstraint');
|
||||
if (!$methodCall instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$args = $methodCall->getArgs();
|
||||
|
|
|
@ -6,11 +6,9 @@ namespace Rector\Symfony\NodeAnalyzer\Annotations;
|
|||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\Symfony\NodeFactory\Annotations\DoctrineAnnotationFromNewFactory;
|
||||
use Rector\Symfony\ValueObject\PropertyAndAnnotation;
|
||||
use Rector\Symfony\ValueObject\ValidatorAssert\PropertyAndAnnotation;
|
||||
final class PropertyAnnotationAssertResolver
|
||||
{
|
||||
/**
|
||||
|
@ -25,25 +23,19 @@ final class PropertyAnnotationAssertResolver
|
|||
private $doctrineAnnotationFromNewFactory;
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
* @var \Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(ValueResolver $valueResolver, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory, NodeNameResolver $nodeNameResolver)
|
||||
private $stmtMethodCallMatcher;
|
||||
public function __construct(ValueResolver $valueResolver, DoctrineAnnotationFromNewFactory $doctrineAnnotationFromNewFactory, \Rector\Symfony\NodeAnalyzer\Annotations\StmtMethodCallMatcher $stmtMethodCallMatcher)
|
||||
{
|
||||
$this->valueResolver = $valueResolver;
|
||||
$this->doctrineAnnotationFromNewFactory = $doctrineAnnotationFromNewFactory;
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
$this->stmtMethodCallMatcher = $stmtMethodCallMatcher;
|
||||
}
|
||||
public function resolve(Stmt $stmt) : ?PropertyAndAnnotation
|
||||
{
|
||||
if (!$stmt instanceof Expression) {
|
||||
return null;
|
||||
}
|
||||
if (!$stmt->expr instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$methodCall = $stmt->expr;
|
||||
if (!$this->nodeNameResolver->isName($methodCall->name, 'addPropertyConstraint')) {
|
||||
$methodCall = $this->stmtMethodCallMatcher->match($stmt, 'addPropertyConstraint');
|
||||
if (!$methodCall instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$args = $methodCall->getArgs();
|
||||
|
|
35
vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/StmtMethodCallMatcher.php
vendored
Normal file
35
vendor/rector/rector-symfony/src/NodeAnalyzer/Annotations/StmtMethodCallMatcher.php
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\NodeAnalyzer\Annotations;
|
||||
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
final class StmtMethodCallMatcher
|
||||
{
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\NodeNameResolver\NodeNameResolver
|
||||
*/
|
||||
private $nodeNameResolver;
|
||||
public function __construct(NodeNameResolver $nodeNameResolver)
|
||||
{
|
||||
$this->nodeNameResolver = $nodeNameResolver;
|
||||
}
|
||||
public function match(Stmt $stmt, string $methodName) : ?MethodCall
|
||||
{
|
||||
if (!$stmt instanceof Expression) {
|
||||
return null;
|
||||
}
|
||||
if (!$stmt->expr instanceof MethodCall) {
|
||||
return null;
|
||||
}
|
||||
$methodCall = $stmt->expr;
|
||||
if (!$this->nodeNameResolver->isName($methodCall->name, $methodName)) {
|
||||
return null;
|
||||
}
|
||||
return $methodCall;
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ final class DoctrineAnnotationKeyToValuesResolver
|
|||
$this->valueResolver = $valueResolver;
|
||||
}
|
||||
/**
|
||||
* @return array<string|null, mixed>
|
||||
* @return array<string|null, mixed>|mixed[]
|
||||
*/
|
||||
public function resolveFromExpr(Expr $expr) : array
|
||||
{
|
||||
|
@ -35,6 +35,10 @@ final class DoctrineAnnotationKeyToValuesResolver
|
|||
$value = $this->wrapStringValuesInQuotes($value, $key);
|
||||
$annotationKeyToValues[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
$singleValue = $this->valueResolver->getValue($expr);
|
||||
$singleValue = $this->wrapStringValuesInQuotes($singleValue, null);
|
||||
return [$singleValue];
|
||||
}
|
||||
return $annotationKeyToValues;
|
||||
}
|
||||
|
|
|
@ -7,11 +7,13 @@ use PhpParser\Node;
|
|||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Property;
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Symfony\NodeAnalyzer\Annotations\ClassAnnotationAssertResolver;
|
||||
use Rector\Symfony\NodeAnalyzer\Annotations\MethodCallAnnotationAssertResolver;
|
||||
use Rector\Symfony\NodeAnalyzer\Annotations\PropertyAnnotationAssertResolver;
|
||||
use Rector\Symfony\ValueObject\ClassMethodAndAnnotation;
|
||||
use Rector\Symfony\ValueObject\PropertyAndAnnotation;
|
||||
use Rector\Symfony\ValueObject\ValidatorAssert\ClassMethodAndAnnotation;
|
||||
use Rector\Symfony\ValueObject\ValidatorAssert\PropertyAndAnnotation;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
|
@ -32,10 +34,16 @@ final class LoadValidatorMetadataToAnnotationRector extends AbstractRector
|
|||
* @var \Rector\Symfony\NodeAnalyzer\Annotations\PropertyAnnotationAssertResolver
|
||||
*/
|
||||
private $propertyAnnotationAssertResolver;
|
||||
public function __construct(MethodCallAnnotationAssertResolver $methodCallAnnotationAssertResolver, PropertyAnnotationAssertResolver $propertyAnnotationAssertResolver)
|
||||
/**
|
||||
* @readonly
|
||||
* @var \Rector\Symfony\NodeAnalyzer\Annotations\ClassAnnotationAssertResolver
|
||||
*/
|
||||
private $classAnnotationAssertResolver;
|
||||
public function __construct(MethodCallAnnotationAssertResolver $methodCallAnnotationAssertResolver, PropertyAnnotationAssertResolver $propertyAnnotationAssertResolver, ClassAnnotationAssertResolver $classAnnotationAssertResolver)
|
||||
{
|
||||
$this->methodCallAnnotationAssertResolver = $methodCallAnnotationAssertResolver;
|
||||
$this->propertyAnnotationAssertResolver = $propertyAnnotationAssertResolver;
|
||||
$this->classAnnotationAssertResolver = $classAnnotationAssertResolver;
|
||||
}
|
||||
public function getRuleDefinition() : RuleDefinition
|
||||
{
|
||||
|
@ -86,10 +94,17 @@ CODE_SAMPLE
|
|||
return null;
|
||||
}
|
||||
foreach ((array) $loadValidatorMetadataClassMethod->stmts as $stmtKey => $classStmt) {
|
||||
// 1. class
|
||||
$doctrineAnnotationTagValueNode = $this->classAnnotationAssertResolver->resolve($classStmt);
|
||||
if ($doctrineAnnotationTagValueNode instanceof DoctrineAnnotationTagValueNode) {
|
||||
$this->refactorClassAnnotation($node, $doctrineAnnotationTagValueNode, $loadValidatorMetadataClassMethod, $stmtKey);
|
||||
}
|
||||
// 2. class methods
|
||||
$classMethodAndAnnotation = $this->methodCallAnnotationAssertResolver->resolve($classStmt);
|
||||
if ($classMethodAndAnnotation instanceof ClassMethodAndAnnotation) {
|
||||
$this->refactorClassMethodAndAnnotation($node, $classMethodAndAnnotation, $loadValidatorMetadataClassMethod, $stmtKey);
|
||||
}
|
||||
// 3. properties
|
||||
$propertyAndAnnotation = $this->propertyAnnotationAssertResolver->resolve($classStmt);
|
||||
if ($propertyAndAnnotation instanceof PropertyAndAnnotation) {
|
||||
$this->refactorPropertyAndAnnotation($node, $propertyAndAnnotation, $loadValidatorMetadataClassMethod, $stmtKey);
|
||||
|
@ -121,4 +136,10 @@ CODE_SAMPLE
|
|||
$propertyPhpDocInfo->addTagValueNode($propertyAndAnnotation->getDoctrineAnnotationTagValueNode());
|
||||
unset($loadValidatorMetadataClassMethod->stmts[$stmtKey]);
|
||||
}
|
||||
private function refactorClassAnnotation(Class_ $class, DoctrineAnnotationTagValueNode $doctrineAnnotationTagValueNode, ClassMethod $loadValidatorMetadataClassMethod, int $stmtKey) : void
|
||||
{
|
||||
$classPhpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($class);
|
||||
$classPhpDocInfo->addTagValueNode($doctrineAnnotationTagValueNode);
|
||||
unset($loadValidatorMetadataClassMethod->stmts[$stmtKey]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\ValueObject;
|
||||
namespace Rector\Symfony\ValueObject\ValidatorAssert;
|
||||
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
final class ClassMethodAndAnnotation
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Symfony\ValueObject;
|
||||
namespace Rector\Symfony\ValueObject\ValidatorAssert;
|
||||
|
||||
use Rector\BetterPhpDocParser\PhpDoc\DoctrineAnnotationTagValueNode;
|
||||
final class PropertyAndAnnotation
|
Loading…
Reference in New Issue
Block a user