Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function paths(array $paths): void
{
Assert::allString($paths);

foreach($paths as $path) {
foreach ($paths as $path) {
if (str_contains($path, '*')) {
continue;
}
Expand Down
9 changes: 6 additions & 3 deletions rules/CodingStyle/ClassNameImport/ShortNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ public function resolveShortClassLikeNames(File $file): array
{
$newStmts = $file->getNewStmts();

/** @var Namespace_[] $namespaces */
$namespaces = array_filter($newStmts, static fn (Stmt $stmt): bool => $stmt instanceof Namespace_ || $stmt instanceof FileWithoutNamespace);
/** @var Namespace_[]|FileWithoutNamespace[] $namespaces */
$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 All @@ -89,7 +92,7 @@ public function resolveShortClassLikeNames(File $file): array
$namespace = current($namespaces);

/** @var ClassLike[] $classLikes */
$classLikes = $this->betterNodeFinder->findInstanceOf($namespace, ClassLike::class);
$classLikes = $this->betterNodeFinder->findInstanceOf($namespace->stmts, ClassLike::class);

$shortClassLikeNames = [];
foreach ($classLikes as $classLike) {
Expand Down