Skip to content

Commit e3950df

Browse files
committed
Clarify Lazy Services usage with final & readonly classes
1 parent c850209 commit e3950df

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

service_container/lazy_services.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ until you interact with the proxy in some way.
2323

2424
.. warning::
2525

26-
Lazy services do not support `final`_ or ``readonly`` classes, but you can use
27-
`Interface Proxifying`_ to work around this limitation.
26+
Lazy services support for `final`_ or ``readonly`` classes was introduced in Symfony 7.3, and
27+
requires PHP 8.4 or newer. You can use `Interface Proxifying`_ to work around this limitation.
2828

2929
.. _lazy-services_configuration:
3030

@@ -145,9 +145,9 @@ It defines an optional parameter used to define interfaces for proxy and interse
145145
Interface Proxifying
146146
--------------------
147147

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

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

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy