Skip to content

[CodeQuality] Skip WillReturnCallbackFallbackToReturnFalseRector when closure ends in throw or never-returning call - #802

Closed
TomasVotruba wants to merge 1 commit into
mainfrom
fix-9931-willreturncallback-skip-terminal
Closed

TomasVotruba wants to merge 1 commit into
mainfrom
fix-9931-willreturncallback-skip-terminal

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9931

WillReturnCallbackFallbackToReturnFalseRector appended a return false; fallback even when the willReturnCallback() closure could not fall through - it ended in a throw or in a call to a method that returns never (e.g. self::fail()). The added statement was dead code.

The fallthrough check only bailed on a trailing Return_. It now also bails when the last statement is a throw, or an expression whose native type is never.

Covered by two skip fixtures matching the reported cases.

… closure ends in throw or never-returning call
@TomasVotruba

Copy link
Copy Markdown
Member Author

Already fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

WillReturnCallbackFallbackToReturnFalseRector adds dead code after exception or method with return never

1 participant