PHP 8.2.31
Preview: SwitchManipulator.php Size: 749 B
/opt/cpanel/ea-wappspector/vendor/rector/rector/rules/Renaming/NodeManipulator/SwitchManipulator.php

<?php

declare (strict_types=1);
namespace Rector\Renaming\NodeManipulator;

use PhpParser\Node\Scalar\LNumber;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Break_;
final class SwitchManipulator
{
    /**
     * @param Stmt[] $stmts
     * @return Stmt[]
     */
    public function removeBreakNodes(array $stmts) : array
    {
        foreach ($stmts as $key => $node) {
            if (!$node instanceof Break_) {
                continue;
            }
            if (!$node->num instanceof LNumber || $node->num->value === 1) {
                unset($stmts[$key]);
                continue;
            }
            $node->num = $node->num->value === 2 ? null : new LNumber($node->num->value - 1);
        }
        return $stmts;
    }
}

Directory Contents

Dirs: 0 × Files: 2

Name Size Perms Modified Actions
8.94 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
749 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).