PHP built in functions/classes etc. are not recognized
After a restart of PhpStorm it started to highlight all built in classes (e.g. \Exception) as undefined and it also doesn't hint php built in functions (e.g. \trim, \strtolower) while typing. It looks like it suddenly doesn't know native php :-) What settings should I check to make everything work again?
Thank you.
Please sign in to leave a comment.
If none of the above suggested methods help - that might be another issue. Could you please share the IDE logs with us via Help > Collect Logs and Diagnostic Data?
It helped me: deleting ~/.cache/JetBrains/PhpStorm2020.2/ folder
I'm fighting the same problem since updating in IntelliJ ultimate with the PHP plugin enabled. I've tried invalidating cache, restarting, etc. All internal PHP functions show as undefined. All projects are impacted.
rm -rf ~/Library/Caches/JetBrains/PhpStorm2020.2/
worked for me too. Invalidate Caches/Restart did not.
On a side note, I looked for the php.jar file and my PhpStorm.app contents looks pretty barren. It's installed with Toolbox. Is this normal?
Scott Moore, the way to fix that is the manual caches folder removal.
Rooster242, yes, it's normal, this is a stub of the application created by Toolbox, the actual application is located in ~/Library/Application Support/JetBrains/Toolbox/apps/PhpStorm.
I had the same problem today.
Everything worked perfectly
The next day the problem occured.
What i did in the meantime:
I installed docker and docker compose. Of course i added my user to the docker group. That often f***s up my ssh config (permissions being reset by adduser command and the ssh client wont use the keys anymore until you fix the permissions of ~/.ssh). So i think it might be possible that this has to do with the problem.
ALSO: Invalidating the cache from inside phpstorm did not solve the problem. Deleting the whole cache-folder did!
So my suspicion: The invalidation does not delete the folder. If you delete the folder manually, phpstorm will re-create it as it should be and it works.
It does not make a whole lot of sense but yea - a fix would be to completly remove the cache directory if the user invalidates the cache.
Invalidating that cache did also not work for me.
I had to delete:
%LOCALAPPDATA%\JetBrains\PhpStorm2020.2\caches
Yep, that's right -- Invalidating Cache is clearly not enough to fix this issue and "caches" directory has to be removed manually.
Same here with version 2020.2 (Linux)
Cache clearing and disabling plugins did not help.
Did not try Arjan's suggestion.
PhpStorm 2020.2
Build #PS-202.6397.115, built on July 29, 2020
Licensed to xxxx
You have a perpetual fallback license for this version
Subscription is active until August 6, 2021
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.8.11-200.fc32.x86_64
GC: ParNew, ConcurrentMarkSweep
Memory: 725M
Cores: 8
Registry: run.processes.with.pty=TRUE
Current Desktop: GNOME
Did you try to remove caches manually, right?
Not yet.
Invalidating the cache and clearing /caches/* did the trick.
Still hope to get a a real fix in an upcoming release.
I had the same issue. It began, after i closed current project and tried to open another one. While it took a long time to open and looked like stuck i have killed PhpStorm process from task manager. After that i had that problem, that none of PHP functions were recognized.
Possibly, because i killed PhpStorm while opening project.
Invalidating Cache did not help.
Clearing /caches/ did the trick.
I hope it helps to fix it.
manually removing cache directory is the only solution that worked for me
https://youtrack.jetbrains.com/issue/WI-54626
Any movements here? Built-in functions are not defined.
Andrew, did you try a workaround with a manual cache removal already?
On Windows i had the same issue.
First I tried all above solutions, none of em worked.
Then I just registered the CLI Interpreter again in PHPstorm Settings->Languages & Frameworks -> PHP.
Now it is working for me.
Any news here? I have the same problem with phpstorm 2020.3 and 2020.4. I also tried to reinstall without plugins, nothing worked!
Did you try any of the solutions listed here? Specifically try deleting the caches directory in IDE system folder.
Had the same problem now again after the update to 2020.3. Had it already when updating to 2020.1.
All the steps that can be done inside PHPStorm didn't help, I had to delete the cache folder manually.
Same thing happened to me, upgrading from PHPStorm 2019 to PHPStorm 2020.3.2. Arjan Frans's solution was the only thing that finally worked.
Had this issue today after upgrading to 2020.3.2 a few days ago from 2019 (found auto update in the toolbox).
Invalidating the cache did not work; had to manually delete the cache folder and give it a couple of minutes to re-index everything.
Running under Lubuntu.
Same issue on Ubuntu 20 with Phpstorm (2020.3.3) installed via snap store. Snap seemed to decide to update phpstorm by itself which proceeded to break everything. Manually deleting caches was the fix. Invalidating the cache from within the app didn't help.
I had the same issue.
I went to Settings-> Editor-> File Types and it turned out that *.php was listed under Text files not PHP for some reason. I changed that and it worked.