File tree Expand file tree Collapse file tree 1 file changed +2
-18
lines changed
Expand file tree Collapse file tree 1 file changed +2
-18
lines changed Original file line number Diff line number Diff line change 22
33namespace PHPStan \DependencyInjection ;
44
5- use function array_key_exists ;
6-
75#[AutowiredService(as: Container::class)]
86final class MemoizingContainer implements Container
97{
@@ -28,26 +26,12 @@ public function hasService(string $serviceName): bool
2826
2927 public function getService (string $ serviceName )
3028 {
31- if (array_key_exists ($ serviceName , $ this ->servicesByName )) {
32- return $ this ->servicesByName [$ serviceName ];
33- }
34-
35- $ service = $ this ->originalContainer ->getService ($ serviceName );
36- $ this ->servicesByName [$ serviceName ] = $ service ;
37-
38- return $ service ;
29+ return $ this ->servicesByName [$ serviceName ] ??= $ this ->originalContainer ->getService ($ serviceName );
3930 }
4031
4132 public function getByType (string $ className )
4233 {
43- if (array_key_exists ($ className , $ this ->servicesByType )) {
44- return $ this ->servicesByType [$ className ];
45- }
46-
47- $ service = $ this ->originalContainer ->getByType ($ className );
48- $ this ->servicesByType [$ className ] = $ service ;
49-
50- return $ service ;
34+ return $ this ->servicesByType [$ className ] ??= $ this ->originalContainer ->getByType ($ className );
5135 }
5236
5337 public function findServiceNamesByType (string $ className ): array
You can’t perform that action at this time.
0 commit comments