Vscode-intelephense: Working with undefined functions from external wordpress *plugins*

Created on 13 Dec 2019  ·  10Comments  ·  Source: bmewburn/vscode-intelephense

Describe the bug
Since v1.3.x (not exactly sure when), intelephense is now throwing problems for functions not defined in my workspace. While it was easy enough to fix for default wordpress functions by adding wordpress to the list of stubs, it's unclear how to handle this for functions from WP plugins (e.g. woocommerce).

To Reproduce

namespace My\Theme;

do_action('theme-action'); //problem removed by adding 'wordpress' to the stub list.

// Throws: Undefined function 'My\Theme\wc_get_formatted_cart_item_data;
echo wc_get_formatted_cart_item_data( $cart_item ); 

//Throws Undefined type Tribe__Tickets_Plus__Commerce__WooCommerce__Mai
$tribe_woo = \Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();

Platform and version
Windows 10. Intelephense 1.3.4

Most helpful comment

There is a way to disable an error notification for a specific line, something like

//@ts-ignore

in typescript?

Example:

//@php-ignore
my_func_defined_elsewhere();

All 10 comments

They're woocommerce, WordPress subs are here https://github.com/php-stubs/wordpress-stubs

Actually, these were added in 1.3.3

See https://github.com/bmewburn/vscode-intelephense/issues/833#issuecomment-563984827

@ntwb Read what he said

My bad 🤦🏼‍♂️ 🤣

Bolting on to this, where can stubs be placed so that they don't have to be added to each project? Is there a general area I can place stubs which will be picked up by all projects?

@TidyLuke See https://github.com/bmewburn/vscode-intelephense/issues/892#issuecomment-565852100 (I've not tested this)

@ntwb Awesome! I only searched open issues before asking, apologies. You guys have been great recently though, thanks!

There is a way to disable an error notification for a specific line, something like

//@ts-ignore

in typescript?

Example:

//@php-ignore
my_func_defined_elsewhere();

Tracking in #954

Was this page helpful?
0 / 5 - 0 ratings

Related issues

steven7mwesigwa picture steven7mwesigwa  ·  4Comments

muuvmuuv picture muuvmuuv  ·  4Comments

dgunay picture dgunay  ·  3Comments

superadmini picture superadmini  ·  4Comments

zlianon picture zlianon  ·  4Comments