{"record":{"id":"7bf703188e381ae6","repo":"rectorphp/rector","slug":"s-is-deprecated-as-it-removes-intermediate-var","errorCode":null,"errorMessage":"\"%s\" is deprecated, as it removes intermediate variables that carry naming and can be re-used later","messagePattern":"\"(.+?)\" is deprecated, as it removes intermediate variables that carry naming and can be re-used later","errorType":"exception","errorClass":"ShouldNotHappenException","httpStatus":null,"severity":"error","filePath":"rules/Php85/Rector/StmtsAwareInterface/SequentialAssignmentsToPipeOperatorRector.php","lineNumber":54,"sourceCode":"    |> function2(...)\n    |> function3(...);\nCODE_SAMPLE\n)]);\n    }\n    public function getNodeTypes(): array\n    {\n        return NodeGroup::STMTS_AWARE;\n    }\n    public function provideMinPhpVersion(): int\n    {\n        return PhpVersionFeature::PIPE_OPERATOER;\n    }\n    /**\n     * @param StmtsAware $node\n     */\n    public function refactor(Node $node): ?Node\n    {\n        throw new ShouldNotHappenException(sprintf('\"%s\" is deprecated, as it removes intermediate variables that carry naming and can be re-used later', self::class));\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":57,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/rules/Php85/Rector/StmtsAwareInterface/SequentialAssignmentsToPipeOperatorRector.php#L36-L57","documentation":"Rector\\Php85\\Rector\\StmtsAwareInterface\\SequentialAssignmentsToPipeOperatorRector is deprecated: refactor() throws Rector\\Exception\\ShouldNotHappenException on the first StmtsAware node. The rule collapsed sequences like $a = f($b); $c = g($a); into a PHP 8.5 pipe chain, deleting the intermediate variables - but those variables carry naming intent and can be reused later, so removing them loses information and can break subsequent code. Like the other pipe rule it only loads for PHP 8.5 targets.","triggerScenarios":"The rule remains in a PHP 8.5 config and rector visits any statement-aware node (function body, method body, if branch, etc.); refactor() throws on the first match.","commonSituations":"Bulk-enabling Php85 rules during a 'modernize everything' pass; keeping the rule from an early pipe-operator experiment; CI breaking after rector removed the implementation.","solutions":["Remove SequentialAssignmentsToPipeOperatorRector from rector.php and keep the named intermediate variables.","Only where a chain is clearly better, hand-write the pipe chain and verify no later statement referenced the removed variables.","Do not carry the rule forward in shared/team configs; it will keep throwing on every run."],"exampleFix":"// before (rector.php)\n->withRules([SequentialAssignmentsToPipeOperatorRector::class])\n\n// after (rector.php) - removed; keep named intermediates\n\n// optional manual rewrite (PHP 8.5), only if $values/$filtered are unused later:\n$values = getValues();            // return getValues() |> array_filter(...);\nreturn array_sum(array_filter($values));","handlingStrategy":"validation","validationCode":"use Rector\\Php85\\Rector\\StmtsAwareInterface\\SequentialAssignmentsToPipeOperatorRector;\n\n$rules = [/* your list */ SequentialAssignmentsToPipeOperatorRector::class];\nif (in_array(SequentialAssignmentsToPipeOperatorRector::class, $rules, true)) {\n    throw new InvalidArgumentException('Rule deprecated; keep named intermediate variables');\n}","typeGuard":null,"tryCatchPattern":"try {\n    exit($rectorApplication->run());\n} catch (\\Rector\\Exception\\ShouldNotHappenException $e) {\n    if (str_contains($e->getMessage(), 'SequentialAssignmentsToPipeOperator')) {\n        fwrite(STDERR, 'Remove the rule; intermediates carry naming and may be reused later.' . PHP_EOL);\n        exit(1);\n    }\n    throw $e;\n}","preventionTips":["Treat variable removal as a semantic change: only fold assignments manually after checking later usage.","Keep pipe-operator adoption in per-PR diffs, not automated full-repo rewrites.","Purge deprecated PHP 8.5 rules from shared configs right after upgrading rector."],"tags":["rector","php","pipe-operator","php85","deprecated-rule"],"backgroundTag":"deprecated-api-invoked","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}