Repository navigation
Make exposed downgrade rules idempotent on repeated application - #409
Merged
Merged
Conversation
These rules kept transforming their own output when a rule runs more than once over the same file: - DowngradeFlexibleHeredocSyntaxRector: marker so a flattened doc is skipped - DowngradeNewMethodCallWithoutParenthesesRector: guard checked the wrong token position - DowngradeIsEnumRector: skip isEnum() already wrapped in a method_exists ternary - DowngradePhp73JsonConstRector: clean the flag in-place, so the error check is appended once - DowngradeCovariantReturnTypeRector: only downgrade to a wider ancestor type - DowngradeProcOpenArrayCommandArgRector: skip a command arg already wrapped
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few downgrade rules were not idempotent - running the rule more than once over the same file kept transforming its own output (infinite re-wrapping or re-appending). This is harmless today, but the upcoming rector-src node-traverser simplification drops the created-by-rule reprocessing guard, so each rule must settle on its own.
Fixes:
newvar token; now both positions are checked.isEnum()call already wrapped in amethod_exists(...) ? ... : falseternary, using the sameIS_IF_TERNARYidiom asDowngradeReflectionGetAttributesRector.Expression, so the traverser never descended into theConstFetchto clean the flag; the flag is now cleaned in place, so the error check is appended once.is_array(...) ? implode(...) : ...ternary (its type isstring|array, so the string check did not catch it).All affected rule tests pass, plus ECS and PHPStan.