Skip to content

Commit

Permalink
[AutoImport] Skip case insensitive conflict defined class name on $re…
Browse files Browse the repository at this point in the history
…ctorConfig->importNames() (#5076)

* [AutoImport] Skip case insensitive defined class name on $rectorConfig->importNames()

* Fixed 🎉
  • Loading branch information
samsonasik committed Sep 24, 2023
1 parent 803d9ec commit 4f19936
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion rules/CodingStyle/ClassNameImport/ShortNameResolver.php
Expand Up @@ -19,6 +19,7 @@
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
use Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher;
use Rector\Core\PhpParser\Node\BetterNodeFinder;
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
use Rector\Core\Util\StringUtils;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver;
Expand Down Expand Up @@ -79,7 +80,7 @@ public function resolveShortClassLikeNames(File $file): array
$newStmts = $file->getNewStmts();

/** @var Namespace_[] $namespaces */
$namespaces = array_filter($newStmts, static fn (Stmt $stmt): bool => $stmt instanceof Namespace_);
$namespaces = array_filter($newStmts, static fn (Stmt $stmt): bool => $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace);
if (count($namespaces) !== 1) {
// only handle single namespace nodes
return [];
Expand Down
@@ -0,0 +1,9 @@
<?php

class Bar
{
public static function execute()
{
echo strtolower(\Foo\BaR::execute());
}
}

0 comments on commit 4f19936

Please sign in to comment.