I just installed PhpStorm 2020.2.1 and while type hinting works for classes imported via "use", many built-in PHP classes and constants, such as __NAMESPACE__
, __DIR__
and the PDO class appear as undefined in the IDE.
I tried invalidating cache and checked settings -> Languages & Frameworks -> PHP Runtime , and even reinstalled PhpStorm, but code that causes no warnings on my colleguaes' IDEs still flag as undefined in mine.
You have some issue with PhpStorm caches on your system (quite a few people do for some reason, mainly those that had previous version) as it works just fine here.
Sadly built-in cache invalidation does not help here and you need to do this manually:
Close IDE.
Using your file manager, go to the caches folder for this IDE version and delete it. Typical folder locations:
%USERPROFILE%\AppData\Local\JetBrains\PhpStorm2020.2\caches
~/.cache/JetBrains/PhpStorm2020.2/caches
~/Library/Caches/JetBrains/PhpStorm2020.2/caches
If you have installed your IDE using Toolbox App then the folder location might be different (the exact path then can be found from idea.log
file (Help | Show Log in XXX
) or perhaps from Toolbox App (look for appropriate options under the "gear" icon for PhpStorm).
Launch IDE, open project and let it re-index the whole thing again.
The ticket to watch after (if you are interested): https://youtrack.jetbrains.com/issue/WI-54626 -- watch it (star/vote/comment) to get notified on any progress.