@@ -240,7 +240,7 @@ public function addTrait(string $trait): void
240240 $ importedClassName = $ this ->addUseStatementIfNecessary ($ trait );
241241
242242 /** @var Node\Stmt\TraitUse[] $traitNodes */
243- $ traitNodes = $ this ->findAllNodes (fn ($ node ) => $ node instanceof Node \Stmt \TraitUse);
243+ $ traitNodes = $ this ->findAllNodes (static fn ($ node ) => $ node instanceof Node \Stmt \TraitUse);
244244
245245 foreach ($ traitNodes as $ node ) {
246246 if ($ node ->traits [0 ]->toString () === $ importedClassName ) {
@@ -433,7 +433,7 @@ private function addCustomGetter(string $propertyName, string $methodName, $retu
433433 break ;
434434 default :
435435 // implement other cases if/when the library needs them
436- throw new \Exception ('Not implemented ' );
436+ throw new \Exception ('Not implemented. ' );
437437 }
438438 }
439439
@@ -964,21 +964,21 @@ private function setSourceCode(string $sourceCode): void
964964
965965 private function getClassNode (): Node \Stmt \Class_
966966 {
967- $ node = $ this ->findFirstNode (fn ($ node ) => $ node instanceof Node \Stmt \Class_);
967+ $ node = $ this ->findFirstNode (static fn ($ node ) => $ node instanceof Node \Stmt \Class_);
968968
969969 if (!$ node ) {
970- throw new \Exception ('Could not find class node ' );
970+ throw new \Exception ('Could not find class node. ' );
971971 }
972972
973973 return $ node ;
974974 }
975975
976976 private function getNamespaceNode (): Node \Stmt \Namespace_
977977 {
978- $ node = $ this ->findFirstNode (fn ($ node ) => $ node instanceof Node \Stmt \Namespace_);
978+ $ node = $ this ->findFirstNode (static fn ($ node ) => $ node instanceof Node \Stmt \Namespace_);
979979
980980 if (!$ node ) {
981- throw new \Exception ('Could not find namespace node ' );
981+ throw new \Exception ('Could not find namespace node. ' );
982982 }
983983
984984 return $ node ;
@@ -1044,10 +1044,10 @@ private function createSingleLineCommentNode(string $comment, string $context):
10441044 switch ($ context ) {
10451045 case self ::CONTEXT_OUTSIDE_CLASS :
10461046 // just not needed yet
1047- throw new \Exception ('not supported ' );
1047+ throw new \Exception ('Not supported. ' );
10481048 case self ::CONTEXT_CLASS :
10491049 // just not needed yet
1050- throw new \Exception ('not supported ' );
1050+ throw new \Exception ('Not supported. ' );
10511051 case self ::CONTEXT_CLASS_METHOD :
10521052 return BuilderHelpers::normalizeStmt (new Node \Expr \Variable (\sprintf ('__COMMENT__VAR_%d ' , \count ($ this ->pendingComments ) - 1 )));
10531053 default :
@@ -1146,16 +1146,16 @@ private function addNodeAfterProperties(Node $newNode): void
11461146 $ classNode = $ this ->getClassNode ();
11471147
11481148 // try to add after last property
1149- $ targetNode = $ this ->findLastNode (fn ($ node ) => $ node instanceof Node \Stmt \Property, [$ classNode ]);
1149+ $ targetNode = $ this ->findLastNode (static fn ($ node ) => $ node instanceof Node \Stmt \Property, [$ classNode ]);
11501150
11511151 // otherwise, try to add after the last constant
11521152 if (!$ targetNode ) {
1153- $ targetNode = $ this ->findLastNode (fn ($ node ) => $ node instanceof Node \Stmt \ClassConst, [$ classNode ]);
1153+ $ targetNode = $ this ->findLastNode (static fn ($ node ) => $ node instanceof Node \Stmt \ClassConst, [$ classNode ]);
11541154 }
11551155
11561156 // otherwise, try to add after the last trait
11571157 if (!$ targetNode ) {
1158- $ targetNode = $ this ->findLastNode (fn ($ node ) => $ node instanceof Node \Stmt \TraitUse, [$ classNode ]);
1158+ $ targetNode = $ this ->findLastNode (static fn ($ node ) => $ node instanceof Node \Stmt \TraitUse, [$ classNode ]);
11591159 }
11601160
11611161 // add the new property after this node
0 commit comments