psalm-plugin-laravel: Could not get class storage for eloquent

Describe the bug Running Psalm with --debug-by-line on a Laravel 8 project I get:

 /var/www/html/app/Models/User.php:1

   Exception

  Could not get class storage for eloquent
Stack trace in the forked worker:
#0 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(750): Psalm\Internal\Provider\ClassLikeStorageProvider->get('Eloquent')
#1 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(394): Psalm\Internal\Analyzer\ClassAnalyzer::addContextProperties(Object(Psalm\Internal\Analyzer\ClassAnalyzer), Object(Psalm\Storage\ClassLikeStorage), Object(Psalm\Context), 'App\\Models\\Mapp...', 'Illuminate\\Data...', Array)
#2 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(213): Psalm\Internal\Analyzer\ClassAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Context))
#3 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(343): Psalm\Internal\Analyzer\FileAnalyzer->analyze(NULL)
#4 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Fork/Pool.php(193): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}(5, '/var/www/html/a...')
#5 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(409): Psalm\Internal\Fork\Pool->__construct(Array, Object(Closure), Object(Closure), Object(Closure), Object(Closure))
#6 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(272): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 5)
#7 /var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(636): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 5, false, true)
#8 /var/www/html/vendor/vimeo/psalm/src/psalm.php(700): Psalm\Internal\Analyzer\ProjectAnalyzer->check('/var/www/html/', true)
#9 /var/www/html/vendor/vimeo/psalm/src/psalm.php(884): Psalm\{closure}(Array)
#10 /var/www/html/vendor/vimeo/psalm/psalm(2): require_once('/var/www/html/v...')
#11 {main}

Ofc I have the issue also without --debug-by-line.

Impacted Versions

barryvdh/laravel-debugbar                      v3.5.7                           
barryvdh/laravel-ide-helper                    v2.9.1                           
fruitcake/laravel-cors                         v2.0.4                        
laravel/framework                              v8.44.0                          
laravel/sail                                   v1.7.0                          
laravel/tinker                                 v2.6.1                           
psalm/plugin-laravel                           v1.4.5                         
spatie/laravel-ray                             1.18.0                           
vimeo/psalm                                    4.7.3                           

Additional context User.php is the standard user class that comes with every fresh new project.

I tried to remove psalm and psalm/plugin-laravel, clear the cache, and I get the same Could not get class storage for eloquent in other parts of the codebase, for example

/var/www/html/tests/Feature/Models/Mapper/v1/TestCase.php:1

I’m stuck with this.

Edit: I forgot to mention that I’m on php 8.0.3

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

I’m afraid I can’t really help without a reproducer – I haven’t run into this specific issue at all

@mr-feek FYI I’m still experiencing the same issue with da4e6bc:

$ composer show | grep -E 'psalm|laravel'
andrey-helldar/laravel-lang-publisher v10.0.4            Publisher lang files for the Laravel Framework, Jetstream, Fortify, Cashier, Spark and Nova from Laravel-Lang/lang
andrey-helldar/laravel-support        v2.0.1             Various helper files for the Laravel and Lumen frameworks
barryvdh/laravel-ide-helper           v2.9.1             Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.
beyondcode/laravel-dump-server        1.7.0              Symfony Var-Dump Server for Laravel
fruitcake/laravel-cors                v2.0.4             Adds CORS (Cross-Origin Resource Sharing) headers support in your Laravel application
laravel-lang/lang                     10.0.2             Languages for Laravel
laravel/framework                     v8.49.0            The Laravel Framework.
laravel/sail                          v1.8.3             Docker files for running a basic Laravel application.
laravel/sanctum                       v2.11.2            Laravel Sanctum provides a featherweight authentication system for SPAs and simple APIs.
laravel/tinker                        v2.6.1             Powerful REPL for the Laravel framework.
laravel/ui                            v3.3.0             Laravel UI utilities and presets.
psalm/plugin-laravel                  dev-master da4e6bc A Laravel plugin for Psalm
sentry/sentry-laravel                 2.7.0              Laravel SDK for Sentry (https://sentry.io)
spatie/laravel-ray                    1.17.4             Easily debug Laravel apps
vimeo/psalm                           4.8.1              A static analysis tool for finding errors in PHP applications
$ vendor/bin/psalm
Scanning files...

   InvalidArgumentException 

  Could not get class storage for illuminate\support\facades\ratelimiter

  at vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:43
     39▕     public function get(string $fq_classlike_name): ClassLikeStorage
     40▕     {
     41▕         $fq_classlike_name_lc = strtolower($fq_classlike_name);
     42▕         if (!isset(self::$storage[$fq_classlike_name_lc])) {
  ➜  43▕             throw new \InvalidArgumentException('Could not get class storage for ' . $fq_classlike_name_lc);
     44▕         }
     45▕ 
     46▕         return self::$storage[$fq_classlike_name_lc];
     47▕     }