Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not searching for phpdoc outside the current scope #82

Closed
marceldev89 opened this issue Dec 12, 2015 · 3 comments
Closed

Not searching for phpdoc outside the current scope #82

marceldev89 opened this issue Dec 12, 2015 · 3 comments

Comments

@marceldev89
Copy link
Contributor

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
    }
}
@complex857
Copy link
Collaborator

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:

  1. 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.

@marceldev89
Copy link
Contributor Author

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.

@complex857
Copy link
Collaborator

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 (-:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants