psalm / psalm-plugin-laravel

A Psalm plugin for Laravel
MIT License
302 stars 72 forks source link

Psalm crashes: Could not get class storage for #106

Closed rubenvanassche closed 4 years ago

rubenvanassche commented 4 years ago

Describe the bug When running psalm, an error occurs with the message: Could not get class storage for. This is happening in the ClassLikeStorageProvider, here: https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php#L41-L48. This method is getting called from here: https://github.com/vimeo/psalm/blob/master/src/Psalm/Internal/Analyzer/Statements/Expression/Call/Method/AtomicMethodCallAnalyzer.php#L339-L341

It seems that the $fq_classlike_name parameter of the get method is null. I've dumped $class_storage and it represents \Illuminate\Database\Eloquent\Builder, that's why I'm creating the issue here and not in the main psalm repository.

When running vendor/bin/psalm --debug-by-line this piece of code, especially the query bit pops up:

return Cart::query()
  ->where('user_uuid', $this->user->getUuid())
  ->where('uuid', $this->session->get('cart_uuid'))
  ->exists();

Cart is just a regular Laravel model nothin special there.

Impacted Versions barryvdh/laravel-debugbar v3.4.1 PHP Debugbar int... barryvdh/laravel-ide-helper v2.8.0 Laravel IDE Help... beyondcode/laravel-dump-server 1.4.0 Symfony Var-Dump... fruitcake/laravel-cors v1.0.6 Adds CORS (Cross... inertiajs/inertia-laravel v0.2.5 The Laravel adap... laravel/framework v7.25.0 The Laravel Fram... laravel/horizon v4.3.3 Dashboard and co... laravel/scout v8.2.1 Laravel Scout pr... laravel/tinker v2.4.2 Powerful REPL fo... propaganistas/laravel-phone 4.2.4 Adds phone numbe... psalm/plugin-laravel dev-master 95761f9 A Laravel plugin... spatie/laravel-backup 6.11.1 A Laravel packag... spatie/laravel-db-snapshots 1.6.1 Quickly dump and... spatie/laravel-event-sourcing 4.2.0 The easiest way ... spatie/laravel-log-dumper 1.3.1 A function to du... spatie/laravel-model-states 1.6.3
spatie/laravel-multitenancy 1.6.4 Make your Larave... spatie/laravel-navigation dev-master 90dc440 Manage menus, br... spatie/laravel-query-builder 2.8.2 Easily build Elo... spatie/laravel-schemaless-attributes 1.7.1 Add schemaless a... spatie/laravel-settings dev-master 1725356 Store your appli... spatie/laravel-sluggable 2.5.0 Generate slugs w... spatie/laravel-stubs 1.1.0 Opinionated Lara... spatie/laravel-tail 4.2.1 Easily tail appl... spatie/laravel-typescript-transformer dev-master 7a73107 Transform your P... spatie/laravel-view-models 1.3.0 View models in L... vimeo/psalm dev-master 9822043 A static analysi...

Any idea what the issue could be?

mr-feek commented 4 years ago

I notice you're on dev-master, it could be https://github.com/vimeo/psalm/issues/4013 .

Could you try updating psalm to the latest dev-master?

rubenvanassche commented 4 years ago

Hi @mr-feek,

That seems to fix it, although another error popped up, maybe we should stop using the master version 😬