r/PHPhelp • u/drajver5siti • Jan 17 '25
PHPStan missing types ?
So we started using PHPStan a few days ago and I noticed that there are missing type definitions.
I tried to implement a custom rule which should implement the \PHPStan\Rules\Rule interface but for some reason it does not exist, vscode reports it as an undefined type error.
This is not the only one, I noticed a few more like
\PHPStan\Type\ObjectType, \PHPStan\Type\Type, \PHPStan\Analyser\Scope.
Any help ?
0
Upvotes
2
u/CyberJack77 Jan 17 '25
How is phpstan installed in your project? Do you use the composer versions (so installed as a dev dependency) or do you use the phar version?
2
u/allen_jb Jan 17 '25
From a quick glance / search it looks like:
PHPStan is distributed as a Phar archive by default (even when you install it using Composer), so, assuming you have everything else set up correctly, if you're using either of the first 2 extensions above (or no additional extensions) this will likely be the reason VS Code claims these classes don't exist.
1
u/Lumethys Jan 17 '25
Did you install the package?