This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244770 - Treat vendor directory as include path
Summary: Treat vendor directory as include path
Status: NEW
Alias: None
Product: php
Classification: Unclassified
Component: Composer (show other bugs)
Version: 8.0.1
Hardware: All All
: P3 normal with 1 vote (vote)
Assignee: Tomas Mysik
URL:
Keywords:
Depends on: 254713
Blocks:
  Show dependency tree
 
Reported: 2014-05-28 17:05 UTC by andreas.benzing
Modified: 2017-05-25 14:48 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andreas.benzing 2014-05-28 17:05:23 UTC
Currently, the vendor directory used for composer dependencies is treated as regular directory in the project with full scanning and the error badge problem reported in #226954. Adding the vendor folder to the ignored folders eliminates error badges but also prevents autocomplete from working correctly. However, if the vendor folder is placed outside the project and included using the PHP include path, everything works as intended and the scanning process is much faster.

My proposed solution is an option to treat the vendors folder as an include path rather than part of the project implicitly.
Comment 1 gnat 2015-01-29 16:47:38 UTC
This would be great to get fixed / handled.
Comment 2 XedinUnknown 2016-09-04 13:41:17 UTC
Status is NEW? This is not an enhancement, but a bug. This causes us to waste time, having to manually find the right files, instead of CTRL-clicking on class and method names, and having to type full names while switching back and forth between tabs. NetBeans has good support for auto-complete and related stuff, which I am very happy about. However, this issue throws it all out of the window, because most people will use Composer (hopefully).
Comment 3 Tomas Mysik 2016-09-05 04:46:30 UTC
Definitely not a defect, sorry. One can easily add any directory to the global/project Include Path via IDE Options/Project Properties dialog.

Thanks.
Comment 4 XedinUnknown 2016-10-12 19:13:48 UTC
Tomas,

I've added the vendor dir as include path. However, I do not get any hints or completion from the libs in that folder. The directories appear in the Projects panel, under Include Path. However, they are all grey, possibly due to being in .gitignore.

I also tried adding the vendor dir to "Extra Folders for Code Analysis", but couldn't. Error appears below:
"Folder "vendor" is not underneath Source/Tests/Selenium directory."

So, how can I get those scanned and get completion/hints from the code in the vendors dir, while having it ignored by Git?
Comment 5 Tomas Mysik 2016-10-13 05:52:05 UTC
(In reply to XedinUnknown from comment #4)
> I've added the vendor dir as include path. However, I do not get any hints
> or completion from the libs in that folder. The directories appear in the
> Projects panel, under Include Path.

This should definitely work but please verify that the vendor folder is not amongst Ignore Folders (in Project Properties). You can also try to clean the cachedir.

> However, they are all grey, possibly due
> to being in .gitignore.

Yes.

> 
> I also tried adding the vendor dir to "Extra Folders for Code Analysis", but
> couldn't. Error appears below:
> "Folder "vendor" is not underneath Source/Tests/Selenium directory."

This is only for code analysis, as label says.

> So, how can I get those scanned and get completion/hints from the code in
> the vendors dir, while having it ignored by Git?

See my first paragraph of this comment, it should work.

Thanks.
[1] http://wiki.netbeans.org/FaqWhatIsUserdir
Comment 6 Wirone 2017-01-12 06:56:40 UTC
Tomas, you are not right.

Vendor dir is a (ignored) part of project because composer.json and composer.lock lives in a project's root dir and those files are responsible for installing dependencies in project. Vendor dir itself is ignored because there's no need to commit all external libraries.

Since it is part of project it can't be added to Include Path ("already part of project" error) and adding it to "Ignored folders" causes that directory disappear from project tree, so vendor classes cannot be navigated and so on.

On the other hand, vendor dir is analyzed just like rest of the project. For example, I have added "frenck/php-compatibility" and some files there contains errors on purpose (for PHPCodeSniffer). It causes that whole project is marked as invalid, but I don't need NetBeans to check vendor libraries since I don't write them, I just use them (and they're working fine! doing what they supposed to do).

Would be great if it could be handled somehow.
Comment 7 XedinUnknown 2017-01-12 09:13:17 UTC
Not 100% sure yet, but it would appear that there is something different about the way the vendor dir is scanned. It's true that after its addition to the include path of NetBeans, I get all features *in my own codebase* that depends on the code in the vendor dir. I am able to see what methods are overriding vendor methods, can Ctrl + click vendor class names etc. But it seems that when I go to the code in the vendor dir, these features are not available. Example:

In my PHP code I have a class `JoinAwareInterface`, which has a method `getJoinEntities()` with return type `ExpressionInterface`. If I Ctrl + click that return type, I go to the above mentioned class declaration in the vendor dir. That class extends `EvaluableInterface`. However, when I click on *that* class name, I am not taken to the declaration of `EvaluableInterface`, which is declared in the same vendor dir.

This is probably what originally lead me to believe that the vendor dir isn't being scanned. How can this be fixed? Is this the intended behaviour?
Comment 8 twifty 2017-05-25 14:48:27 UTC
I have to agree in that errors within the vendor directory cause problems for the whole project. Many of the errors are actually related to a third party's test files and are not real errors at all.

We need a way to tell netbeans to treat the vendors directory as if it were part of the "include path" but not part of the "project source".

Also, all these vendor files should be "read only", or at least we should be given the option to set it so. I have often used 'find and replace', only to have it also change vendor files. This makes bugs hard to find as they are not within our own source, and unless cloned from git, composer will not detect the changes. Even when they were cloned, composer will not update until the issue is fixed (revert changes or delete the package).

Marking 'vendor' as external to our source, will 1) eliminate errors within that directory effecting the 'real' source, and 2) speed up 'find and replace' (it doesn't need to look in the vendors).