Closed MaksBrainiac closed 3 years ago
Looks like duplicate for https://github.com/psalm/psalm-plugin-laravel/issues/110
Here is a list of 1262 keys that self::$storage
has when the error occurs
Only three facades are in the storage: 🤔
illuminate\support\facades\crypt
illuminate\support\facades\date
illuminate\support\facades\facade
Stacktrace:
ClassLikeStorageProvider.php:43, Psalm\Internal\Provider\ClassLikeStorageProvider->get()
Populator.php:123, Psalm\Internal\Codebase\Populator->populateCodebase()
Codebase.php:476, Psalm\Codebase->scanFiles()
ProjectAnalyzer.php:1173, Psalm\Internal\Analyzer\ProjectAnalyzer->checkPaths()
Psalm.php:363, Psalm\Internal\Cli\Psalm::run()
psalm:4, {main}()
Here is the state:
// Psalm\Codebase->scanFiles()
$threads = 1;
$has_changes = true;
// Psalm\Internal\Codebase\Populator->populateCodebase()
$class_storage->name = "Illuminate\Support\Facades\Facade";
$class_storage->dependent_classlikes = [
'illuminate\support\facades\date' => true,
'helldar\laravelsupport\facades\dumper' => true,
'illuminate\support\facades\auth' => true,
'illuminate\support\facades\db' => true,
'illuminate\support\facades\broadcast' => true,
'illuminate\support\facades\route' => true,
'illuminate\support\facades\ratelimiter' => true,
'illuminate\support\facades\storage' => true,
'illuminate\support\facades\app' => true,
'illuminate\support\facades\validator' => true,
'illuminate\support\facades\hash' => true,
'illuminate\support\facades\event' => true,
'illuminate\support\facades\gate' => true,
'illuminate\support\facades\password' => true,
'illuminate\support\facades\crypt' => true,
];
Stacktrace:
That's actually not the right stacktrace, because at Populator.php:123
the \InvalidArgumentException
is caught.
Here's the right stacktrace:
ClassLikeStorageProvider.php:43, Psalm\Internal\Provider\ClassLikeStorageProvider->get()
ClassLikeNodeScanner.php:198, Psalm\Internal\PhpVisitor\Reflector\ClassLikeNodeScanner->start()
ReflectorVisitor.php:183, Psalm\Internal\PhpVisitor\ReflectorVisitor->enterNode()
NodeTraverser.php:200, PhpParser\NodeTraverser->traverseArray()
NodeTraverser.php:114, PhpParser\NodeTraverser->traverseNode()
NodeTraverser.php:223, PhpParser\NodeTraverser->traverseArray()
NodeTraverser.php:91, PhpParser\NodeTraverser->traverse()
FileScanner.php:86, Psalm\Internal\Scanner\FileScanner->scan()
Scanner.php:578, Psalm\Internal\Codebase\Scanner->scanFile()
Scanner.php:329, Psalm\Internal\Codebase\Scanner->Psalm\Internal\Codebase\{closure:/var/www/html/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Scanner.php:325-331}()
Scanner.php:448, Psalm\Internal\Codebase\Scanner->scanFilePaths()
Scanner.php:293, Psalm\Internal\Codebase\Scanner->scanFiles()
Codebase.php:473, Psalm\Codebase->scanFiles()
Config.php:1942, Psalm\Config->visitStubFiles()
ProjectAnalyzer.php:1175, Psalm\Internal\Analyzer\ProjectAnalyzer->checkPaths()
Psalm.php:363, Psalm\Internal\Cli\Psalm::run()
psalm:4, {main}()
State:
// ClassLikeStorageProvider->get(), line 43
$fq_classlike_name = 'illuminate\\support\\facades\\ratelimiter';
$fq_classlike_name_lc = 'illuminate\\support\\facades\\ratelimiter';
$this->storage = [
// 1595 elements
];
$this->new_storage = [
// 709 elements
];
// ClassLikeNodeScanner->start(), line 198
$class_name = "Facade";
$dependant_name_lc = "illuminate\support\facades\ratelimiter";
$fq_classlike_name = "Illuminate\Support\Facades\Facade";
$name_location->file_name = "vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php";
$storage->name = 'Illuminate\Support\Facades\Facade';
$storage->dependent_classlikes = [
'illuminate\support\facades\date' => true,
'helldar\laravelsupport\facades\dumper' => true,
'illuminate\support\facades\auth' => true,
'illuminate\support\facades\db' => true,
'illuminate\support\facades\broadcast' => true,
'illuminate\support\facades\route' => true,
'illuminate\support\facades\ratelimiter' => true,
'illuminate\support\facades\storage' => true,
'illuminate\support\facades\app' => true,
'illuminate\support\facades\validator' => true,
'illuminate\support\facades\hash' => true,
'illuminate\support\facades\event' => true,
'illuminate\support\facades\gate' => true,
'illuminate\support\facades\password' => true,
'illuminate\support\facades\crypt' => true,
];
Both $this->storage
and $this->new_storage
contain illuminate\cache\ratelimiter
, but none contains illuminate\support\facades\ratelimiter
.
By the way, Illuminate\Support\Facades\RateLimiter
is referenced in app/Providers/RouteServiceProvider.php
.
@mr-feek Does this help in any way to track down the issue?
I have another theory: We use Dependabot to update our dependencies on a daily basis. This also means that laravel/framework
gets updated regularly. Maybe Psalm gets confused by the changing timestamp in the vendor/laravel/framework
directory. This wouldn't explain why it happens to Illuminate\Support\Facades\RateLimiter
though.
Here's an important difference of the RateLimiter
facade: In contrast to most of the other facades, that facade is NOT listed in the config/app.php
:
This also means it won't be listed in the stubs.stubphp
generated by the FacadeStubProvider
via ide-helper:generate
.
When running psalm, often an error occurs with the message: Could not get class storage for illuminate\support\facades\ratelimiter
InvalidArgumentException
Could not get class storage for illuminate\support\facades\ratelimiter
at vendor/vimeo/psalm/src/Psalm/Internal/Provider/ClassLikeStorageProvider.php:42 38▕ public function get(string $fq_classlike_name): ClassLikeStorage 39▕ { 40▕ $fq_classlike_name_lc = strtolower($fq_classlike_name); 41▕ if (!isset(self::$storage[$fq_classlike_name_lc])) { ➜ 42▕ throw new \InvalidArgumentException('Could not get class storage for ' . $fq_classlike_name_lc); 43▕ } 44▕ 45▕ return self::$storage[$fq_classlike_name_lc]; 46▕ }
barryvdh/laravel-ide-helper v2.9.1 laravel/framework v8.33.1 psalm/plugin-laravel v1.4.2 vimeo/psalm 4.6.4