Updated Rector to commit 0d86656f904c940d8573f4966e753ffb76e010c2

0d86656f90 [Performance] Avoid multiple traverse on BetterNodeFinder::hasInstanceof() (#6742)
This commit is contained in:
Tomas Votruba 2025-02-19 11:00:30 +00:00
parent 3fbef1781c
commit 78581c79f5
3 changed files with 10 additions and 15 deletions

View File

@ -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
*/

View File

@ -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

View File

@ -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