diff --git a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php index ab26f5288b8..884c170ee64 100644 --- a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php @@ -9,13 +9,14 @@ use PhpParser\Node\Expr\Array_; use PhpParser\Node\Expr\MethodCall; use PhpParser\Node\Identifier; use PhpParser\Node\Stmt\ClassMethod; +use PHPStan\Analyser\Scope; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; use Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector; use Rector\CodingStyle\Reflection\VendorLocationDetector; use Rector\Core\Rector\AbstractRector; use Rector\Core\Reflection\ReflectionResolver; -use Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer; +use Rector\NodeTypeResolver\Node\AttributeKey; use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; /** @@ -38,17 +39,11 @@ final class UnSpreadOperatorRector extends \Rector\Core\Rector\AbstractRector * @var \Rector\CodingStyle\Reflection\VendorLocationDetector */ private $vendorLocationDetector; - /** - * @readonly - * @var \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer - */ - private $classChildAnalyzer; - public function __construct(\Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector $spreadVariablesCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector, \Rector\FamilyTree\NodeAnalyzer\ClassChildAnalyzer $classChildAnalyzer) + public function __construct(\Rector\CodingStyle\NodeAnalyzer\SpreadVariablesCollector $spreadVariablesCollector, \Rector\Core\Reflection\ReflectionResolver $reflectionResolver, \Rector\CodingStyle\Reflection\VendorLocationDetector $vendorLocationDetector) { $this->spreadVariablesCollector = $spreadVariablesCollector; $this->reflectionResolver = $reflectionResolver; $this->vendorLocationDetector = $vendorLocationDetector; - $this->classChildAnalyzer = $classChildAnalyzer; } public function getRuleDefinition() : \Symplify\RuleDocGenerator\ValueObject\RuleDefinition { @@ -99,15 +94,7 @@ CODE_SAMPLE } private function refactorClassMethod(\PhpParser\Node\Stmt\ClassMethod $classMethod) : ?\PhpParser\Node\Stmt\ClassMethod { - $classReflection = $this->reflectionResolver->resolveClassReflection($classMethod); - if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { - return null; - } - if ($this->isInPHPUnitTestCase($classReflection, $classMethod)) { - return null; - } - $methodName = $this->nodeNameResolver->getName($classMethod); - if ($this->classChildAnalyzer->hasParentClassMethod($classReflection, $methodName)) { + if ($this->isInPHPUnitTestCase($classMethod)) { return null; } $spreadParams = $this->spreadVariablesCollector->resolveFromClassMethod($classMethod); @@ -206,11 +193,19 @@ CODE_SAMPLE } return \false; } - private function isInPHPUnitTestCase(\PHPStan\Reflection\ClassReflection $classReflection, \PhpParser\Node\Stmt\ClassMethod $classMethod) : bool + private function isInPHPUnitTestCase(\PhpParser\Node\Stmt\ClassMethod $classMethod) : bool { + $scope = $classMethod->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::SCOPE); + if (!$scope instanceof \PHPStan\Analyser\Scope) { + return \false; + } if (!$classMethod->isPublic()) { return \false; } + $classReflection = $scope->getClassReflection(); + if (!$classReflection instanceof \PHPStan\Reflection\ClassReflection) { + return \false; + } return $classReflection->isSubclassOf('PHPUnit\\Framework\\TestCase'); } } diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index dcfe850660b..02c21469269 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -16,11 +16,11 @@ final class VersionResolver /** * @var string */ - public const PACKAGE_VERSION = '6327904617df939cbc81793cdbaab5cc726d3688'; + public const PACKAGE_VERSION = 'e978256f4d98b6c8bc8ab55cd3c590420a1d4216'; /** * @var string */ - public const RELEASE_DATE = '2022-05-04 08:51:17'; + public const RELEASE_DATE = '2022-05-04 08:51:03'; /** * @var string */ diff --git a/vendor/autoload.php b/vendor/autoload.php index 7aa8b03a775..f201b847a1e 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -9,4 +9,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4::getLoader(); +return ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index defbf730c76..3b797a2924f 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4 +class ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee { private static $loader; @@ -22,19 +22,19 @@ class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $includeFiles = \Composer\Autoload\ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$files; + $includeFiles = \Composer\Autoload\ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$files; foreach ($includeFiles as $fileIdentifier => $file) { - composerRequiref8f5ffb0bbab6536d43def1c30de86f4($fileIdentifier, $file); + composerRequired18718f34b9e5fa882f1bb073800feee($fileIdentifier, $file); } return $loader; @@ -46,7 +46,7 @@ class ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4 * @param string $file * @return void */ -function composerRequiref8f5ffb0bbab6536d43def1c30de86f4($fileIdentifier, $file) +function composerRequired18718f34b9e5fa882f1bb073800feee($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 0a6ad24870a..36afa7826a4 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4 +class ComposerStaticInitd18718f34b9e5fa882f1bb073800feee { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', @@ -3880,9 +3880,9 @@ class ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitf8f5ffb0bbab6536d43def1c30de86f4::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInitd18718f34b9e5fa882f1bb073800feee::$classMap; }, null, ClassLoader::class); } diff --git a/vendor/scoper-autoload.php b/vendor/scoper-autoload.php index 9df02f19aa4..1e6e2536120 100644 --- a/vendor/scoper-autoload.php +++ b/vendor/scoper-autoload.php @@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php'; if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { spl_autoload_call('RectorPrefix20220504\AutoloadIncluder'); } -if (!class_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false) && !interface_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false) && !trait_exists('ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4', false)) { - spl_autoload_call('RectorPrefix20220504\ComposerAutoloaderInitf8f5ffb0bbab6536d43def1c30de86f4'); +if (!class_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false) && !interface_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false) && !trait_exists('ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee', false)) { + spl_autoload_call('RectorPrefix20220504\ComposerAutoloaderInitd18718f34b9e5fa882f1bb073800feee'); } if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) { spl_autoload_call('RectorPrefix20220504\Helmich\TypoScriptParser\Parser\AST\Statement'); @@ -59,9 +59,9 @@ if (!function_exists('print_node')) { return \RectorPrefix20220504\print_node(...func_get_args()); } } -if (!function_exists('composerRequiref8f5ffb0bbab6536d43def1c30de86f4')) { - function composerRequiref8f5ffb0bbab6536d43def1c30de86f4() { - return \RectorPrefix20220504\composerRequiref8f5ffb0bbab6536d43def1c30de86f4(...func_get_args()); +if (!function_exists('composerRequired18718f34b9e5fa882f1bb073800feee')) { + function composerRequired18718f34b9e5fa882f1bb073800feee() { + return \RectorPrefix20220504\composerRequired18718f34b9e5fa882f1bb073800feee(...func_get_args()); } } if (!function_exists('scanPath')) {