Skip to content

Commit

Permalink
cs
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Jun 6, 2022
1 parent 66665bd commit b3c837f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ private function resolveFullyQualifiedClass(
Node $node,
string $tag,
bool $returnNullOnUnknownClass
): ?string
{
): ?string {
$scope = $node->getAttribute(AttributeKey::SCOPE);

if ($scope instanceof Scope) {
Expand All @@ -93,7 +92,7 @@ private function resolveFullyQualifiedClass(
return $this->resolveAsAliased($uses, $tag, $returnNullOnUnknownClass);
}

if (str_starts_with($tag, '\\') && $this->reflectionProvider->hasClass($tag)) {
if ($this->isPreslashedExistingClass($tag)) {
// Global or absolute Class
return $tag;
}
Expand Down Expand Up @@ -138,4 +137,13 @@ private function resolveClass(?string $class, bool $returnNullOnUnknownClass): ?
$resolvedClass = $this->reflectionProvider->hasClass($class) ? $class : null;
return $returnNullOnUnknownClass ? $resolvedClass : $class;
}

private function isPreslashedExistingClass(string $tag): bool
{
if (! str_starts_with($tag, '\\')) {
return false;
}

return $this->reflectionProvider->hasClass($tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Rector\Testing\PHPUnit\AbstractRectorTestCase;
use Symplify\SmartFileSystem\SmartFileInfo;

class DoNotReplaceUnknownClassesTest extends AbstractRectorTestCase
final class DoNotReplaceUnknownClassesTest extends AbstractRectorTestCase
{
/**
* @dataProvider provideData()
Expand Down

0 comments on commit b3c837f

Please sign in to comment.