Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm 2020.2 - PHP Built-in functions are not recognized

Tags:

php

phpstorm

I just installed PhpStorm 2020.2, and notice that all php base classes like Closure or mysqli are not been identified by the IDE.

Looking at the left where the PHP base files are, it just show the folders, like you can see in the first image, on the other hand, my older PhpStorm 2017 has the folders with the files inside it and cant identify all php base classes

PhpStorm 2020.2 enter image description here

PhpStorm 2017 enter image description here

like image 530
SpaceDogCS Avatar asked Sep 25 '20 19:09

SpaceDogCS


Video Answer


2 Answers

It's a known issue. AFAIK there is still no solid idea on why it happens and why only some users are affected.

https://youtrack.jetbrains.com/issue/WI-54626 -- watch this ticket (star/vote/comment) to get notified on any progress. Fixed in PhpStorm 2021.1.1 version.


Current workaround:

  1. Close IDE
  2. Locate folder where PhpStorm 2020.2 stores indexes/caches on your computer (see below)
  3. Delete that folder (as standard "Invalidate caches" does not help here)
  4. Launch IDE

Typical locations for caches folder for different OS:

  • Windows: %USERPROFILE%\AppData\Local\JetBrains\PhpStorm2020.2\caches
  • Linux: ~/.cache/JetBrains/PhpStorm2020.2/caches
  • macOS: ~/Library/Caches/JetBrains/PhpStorm2020.2/caches

For 2021.1 version: use File | Invalidate Caches... -- it now better clears them so no need to delete such folders manually.

  1. File | Invalidate Caches...
  2. Select top 2 options (maybe only 1st will be enough, but better use both)
  3. Use Invalidate and Restart button there
  4. After the IDE will restart, open the project and let re-indexing to complete.

enter image description here

If the issue persists (i.e. comes back the next day / after restart) then it's a different cause and you will have to wait for 2021.1.1 build.

like image 187
LazyOne Avatar answered Oct 16 '22 16:10

LazyOne


Before doing all that @lazyone has said 👌, make sure that the Phpstorm php interpreter is set correctly. You can check that from here:

File/settings/languages & frameworks/php/

like image 36
Seyed Amir KhalifehSoltani Avatar answered Oct 16 '22 14:10

Seyed Amir KhalifehSoltani