Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare a global class so I don't get an error in Undefined type in intelephense in visual code

I'm new to visual studio code and intelephense. I'm working with WordPress and using a class called WP_CLI which's a system installed. So, if I'm not wrong, class WP_CLI is not in my path so I get Undefined type 'WP_CLI'.intelephense(1009)

The ideal solution for me would be to be able to tell inteliphense that WP_CLI is defined elsewhere and not to bother with this error. Not to disable Undefined type altogether.

I can't find the comment to disable it. I've found the similar /** @var int $foo */ for variables but I can't find the documentation for it so I can do the same with classes.

Is there an option to do that?

like image 456
Miquel Adell Avatar asked Nov 14 '22 23:11

Miquel Adell


1 Answers

I found installing the stubs for WP_CLI fixes the issue.

like image 73
mrmadhat Avatar answered Dec 18 '22 08:12

mrmadhat