Skip to content

Commit

Permalink
verify short name
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik committed Jan 18, 2025
1 parent 19886c9 commit 7f6475d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions rules/CodingStyle/Application/UseImportsAdder.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,10 @@ private function getNamespaceName(Namespace_ $namespace): ?string

private function isCurrentNamespace(string $namespaceName, ObjectType $objectType): bool
{
$afterCurrentNamespace = Strings::after($objectType->getClassName(), $namespaceName . '\\');
if ($afterCurrentNamespace === null) {
if (! str_starts_with($objectType->getClassName(), $namespaceName . '\\')) {
return false;
}

return str_starts_with($objectType->getClassName(), $namespaceName . '\\')
&& ! \str_contains($afterCurrentNamespace, '\\');
return $namespaceName . '\\' . $objectType->getShortName() === $objectType->getClassName();
}
}

0 comments on commit 7f6475d

Please sign in to comment.