Updated Rector to commit 97214e0856d96bdc8e4536746fcaca0b5bc27be1

97214e0856 [NodeAnalyzer] Remove #[Required] on CallAnalyzer (#4697)
This commit is contained in:
Tomas Votruba 2023-08-07 05:31:14 +00:00
parent fa20ce4ba0
commit 197a05c117
6 changed files with 24 additions and 34 deletions

View File

@ -139,8 +139,6 @@ CODE_SAMPLE
if ($return->getAttribute(AttributeKey::IS_BYREF_RETURN) === \true) {
return \true;
}
/** @var Variable $variable */
$variable = $return->expr;
if (!$previousStmt instanceof Expression) {
return \true;
}
@ -149,6 +147,7 @@ CODE_SAMPLE
if (!$previousNode instanceof AssignOp && !$previousNode instanceof Assign) {
return \true;
}
$variable = $return->expr;
// is the same variable
if (!$this->nodeComparator->areNodesEqual($previousNode->var, $variable)) {
return \true;
@ -156,7 +155,9 @@ CODE_SAMPLE
if ($this->variableAnalyzer->isStaticOrGlobal($variable)) {
return \true;
}
if ($this->callAnalyzer->isNewInstance($previousNode->var, $this->reflectionProvider)) {
/** @var Variable $previousVar */
$previousVar = $previousNode->var;
if ($this->callAnalyzer->isNewInstance($previousVar, $this->reflectionProvider)) {
return \true;
}
return $this->variableAnalyzer->isUsedByReference($variable);

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'bb284f658574249ce2f2da444b8c0d982b811819';
public const PACKAGE_VERSION = '97214e0856d96bdc8e4536746fcaca0b5bc27be1';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2023-08-07 12:06:43';
public const RELEASE_DATE = '2023-08-07 12:26:56';
/**
* @var int
*/

View File

@ -6,33 +6,21 @@ namespace Rector\Core\NodeAnalyzer;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\BinaryOp;
use PhpParser\Node\Expr\BooleanNot;
use PhpParser\Node\Expr\Clone_;
use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Expr\NullsafeMethodCall;
use PhpParser\Node\Expr\StaticCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Stmt\If_;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ReflectionProvider;
use PHPStan\Type\ObjectType;
use Rector\NodeTypeResolver\NodeTypeResolver;
use RectorPrefix202308\Symfony\Contracts\Service\Attribute\Required;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class CallAnalyzer
{
/**
* @var array<class-string<Expr>>
*/
private const OBJECT_CALL_TYPES = [MethodCall::class, NullsafeMethodCall::class, StaticCall::class];
/**
* @var \Rector\NodeTypeResolver\NodeTypeResolver
*/
private $nodeTypeResolver;
/**
* @required
*/
public function autowire(NodeTypeResolver $nodeTypeResolver) : void
{
$this->nodeTypeResolver = $nodeTypeResolver;
}
public function isObjectCall(Expr $expr) : bool
{
if ($expr instanceof BooleanNot) {
@ -62,12 +50,13 @@ final class CallAnalyzer
}
return \false;
}
public function isNewInstance(Expr $expr, ReflectionProvider $reflectionProvider) : bool
public function isNewInstance(Variable $variable, ReflectionProvider $reflectionProvider) : bool
{
if ($expr instanceof Clone_ || $expr instanceof New_) {
return \true;
$scope = $variable->getAttribute(AttributeKey::SCOPE);
if (!$scope instanceof Scope) {
return \false;
}
$type = $this->nodeTypeResolver->getType($expr);
$type = $scope->getNativeType($variable);
if (!$type instanceof ObjectType) {
return \false;
}

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit4013706d2dd11978b824fafafdd023d2::getLoader();
return ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit4013706d2dd11978b824fafafdd023d2
class ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit4013706d2dd11978b824fafafdd023d2
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit4013706d2dd11978b824fafafdd023d2', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit4013706d2dd11978b824fafafdd023d2', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit5d5c52751c7ce5eebc329749e6026db6', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit4013706d2dd11978b824fafafdd023d2::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit4013706d2dd11978b824fafafdd023d2::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit4013706d2dd11978b824fafafdd023d2
class ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -3010,9 +3010,9 @@ class ComposerStaticInit4013706d2dd11978b824fafafdd023d2
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit4013706d2dd11978b824fafafdd023d2::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit4013706d2dd11978b824fafafdd023d2::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit4013706d2dd11978b824fafafdd023d2::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5d5c52751c7ce5eebc329749e6026db6::$classMap;
}, null, ClassLoader::class);
}