Skip to content

Commit 73a1ef4

Browse files
committed
Updated Rector to commit d8d31debc51ab5df1d30655846bb0fbd9f76039b
rectorphp/rector-src@d8d31de [Performance] Use more performance spl_object_id() (#4876)
1 parent de9ddf6 commit 73a1ef4

11 files changed

Lines changed: 53 additions & 53 deletions

File tree

packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfoFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ final class PhpDocInfoFactory
6161
*/
6262
private $phpDocNodeByTypeFinder;
6363
/**
64-
* @var array<string, PhpDocInfo>
64+
* @var array<int, PhpDocInfo>
6565
*/
66-
private $phpDocInfosByObjectHash = [];
66+
private $phpDocInfosByObjectId = [];
6767
public function __construct(PhpDocNodeMapper $phpDocNodeMapper, CurrentNodeProvider $currentNodeProvider, Lexer $lexer, BetterPhpDocParser $betterPhpDocParser, StaticTypeMapper $staticTypeMapper, AnnotationNaming $annotationNaming, RectorChangeCollector $rectorChangeCollector, PhpDocNodeByTypeFinder $phpDocNodeByTypeFinder)
6868
{
6969
$this->phpDocNodeMapper = $phpDocNodeMapper;
@@ -90,9 +90,9 @@ public function createFromNodeOrEmpty(Node $node) : \Rector\BetterPhpDocParser\P
9090
}
9191
public function createFromNode(Node $node) : ?\Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo
9292
{
93-
$objectHash = \spl_object_hash($node);
94-
if (isset($this->phpDocInfosByObjectHash[$objectHash])) {
95-
return $this->phpDocInfosByObjectHash[$objectHash];
93+
$objectId = \spl_object_id($node);
94+
if (isset($this->phpDocInfosByObjectId[$objectId])) {
95+
return $this->phpDocInfosByObjectId[$objectId];
9696
}
9797
/** @see \Rector\BetterPhpDocParser\PhpDocParser\DoctrineAnnotationDecorator::decorate() */
9898
$this->currentNodeProvider->setNode($node);
@@ -111,7 +111,7 @@ public function createFromNode(Node $node) : ?\Rector\BetterPhpDocParser\PhpDocI
111111
$this->setPositionOfLastToken($phpDocNode);
112112
}
113113
$phpDocInfo = $this->createFromPhpDocNode($phpDocNode, $tokenIterator, $node);
114-
$this->phpDocInfosByObjectHash[$objectHash] = $phpDocInfo;
114+
$this->phpDocInfosByObjectId[$objectId] = $phpDocInfo;
115115
return $phpDocInfo;
116116
}
117117
/**

packages/BetterPhpDocParser/PhpDocParser/ClassAnnotationMatcher.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ public function __construct(UseImportNameMatcher $useImportNameMatcher, UseImpor
4444
}
4545
public function resolveTagFullyQualifiedName(string $tag, Node $node) : string
4646
{
47-
$uniqueHash = $tag . \spl_object_hash($node);
48-
if (isset($this->fullyQualifiedNameByHash[$uniqueHash])) {
49-
return $this->fullyQualifiedNameByHash[$uniqueHash];
47+
$uniqueId = $tag . \spl_object_id($node);
48+
if (isset($this->fullyQualifiedNameByHash[$uniqueId])) {
49+
return $this->fullyQualifiedNameByHash[$uniqueId];
5050
}
5151
$tag = \ltrim($tag, '@');
5252
$uses = $this->useImportsResolver->resolve();
5353
$fullyQualifiedClass = $this->resolveFullyQualifiedClass($uses, $node, $tag, \false);
5454
if ($fullyQualifiedClass === null) {
5555
$fullyQualifiedClass = $tag;
5656
}
57-
$this->fullyQualifiedNameByHash[$uniqueHash] = $fullyQualifiedClass;
57+
$this->fullyQualifiedNameByHash[$uniqueId] = $fullyQualifiedClass;
5858
return $fullyQualifiedClass;
5959
}
6060
/**

packages/PhpDocParser/NodeVisitor/CallableNodeVisitor.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ final class CallableNodeVisitor extends NodeVisitorAbstract
1616
*/
1717
private $callable;
1818
/**
19-
* @var string|null
19+
* @var int|null
2020
*/
21-
private $nodeHashToRemove;
21+
private $nodeIdToRemove;
2222
/**
2323
* @param callable(Node $node): (int|Node|null) $callable
2424
*/
@@ -36,7 +36,7 @@ public function enterNode(Node $node)
3636
/** @var int|Node|null $newNode */
3737
$newNode = $callable($node);
3838
if ($newNode === NodeTraverser::REMOVE_NODE) {
39-
$this->nodeHashToRemove = \spl_object_hash($originalNode);
39+
$this->nodeIdToRemove = \spl_object_id($originalNode);
4040
return $originalNode;
4141
}
4242
if ($originalNode instanceof Stmt && $newNode instanceof Expr) {
@@ -49,8 +49,8 @@ public function enterNode(Node $node)
4949
*/
5050
public function leaveNode(Node $node)
5151
{
52-
if ($this->nodeHashToRemove === \spl_object_hash($node)) {
53-
$this->nodeHashToRemove = null;
52+
if ($this->nodeIdToRemove === \spl_object_id($node)) {
53+
$this->nodeIdToRemove = null;
5454
return NodeTraverser::REMOVE_NODE;
5555
}
5656
return $node;

rules/Naming/Naming/ConflictingNameResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ final class ConflictingNameResolver
4040
*/
4141
private $functionLikeManipulator;
4242
/**
43-
* @var array<string, string[]>
43+
* @var array<int, string[]>
4444
*/
4545
private $conflictingVariableNamesByClassMethod = [];
4646
public function __construct(ArrayFilter $arrayFilter, BetterNodeFinder $betterNodeFinder, \Rector\Naming\Naming\ExpectedNameResolver $expectedNameResolver, MatchParamTypeExpectedNameResolver $matchParamTypeExpectedNameResolver, FunctionLikeManipulator $functionLikeManipulator)
@@ -82,16 +82,16 @@ public function hasNameIsInFunctionLike(string $variableName, $functionLike) : b
8282
private function resolveConflictingVariableNamesForNew($functionLike) : array
8383
{
8484
// cache it!
85-
$classMethodHash = \spl_object_hash($functionLike);
86-
if (isset($this->conflictingVariableNamesByClassMethod[$classMethodHash])) {
87-
return $this->conflictingVariableNamesByClassMethod[$classMethodHash];
85+
$classMethodId = \spl_object_id($functionLike);
86+
if (isset($this->conflictingVariableNamesByClassMethod[$classMethodId])) {
87+
return $this->conflictingVariableNamesByClassMethod[$classMethodId];
8888
}
8989
$paramNames = $this->functionLikeManipulator->resolveParamNames($functionLike);
9090
$newAssignNames = $this->resolveForNewAssigns($functionLike);
9191
$nonNewAssignNames = $this->resolveForNonNewAssigns($functionLike);
9292
$protectedNames = \array_merge($paramNames, $newAssignNames, $nonNewAssignNames);
9393
$protectedNames = $this->arrayFilter->filterWithAtLeastTwoOccurences($protectedNames);
94-
$this->conflictingVariableNamesByClassMethod[$classMethodHash] = $protectedNames;
94+
$this->conflictingVariableNamesByClassMethod[$classMethodId] = $protectedNames;
9595
return $protectedNames;
9696
}
9797
/**

rules/Naming/Naming/OverridenExistingNamesResolver.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ final class OverridenExistingNamesResolver
3030
*/
3131
private $nodeNameResolver;
3232
/**
33-
* @var array<string, array<int, string>>
33+
* @var array<int, array<int, string>>
3434
*/
3535
private $overridenExistingVariableNamesByClassMethod = [];
3636
public function __construct(ArrayFilter $arrayFilter, BetterNodeFinder $betterNodeFinder, NodeNameResolver $nodeNameResolver)
@@ -73,9 +73,9 @@ public function hasNameInFunctionLikeForParam(string $expectedName, $classMethod
7373
*/
7474
private function resolveOveriddenNamesForNew($functionLike) : array
7575
{
76-
$classMethodHash = \spl_object_hash($functionLike);
77-
if (isset($this->overridenExistingVariableNamesByClassMethod[$classMethodHash])) {
78-
return $this->overridenExistingVariableNamesByClassMethod[$classMethodHash];
76+
$classMethodId = \spl_object_id($functionLike);
77+
if (isset($this->overridenExistingVariableNamesByClassMethod[$classMethodId])) {
78+
return $this->overridenExistingVariableNamesByClassMethod[$classMethodId];
7979
}
8080
$currentlyUsedNames = [];
8181
/** @var Assign[] $assigns */
@@ -91,7 +91,7 @@ private function resolveOveriddenNamesForNew($functionLike) : array
9191
}
9292
$currentlyUsedNames = \array_values($currentlyUsedNames);
9393
$currentlyUsedNames = $this->arrayFilter->filterWithAtLeastTwoOccurences($currentlyUsedNames);
94-
$this->overridenExistingVariableNamesByClassMethod[$classMethodHash] = $currentlyUsedNames;
94+
$this->overridenExistingVariableNamesByClassMethod[$classMethodId] = $currentlyUsedNames;
9595
return $currentlyUsedNames;
9696
}
9797
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = 'c03fd2ad2625f1a0cf6a02d9875078b7114381ad';
22+
public const PACKAGE_VERSION = 'd8d31debc51ab5df1d30655846bb0fbd9f76039b';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2023-08-28 21:22:21';
27+
public const RELEASE_DATE = '2023-08-29 00:39:22';
2828
/**
2929
* @var int
3030
*/

src/NodeManipulator/ClassMethodAssignManipulator.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class ClassMethodAssignManipulator
2222
*/
2323
private $nodeNameResolver;
2424
/**
25-
* @var array<string, string[]>
25+
* @var array<int, string[]>
2626
*/
2727
private $alreadyAddedClassMethodNames = [];
2828
public function __construct(NodeFactory $nodeFactory, NodeNameResolver $nodeNameResolver)
@@ -37,8 +37,8 @@ public function addParameterAndAssignToMethod(ClassMethod $classMethod, string $
3737
}
3838
$classMethod->params[] = $this->nodeFactory->createParamFromNameAndType($name, $type);
3939
$classMethod->stmts[] = new Expression($assign);
40-
$classMethodHash = \spl_object_hash($classMethod);
41-
$this->alreadyAddedClassMethodNames[$classMethodHash][] = $name;
40+
$classMethodId = \spl_object_id($classMethod);
41+
$this->alreadyAddedClassMethodNames[$classMethodId][] = $name;
4242
}
4343
private function hasMethodParameter(ClassMethod $classMethod, string $name) : bool
4444
{
@@ -47,10 +47,10 @@ private function hasMethodParameter(ClassMethod $classMethod, string $name) : bo
4747
return \true;
4848
}
4949
}
50-
$classMethodHash = \spl_object_hash($classMethod);
51-
if (!isset($this->alreadyAddedClassMethodNames[$classMethodHash])) {
50+
$classMethodId = \spl_object_id($classMethod);
51+
if (!isset($this->alreadyAddedClassMethodNames[$classMethodId])) {
5252
return \false;
5353
}
54-
return \in_array($name, $this->alreadyAddedClassMethodNames[$classMethodHash], \true);
54+
return \in_array($name, $this->alreadyAddedClassMethodNames[$classMethodId], \true);
5555
}
5656
}

src/Rector/AbstractRector.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ abstract class AbstractRector extends NodeVisitorAbstract implements RectorInter
109109
*/
110110
private $currentFileProvider;
111111
/**
112-
* @var array<string, Node[]>
112+
* @var array<int, Node[]>
113113
*/
114114
private $nodesToReturn = [];
115115
/**
@@ -121,9 +121,9 @@ abstract class AbstractRector extends NodeVisitorAbstract implements RectorInter
121121
*/
122122
private $rectorOutput;
123123
/**
124-
* @var string|null
124+
* @var int|null
125125
*/
126-
private $toBeRemovedNodeHash;
126+
private $toBeRemovedNodeId;
127127
public function autowire(NodeNameResolver $nodeNameResolver, NodeTypeResolver $nodeTypeResolver, SimpleCallableNodeTraverser $simpleCallableNodeTraverser, NodeFactory $nodeFactory, PhpDocInfoFactory $phpDocInfoFactory, StaticTypeMapper $staticTypeMapper, CurrentRectorProvider $currentRectorProvider, CurrentNodeProvider $currentNodeProvider, Skipper $skipper, ValueResolver $valueResolver, BetterNodeFinder $betterNodeFinder, NodeComparator $nodeComparator, CurrentFileProvider $currentFileProvider, CreatedByRuleDecorator $createdByRuleDecorator, ChangedNodeScopeRefresher $changedNodeScopeRefresher, RectorOutput $rectorOutput) : void
128128
{
129129
$this->nodeNameResolver = $nodeNameResolver;
@@ -187,7 +187,7 @@ public final function enterNode(Node $node)
187187
}
188188
// @see NodeTraverser::* codes, e.g. removal of node of stopping the traversing
189189
if ($refactoredNode === NodeTraverser::REMOVE_NODE) {
190-
$this->toBeRemovedNodeHash = \spl_object_hash($originalNode);
190+
$this->toBeRemovedNodeId = \spl_object_id($originalNode);
191191
// notify this rule changing code
192192
$rectorWithLineChange = new RectorWithLineChange(static::class, $originalNode->getLine());
193193
$this->file->addRectorClassWithLine($rectorWithLineChange);
@@ -224,12 +224,12 @@ public function leaveNode(Node $node)
224224
if ($node->hasAttribute(AttributeKey::ORIGINAL_NODE)) {
225225
return null;
226226
}
227-
$objectHash = \spl_object_hash($node);
228-
if ($this->toBeRemovedNodeHash === $objectHash) {
229-
$this->toBeRemovedNodeHash = null;
227+
$objectId = \spl_object_id($node);
228+
if ($this->toBeRemovedNodeId === $objectId) {
229+
$this->toBeRemovedNodeId = null;
230230
return NodeTraverser::REMOVE_NODE;
231231
}
232-
return $this->nodesToReturn[$objectHash] ?? $node;
232+
return $this->nodesToReturn[$objectId] ?? $node;
233233
}
234234
protected function isName(Node $node, string $name) : bool
235235
{
@@ -313,9 +313,9 @@ private function postRefactorProcess(Node $originalNode, Node $node, $refactored
313313
$this->mirrorComments($firstNode, $originalNode);
314314
$this->refreshScopeNodes($refactoredNode, $filePath, $currentScope);
315315
// search "infinite recursion" in https://github.com/nikic/PHP-Parser/blob/master/doc/component/Walking_the_AST.markdown
316-
$originalNodeHash = \spl_object_hash($originalNode);
316+
$originalNodeId = \spl_object_id($originalNode);
317317
// will be replaced in leaveNode() the original node must be passed
318-
$this->nodesToReturn[$originalNodeHash] = $refactoredNode;
318+
$this->nodesToReturn[$originalNodeId] = $refactoredNode;
319319
return $originalNode;
320320
}
321321
$this->refreshScopeNodes($refactoredNode, $filePath, $currentScope);

vendor/autoload.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222

2323
require_once __DIR__ . '/composer/autoload_real.php';
2424

25-
return ComposerAutoloaderInit129728a48b87039bca6f60cdcf06f91f::getLoader();
25+
return ComposerAutoloaderInitc91db9ccbfaf98d91070b72dda598fcd::getLoader();

vendor/composer/autoload_real.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// autoload_real.php @generated by Composer
44

5-
class ComposerAutoloaderInit129728a48b87039bca6f60cdcf06f91f
5+
class ComposerAutoloaderInitc91db9ccbfaf98d91070b72dda598fcd
66
{
77
private static $loader;
88

@@ -22,17 +22,17 @@ public static function getLoader()
2222
return self::$loader;
2323
}
2424

25-
spl_autoload_register(array('ComposerAutoloaderInit129728a48b87039bca6f60cdcf06f91f', 'loadClassLoader'), true, true);
25+
spl_autoload_register(array('ComposerAutoloaderInitc91db9ccbfaf98d91070b72dda598fcd', 'loadClassLoader'), true, true);
2626
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27-
spl_autoload_unregister(array('ComposerAutoloaderInit129728a48b87039bca6f60cdcf06f91f', 'loadClassLoader'));
27+
spl_autoload_unregister(array('ComposerAutoloaderInitc91db9ccbfaf98d91070b72dda598fcd', 'loadClassLoader'));
2828

2929
require __DIR__ . '/autoload_static.php';
30-
call_user_func(\Composer\Autoload\ComposerStaticInit129728a48b87039bca6f60cdcf06f91f::getInitializer($loader));
30+
call_user_func(\Composer\Autoload\ComposerStaticInitc91db9ccbfaf98d91070b72dda598fcd::getInitializer($loader));
3131

3232
$loader->setClassMapAuthoritative(true);
3333
$loader->register(true);
3434

35-
$filesToLoad = \Composer\Autoload\ComposerStaticInit129728a48b87039bca6f60cdcf06f91f::$files;
35+
$filesToLoad = \Composer\Autoload\ComposerStaticInitc91db9ccbfaf98d91070b72dda598fcd::$files;
3636
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
3737
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
3838
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

0 commit comments

Comments
 (0)