Updated Rector to commit ac3d2f6bb311bfaddc484f2839119469a571b1a9

ac3d2f6bb3 [Performance] [PostRector] Avoid unnecessary traverse() to count total namespaces on NameImportingPostRector (#6191)
This commit is contained in:
Tomas Votruba 2024-07-26 08:34:48 +00:00
parent 2cff9fb625
commit ea7301739d
2 changed files with 13 additions and 6 deletions

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = '2896dca2a2c53c579d7a21916056e3d0afa2439c';
public const PACKAGE_VERSION = 'ac3d2f6bb311bfaddc484f2839119469a571b1a9';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-07-26 10:03:34';
public const RELEASE_DATE = '2024-07-26 10:32:17';
/**
* @var int
*/

View File

@ -79,10 +79,17 @@ final class NameImportingPostRector extends \Rector\PostRector\Rector\AbstractPo
*/
public function shouldTraverse(array $stmts) : bool
{
$namespaces = $this->betterNodeFinder->findInstanceOf($stmts, Namespace_::class);
// skip if 2 namespaces are present
if (\count($namespaces) > 1) {
return \false;
$totalNamespaces = 0;
// just loop the first level stmts to locate namespace to improve performance
// as namespace is always on first level
foreach ($stmts as $stmt) {
if ($stmt instanceof Namespace_) {
++$totalNamespaces;
}
// skip if 2 namespaces are present
if ($totalNamespaces === 2) {
return \false;
}
}
return !$this->betterNodeFinder->hasInstancesOf($stmts, [InlineHTML::class]);
}