167167use function usort ;
168168use const PHP_INT_MAX ;
169169use const PHP_INT_MIN ;
170+ use const PHP_VERSION_ID ;
170171
171172class MutatingScope implements Scope, NodeCallbackInvoker
172173{
@@ -205,7 +206,7 @@ class MutatingScope implements Scope, NodeCallbackInvoker
205206 * @param list<array{MethodReflection|FunctionReflection|null, ParameterReflection|null}> $inFunctionCallsStack
206207 */
207208 public function __construct (
208- private InternalScopeFactory $ scopeFactory ,
209+ protected InternalScopeFactory $ scopeFactory ,
209210 private ReflectionProvider $ reflectionProvider ,
210211 private InitializerExprTypeResolver $ initializerExprTypeResolver ,
211212 private DynamicReturnTypeExtensionRegistry $ dynamicReturnTypeExtensionRegistry ,
@@ -217,26 +218,26 @@ public function __construct(
217218 private NodeScopeResolver $ nodeScopeResolver ,
218219 private RicherScopeGetTypeHelper $ richerScopeGetTypeHelper ,
219220 private ConstantResolver $ constantResolver ,
220- private ScopeContext $ context ,
221+ protected ScopeContext $ context ,
221222 private PhpVersion $ phpVersion ,
222223 private AttributeReflectionFactory $ attributeReflectionFactory ,
223224 private int |array |null $ configPhpVersion ,
224225 private $ nodeCallback = null ,
225226 private bool $ declareStrictTypes = false ,
226227 private PhpFunctionFromParserNodeReflection |null $ function = null ,
227228 ?string $ namespace = null ,
228- private array $ expressionTypes = [],
229- private array $ nativeExpressionTypes = [],
230- private array $ conditionalExpressions = [],
231- private array $ inClosureBindScopeClasses = [],
229+ protected array $ expressionTypes = [],
230+ protected array $ nativeExpressionTypes = [],
231+ protected array $ conditionalExpressions = [],
232+ protected array $ inClosureBindScopeClasses = [],
232233 private ?ClosureType $ anonymousFunctionReflection = null ,
233234 private bool $ inFirstLevelStatement = true ,
234- private array $ currentlyAssignedExpressions = [],
235- private array $ currentlyAllowedUndefinedExpressions = [],
236- private array $ inFunctionCallsStack = [],
237- private bool $ afterExtractCall = false ,
235+ protected array $ currentlyAssignedExpressions = [],
236+ protected array $ currentlyAllowedUndefinedExpressions = [],
237+ protected array $ inFunctionCallsStack = [],
238+ protected bool $ afterExtractCall = false ,
238239 private ?Scope $ parentScope = null ,
239- private bool $ nativeTypesPromoted = false ,
240+ protected bool $ nativeTypesPromoted = false ,
240241 )
241242 {
242243 if ($ namespace === '' ) {
@@ -248,8 +249,8 @@ public function __construct(
248249
249250 public function toFiberScope (): self
250251 {
251- if (static ::class === FiberScope::class ) {
252- return $ this ;
252+ if (PHP_VERSION_ID < 80100 ) {
253+ throw new ShouldNotHappenException ( ' Cannot create FiberScope below PHP 8.1 ' ) ;
253254 }
254255
255256 return $ this ->scopeFactory ->toFiberFactory ()->create (
@@ -274,28 +275,7 @@ public function toFiberScope(): self
274275
275276 public function toMutatingScope (): self
276277 {
277- if (static ::class === self ::class) {
278- return $ this ;
279- }
280-
281- return $ this ->scopeFactory ->toMutatingFactory ()->create (
282- $ this ->context ,
283- $ this ->isDeclareStrictTypes (),
284- $ this ->getFunction (),
285- $ this ->getNamespace (),
286- $ this ->expressionTypes ,
287- $ this ->nativeExpressionTypes ,
288- $ this ->conditionalExpressions ,
289- $ this ->inClosureBindScopeClasses ,
290- $ this ->anonymousFunctionReflection ,
291- $ this ->isInFirstLevelStatement (),
292- $ this ->currentlyAssignedExpressions ,
293- $ this ->currentlyAllowedUndefinedExpressions ,
294- $ this ->inFunctionCallsStack ,
295- $ this ->afterExtractCall ,
296- $ this ->parentScope ,
297- $ this ->nativeTypesPromoted ,
298- );
278+ return $ this ;
299279 }
300280
301281 /** @api */
0 commit comments