diff --git a/src/Psalm/Exception/ClassStorageNotFoundException.php b/src/Psalm/Exception/ClassStorageNotFoundException.php new file mode 100644 index 00000000000..9c5cd0c8f01 --- /dev/null +++ b/src/Psalm/Exception/ClassStorageNotFoundException.php @@ -0,0 +1,26 @@ +name = $name; + return $this; + } + + public function getName(): ?string + { + return $this->name; + } +} diff --git a/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php b/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php index 1be26f84398..1ad0e54e02d 100644 --- a/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php +++ b/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use LogicException; +use Psalm\Exception\ClassStorageNotFoundException; use Psalm\Storage\ClassLikeStorage; use function strtolower; @@ -40,7 +41,9 @@ public function get(string $fq_classlike_name): ClassLikeStorage $fq_classlike_name_lc = strtolower($fq_classlike_name); /** @psalm-suppress ImpureStaticProperty Used only for caching */ if (!isset(self::$storage[$fq_classlike_name_lc])) { - throw new InvalidArgumentException('Could not get class storage for ' . $fq_classlike_name_lc); + throw (new ClassStorageNotFoundException( + 'Could not get class storage for ' . $fq_classlike_name_lc) + )->setName($fq_classlike_name_lc); } /** @psalm-suppress ImpureStaticProperty Used only for caching */