mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-13 12:33:52 +01:00
Check for root namespace class differently.
This commit is contained in:
parent
4c5b5340ef
commit
dae17c98a0
@ -2,6 +2,7 @@
|
||||
|
||||
namespace Rector\CodingStyle\Rector\Namespace_;
|
||||
|
||||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use Rector\CodingStyle\Node\NameImporter;
|
||||
@ -82,8 +83,11 @@ PHP
|
||||
public function refactor(Node $node): ?Node
|
||||
{
|
||||
// Importing root namespace classes (like \DateTime) is optional
|
||||
if (!$this->shouldImportRootNamespaceClasses && $node instanceof Name && !$node->isQualified()) {
|
||||
return null;
|
||||
if (! $this->shouldImportRootNamespaceClasses) {
|
||||
$name = $this->getName($node);
|
||||
if (Strings::startsWith($name, '\\') && substr_count($name, '\\') === 1) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
$this->useAddingCommander->analyseFileInfoUseStatements($node);
|
||||
|
Loading…
x
Reference in New Issue
Block a user