Vscode-intelephense: Undefined function in PHP core functions

Created on 4 Dec 2019  路  5Comments  路  Source: bmewburn/vscode-intelephense

VSCode automatically updated intelephense from 1.3.0 to 1.3.1 and start mark a lot of function calls from WordPress and PHP native calls as _Undefined function_.

bmewburn suggestion looks like a temporary fix but I do wish it to keep highlighting what is undefined.

How to fix this?

Screenshot 2019-12-04 at 09 42 17
Screenshot_2019-12-04_at_09_36_19

Most helpful comment

Also you can try open full project in you code editor, not only theme folder.

All 5 comments

For first screenshot https://github.com/bmewburn/vscode-intelephense/issues/787#issuecomment-561342711

Second is a weird one, and I can't reproduce it. It looks like intelephense.stubs setting don't have Core nor standard. Can you check this setting?
Can you also check if \function_exists will work?

For first screenshot #787 (comment)

Thanks, this is very usefull.

Second is a weird one, and I can't reproduce it. It looks like intelephense.stubs setting don't have Core nor standard. Can you check this setting?
Can you also check if \function_exists will work?

The settings for excluding files were incorrect and were causing the problem.
There was something like this :

"intelephense.files.exclude": {
"vendor": true,
"build": true,
"packages": true,
"node_modules": true,
"wp-includes": true,
"wp-admin": true
}

And it should be:
"intelephense.files.exclude": [
"**/vendor/**",
"**/build/**",
"**/packages/**",
"**/node_modules/**",
"**/wp-includes/**",
"**/wp-admin/**"
],

Combining the you're first suggestion with this change fixs it.

I solved it by installing composer require --dev giacocorsiglia/wordpress-stubs and setting "intelephense.files.maxSize": 3200000, in the VSCode editor.

Also you can try open full project in you code editor, not only theme folder.

If you're using WSL (tested on V2 at least), you need to add the composer global path to the include paths like so on settings.json

"intelephense.environment.includePaths": [
     "/home/ilan/.composer/vendor/",
  ],

Then I required the WordPress and ACF stubs, like @ahmadawais said, but globally:

composer require global giacocorsiglia/wordpress-stubs paulthewalton/acf-stubs paulthewalton/acf-pro-stubs

This is probably useful on #907 and #892 as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

umpirsky picture umpirsky  路  4Comments

mushmelty picture mushmelty  路  4Comments

zlianon picture zlianon  路  3Comments

aleksandervines picture aleksandervines  路  3Comments

ghost picture ghost  路  3Comments