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.

68 comments
Comment actions Permalink

Thanks. Do you have this problem in one particular project? What if you create an empty project - would the problem reoccur there?

0
Comment actions Permalink

Hello !

I've got the same problem, tried everything said above.

It happens in every projects (i even tried to create an empty project as you mentioned, same problem)

0
Comment actions Permalink

I just created a new project and the problem reoccurs. Sorry :(

e.g.

0
Comment actions Permalink

I see you've tried to reinstall the app: how exactly did you do this? Did you remove the app entirely with sudo rm -rf /Applications/PhpStorm.app?

0
Comment actions Permalink

I did this:

rm -rf /Applications/PhpStorm.app/

rm -rf ~/Library/Application\ Support/JetBrains/

rm -rf ~/Library/Application\ Support/PhpStorm*

rm -rf ~/Library/Caches/JetBrains/

rm -rf ~/Library/Caches/PhpStorm*

rm -rf ~/Projects/my-project/.idea

But maybe I forgot something because if I remember correctly my previous settings (theme, font, IDE sync, etc) always seemed to be there. I had to reset PHPStorm to default settings after reinstalling.

0
Comment actions Permalink

Please check the following:

1) Do you have PHP Runtime node under your Project view?

2) please check that you have a php.jar file at your IDE installation location. On Mac it's /Applications/PhpStorm.app/Contents/plugins/php/lib/. The file is 31,9MB as seen on a screenshot.

0
Comment actions Permalink

Everything looks good on this side:

0
Comment actions Permalink

Thanks! Notice there are no arrows against folders on your screenshot. It means that IDE is having troubles opening those files.

The ls -la output also differs a bit: php.jar on your installation has extended attributes. Please try removing them with xattr -c /Applications/PhpStorm.app/Contents/plugins/php/lib/php.jar

0
Comment actions Permalink

I removed the extended attributes but nothing changes. Even after restarting PHPStorm.

0
Comment actions Permalink

Could you please check if you can open the php.jar with "Archive Utility" app and browse it?

0
Comment actions Permalink

It works fine:

0
Comment actions Permalink

I tried this solution again and... it works: https://twitter.com/alexbusu_dev/status/1289221039256481798

However, I have already run this command earlier, I can see it in my bash history. I think my error was deleting the cache and then reinstalling PHPStorm. The correct manipulation would be to install PHPStorm/the update, delete the cache and restart PHPStorm.

 

So here is the fix:

on Linux, execute this command: rm -rf ~/.cache/JetBrains/PhpStorm2020.2/

on macOs: rm -rf ~/Library/Caches/JetBrains/PhpStorm2020.2/

Then restart PHPStorm.

9
Comment actions Permalink

Thanks  Baptiste, this solution really worked.

0
Comment actions Permalink

Baptiste's solution also worked for me on Windows, where simply invalidating the cache from within PhpStorm was not.

 

On Windows I deleted the files in:

%LOCALAPPDATA%\JetBrains\PhpStorm2020.2\caches

0
Comment actions Permalink

Same here after update to version 2020.2. I have IDE installed via Toolbox.

Standard functions like is_array() are not recognized. I've invalidated cache, disabled plugins etc. I have checked all libs from PHP Runtime. Nothing worked.

Solution with manually removing cache worked. Thanks!

0
Comment actions Permalink

Same here. Invalidating caches didn't work, removing the Cache directory manually helped

3
Comment actions Permalink

If anyone still has the issue and did not clear up the caches manually, please archive the idea.system.path folder, the idea.config.path folder, collect the logs (Help | Collect Logs and Diagnostic Data) and upload all of this here sharing the upload ID.
We need something we can reproduce the issue with badly. Thank you so much!

0
Comment actions Permalink

I have exactly the same issue. I am on Ubuntu with PHPStorm installed via Snap. Only project libraries are recognized. Functions like substr are all unavailable. Tried invalidate caches and some other suggestions, didn't work.

0
Comment actions Permalink

Maybe this helps: when I go to the composer tab in my settings, I see an endless spinner below the composer path. I am also sure this was not the case before the update. As a consequence, I cannot press the apply button and my changes are not taken into account. These things could be linked? Composer is also about external libraries.

0
Comment actions Permalink

Folks, we have extracted issue reports to the YouTrack ticket:
https://youtrack.jetbrains.com/issue/WI-54626

Please feel free to follow and comment.

1
Comment actions Permalink

Guys, we have one more question, as we cannot figure out what caused the issue.
Did any of you manage to solve the problem by simply removing the caches folder, without re-installing PhpStorm?

0
Comment actions Permalink

Eugene Morozov yes.

"Invalidate caches and restart" failed to solve the problem. Executed `rm -rf ~/.cache/JetBrains/PhpStorm2020.2`, closed and reopened PhpStorm. That resolved the issue for me. I did not re-install PhpStorm.

(ArchLinux; https://aur.archlinux.org/packages/phpstorm/)

1
Comment actions Permalink

Solution of Mykola Veriga worked: uninstall with the toolbox app and then a fresh install. In my case, all settings were automatically preserved.

0
Comment actions Permalink

I had to remove the cache manually on windows 10

 

C:\Users\user-pc\AppData\Local\JetBrains\PhpStorm2020.2\caches

 

Why the do we pay so much money for this bullshit?

0
Comment actions Permalink

The same issues for me for all projects.
Clean cache doesnt help, reset ide doesnt help, new project doesnt help, delete .idea doesnt help, disable downloaded plugins doesnt help.

<link removed>

After closing phpstorm and then by manually deleting ~/Library/Caches/JetBrains and then relaunching PhpStorm it solved the issue.

Its on Mac.

Guys, we are paying a lot for licences - it isnt so hard to figure out the issue and provide fix.

0
Comment actions Permalink

Our developers are working on it: https://youtrack.jetbrains.com/issue/WI-54626. Unfortunately we're still can't see what's causing this.

0
Comment actions Permalink

I'm having the same problem with a fresh install on a brand new Mac, none of the suggested solutions help. What info can I provide Dmitry Tronin

0
Comment actions Permalink

Rmcleod79

Please make sure you've deleted ~/Library/Caches/JetBrains/PhpStorm2020.2/caches directory. Then restart PhpStorm & check the problem again.

0
Comment actions Permalink

Dmitry Tronin
I have tried that with no luck, I have also tried the other solution of cloning the stubs directory from GitHub and linking that in PHPStorm and the issue still persists. I was wondering if there was any info I could give you to help your developers who are looking at it, before I try reinstalling using JetBrainsToolbox.

0

Please sign in to leave a comment.