Not searching for phpdoc outside the current scope
Closed this issue · 3 comments
It seems that the plugin isn't searching for phpdoc outside the current scope. I tested it with and without other plugins and a nearly empty .vimrc file but that doesn't seem to change a thing.
This is probably somehow related to #70 but it still won't work properly when I checkout the commit that fixes that specific issue.
Non working example:
class MyClass {
/* @var OtherClass */
private $property;
public myFunction() {
$property-> // not working
}
}Working example:
class MyClass {
private $property;
public myFunction() {
/* @var OtherClass $property */
$property-> // working
}
}The "docblock type for class properties" type guessing is working as far as i can tell.
By looking at your example i think there's two things that might cause your situation:
- The line:
$property-> ... //
Seems to lack the $this-> in front of the property (i assume this is just because the ad-hoc example and probably not the case in the actual code)
2. The type annotations should be in docblock comments while in your example you have a simple multiline comment, so instead of:
/* @var OtherClass */
You should write:
/** @var OtherClass */
Your confusion is understandable because for the simple in-line type comment (your second "working example") works with either version (and with // type comments too for that matter) for convenience, but it could be more confusing than convenient... sorry about that.
Ah, using the proper docblock comments seems to be working fine. My bad.
Also had a compatibility issue with YouCompleteMe where it wouldn't show the correct completion candidates on the -> trigger. This was fixed by adding autocmd FileType php set omnifunc=phpcomplete#CompletePHP to my vimrc.
Little offtopic; are there any plans to handle the @property tag? This would be really useful when working with frameworks (CakePHP in this case) since they attach classes to other classes as properties automagically.
Afaik the omnifunc should be set on php files by the default runtime's filetype plugin for php but it could be that YCM doesn't find the buffer local setting (setlocal vs set), I'm not sure, i don't use YCM myself. Thanks for the heads up anyway.
As for the @property tag, yes it would be nice, and I've thought about it but not sure how to implement (the nice way would be if ctags could just generate tags for those too), but since the plugin grabs the sources for the class files anyway later it should be doable... i need to look into that again (-: