mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-16 13:00:23 +01:00
Updated Rector to commit 66d93167af53e4116e73f6dc011f02ac23efbd6f
66d93167af
[DeadCode] Add ReplaceBlockToItsStmtsRector (#6641)
This commit is contained in:
parent
232892cf57
commit
79bfc87e90
49
rules/DeadCode/Rector/Block/ReplaceBlockToItsStmtsRector.php
Normal file
49
rules/DeadCode/Rector/Block/ReplaceBlockToItsStmtsRector.php
Normal file
@ -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;
|
||||
}
|
||||
}
|
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = 'f3242bfadc709ca567975be62691944b5f8301ee';
|
||||
public const PACKAGE_VERSION = '66d93167af53e4116e73f6dc011f02ac23efbd6f';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2025-01-01 14:09:44';
|
||||
public const RELEASE_DATE = '2025-01-01 23:32:36';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -8,6 +8,7 @@ use Rector\Contract\Rector\RectorInterface;
|
||||
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
|
||||
use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
|
||||
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
|
||||
use Rector\DeadCode\Rector\Block\ReplaceBlockToItsStmtsRector;
|
||||
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
|
||||
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
|
||||
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
|
||||
@ -80,6 +81,7 @@ final class DeadCodeLevel
|
||||
RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
|
||||
RemoveNullPropertyInitializationRector::class,
|
||||
RemoveUselessReturnExprInConstructRector::class,
|
||||
ReplaceBlockToItsStmtsRector::class,
|
||||
RemoveTypedPropertyDeadInstanceOfRector::class,
|
||||
TernaryToBooleanOrFalseToBooleanAndRector::class,
|
||||
RemoveDoubleAssignRector::class,
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1303,6 +1303,7 @@ return array(
|
||||
'Rector\\DeadCode\\Rector\\Array_\\RemoveDuplicatedArrayKeyRector' => $baseDir . '/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Assign\\RemoveDoubleAssignRector' => $baseDir . '/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Assign\\RemoveUnusedVariableAssignRector' => $baseDir . '/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Block\\ReplaceBlockToItsStmtsRector' => $baseDir . '/rules/DeadCode/Rector/Block/ReplaceBlockToItsStmtsRector.php',
|
||||
'Rector\\DeadCode\\Rector\\BooleanAnd\\RemoveAndTrueRector' => $baseDir . '/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Cast\\RecastingRemovalRector' => $baseDir . '/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php',
|
||||
'Rector\\DeadCode\\Rector\\ClassConst\\RemoveUnusedPrivateClassConstantRector' => $baseDir . '/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php',
|
||||
|
1
vendor/composer/autoload_static.php
vendored
1
vendor/composer/autoload_static.php
vendored
@ -1522,6 +1522,7 @@ class ComposerStaticInit4fb50f2d4af661ecee2245f9ff725125
|
||||
'Rector\\DeadCode\\Rector\\Array_\\RemoveDuplicatedArrayKeyRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Assign\\RemoveDoubleAssignRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Assign\\RemoveUnusedVariableAssignRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Block\\ReplaceBlockToItsStmtsRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Block/ReplaceBlockToItsStmtsRector.php',
|
||||
'Rector\\DeadCode\\Rector\\BooleanAnd\\RemoveAndTrueRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php',
|
||||
'Rector\\DeadCode\\Rector\\Cast\\RecastingRemovalRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Cast/RecastingRemovalRector.php',
|
||||
'Rector\\DeadCode\\Rector\\ClassConst\\RemoveUnusedPrivateClassConstantRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php',
|
||||
|
Loading…
x
Reference in New Issue
Block a user