From 08d352028213aa1151f7138e358d423c96c58370 Mon Sep 17 00:00:00 2001 From: Tymoteusz Motylewski Date: Tue, 29 Jun 2021 16:42:55 +0200 Subject: [PATCH] Handle case when getResourceModelClassName returns false In case the magento identifier can't be translated into a class name, return meaningful error which mentions this identifier. e.g. Class banner/banner_collection was not found while trying to analyse it - discovering symbols is probably not configured properly. --- src/Type/Mage/GetResourceModel.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Type/Mage/GetResourceModel.php b/src/Type/Mage/GetResourceModel.php index c6eaffa..5c24a0f 100644 --- a/src/Type/Mage/GetResourceModel.php +++ b/src/Type/Mage/GetResourceModel.php @@ -7,11 +7,15 @@ final class GetResourceModel extends StaticMethodReturnTypeDetector { public function getMagentoClassName(string $identifier): string { - return $this->getMagentoConfig()->getResourceModelClassName($identifier); + $className = $this->getMagentoConfig()->getResourceModelClassName($identifier); + if ($className === false) { + throw new \PHPStan\Broker\ClassNotFoundException($identifier); + } + return $className; } protected static function getMethodName(): string { return 'getResourceModel'; } -} \ No newline at end of file +}