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

Do not require variable too exist in IntelliJ-type phpdoc #238

Closed
hultberg opened this issue Sep 15, 2016 · 4 comments
Closed

Do not require variable too exist in IntelliJ-type phpdoc #238

hultberg opened this issue Sep 15, 2016 · 4 comments
Labels

Comments

@hultberg
Copy link
Contributor

Hello! Currently, the php-integrator-base requires a variable to be defined before being able to give autocomplete, if the variable is documented IntelliJ-type doc.

I would like this requirement to be removed so one can define a variable in IntelliJ-type phpdocs and expect them to be resolved.

Example:
view.php

<?php

// $variable is defined before this file is included.
/** @var AClass $variable */

$variable->
//        ^- No autocomplete

// However, when I define the variable inside this file, it autocmpletes:

/** @var AClass $variable */
$variable = $variable;

$variable->
//        ^- I get suggestions (autocomplete)
@ghost
Copy link

ghost commented Sep 15, 2016

This is indeed an issue. I've also previously encountered it and it seems to only manifest in certain circumstances (i.e. sometimes you can get it working).

The reason this happens is that when you type $foo->, php-parser (which is used to analyze source code) picks this up as invalid PHP code as the expression is not complete. It can partially recover from these kind of errors, but to do this it usually simply drops the statement entirely. Because of this I roll a bit of manual parsing to get these "erroneous" expressions out anyway, but as comments are attached to the next "node" in php-parser, the comment is never picked up in the first place.

The bad news is that this is rather hard to fix for me as everything depends on php-parser, but the good news is that in the upcoming version 3.0.0, it grew some additional error recovery for precisely these kind of statements, so I may get lucky and get it working for free as soon as I upgrade (which will happen when it becomes stable) [1].

[1] nikic/PHP-Parser#262

@ghost ghost added the bug label Sep 15, 2016
@ghost
Copy link

ghost commented Dec 3, 2016

Good news! After upgrading the core to php-parser 3.0 [1], this problem appears to be solved. The fix will be included in the upcoming 2.0 release.

[1] https://github.com/php-integrator/core/commit/ad15e1c337289603856ee9cf542562a4fe32100c

@hultberg
Copy link
Contributor Author

hultberg commented Dec 3, 2016

@Gert-dev Looking forward to the 2.0 release. 😄

@ghost
Copy link

ghost commented Dec 13, 2016

I've just released 2.0! I'll close this as it should be solved, but if it isn't, feel free to give me a shout here.

@ghost ghost closed this as completed Dec 13, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant