Updated Rector to commit 66d93167af53e4116e73f6dc011f02ac23efbd6f

66d93167af [DeadCode] Add ReplaceBlockToItsStmtsRector (#6641)
This commit is contained in:
Tomas Votruba 2025-01-01 16:35:01 +00:00
parent 232892cf57
commit 79bfc87e90
5 changed files with 55 additions and 2 deletions

View 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;
}
}

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'f3242bfadc709ca567975be62691944b5f8301ee'; public const PACKAGE_VERSION = '66d93167af53e4116e73f6dc011f02ac23efbd6f';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2025-01-01 14:09:44'; public const RELEASE_DATE = '2025-01-01 23:32:36';
/** /**
* @var int * @var int
*/ */

View File

@ -8,6 +8,7 @@ use Rector\Contract\Rector\RectorInterface;
use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector; use Rector\DeadCode\Rector\Array_\RemoveDuplicatedArrayKeyRector;
use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector; use Rector\DeadCode\Rector\Assign\RemoveDoubleAssignRector;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector; use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
use Rector\DeadCode\Rector\Block\ReplaceBlockToItsStmtsRector;
use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector; use Rector\DeadCode\Rector\BooleanAnd\RemoveAndTrueRector;
use Rector\DeadCode\Rector\Cast\RecastingRemovalRector; use Rector\DeadCode\Rector\Cast\RecastingRemovalRector;
use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector; use Rector\DeadCode\Rector\ClassConst\RemoveUnusedPrivateClassConstantRector;
@ -80,6 +81,7 @@ final class DeadCodeLevel
RemoveUnusedNonEmptyArrayBeforeForeachRector::class, RemoveUnusedNonEmptyArrayBeforeForeachRector::class,
RemoveNullPropertyInitializationRector::class, RemoveNullPropertyInitializationRector::class,
RemoveUselessReturnExprInConstructRector::class, RemoveUselessReturnExprInConstructRector::class,
ReplaceBlockToItsStmtsRector::class,
RemoveTypedPropertyDeadInstanceOfRector::class, RemoveTypedPropertyDeadInstanceOfRector::class,
TernaryToBooleanOrFalseToBooleanAndRector::class, TernaryToBooleanOrFalseToBooleanAndRector::class,
RemoveDoubleAssignRector::class, RemoveDoubleAssignRector::class,

View File

@ -1303,6 +1303,7 @@ return array(
'Rector\\DeadCode\\Rector\\Array_\\RemoveDuplicatedArrayKeyRector' => $baseDir . '/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php', '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\\RemoveDoubleAssignRector' => $baseDir . '/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php',
'Rector\\DeadCode\\Rector\\Assign\\RemoveUnusedVariableAssignRector' => $baseDir . '/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.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\\BooleanAnd\\RemoveAndTrueRector' => $baseDir . '/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php',
'Rector\\DeadCode\\Rector\\Cast\\RecastingRemovalRector' => $baseDir . '/rules/DeadCode/Rector/Cast/RecastingRemovalRector.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', 'Rector\\DeadCode\\Rector\\ClassConst\\RemoveUnusedPrivateClassConstantRector' => $baseDir . '/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php',

View File

@ -1522,6 +1522,7 @@ class ComposerStaticInit4fb50f2d4af661ecee2245f9ff725125
'Rector\\DeadCode\\Rector\\Array_\\RemoveDuplicatedArrayKeyRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Array_/RemoveDuplicatedArrayKeyRector.php', '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\\RemoveDoubleAssignRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Assign/RemoveDoubleAssignRector.php',
'Rector\\DeadCode\\Rector\\Assign\\RemoveUnusedVariableAssignRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Assign/RemoveUnusedVariableAssignRector.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\\BooleanAnd\\RemoveAndTrueRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/BooleanAnd/RemoveAndTrueRector.php',
'Rector\\DeadCode\\Rector\\Cast\\RecastingRemovalRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/Cast/RecastingRemovalRector.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', 'Rector\\DeadCode\\Rector\\ClassConst\\RemoveUnusedPrivateClassConstantRector' => __DIR__ . '/../..' . '/rules/DeadCode/Rector/ClassConst/RemoveUnusedPrivateClassConstantRector.php',