Skip to content

[CodeQuality] Skip never-returning fall-through in WillReturnCallbackFallbackToReturnFalseRector - #801

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-willreturncallback-never-fallthrough
Oct 15, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-willreturncallback-never-fallthrough

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes rectorphp/rector#9931

The rule added a return false; fallback even when the willReturnCallback() closure could not fall through, because its last statement either throws or calls a never-returning method (e.g. self::fail(), which is typed @return never). That added dead code.

Now it bails out when the last statement is a throw or an expression whose type resolves to never.

Covered by two skip fixtures (self::fail() and throw).

@TomasVotruba
TomasVotruba merged commit bc7473c into main Oct 15, 2026
8 checks passed
@TomasVotruba
TomasVotruba deleted the fix-willreturncallback-never-fallthrough branch October 15, 2026 14:50
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