-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Rector to commit 66d93167af53e4116e73f6dc011f02ac23efbd6f
rectorphp/rector-src@66d9316 [DeadCode] Add ReplaceBlockToItsStmtsRector (#6641)
- Loading branch information
1 parent
232892c
commit 79bfc87
Showing
5 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
rules/DeadCode/Rector/Block/ReplaceBlockToItsStmtsRector.php
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,49 @@ | ||
<?php | ||
|
||
declare (strict_types=1); | ||
namespace Rector\DeadCode\Rector\Block; | ||
|
||
use PhpParser\Node; | ||
use PhpParser\Node\Stmt; | ||
use PhpParser\Node\Stmt\Block; | ||
use Rector\Rector\AbstractRector; | ||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample; | ||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition; | ||
/** | ||
* @see \Rector\Tests\DeadCode\Rector\Block\ReplaceBlockToItsStmtsRector\ReplaceBlockToItsStmtsRectorTest | ||
* @see https://3v4l.org/ZUfEV | ||
*/ | ||
final class ReplaceBlockToItsStmtsRector extends AbstractRector | ||
{ | ||
public function getRuleDefinition() : RuleDefinition | ||
{ | ||
return new RuleDefinition('Replace Block Stmt with its stmts', [new CodeSample(<<<'CODE_SAMPLE' | ||
{ | ||
echo "statement 1"; | ||
echo PHP_EOL; | ||
echo "statement 2"; | ||
} | ||
CODE_SAMPLE | ||
, <<<'CODE_SAMPLE' | ||
echo "statement 1"; | ||
echo PHP_EOL; | ||
echo "statement 2"; | ||
CODE_SAMPLE | ||
)]); | ||
} | ||
/** | ||
* @return array<class-string<Node>> | ||
*/ | ||
public function getNodeTypes() : array | ||
{ | ||
return [Block::class]; | ||
} | ||
/** | ||
* @param Block $node | ||
* @return Stmt[] | ||
*/ | ||
public function refactor(Node $node) : array | ||
{ | ||
return $node->stmts; | ||
} | ||
} |
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
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