Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DeadCode] Add Function_ support on RemoveUselessReturnTagRector (#5325)
- Loading branch information
1 parent
005ccc3
commit 4531aeb
Showing
4 changed files
with
42 additions
and
11 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...ests/DeadCode/Rector/ClassMethod/RemoveUselessReturnTagRector/Fixture/on_function.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 | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
/** | ||
* @return stdClass | ||
*/ | ||
function foo(): stdClass | ||
{ | ||
return new stdClass(); | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector\Fixture; | ||
|
||
use stdClass; | ||
|
||
function foo(): stdClass | ||
{ | ||
return new stdClass(); | ||
} | ||
|
||
?> |
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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt\ClassMethod; | ||
use PhpParser\Node\Stmt\Function_; | ||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory; | ||
use Rector\Comments\NodeDocBlock\DocBlockUpdater; | ||
use Rector\Core\Rector\AbstractRector; | ||
|
@@ -65,11 +66,11 @@ public function foo(): stdClass | |
*/ | ||
public function getNodeTypes(): array | ||
{ | ||
return [ClassMethod::class]; | ||
return [ClassMethod::class, Function_::class]; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
samsonasik
Author
Member
|
||
} | ||
|
||
/** | ||
* @param ClassMethod $node | ||
* @param ClassMethod|Function_ $node | ||
*/ | ||
public function refactor(Node $node): ?Node | ||
{ | ||
|
do we need the same for arrow functions?