diff --git a/composer.json b/composer.json index c472670..30bc134 100644 --- a/composer.json +++ b/composer.json @@ -11,13 +11,13 @@ ], "require": { "php": "^7.4", - "phpstan/phpstan": "^1.9" + "phpstan/phpstan": "^2.0" }, "require-dev": { "cakephp/cakephp": "^2.10.24", - "phpstan/phpstan-phpunit": "^1.3", - "phpunit/phpunit": "^9.6", - "nunomaduro/phpinsights": "^2.7" + "nunomaduro/phpinsights": "^2.7", + "phpstan/phpstan-phpunit": "^2.0", + "phpunit/phpunit": "^9.6" }, "autoload": { "psr-4": { @@ -62,6 +62,7 @@ "config": { "allow-plugins": { "dealerdirect/phpcodesniffer-composer-installer": true - } + }, + "sort-packages": true } } diff --git a/src/ClassRegistryInitExtension.php b/src/ClassRegistryInitExtension.php index 97cbe8e..498e41f 100644 --- a/src/ClassRegistryInitExtension.php +++ b/src/ClassRegistryInitExtension.php @@ -50,20 +50,18 @@ public function isStaticMethodSupported(MethodReflection $methodReflection): boo public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, Scope $scope): ?Type { - $argumentType = $scope->getType($methodCall->getArgs()[0]->value); + $type = $scope->getType($methodCall->getArgs()[0]->value); - if (!$argumentType instanceof ConstantStringType) { - return $this->getDefaultType(); - } - - $value = $argumentType->getValue(); + foreach ($type->getConstantStrings() as $constantString) { + $value = $constantString->getValue(); - if ($this->reflectionProvider->hasClass($value)) { - return new ObjectType($value); - } + if ($this->reflectionProvider->hasClass($value)) { + return new ObjectType($value); + } - if ($this->schemaService->hasTable(Inflector::tableize($value))) { - return new ObjectType('Model'); + if ($this->schemaService->hasTable(Inflector::tableize($value))) { + return new ObjectType('Model'); + } } return $this->getDefaultType();