[Symfony44] Add try/catch fixtures with statements before the return - #986
Merged
Conversation
ConsoleExecuteReturnIntRector appended a second, unreachable "return 0;" after a try/catch whose branches did work before returning. Fixed upstream in rector-src #8260; lock the behaviour in here.
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.
Follow-up to rectorphp/rector-src#8260, which is now merged.
ConsoleExecuteReturnIntRectorappended a second, unreachablereturn 0;after atry/catchwhose branches did real work before returning:The cause was in
TerminatedNodeAnalyzer, which bailed out whenever the second-to-last statement of a branch was not itself a terminator. The existingskip_try_catch_return.php.incdid not catch it, as its branches are barereturns with no preceding statement.No rule change is needed here, the fix comes from rector-src. This only pins the behaviour:
try_catch_return_with_stmts_before_return.php.inc— return type is added, no extrareturn 0;skip_try_catch_return_with_stmts_before_return.php.inc— already typed: int, nothing changes at allBoth fail against the pre-#8260 analyzer with exactly the
+ return 0;above, and pass against currentdev-main.