@@ -70,7 +70,6 @@ public function extractMethodBodies(string $className): array
70
70
71
71
$ res = [];
72
72
foreach ($ nodeFinder ->findInstanceOf ($ classNode , Node \Stmt \ClassMethod::class) as $ methodNode ) {
73
- assert ($ methodNode instanceof Node \Stmt \ClassMethod);
74
73
if ($ methodNode ->stmts ) {
75
74
$ res [$ methodNode ->name ->toString ()] = $ this ->getReformattedContents ($ methodNode ->stmts , 2 );
76
75
}
@@ -110,7 +109,7 @@ public function extractPropertyHookBodies(string $className): array
110
109
}
111
110
112
111
113
- public function extractFunctionBody (string $ name ): ? string
112
+ public function extractFunctionBody (string $ name ): string
114
113
{
115
114
$ functionNode = (new NodeFinder )->findFirst (
116
115
$ this ->statements ,
@@ -250,7 +249,6 @@ public function extractAll(): PhpFile
250
249
$ namespaces = ['' => $ this ->statements ];
251
250
foreach ($ this ->statements as $ node ) {
252
251
if ($ node instanceof Node \Stmt \Declare_
253
- && $ node ->declares [0 ] instanceof Node \Stmt \DeclareDeclare
254
252
&& $ node ->declares [0 ]->key ->name === 'strict_types '
255
253
&& $ node ->declares [0 ]->value instanceof Node \Scalar \LNumber
256
254
) {
@@ -344,6 +342,7 @@ private function addTraitToClass(ClassLike $class, Node\Stmt\TraitUse $node): vo
344
342
foreach ($ node ->traits as $ item ) {
345
343
$ trait = $ class ->addTrait ($ item ->toString ());
346
344
}
345
+ assert ($ trait instanceof TraitUse);
347
346
348
347
foreach ($ node ->adaptations as $ item ) {
349
348
$ trait ->addResolution (rtrim ($ this ->getReformattedContents ([$ item ], 0 ), '; ' ));
@@ -528,10 +527,7 @@ private function toValue(Node\Expr $node): mixed
528
527
return new Literal ($ this ->getReformattedContents ([$ node ], 0 ));
529
528
530
529
} 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 );
535
531
if ($ key instanceof Literal) {
536
532
return new Literal ($ this ->getReformattedContents ([$ node ], 0 ));
537
533
}
0 commit comments