Skip to content

Commit 21673aa

Browse files
authored
Merge pull request #9 from sidz/use-phpstan-2
Support PHPStan 2
2 parents 2d96028 + 3cb307e commit 21673aa

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
],
1212
"require": {
1313
"php": "^7.4",
14-
"phpstan/phpstan": "^1.9"
14+
"phpstan/phpstan": "^2.0"
1515
},
1616
"require-dev": {
1717
"cakephp/cakephp": "^2.10.24",
18-
"phpstan/phpstan-phpunit": "^1.3",
19-
"phpunit/phpunit": "^9.6",
20-
"nunomaduro/phpinsights": "^2.7"
18+
"nunomaduro/phpinsights": "^2.7",
19+
"phpstan/phpstan-phpunit": "^2.0",
20+
"phpunit/phpunit": "^9.6"
2121
},
2222
"autoload": {
2323
"psr-4": {
@@ -62,6 +62,7 @@
6262
"config": {
6363
"allow-plugins": {
6464
"dealerdirect/phpcodesniffer-composer-installer": true
65-
}
65+
},
66+
"sort-packages": true
6667
}
6768
}

src/ClassRegistryInitExtension.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,18 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo
5050

5151
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type
5252
{
53-
$argumentType = $scope->getType($methodCall->getArgs()[0]->value);
53+
$type = $scope->getType($methodCall->getArgs()[0]->value);
5454

55-
if (!$argumentType instanceof ConstantStringType) {
56-
return $this->getDefaultType();
57-
}
58-
59-
$value = $argumentType->getValue();
55+
foreach ($type->getConstantStrings() as $constantString) {
56+
$value = $constantString->getValue();
6057

61-
if ($this->reflectionProvider->hasClass($value)) {
62-
return new ObjectType($value);
63-
}
58+
if ($this->reflectionProvider->hasClass($value)) {
59+
return new ObjectType($value);
60+
}
6461

65-
if ($this->schemaService->hasTable(Inflector::tableize($value))) {
66-
return new ObjectType('Model');
62+
if ($this->schemaService->hasTable(Inflector::tableize($value))) {
63+
return new ObjectType('Model');
64+
}
6765
}
6866

6967
return $this->getDefaultType();

0 commit comments

Comments
 (0)