You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cb215d3
Browse filesBrowse the repository at this point in the historyBrowse files
Apply finally scope changes to try-catch exit points and check by-ref return types after finally
* `TryCatchHandler` now runs `MutatingScope::processFinallyScope()` on every exit
point leaving a try or catch block, so the state a `return`/`break`/`continue`/`goto`
carries out of the statement includes what the `finally` block did afterwards.
This also makes nested try-finally blocks compose.
* New `ReturnAfterFinallyNode` virtual node is emitted for each `return` exit point
with that post-`finally` scope, collected by the function/method/closure/property-hook
node gatherers and exposed as `ReturnStatementsNode::getReturnStatementsAfterFinally()`.
* New `ReturnTypeAfterFinallyRule` (level 3, identifier `return.byRefFinally`) reports
when a function returning by reference hands out a value that the `finally` block
changes into something the declared return type does not accept. Return statements
that already mismatch at the `return` itself are left to the regular return type rules.
* Covers functions, methods, static methods, `__invoke`, closures and `&get` property
hooks; returns from `catch` blocks; nested `finally` blocks; local/static variables,
by-ref parameters, properties, static properties and array offsets; native and
PHPDoc-only return types. Generators are skipped (their return value is not by-ref)
and so is a `finally` that always terminates (already covered by
`OverwrittenExitPointByFinallyRule`). `unset()` in `finally` is correctly not
reported - the returned reference survives it.
0 commit comments