@@ -25,33 +25,33 @@ final class LazyInternalScopeFactory implements InternalScopeFactory
2525{
2626
2727 /** @var int|array{min: int, max: int}|null */
28- private int |array |null $ phpVersion ;
28+ private readonly int |array |null $ phpVersion ;
2929
30- private readonly Parser $ currentSimpleVersionParser ;
30+ private ? Parser $ currentSimpleVersionParser = null ;
3131
32- private readonly ReflectionProvider $ reflectionProvider ;
32+ private ? ReflectionProvider $ reflectionProvider = null ;
3333
34- private readonly InitializerExprTypeResolver $ initializerExprTypeResolver ;
34+ private ? InitializerExprTypeResolver $ initializerExprTypeResolver = null ;
3535
36- private readonly DynamicReturnTypeExtensionRegistry $ dynamicReturnTypeExtensionRegistry ;
36+ private ? DynamicReturnTypeExtensionRegistry $ dynamicReturnTypeExtensionRegistry = null ;
3737
38- private readonly ExpressionTypeResolverExtensionRegistry $ expressionTypeResolverExtensionRegistry ;
38+ private ? ExpressionTypeResolverExtensionRegistry $ expressionTypeResolverExtensionRegistry = null ;
3939
40- private readonly ExprPrinter $ exprPrinter ;
40+ private ? ExprPrinter $ exprPrinter = null ;
4141
42- private readonly TypeSpecifier $ typeSpecifier ;
42+ private ? TypeSpecifier $ typeSpecifier = null ;
4343
44- private readonly PropertyReflectionFinder $ propertyReflectionFinder ;
44+ private ? PropertyReflectionFinder $ propertyReflectionFinder = null ;
4545
46- private readonly NodeScopeResolver $ nodeScopeResolver ;
46+ private ? NodeScopeResolver $ nodeScopeResolver = null ;
4747
48- private readonly RicherScopeGetTypeHelper $ richerScopeGetTypeHelper ;
48+ private ? RicherScopeGetTypeHelper $ richerScopeGetTypeHelper = null ;
4949
50- private readonly ConstantResolver $ constantResolver ;
50+ private ? ConstantResolver $ constantResolver = null ;
5151
52- private readonly PhpVersion $ phpVersionType ;
52+ private ? PhpVersion $ phpVersionType = null ;
5353
54- private readonly AttributeReflectionFactory $ attributeReflectionFactory ;
54+ private ? AttributeReflectionFactory $ attributeReflectionFactory = null ;
5555
5656 /**
5757 * @param callable(Node $node, Scope $scope): void|null $nodeCallback
@@ -63,22 +63,6 @@ public function __construct(
6363 )
6464 {
6565 $ this ->phpVersion = $ this ->container ->getParameter ('phpVersion ' );
66- $ this ->currentSimpleVersionParser = $ this ->container ->getService ('currentPhpVersionSimpleParser ' );
67-
68- $ this ->reflectionProvider = $ this ->container ->getByType (ReflectionProvider::class);
69- $ this ->initializerExprTypeResolver = $ this ->container ->getByType (InitializerExprTypeResolver::class);
70- $ this ->dynamicReturnTypeExtensionRegistry = $ this ->container ->getByType (DynamicReturnTypeExtensionRegistryProvider::class)->getRegistry ();
71- $ this ->expressionTypeResolverExtensionRegistry = $ this ->container ->getByType (ExpressionTypeResolverExtensionRegistryProvider::class)->getRegistry ();
72- $ this ->exprPrinter = $ this ->container ->getByType (ExprPrinter::class);
73- $ this ->typeSpecifier = $ this ->container ->getByType (TypeSpecifier::class);
74- $ this ->propertyReflectionFinder = $ this ->container ->getByType (PropertyReflectionFinder::class);
75-
76- $ this ->nodeScopeResolver = $ this ->container ->getByType (NodeScopeResolver::class);
77- $ this ->richerScopeGetTypeHelper = $ this ->container ->getByType (RicherScopeGetTypeHelper::class);
78- $ this ->constantResolver = $ this ->container ->getByType (ConstantResolver::class);
79-
80- $ this ->phpVersionType = $ this ->container ->getByType (PhpVersion::class);
81- $ this ->attributeReflectionFactory = $ this ->container ->getByType (AttributeReflectionFactory::class);
8266 }
8367
8468 public function create (
@@ -105,6 +89,23 @@ public function create(
10589 $ className = FiberScope::class;
10690 }
10791
92+ $ this ->currentSimpleVersionParser ??= $ this ->container ->getService ('currentPhpVersionSimpleParser ' );
93+
94+ $ this ->reflectionProvider ??= $ this ->container ->getByType (ReflectionProvider::class);
95+ $ this ->initializerExprTypeResolver ??= $ this ->container ->getByType (InitializerExprTypeResolver::class);
96+ $ this ->dynamicReturnTypeExtensionRegistry ??= $ this ->container ->getByType (DynamicReturnTypeExtensionRegistryProvider::class)->getRegistry ();
97+ $ this ->expressionTypeResolverExtensionRegistry ??= $ this ->container ->getByType (ExpressionTypeResolverExtensionRegistryProvider::class)->getRegistry ();
98+ $ this ->exprPrinter ??= $ this ->container ->getByType (ExprPrinter::class);
99+ $ this ->typeSpecifier ??= $ this ->container ->getByType (TypeSpecifier::class);
100+ $ this ->propertyReflectionFinder ??= $ this ->container ->getByType (PropertyReflectionFinder::class);
101+
102+ $ this ->nodeScopeResolver ??= $ this ->container ->getByType (NodeScopeResolver::class);
103+ $ this ->richerScopeGetTypeHelper ??= $ this ->container ->getByType (RicherScopeGetTypeHelper::class);
104+ $ this ->constantResolver ??= $ this ->container ->getByType (ConstantResolver::class);
105+
106+ $ this ->phpVersionType ??= $ this ->container ->getByType (PhpVersion::class);
107+ $ this ->attributeReflectionFactory ??= $ this ->container ->getByType (AttributeReflectionFactory::class);
108+
108109 return new $ className (
109110 $ this ,
110111 $ this ->reflectionProvider ,
0 commit comments