Repository navigation
Don't return from a finally block (deprecated in PHP 8.6) - #400
Merged
Merged
Conversation
PHP 8.6 emits "Returning from a finally block is deprecated" when compiling Http2Driver.php. The return in handleStreamEnd() only skipped releasing a stream that was already closed: the check is now part of the release condition. As a side effect, an exception thrown in the try block is no longer discarded when the stream closed meanwhile. CI also runs on PHP 8.6 (without psalm, whose phar requires PHP <= 8.5).
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.
PHP 8.6 deprecates returning from a
finallyblock, and it reports this when the file is compiled:It's the only occurrence in
src(I linted every file on PHP 8.6.0). Applications whose error handler turns deprecations into exceptions fail as soon asHttp2Driveris loaded.The
returninhandleStreamEnd()only skipped releasing a stream that had already been closed, so that check is now part of the release condition. Behaviour stays the same with one exception: areturninfinallyalso discards an exception thrown in thetryblock, so if the body queue or the trailers deferred threw while the stream was being closed, that exception was silently dropped. It now propagates, which I believe was the intent.CI also runs on PHP 8.6, with and without FFI. psalm is skipped on those jobs because
psalm.pharrequires PHP <= 8.5; the 8.5 jobs still run it. On 8.6 locally, the test suite passes (138 tests), and so do php-cs-fixer (with thePHP_CS_FIXER_IGNORE_ENVthe workflow already sets) and composer-require-checker.