Skip to content

Commit c720728

Browse files
Refactor
1 parent a5cece4 commit c720728

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

‎src/Analyser/RuleErrorTransformer.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function transform(
7676
) {
7777
$line = $ruleError->getLine();
7878
} else {
79-
$line = $this->getLineFromNode($node);
79+
$line = self::getLineFromNode($node);
8080
}
8181
if (
8282
$ruleError instanceof FileRuleError
@@ -168,10 +168,10 @@ public function transform(
168168
);
169169
}
170170

171-
private function getLineFromNode(Node $node): int
171+
public static function getLineFromNode(Node $node): int
172172
{
173173
if ($node instanceof PropertyAssignNode) {
174-
return $this->getLineFromNode($node->getPropertyFetch());
174+
return self::getLineFromNode($node->getPropertyFetch());
175175
}
176176

177177
if (

‎src/Rules/FunctionCallParametersCheck.php‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use PhpParser\Node;
66
use PhpParser\Node\Expr;
77
use PHPStan\Analyser\MutatingScope;
8+
use PHPStan\Analyser\RuleErrorTransformer;
89
use PHPStan\Analyser\Scope;
910
use PHPStan\DependencyInjection\AutowiredParameter;
1011
use PHPStan\DependencyInjection\AutowiredService;
@@ -89,11 +90,7 @@ public function check(
8990
string $namedArgumentMessage,
9091
): array
9192
{
92-
if ($funcCall instanceof Node\Expr\MethodCall || $funcCall instanceof Node\Expr\StaticCall || $funcCall instanceof Node\Expr\FuncCall) {
93-
$funcCallLine = $funcCall->name->getStartLine();
94-
} else {
95-
$funcCallLine = $funcCall->getStartLine();
96-
}
93+
$funcCallLine = RuleErrorTransformer::getLineFromNode($funcCall);
9794

9895
$functionParametersMinCount = 0;
9996
$functionParametersMaxCount = 0;

0 commit comments

Comments
 (0)