Skip to content

Commit

Permalink
[PostRector] Handle with FQCN docblock on UnusedImportRemovingPostRec…
Browse files Browse the repository at this point in the history
…tor (#6722)

* [PostRector] Handle with FQCN docblock on UnusedImportRemovingPostRector

* [PostRector] Handle with FQCN docblock on UnusedImportRemovingPostRector

* rollback

* Fix
  • Loading branch information
samsonasik authored Feb 7, 2025
1 parent ecd8b37 commit 59d4bca
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ $var = get();

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\Fixture;

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\OldClass as OldSomeClass;

/** @var \Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\NewClass $var */
$var = get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ $var = get();

namespace Rector\Tests\Renaming\Rector\Name\RenameClassRector\Fixture;

use Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source as SomeSource;

/** @var \Rector\Tests\Renaming\Rector\Name\RenameClassRector\Source\NewClass $var */
$var = get();

Expand Down
4 changes: 4 additions & 0 deletions src/PostRector/Rector/UnusedImportRemovingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ private function isUseImportUsed(

// match partial import
foreach ($names as $name) {
if (str_starts_with($name, '\\')) {
continue;
}

if ($this->isSubNamespace($name, $comparedName, $namespacedPrefix)) {
return true;
}
Expand Down
33 changes: 33 additions & 0 deletions tests/Issues/NamespacedUse/Fixture/with_fqcn_docblock.php.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Test;

use OtherClass;

class MyClass
{
/**
* @param \ThirdClass $user
*/
public function __construct($user)
{
}
}

?>
-----
<?php

namespace Test;

class MyClass
{
/**
* @param \ThirdClass $user
*/
public function __construct($user)
{
}
}

?>

0 comments on commit 59d4bca

Please sign in to comment.