@@ -70,7 +70,6 @@ public function extractMethodBodies(string $className): array
7070
7171 $ res = [];
7272 foreach ($ nodeFinder ->findInstanceOf ($ classNode , Node \Stmt \ClassMethod::class) as $ methodNode ) {
73- assert ($ methodNode instanceof Node \Stmt \ClassMethod);
7473 if ($ methodNode ->stmts ) {
7574 $ res [$ methodNode ->name ->toString ()] = $ this ->getReformattedContents ($ methodNode ->stmts , 2 );
7675 }
@@ -110,7 +109,7 @@ public function extractPropertyHookBodies(string $className): array
110109 }
111110
112111
113- public function extractFunctionBody (string $ name ): ? string
112+ public function extractFunctionBody (string $ name ): string
114113 {
115114 $ functionNode = (new NodeFinder )->findFirst (
116115 $ this ->statements ,
@@ -250,7 +249,6 @@ public function extractAll(): PhpFile
250249 $ namespaces = ['' => $ this ->statements ];
251250 foreach ($ this ->statements as $ node ) {
252251 if ($ node instanceof Node \Stmt \Declare_
253- && $ node ->declares [0 ] instanceof Node \Stmt \DeclareDeclare
254252 && $ node ->declares [0 ]->key ->name === 'strict_types '
255253 && $ node ->declares [0 ]->value instanceof Node \Scalar \LNumber
256254 ) {
@@ -344,6 +342,7 @@ private function addTraitToClass(ClassLike $class, Node\Stmt\TraitUse $node): vo
344342 foreach ($ node ->traits as $ item ) {
345343 $ trait = $ class ->addTrait ($ item ->toString ());
346344 }
345+ assert ($ trait instanceof TraitUse);
347346
348347 foreach ($ node ->adaptations as $ item ) {
349348 $ trait ->addResolution (rtrim ($ this ->getReformattedContents ([$ item ], 0 ), '; ' ));
@@ -528,10 +527,7 @@ private function toValue(Node\Expr $node): mixed
528527 return new Literal ($ this ->getReformattedContents ([$ node ], 0 ));
529528
530529 } elseif ($ item ->key ) {
531- $ key = $ item ->key instanceof Node \Identifier
532- ? $ item ->key ->name
533- : $ this ->toValue ($ item ->key );
534-
530+ $ key = $ this ->toValue ($ item ->key );
535531 if ($ key instanceof Literal) {
536532 return new Literal ($ this ->getReformattedContents ([$ node ], 0 ));
537533 }
0 commit comments