Skip to content

Fix PHP 8.6 'Returning from a finally block' deprecation in PackageResolver - #1104

Open
mickverm wants to merge 1 commit into
symfony:2.xfrom
mickverm:php-8.6-deprecation
Open

mickverm wants to merge 1 commit into
symfony:2.xfrom
mickverm:php-8.6-deprecation

Conversation

@mickverm

@mickverm mickverm commented Sep 24, 2026 •

Copy link
Copy Markdown

PHP 8.6 deprecates returning from a finally block.

The current implementation returns from finally. When an exception is thrown in the try block, $config remains undefined, causing !isset($config['extra']['symfony']['require']) to evaluate to true. As a result, the finally block returns '' and the original exception is swallowed.

To preserve this existing behaviour while removing the deprecated return from finally, the exception is explicitly caught and '' is returned from the catch block instead.

No functional change is intended.

@mickverm

Copy link
Copy Markdown
Author

The CS error is unrelated to the change.

Comment thread src/PackageResolver.php
@mickverm
mickverm requested a review from stof September 24, 2026 14:52
Comment thread src/PackageResolver.php
return '';
}

if (!$isRequire || !isset($config['extra']['symfony']['require'])) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if(!$isRequire) could even be moved before the try.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants