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.

83 comments
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.

16
Comment actions Permalink

I encountered the same problem, where native classes and functions were not being recognized by PhpStorm (2019.1.2).

It appears something in the cache/indexing was corrupted as I couldn't pull up any quick documentation on it, nor could I navigate (Ctrl + click) to the definition... No obvious cause found...

The solution for me was to invalidate my cache (File->Invalidate Caches / Restart)

After re-indexing and re-caching it is working as expected now.

9
Comment actions Permalink

Same issue after updating to 2020.2

6
Comment actions Permalink

Disabling plugins and invalidating the cache didn't help.

 

As a workaround I found this solution: https://stackoverflow.com/questions/30328805/phpstorm-how-to-add-method-stubs-from-a-pecl-library-that-phpstorm-doesnt-curr

 

1. Clone the stubs repository

2. Configure the default stubs path

6
Comment actions Permalink

I reinstalled PHPStorm with https://www.jetbrains.com/toolbox-app/
and the issue was resolved

5
Comment actions Permalink

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

5
Comment actions Permalink

I got the same bug after updating it to 2020.2

4
Comment actions Permalink

I have the same Issue since i updated.

PhpStorm 2020.2
Build #PS-202.6397.115, built on July 29, 2020
Licensed to active value GmbH / Chris Adam
Subscription is active until June 16, 2021
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.0.0-38-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 1917M
Cores: 12
Registry: run.processes.with.pty=TRUE, ide.balloon.shadow.size=0
Non-Bundled Plugins: com.chrisrm.idea.MaterialThemeUI, com.jensteichert.themes.nightowl, com.mallowigi, de.espend.idea.php.annotation, fr.adrienbrault.idea.symfony2plugin, izhangzhihao.rainbow.brackets
Current Desktop: ubuntu:GNOME

3
Comment actions Permalink

I have this issue too after update to PhpStorm 2020.2

 

PhpStorm 2020.2
Build #PS-202.6397.115, built on July 29, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Registry: run.processes.with.pty=TRUE, debugger.watches.in.variables=false
Non-Bundled Plugins: de.netnexus.camelcaseplugin, intellij.prettierJS, de.espend.idea.laravel, com.kalessil.phpStorm.phpInspectionsEA, de.espend.idea.php.annotation

3
Comment actions Permalink

The same happened today after snap update.
Details:

PhpStorm 2020.2
Build #PS-202.6397.115, built on July 29, 2020
Licensed to PhpStorm Evaluator
Expiration date: August 29, 2020
Runtime version: 11.0.7+10-b944.20 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 5.4.0-42-generic
GC: ParNew, ConcurrentMarkSweep
Memory: 841M
Cores: 4
Registry: run.processes.with.pty=TRUE
Non-Bundled Plugins: com.aurimasniekis.phppsr4namespacedetector, ru.adelf.idea.dotenv
Current Desktop: ubuntu:GNOME

2
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

2
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/)

2
Comment actions Permalink

It helped me: deleting ~/.cache/JetBrains/PhpStorm2020.2/ folder

2
Comment actions Permalink

Did you try to remove caches manually, right?

2
Comment actions Permalink

 

Had the same problems, and only

  • disabling some 3rd party plugins

helped. I had two new RDF related plugins installed (LNKD.tech Editor, RDF and SPARQL). After disabling them PHPStorm again recognized php standard functions etc.

1
Comment actions Permalink

Please try opening plugins directory and delete all plugin folders manually. and then restart IDE. If that doesn't help - please attach a screenshot of the problem + share your idea.log file. You can also contact us via Help | Contact Support to do this privately.

1
Comment actions Permalink

1) do you have PhpStorm installed via ToolBox app or a standalone app or via snap?

2) do you have "Core" PHP runtime enabled at File | Settings | Languages & Frameworks | PHP?

1
Comment actions Permalink

Thanks  Baptiste, this solution really worked.

1
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!

1
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

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.

1
Comment actions Permalink

Rmcleod79

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

1
Comment actions Permalink

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?

1
Comment actions Permalink

Yep, that's right -- Invalidating Cache is clearly not enough to fix this issue and "caches" directory has to be removed manually.

1
Comment actions Permalink

Not yet.

Invalidating the cache and clearing /caches/* did the trick.

Still hope to get a a real fix in an upcoming release.

1
Comment actions Permalink

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.

1
Comment actions Permalink

Did you try any of the solutions listed here? Specifically try deleting the caches directory in IDE system folder.

1
Comment actions Permalink

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.

1
Comment actions Permalink

I was looking for it for half an hour and of course, right after posting this question, I found it :)

"Settings/Languages & Frameworks/PHP/PHP Runtime/Sync Extensions with Interpreter."

0

Please sign in to leave a comment.