Skip to content

Commit 39f9161

Browse files
committed
staticcall
1 parent a5cee18 commit 39f9161

15 files changed

+239
-320
lines changed

.phpstan-dba-mysqli.cache

Lines changed: 3 additions & 247 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
"php": "^7.4 || ^8.0",
88
"composer-runtime-api": "^2.0",
99
"composer/semver": "^3.2",
10-
"doctrine/dbal": "3.*|4.*",
11-
"phpstan/phpstan": "^2.0"
10+
"doctrine/dbal": "3.*",
11+
"phpstan/phpstan": "^2.0",
12+
"sqlftw/sqlftw": "^0.1.17"
1213
},
1314
"require-dev": {
1415
"ext-mysqli": "*",

src/Rules/QueryPlanAnalyzerRule.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use PhpParser\Node\Expr\CallLike;
99
use PhpParser\Node\Expr\MethodCall;
1010
use PhpParser\Node\Expr\New_;
11+
use PhpParser\Node\Expr\StaticCall;
12+
use PhpParser\Node\Identifier;
13+
use PhpParser\Node\Name;
1114
use PhpParser\Node\Name\FullyQualified;
1215
use PHPStan\Analyser\Scope;
1316
use PHPStan\Reflection\ReflectionProvider;
@@ -30,7 +33,7 @@ final class QueryPlanAnalyzerRule implements Rule
3033
/**
3134
* @var list<string>
3235
*/
33-
private array $classMethods;
36+
public array $classMethods;
3437

3538
private ReflectionProvider $reflectionProvider;
3639

@@ -56,6 +59,15 @@ public function processNode(Node $callLike, Scope $scope): array
5659
}
5760

5861
$methodReflection = $scope->getMethodReflection($scope->getType($callLike->var), $callLike->name->toString());
62+
} elseif ($callLike instanceof StaticCall) {
63+
if (! $callLike->name instanceof Identifier) {
64+
return [];
65+
}
66+
if (! $callLike->class instanceof Name) {
67+
return [];
68+
}
69+
$classType = $scope->resolveTypeByName($callLike->class);
70+
$methodReflection = $scope->getMethodReflection($classType, $callLike->name->toString());
5971
} elseif ($callLike instanceof New_) {
6072
if (! $callLike->class instanceof FullyQualified) {
6173
return [];
@@ -105,7 +117,7 @@ public function processNode(Node $callLike, Scope $scope): array
105117
}
106118

107119
/**
108-
* @param MethodCall|New_ $callLike
120+
* @param MethodCall|StaticCall|New_ $callLike
109121
*
110122
* @return list<IdentifierRuleError>
111123
*/

src/Rules/SyntaxErrorInPreparedStatementMethodRule.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use PhpParser\Node\Expr\CallLike;
99
use PhpParser\Node\Expr\MethodCall;
1010
use PhpParser\Node\Expr\New_;
11+
use PhpParser\Node\Expr\StaticCall;
12+
use PhpParser\Node\Identifier;
13+
use PhpParser\Node\Name;
1114
use PhpParser\Node\Name\FullyQualified;
1215
use PHPStan\Analyser\Scope;
1316
use PHPStan\Reflection\ReflectionProvider;
@@ -57,6 +60,15 @@ public function processNode(Node $callLike, Scope $scope): array
5760
}
5861

5962
$methodReflection = $scope->getMethodReflection($scope->getType($callLike->var), $callLike->name->toString());
63+
} elseif ($callLike instanceof StaticCall) {
64+
if (! $callLike->name instanceof Identifier) {
65+
return [];
66+
}
67+
if (! $callLike->class instanceof Name) {
68+
return [];
69+
}
70+
$classType = $scope->resolveTypeByName($callLike->class);
71+
$methodReflection = $scope->getMethodReflection($classType, $callLike->name->toString());
6072
} elseif ($callLike instanceof New_) {
6173
if (! $callLike->class instanceof FullyQualified) {
6274
return [];
@@ -96,7 +108,7 @@ public function processNode(Node $callLike, Scope $scope): array
96108
}
97109

98110
/**
99-
* @param MethodCall|New_ $callLike
111+
* @param MethodCall|StaticCall|New_ $callLike
100112
*
101113
* @return list<IdentifierRuleError>
102114
*/

0 commit comments

Comments
 (0)