@@ -21,9 +21,6 @@ public function getNodeType(): string
2121
2222 public function processNode (Node $ node , Scope $ scope ): array
2323 {
24- /** @var InClassMethodNode $node */
25- $ node = $ node ;
26-
2724 if ($ scope ->getClassReflection () === null ) {
2825 return [];
2926 }
@@ -42,16 +39,18 @@ public function processNode(Node $node, Scope $scope): array
4239 return [];
4340 }
4441
45- if (!in_array (strtolower ($ node ->getOriginalNode ()->name ->name ), ['setup ' , 'teardown ' ], true )) {
42+ $ methodName = $ node ->getOriginalNode ()->name ->name ;
43+
44+ if (!in_array (strtolower ($ methodName ), ['setup ' , 'teardown ' ], true )) {
4645 return [];
4746 }
4847
49- $ hasParentCall = $ this ->hasParentClassCall ($ node ->getOriginalNode ()->getStmts ());
48+ $ hasParentCall = $ this ->hasParentClassCall ($ node ->getOriginalNode ()->getStmts (), strtolower ( $ methodName ) );
5049
5150 if (!$ hasParentCall ) {
5251 return [
5352 RuleErrorBuilder::message (
54- sprintf ('Missing call to parent::%s method. ' , $ node -> getOriginalNode ()-> name -> name )
53+ sprintf ('Missing call to parent::%s() method. ' , $ methodName )
5554 )->build (),
5655 ];
5756 }
@@ -61,10 +60,11 @@ public function processNode(Node $node, Scope $scope): array
6160
6261 /**
6362 * @param Node\Stmt[]|null $stmts
63+ * @param string $methodName
6464 *
6565 * @return bool
6666 */
67- private function hasParentClassCall (?array $ stmts ): bool
67+ private function hasParentClassCall (?array $ stmts, string $ methodName ): bool
6868 {
6969 if ($ stmts === null ) {
7070 return false ;
@@ -93,7 +93,7 @@ private function hasParentClassCall(?array $stmts): bool
9393 continue ;
9494 }
9595
96- if (in_array ( strtolower ($ stmt ->expr ->name ->name ), [ ' setup ' , ' teardown ' ], true ) ) {
96+ if (strtolower ($ stmt ->expr ->name ->name ) === $ methodName ) {
9797 return true ;
9898 }
9999 }
0 commit comments