Deprecate returning from a finally block - #22509
Open
aldemeery wants to merge 1 commit into
Open
Conversation
Member
|
Could this be rebased with the conflict fixed and marked as ready? (ideally before tomorrow's tagging) |
Girgias
reviewed
Aug 10, 2026
| OK | ||
| --EXPECTF-- | ||
| Deprecated: Returning from a finally block is deprecated in %s on line %d | ||
| OK No newline at end of file |
Member
There was a problem hiding this comment.
Please keep the EOL before EOF in the tests.
Member
There was a problem hiding this comment.
Oh sorry, missed that you already requested this. 🙂
iluuu1994
reviewed
Aug 11, 2026
| before return | ||
| before return in inner finally | ||
| outer finally run | ||
| outer finally run No newline at end of file |
Member
There was a problem hiding this comment.
Please add trailing newlines to all files.
aldemeery
force-pushed
the
deprecate-return-in-finally
branch
from
August 12, 2026 00:13
8199001 to
44c42a6
Compare
Author
|
@Girgias Rebased and marked ready. Also fixed the trailing newlines you and @iluuu1994 flagged...Thanks for the nudge. |
aldemeery
marked this pull request as ready for review
August 12, 2026 00:22
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.
This PR implements the "return inside finally" deprecation from the PHP 8.6 deprecations RFC.
https://wiki.php.net/rfc/deprecations_php_8_6#deprecate_returning_from_a_finally_block
Returning from a finally block now raises
E_DEPRECATEDat compile time.The check tracks the return lexically. Returning from the try or catch part is still fine, and a return inside a nested closure stays fine because the closure has its own scope. A return in a nested try that is itself inside the finally does get flagged though.
Zend/tests/try/finally_return_deprecation.phptcovers all of that.The rest of the diff adds the deprecation line to existing tests that already return from a finally.