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

Clarify Lazy Services usage withfinal &readonly classes#21065

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

Open
kiler129 wants to merge1 commit intosymfony:7.3
base:7.3
Choose a base branch
Loading
fromkiler129:patch-4
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletionsservice_container/lazy_services.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -23,8 +23,8 @@ until you interact with the proxy in some way.

.. warning::

Lazy servicesdo notsupport `final`_ or ``readonly`` classes, but you can use
`Interface Proxifying`_ to work around this limitation.
Lazy services supportfor`final`_ or ``readonly`` classes was introduced in Symfony 7.3, and
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not a warning anymore, make let's move this to a versionadded 7.3 directive?

requires PHP 8.4 or newer. You can use`Interface Proxifying`_ to work around this limitation.

.. _lazy-services_configuration:

Expand DownExpand Up@@ -145,9 +145,9 @@ It defines an optional parameter used to define interfaces for proxy and interse
Interface Proxifying
--------------------

Under the hood,proxies generated to lazily load services inherit from the class
used bythe service. However, sometimes this is not possible at all (e.g. because
the class is`final`_and can not be extended)ornot convenient.
Under the hood,lazy services leverage `lazy objects`_ since PHP 8.4 and Symfony 7.3. In earlier version,
proxy objects inheriting fromthe service's class are generated. One of the limitations of proxy objects
is inability to extend`final`_ or``readonly`` classes.

To workaround this limitation, you can configure a proxy to only implement
specific interfaces.
Expand DownExpand Up@@ -231,4 +231,5 @@ implement multiple interfaces by adding new "proxy" tags.

.. _`ghost object`: https://en.wikipedia.org/wiki/Lazy_loading#Ghost
.. _`final`: https://www.php.net/manual/en/language.oop5.final.php
.. _`lazy objects`: https://www.php.net/manual/en/language.oop5.lazy-objects.php
.. _`proxy`: https://en.wikipedia.org/wiki/Proxy_pattern

[8]ページ先頭

©2009-2025 Movatter.jp