mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-14 12:29:43 +01:00
Updated Rector to commit 9e8925edfd766a78d2cc20684863899d64df9586
9e8925edfd
[TypeDeclaration] Remove parent attribute on ObjectTypeSpecifier (#4290)
This commit is contained in:
parent
2db1132a3e
commit
f9aed43e7b
@ -200,4 +200,8 @@ final class AttributeKey
|
||||
* @var string
|
||||
*/
|
||||
public const IS_ARRAY_IN_ATTRIBUTE = 'is_array_in_attribute';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const IS_OBJECT_CALLER = 'is_object_caller';
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\NodeVisitorAbstract;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\Contract\NodeVisitor\ScopeResolverNodeVisitorInterface;
|
||||
final class ObjectNodeVisitor extends NodeVisitorAbstract implements ScopeResolverNodeVisitorInterface
|
||||
{
|
||||
public function enterNode(Node $node) : ?Node
|
||||
{
|
||||
if ($node instanceof MethodCall) {
|
||||
$node->var->setAttribute(AttributeKey::IS_OBJECT_CALLER, \true);
|
||||
return null;
|
||||
}
|
||||
if ($node instanceof StaticCall) {
|
||||
$node->class->setAttribute(AttributeKey::IS_OBJECT_CALLER, \true);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -5,8 +5,6 @@ namespace Rector\TypeDeclaration\PHPStan;
|
||||
|
||||
use RectorPrefix202306\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\GroupUse;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
@ -93,7 +91,7 @@ final class ObjectTypeSpecifier
|
||||
return null;
|
||||
}
|
||||
$className = $objectType->getClassName();
|
||||
$parentNode = $node->getAttribute(AttributeKey::PARENT_NODE);
|
||||
$isObjectCaller = $node->getAttribute(AttributeKey::IS_OBJECT_CALLER) === \true;
|
||||
foreach ($uses as $use) {
|
||||
$prefix = $this->useImportsResolver->resolvePrefix($use);
|
||||
foreach ($use->uses as $useUse) {
|
||||
@ -103,7 +101,7 @@ final class ObjectTypeSpecifier
|
||||
$useName = $prefix . $useUse->name->toString();
|
||||
$alias = $useUse->alias->toString();
|
||||
$fullyQualifiedName = $prefix . $useUse->name->toString();
|
||||
$processAliasedObject = $this->processAliasedObject($alias, $className, $useName, $parentNode, $fullyQualifiedName);
|
||||
$processAliasedObject = $this->processAliasedObject($alias, $className, $useName, $fullyQualifiedName, $isObjectCaller);
|
||||
if ($processAliasedObject instanceof AliasedObjectType) {
|
||||
return $processAliasedObject;
|
||||
}
|
||||
@ -111,14 +109,14 @@ final class ObjectTypeSpecifier
|
||||
}
|
||||
return null;
|
||||
}
|
||||
private function processAliasedObject(string $alias, string $className, string $useName, ?Node $parentNode, string $fullyQualifiedName) : ?AliasedObjectType
|
||||
private function processAliasedObject(string $alias, string $className, string $useName, string $fullyQualifiedName, bool $isObjectCaller) : ?AliasedObjectType
|
||||
{
|
||||
// A. is alias in use statement matching this class alias
|
||||
if ($alias === $className) {
|
||||
return new AliasedObjectType($alias, $fullyQualifiedName);
|
||||
}
|
||||
// B. is aliased classes matching the class name and parent node is MethodCall/StaticCall
|
||||
if ($useName === $className && ($parentNode instanceof MethodCall || $parentNode instanceof StaticCall)) {
|
||||
if ($useName === $className && $isObjectCaller) {
|
||||
return new AliasedObjectType($useName, $fullyQualifiedName);
|
||||
}
|
||||
// C. is aliased classes matching the class name
|
||||
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '94cbadbac6df528e9061bdb68d56cf7f91295584';
|
||||
public const PACKAGE_VERSION = '9e8925edfd766a78d2cc20684863899d64df9586';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2023-06-20 00:03:57';
|
||||
public const RELEASE_DATE = '2023-06-20 00:22:32';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
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 ComposerAutoloaderInit2d5a2d736603b65cfde3d3a2b85412e0::getLoader();
|
||||
return ComposerAutoloaderInit5f8f68659fbc828cd4efb53a7aa60624::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -2032,6 +2032,7 @@ return array(
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ByRefVariableNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ContextNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ContextNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\GlobalVariableNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/GlobalVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ObjectNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ObjectNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\RemoveDeepChainMethodCallNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\StaticVariableNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StaticVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\StmtKeyNodeVisitor' => $baseDir . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php',
|
||||
|
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 ComposerAutoloaderInit2d5a2d736603b65cfde3d3a2b85412e0
|
||||
class ComposerAutoloaderInit5f8f68659fbc828cd4efb53a7aa60624
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,17 +22,17 @@ class ComposerAutoloaderInit2d5a2d736603b65cfde3d3a2b85412e0
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit2d5a2d736603b65cfde3d3a2b85412e0', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5f8f68659fbc828cd4efb53a7aa60624', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit2d5a2d736603b65cfde3d3a2b85412e0', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5f8f68659fbc828cd4efb53a7aa60624', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624::getInitializer($loader));
|
||||
|
||||
$loader->setClassMapAuthoritative(true);
|
||||
$loader->register(true);
|
||||
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0::$files;
|
||||
$filesToLoad = \Composer\Autoload\ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624::$files;
|
||||
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0
|
||||
class ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624
|
||||
{
|
||||
public static $files = array (
|
||||
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
|
||||
@ -2283,6 +2283,7 @@ class ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ByRefVariableNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ByRefVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ContextNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ContextNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\GlobalVariableNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/GlobalVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\ObjectNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/ObjectNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\RemoveDeepChainMethodCallNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/RemoveDeepChainMethodCallNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\StaticVariableNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StaticVariableNodeVisitor.php',
|
||||
'Rector\\NodeTypeResolver\\PHPStan\\Scope\\NodeVisitor\\StmtKeyNodeVisitor' => __DIR__ . '/../..' . '/packages/NodeTypeResolver/PHPStan/Scope/NodeVisitor/StmtKeyNodeVisitor.php',
|
||||
@ -3095,9 +3096,9 @@ class ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit2d5a2d736603b65cfde3d3a2b85412e0::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit5f8f68659fbc828cd4efb53a7aa60624::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user