-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PostRector] Allow unused alias removal from Use_ on UnusedImportRemo…
…vingPostRector (#3477) * [PostRector] Allow unused alias removal from Use_ on UnusedImportRemovingPostRector * uniquate name * check prefixed * clean up * clean up * clean up * Fix phpstan * fix * aliased part * aliased part * Final touch: array_unique() in final merge * final touch: add fixture aliased part on docblock
- Loading branch information
1 parent
1138101
commit c240c69
Showing
9 changed files
with
289 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
tests/Issues/NamespacedUse/Fixture/namespaced_class_aliased.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NamespacedClassAliased | ||
{ | ||
public function run(): Foo | ||
{ | ||
return new Foo('test'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
|
||
class NamespacedClassAliased | ||
{ | ||
public function run(): Foo | ||
{ | ||
return new Foo('test'); | ||
} | ||
} | ||
|
||
?> |
36 changes: 36 additions & 0 deletions
36
tests/Issues/NamespacedUse/Fixture/namespaced_class_aliased_docblock.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NamespacedClassAliasedDocblock | ||
{ | ||
/** | ||
* @param Foo $param | ||
*/ | ||
public function run($param) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
|
||
class NamespacedClassAliasedDocblock | ||
{ | ||
/** | ||
* @param Foo $param | ||
*/ | ||
public function run($param) | ||
{ | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
tests/Issues/NamespacedUse/Fixture/namespaced_class_aliased_part.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NamespacedClassAliasedPart | ||
{ | ||
public function run2(): Foo\String_ | ||
{ | ||
return new Foo\String_('test'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
|
||
class NamespacedClassAliasedPart | ||
{ | ||
public function run2(): Foo\String_ | ||
{ | ||
return new Foo\String_('test'); | ||
} | ||
} | ||
|
||
?> |
36 changes: 36 additions & 0 deletions
36
tests/Issues/NamespacedUse/Fixture/namespaced_class_aliased_part_docblock.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NamespacedClassAliasedPartDocblock | ||
{ | ||
/** | ||
* @param Foo\String_ $param | ||
*/ | ||
public function run2($param) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Core\Tests\Issues\NamespacedUse\Fixture; | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
|
||
class NamespacedClassAliasedPartDocblock | ||
{ | ||
/** | ||
* @param Foo\String_ $param | ||
*/ | ||
public function run2($param) | ||
{ | ||
} | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/NoNamespaced/Fixture/no_namespaced_class_aliased.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NoNamespacedClassAliased | ||
{ | ||
public function run(): Foo | ||
{ | ||
return new Foo('test'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
|
||
class NoNamespacedClassAliased | ||
{ | ||
public function run(): Foo | ||
{ | ||
return new Foo('test'); | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
tests/Issues/NoNamespaced/Fixture/no_namespaced_class_aliased_docblock.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NoNamespacedClassAliasedDocblock | ||
{ | ||
/** | ||
* @param Foo $param | ||
*/ | ||
public function run($param) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use PhpParser\Node\Scalar\String_ as Foo; | ||
|
||
class NoNamespacedClassAliasedDocblock | ||
{ | ||
/** | ||
* @param Foo $param | ||
*/ | ||
public function run($param) | ||
{ | ||
} | ||
} | ||
|
||
?> |
28 changes: 28 additions & 0 deletions
28
tests/Issues/NoNamespaced/Fixture/no_namespaced_class_aliased_part.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NoNamespacedClassAliasedPart | ||
{ | ||
public function run2(): Foo\String_ | ||
{ | ||
return new Foo\String_('test'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
|
||
class NoNamespacedClassAliasedPart | ||
{ | ||
public function run2(): Foo\String_ | ||
{ | ||
return new Foo\String_('test'); | ||
} | ||
} | ||
|
||
?> |
32 changes: 32 additions & 0 deletions
32
tests/Issues/NoNamespaced/Fixture/no_namespaced_class_aliased_part_docblock.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
use PhpParser\Node\Stmt\Expression as Bar; | ||
|
||
class NoNamespacedClassAliasedPartDocblock | ||
{ | ||
/** | ||
* @param Foo\String_ $param | ||
*/ | ||
public function run2($param) | ||
{ | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
use PhpParser\Node\Scalar as Foo; | ||
|
||
class NoNamespacedClassAliasedPartDocblock | ||
{ | ||
/** | ||
* @param Foo\String_ $param | ||
*/ | ||
public function run2($param) | ||
{ | ||
} | ||
} | ||
|
||
?> |