@@ -293,7 +293,7 @@ private function addClassLikeToFile(PhpFile $phpFile, Node\Stmt\ClassLike $node)
293293 $ class = $ phpFile ->addClass ($ node ->namespacedName ->toString ());
294294 $ class ->setFinal ($ node ->isFinal ());
295295 $ class ->setAbstract ($ node ->isAbstract ());
296- $ class ->setReadOnly (method_exists ( $ node , ' isReadonly ' ) && $ node ->isReadonly ());
296+ $ class ->setReadOnly ($ node ->isReadonly ());
297297 if ($ node ->extends ) {
298298 $ class ->setExtends ($ node ->extends ->toString ());
299299 }
@@ -363,11 +363,11 @@ private function addPropertyToClass(ClassLike $class, Node\Stmt\Property $node):
363363 $ prop ->setValue ($ this ->toValue ($ item ->default ));
364364 }
365365
366- $ prop ->setReadOnly (( method_exists ( $ node, ' isReadonly ' ) && $ node ->isReadonly () ) || ($ class instanceof ClassType && $ class ->isReadOnly ()));
366+ $ prop ->setReadOnly ($ node ->isReadonly () || ($ class instanceof ClassType && $ class ->isReadOnly ()));
367367 $ this ->addCommentAndAttributes ($ prop , $ node );
368368
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 ));
371371 $ this ->addHooksToProperty ($ prop , $ node );
372372 }
373373 }
@@ -411,7 +411,7 @@ private function addConstantToClass(ClassLike $class, Node\Stmt\ClassConst $node
411411 foreach ($ node ->consts as $ item ) {
412412 $ const = $ class ->addConstant ($ item ->name ->toString (), $ this ->toValue ($ item ->value ));
413413 $ const ->setVisibility ($ this ->toVisibility ($ node ->flags ));
414- $ const ->setFinal (method_exists ( $ node , ' isFinal ' ) && $ node ->isFinal ());
414+ $ const ->setFinal ($ node ->isFinal ());
415415 $ this ->addCommentAndAttributes ($ const , $ node );
416416 }
417417 }
@@ -479,7 +479,7 @@ private function setupFunction(GlobalFunction|Method|PropertyHook $function, Nod
479479 if ($ getVisibility || $ setVisibility || $ final ) {
480480 $ param = $ function ->addPromotedParameter ($ item ->var ->name )
481481 ->setVisibility ($ getVisibility , $ setVisibility )
482- ->setReadonly (( bool ) ( $ item ->flags & Node \ Stmt \Class_:: MODIFIER_READONLY ))
482+ ->setReadonly ($ item ->isReadonly ( ))
483483 ->setFinal ($ final );
484484 $ this ->addHooksToProperty ($ param , $ item );
485485 } else {
@@ -549,9 +549,9 @@ private function toValue(Node\Expr $node): mixed
549549 private function toVisibility (int $ flags ): ?string
550550 {
551551 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,
555555 default => null ,
556556 };
557557 }
0 commit comments