mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-13 20:12:07 +01:00
Updated Rector to commit 0d86656f904c940d8573f4966e753ffb76e010c2
0d86656f90
[Performance] Avoid multiple traverse on BetterNodeFinder::hasInstanceof() (#6742)
This commit is contained in:
parent
3fbef1781c
commit
78581c79f5
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '5b054eaa33bcd3cede29c544603cd31dd2959631';
|
||||
public const PACKAGE_VERSION = '0d86656f904c940d8573f4966e753ffb76e010c2';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2025-02-19 11:12:02';
|
||||
public const RELEASE_DATE = '2025-02-19 17:57:56';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -135,12 +135,7 @@ final class IfManipulator
|
||||
if (!$this->isIfWithoutElseAndElseIfs($currentIf)) {
|
||||
return [];
|
||||
}
|
||||
$return = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Return_::class);
|
||||
if ($return instanceof Return_) {
|
||||
return [];
|
||||
}
|
||||
$exit = $this->betterNodeFinder->findFirstInstanceOf($currentIf->stmts, Exit_::class);
|
||||
if ($exit instanceof Exit_) {
|
||||
if ($this->betterNodeFinder->hasInstancesOf($currentIf->stmts, [Return_::class, Exit_::class])) {
|
||||
return [];
|
||||
}
|
||||
// last if is with the expression
|
||||
|
@ -117,14 +117,14 @@ final class BetterNodeFinder
|
||||
public function hasInstancesOf($nodes, array $types) : bool
|
||||
{
|
||||
Assert::allIsAOf($types, Node::class);
|
||||
foreach ($types as $type) {
|
||||
$foundNode = $this->nodeFinder->findFirstInstanceOf($nodes, $type);
|
||||
if (!$foundNode instanceof Node) {
|
||||
continue;
|
||||
return (bool) $this->nodeFinder->findFirst($nodes, static function (Node $node) use($types) : bool {
|
||||
foreach ($types as $type) {
|
||||
if ($node instanceof $type) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
return \false;
|
||||
return \false;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* @param Node|Node[] $nodes
|
||||
|
Loading…
x
Reference in New Issue
Block a user