@@ -293,7 +293,7 @@ private function addClassLikeToFile(PhpFile $phpFile, Node\Stmt\ClassLike $node)
293
293
$ class = $ phpFile ->addClass ($ node ->namespacedName ->toString ());
294
294
$ class ->setFinal ($ node ->isFinal ());
295
295
$ class ->setAbstract ($ node ->isAbstract ());
296
- $ class ->setReadOnly (method_exists ( $ node , ' isReadonly ' ) && $ node ->isReadonly ());
296
+ $ class ->setReadOnly ($ node ->isReadonly ());
297
297
if ($ node ->extends ) {
298
298
$ class ->setExtends ($ node ->extends ->toString ());
299
299
}
@@ -363,11 +363,11 @@ private function addPropertyToClass(ClassLike $class, Node\Stmt\Property $node):
363
363
$ prop ->setValue ($ this ->toValue ($ item ->default ));
364
364
}
365
365
366
- $ prop ->setReadOnly (( method_exists ( $ node, ' isReadonly ' ) && $ node ->isReadonly () ) || ($ class instanceof ClassType && $ class ->isReadOnly ()));
366
+ $ prop ->setReadOnly ($ node ->isReadonly () || ($ class instanceof ClassType && $ class ->isReadOnly ()));
367
367
$ this ->addCommentAndAttributes ($ prop , $ node );
368
368
369
- $ prop ->setAbstract ((bool ) ($ node ->flags & Node \ Stmt \Class_:: MODIFIER_ABSTRACT ));
370
- $ prop ->setFinal ((bool ) ($ node ->flags & Node \ Stmt \Class_:: MODIFIER_FINAL ));
369
+ $ prop ->setAbstract ((bool ) ($ node ->flags & Modifiers:: ABSTRACT ));
370
+ $ prop ->setFinal ((bool ) ($ node ->flags & Modifiers:: FINAL ));
371
371
$ this ->addHooksToProperty ($ prop , $ node );
372
372
}
373
373
}
@@ -411,7 +411,7 @@ private function addConstantToClass(ClassLike $class, Node\Stmt\ClassConst $node
411
411
foreach ($ node ->consts as $ item ) {
412
412
$ const = $ class ->addConstant ($ item ->name ->toString (), $ this ->toValue ($ item ->value ));
413
413
$ const ->setVisibility ($ this ->toVisibility ($ node ->flags ));
414
- $ const ->setFinal (method_exists ( $ node , ' isFinal ' ) && $ node ->isFinal ());
414
+ $ const ->setFinal ($ node ->isFinal ());
415
415
$ this ->addCommentAndAttributes ($ const , $ node );
416
416
}
417
417
}
@@ -479,7 +479,7 @@ private function setupFunction(GlobalFunction|Method|PropertyHook $function, Nod
479
479
if ($ getVisibility || $ setVisibility || $ final ) {
480
480
$ param = $ function ->addPromotedParameter ($ item ->var ->name )
481
481
->setVisibility ($ getVisibility , $ setVisibility )
482
- ->setReadonly (( bool ) ( $ item ->flags & Node \ Stmt \Class_:: MODIFIER_READONLY ))
482
+ ->setReadonly ($ item ->isReadonly ( ))
483
483
->setFinal ($ final );
484
484
$ this ->addHooksToProperty ($ param , $ item );
485
485
} else {
@@ -549,9 +549,9 @@ private function toValue(Node\Expr $node): mixed
549
549
private function toVisibility (int $ flags ): ?string
550
550
{
551
551
return match (true ) {
552
- (bool ) ($ flags & Node \ Stmt \Class_:: MODIFIER_PUBLIC ) => Visibility::Public,
553
- (bool ) ($ flags & Node \ Stmt \Class_:: MODIFIER_PROTECTED ) => Visibility::Protected,
554
- (bool ) ($ flags & Node \ Stmt \Class_:: MODIFIER_PRIVATE ) => Visibility::Private,
552
+ (bool ) ($ flags & Modifiers:: PUBLIC ) => Visibility::Public,
553
+ (bool ) ($ flags & Modifiers:: PROTECTED ) => Visibility::Protected,
554
+ (bool ) ($ flags & Modifiers:: PRIVATE ) => Visibility::Private,
555
555
default => null ,
556
556
};
557
557
}
0 commit comments