From ec1aef0b55c0fd10a5ce67b05c579f8d18a00d20 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 7 Aug 2023 09:47:53 +0000 Subject: [PATCH] Updated Rector to commit bb2e1e5fc0d15c83cd9df52d7fe6da22c1bb169d https://github.com/rectorphp/rector-src/commit/bb2e1e5fc0d15c83cd9df52d7fe6da22c1bb169d [NodeAnalyzer] Pass ReflectionProvider to __construct() on CallAnalyzer (#4699) --- .../SimplifyUselessVariableRector.php | 11 ++--------- src/Application/VersionResolver.php | 4 ++-- src/NodeAnalyzer/CallAnalyzer.php | 15 ++++++++++++--- vendor/autoload.php | 2 +- vendor/composer/autoload_real.php | 10 +++++----- vendor/composer/autoload_static.php | 8 ++++---- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php index 36f298583d1..5b71f57773b 100644 --- a/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php +++ b/rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php @@ -13,7 +13,6 @@ use PhpParser\Node\Stmt\Expression; use PhpParser\Node\Stmt\Return_; use PHPStan\Analyser\Scope; use PHPStan\Reflection\FunctionReflection; -use PHPStan\Reflection\ReflectionProvider; use PHPStan\Type\MixedType; use Rector\Core\Contract\PhpParser\Node\StmtsAwareInterface; use Rector\Core\NodeAnalyzer\CallAnalyzer; @@ -43,17 +42,11 @@ final class SimplifyUselessVariableRector extends AbstractScopeAwareRector * @var \Rector\Core\NodeAnalyzer\CallAnalyzer */ private $callAnalyzer; - /** - * @readonly - * @var \PHPStan\Reflection\ReflectionProvider - */ - private $reflectionProvider; - public function __construct(AssignAndBinaryMap $assignAndBinaryMap, VariableAnalyzer $variableAnalyzer, CallAnalyzer $callAnalyzer, ReflectionProvider $reflectionProvider) + public function __construct(AssignAndBinaryMap $assignAndBinaryMap, VariableAnalyzer $variableAnalyzer, CallAnalyzer $callAnalyzer) { $this->assignAndBinaryMap = $assignAndBinaryMap; $this->variableAnalyzer = $variableAnalyzer; $this->callAnalyzer = $callAnalyzer; - $this->reflectionProvider = $reflectionProvider; } public function getRuleDefinition() : RuleDefinition { @@ -157,7 +150,7 @@ CODE_SAMPLE } /** @var Variable $previousVar */ $previousVar = $previousNode->var; - if ($this->callAnalyzer->isNewInstance($previousVar, $this->reflectionProvider)) { + if ($this->callAnalyzer->isNewInstance($previousVar)) { return \true; } return $this->variableAnalyzer->isUsedByReference($variable); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index b8eaf610af0..3e73c9573ec 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '97214e0856d96bdc8e4536746fcaca0b5bc27be1'; + public const PACKAGE_VERSION = 'bb2e1e5fc0d15c83cd9df52d7fe6da22c1bb169d'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-07 12:26:56'; + public const RELEASE_DATE = '2023-08-07 16:44:11'; /** * @var int */ diff --git a/src/NodeAnalyzer/CallAnalyzer.php b/src/NodeAnalyzer/CallAnalyzer.php index b3ff6512293..604f513a8e6 100644 --- a/src/NodeAnalyzer/CallAnalyzer.php +++ b/src/NodeAnalyzer/CallAnalyzer.php @@ -17,10 +17,19 @@ use PHPStan\Type\ObjectType; use Rector\NodeTypeResolver\Node\AttributeKey; final class CallAnalyzer { + /** + * @readonly + * @var \PHPStan\Reflection\ReflectionProvider + */ + private $reflectionProvider; /** * @var array> */ private const OBJECT_CALL_TYPES = [MethodCall::class, NullsafeMethodCall::class, StaticCall::class]; + public function __construct(ReflectionProvider $reflectionProvider) + { + $this->reflectionProvider = $reflectionProvider; + } public function isObjectCall(Expr $expr) : bool { if ($expr instanceof BooleanNot) { @@ -50,7 +59,7 @@ final class CallAnalyzer } return \false; } - public function isNewInstance(Variable $variable, ReflectionProvider $reflectionProvider) : bool + public function isNewInstance(Variable $variable) : bool { $scope = $variable->getAttribute(AttributeKey::SCOPE); if (!$scope instanceof Scope) { @@ -61,10 +70,10 @@ final class CallAnalyzer return \false; } $className = $type->getClassName(); - if (!$reflectionProvider->hasClass($className)) { + if (!$this->reflectionProvider->hasClass($className)) { return \false; } - $classReflection = $reflectionProvider->getClass($className); + $classReflection = $this->reflectionProvider->getClass($className); return $classReflection->getNativeReflection()->isInstantiable(); } } diff --git a/vendor/autoload.php b/vendor/autoload.php index 982da97ba52..ecf004abe2b 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6::getLoader(); +return ComposerAutoloaderInit634b45217e6bbd035de9cf3ebf93b76d::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 1ba99dff724..b6a9ca60c54 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6 +class ComposerAutoloaderInit634b45217e6bbd035de9cf3ebf93b76d { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit634b45217e6bbd035de9cf3ebf93b76d', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit634b45217e6bbd035de9cf3ebf93b76d', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d::$files; $requireFile = \Closure::bind(static function ($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 09a25b55642..a2e3647ad47 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6 +class ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3010,9 +3010,9 @@ class ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit634b45217e6bbd035de9cf3ebf93b76d::$classMap; }, null, ClassLoader::class); }