File tree Expand file tree Collapse file tree
tests/PHPStan/Rules/Properties/data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ public function transform(
7676 ) {
7777 $ line = $ ruleError ->getLine ();
7878 } else {
79- $ line = self ::getLineFromNode ($ node );
79+ $ line = self ::getStartLineFromNode ($ node );
8080 }
8181 if (
8282 $ ruleError instanceof FileRuleError
@@ -168,20 +168,16 @@ public function transform(
168168 );
169169 }
170170
171- public static function getLineFromNode (Node $ node ): int
171+ public static function getStartLineFromNode (Node $ node ): int
172172 {
173- if ($ node instanceof PropertyAssignNode) {
174- return self ::getLineFromNode ($ node ->getPropertyFetch ());
175- }
176-
177- if (
178- $ node instanceof Node \Expr \PropertyFetch
179- || $ node instanceof Node \Expr \MethodCall
180- ) {
181- return $ node ->name ->getStartLine ();
182- }
183-
184- return $ node ->getStartLine ();
173+ $ line = match (true ) {
174+ $ node instanceof PropertyAssignNode => self ::getStartLineFromNode ($ node ->getPropertyFetch ()),
175+ $ node instanceof Node \Expr \PropertyFetch,
176+ $ node instanceof Node \Expr \MethodCall => $ node ->name ->getStartLine (),
177+ default => -1 ,
178+ };
179+
180+ return $ line !== -1 ? $ line : $ node ->getStartLine ();
185181 }
186182
187183}
Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ public function check(
9090 string $ namedArgumentMessage ,
9191 ): array
9292 {
93- $ funcCallLine = RuleErrorTransformer ::getLineFromNode ($ funcCall );
93+ $ funcCallLine = RuleErrorTransformer ::getStartLineFromNode ($ funcCall );
9494
9595 $ functionParametersMinCount = 0 ;
9696 $ functionParametersMaxCount = 0 ;
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class HelloWorld
99 /**
1010 * @return $this
1111 */
12- public function x (): static
12+ public function x ()
1313 {
1414 return $ this ;
1515 }
You can’t perform that action at this time.
0 commit comments