vscode-intelephense icon indicating copy to clipboard operation
vscode-intelephense copied to clipboard

Stubs in included paths not being recognized

Open UVLabs opened this issue 3 years ago • 9 comments

Describe the bug

I downloaded the WP CLI stubs from

Unfortunately adding the path to the directory in included_paths didn't work like it did with the WooCommerce plugin (so that I can jump to definitions to see what they do under the hood)

I restarted editor multiple times but no dice.

What worked is adding that same! path to the list of intelephense stubs in settings.json.

Note: I tried adding to included paths for User since I need these symbols throughout multiple workspaces.

To Reproduce Try using the WP_CLI constant in a file while having the stubs github repo in your list of included paths.

Expected behavior Steps should be recorgnized

Screenshots Doesn't work:

Screenshot 2021-10-03 at 9 27 24 AM

Works:

Screenshot 2021-10-03 at 9 27 50 AM

Platform and version MAC OS Big Sur Intelephense 1.7.1 Premium

UVLabs avatar Oct 03 '21 13:10 UVLabs

Hey @bmewburn but I have the same issue, but in my case on Windows / WSL2.

No matter what path I tried in intelephense.environment.includePaths I couldn't get it to work. I tried referencing folders in both my Windows file system and my WSL2 instance -- neither work.

If instead I do what @UVLabs reported and use intelephense.stubs it works (using either a Window file system path or with a WSL2 path), despite settings.json reporting it as "Value not accepted." It's cool this works, but the error message is annoying and getting it to work property via includePaths would be greatly appreciated.

In other words, this worked:

    "intelephense.stubs": [
        "/home/onetrev/stubs"
        "apache",
        "bcmath",
        "bz2"
        ....
     ]

Not sure if it makes a difference, but it might help you bug test, I'm running with a premium license.👍

onetrev avatar Dec 26 '21 09:12 onetrev

I've run into this issue as well.

My old includePaths still works for files that have been previously added:

  "intelephense.environment.includePaths": [
    "/Users/Jacob/Projects/Assets/Stubs",
  ],

But any new files added are not registered, unless I add them to the "intelephense.stubs" array, which throws a warning that the value is not an accepted match, but works regardless.

jacobcassidy avatar Nov 19 '23 12:11 jacobcassidy

I'm seeing the same issue, adding them intelephense.stubs works, they don't need to be in intelephense.environment.includePaths

senadir avatar Dec 05 '23 10:12 senadir

Just to be clear, as I'm really hoping @bmewburn can fix this long standing issue, while adding it to intelephense.stubs works, you do get this warning:

"Value is not accepted."

You should be able to add the path to intelephense.environment.includePaths from how I understand it. Which would be ideal as then you wouldn't receive the above warning message.

onetrev avatar Dec 05 '23 22:12 onetrev

Having trouble reproducing this issue. It's working for me.

bmewburn avatar Dec 09 '23 05:12 bmewburn

Hey @bmewburn, I just did some testing. And you are right, includPaths works, well sort of / mostly. There is a potential problem still...

I am able to add a path to intelephense.environment.includePaths, and Intelephense picks up my acf-pro-stubs.php file in there. Cool. That totally works as it should. But in my stubs folder, I have other stubs, including the two Wordpress stubs I want, wordpress-globals.php and wordpress-stubs.php. Those stubs though do not get picked up. If I add the this same folder to intelephense.stubs it does work. That's weird isn't it?

Yes, I do know I can add Wordpress to this setting, intelephense.stubs, but then when I do it creates a huge list in my settings.json file, and that bugs me as I like to keep things short and tidy. It's a problem I know. :) Regardless though, shouldn't all stubs in intelephense.environment.includePaths work? Thanks! And I really hope that helps explain it better.

onetrev avatar Dec 10 '23 01:12 onetrev

@onetrev might the files be larger than the max file size setting? intelephense.files.maxSize

bmewburn avatar Dec 10 '23 06:12 bmewburn

@onetrev might the files be larger than the max file size setting? intelephense.files.maxSize

That looks like the cause. I just updated my intelephense.files.maxSize from 1MB (1000000 bytes) to 10MB (10000000 bytes) and all paths work again in the folder I added to the intelephense.environment.includePaths

jacobcassidy avatar Dec 10 '23 12:12 jacobcassidy

Confirmed @bmewburn. Thank you! Relief. As @jacobcassidy also noted, this fixed the issue. I'd say this issue could now be closed.

onetrev avatar Dec 10 '23 23:12 onetrev