mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
Updated Rector to commit ac3d2f6bb311bfaddc484f2839119469a571b1a9
ac3d2f6bb3
[Performance] [PostRector] Avoid unnecessary traverse() to count total namespaces on NameImportingPostRector (#6191)
This commit is contained in:
parent
2cff9fb625
commit
ea7301739d
@ -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
|
||||
*/
|
||||
|
@ -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]);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user