Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[DependencyInjection] Leverage native lazy objects for lazy services#59913

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nicolas-grekas merged 1 commit intosymfony:7.3fromnicolas-grekas:di-native-lazy
Mar 13, 2025

Conversation

nicolas-grekas
Copy link
Member

QA
Branch?7.3
Bug fix?no
New feature?yes
Deprecations?yes
Issues-
LicenseMIT

When a service is lazy, we can leverage native lazy objects on PHP 8.4.

(Note that we still need var-exporter to generate lazy proxies when using theproxy tag - aka when proxying "by interface".)

iosifch and rvanlaak reacted with heart emoji
if (!$manager instanceof LazyLoadingInterface) {
throw new \LogicException(\sprintf('Resetting a non-lazy manager service is not supported. Declare the "%s" service as lazy.', $name));
}
trigger_deprecation('symfony/doctrine-bridge', '7.3', 'Support for proxy-manager is deprecated.');
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This case should never happen (who would use proxy-manager directly instead of Symfony's lazy services for the Doctrine EM!?), still added for completeness.

Copy link
Member

Choose a reason for hiding this comment

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

isn't this deprecation always triggered on PHP 8.3 and older ?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

it's guarded byif (!$manager instanceof LazyLoadingInterface) { (note the!) so only when ppl use proxy-manager, which we don't anymore thanks to var-exporter.

Copy link
Member

Choose a reason for hiding this comment

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

no. This deprecation is triggeredafter that if, when we haven't thrown an exception (and so in the case where we will actually reset the object)

Copy link
Member

Choose a reason for hiding this comment

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

oh, I missed that the case of lazy objects using var-exporter are handledbefore the check for PHP 8.4, so this is not the code path we reach in modern projects.

@nicolas-grekasnicolas-grekas merged commit0c11d82 intosymfony:7.3Mar 13, 2025
8 of 11 checks passed
@nicolas-grekasnicolas-grekas deleted the di-native-lazy branchMarch 13, 2025 14:47
@rvanlaak
Copy link
Contributor

Nice! Could this PR possibly also improve performance? Any idea on how to benchmark that?

@fabpotfabpot mentioned this pull requestMay 2, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof left review comments

Assignees
No one assigned
Projects
None yet
Milestone
7.3
Development

Successfully merging this pull request may close these issues.

4 participants
@nicolas-grekas@rvanlaak@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp