Skip to content

Commit 61f38c7

Browse files
bug #46478 [Contracts] remove static cache from ServiceSubscriberTrait (kbond)
This PR was merged into the 4.4 branch. Discussion ---------- [Contracts] remove static cache from `ServiceSubscriberTrait` | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a I found an edge case when using this trait on a class that extends a parent class that implements `getSubscribedServices()`. The issue occurs if the parent _dynamically_ determines the return value of `getSubscribedServices()` based on something in the child class (in my case, using reflection). It's fine if only one class extends this parent but when multiple do, only the first class registered in the container has the proper services. The next classes have the same as the first because of the static variable. Commits ------- d0843be [DependencyInjection] remove static cache from `ServiceSubscriberTrait`
2 parents 5c29d51 + d0843be commit 61f38c7

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

src/Symfony/Contracts/Service/ServiceSubscriberTrait.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ trait ServiceSubscriberTrait
2929
*/
3030
public static function getSubscribedServices(): array
3131
{
32-
static $services;
33-
34-
if (null !== $services) {
35-
return $services;
36-
}
37-
3832
$services = method_exists(get_parent_class(self::class) ?: '', __FUNCTION__) ? parent::getSubscribedServices() : [];
3933

4034
foreach ((new \ReflectionClass(self::class))->getMethods() as $method) {

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