mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-20 07:19:47 +01:00
Updated Rector to commit bb2e1e5fc0d15c83cd9df52d7fe6da22c1bb169d
bb2e1e5fc0
[NodeAnalyzer] Pass ReflectionProvider to __construct() on CallAnalyzer (#4699)
This commit is contained in:
parent
197a05c117
commit
ec1aef0b55
rules/CodeQuality/Rector/FunctionLike
src
vendor
@ -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);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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<class-string<Expr>>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6::getLoader();
|
||||
return ComposerAutoloaderInit634b45217e6bbd035de9cf3ebf93b76d::getLoader();
|
||||
|
10
vendor/composer/autoload_real.php
vendored
10
vendor/composer/autoload_real.php
vendored
@ -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;
|
||||
|
8
vendor/composer/autoload_static.php
vendored
8
vendor/composer/autoload_static.php
vendored
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user