Closed ghost closed 9 years ago
Hello,
I'm testing it today ;)
:+1:
/** @var XXXX */
$x = 5;
(just before the variable assignment) seems to not work anymore. Is it wanted ?
Strange, I can't reproduce this, neither outside functions nor inside functions, I tried placing the following under function main
in my test repository:
/** @var SomeClass */
$test = 5;
$test->works();
As well as the test method I linked to in the OP testVariableTypeOverrides
:
/** @var FooClass */
$var1 = 'Should be a FooClass';
$var1->fooFunc();
Do you have any more information on how I could reproduce it?
I don't really know..
/** @var ManagerRegistry */
$user = $this->tokenStorage->getToken()->getUser();
$user->{fail}
/** @var ManagerRegistry $user */
$user = $this->tokenStorage->getToken()->getUser();
$user->{success}
(yep, the code does not have any sense, that was just an other test) I'll try it on an other project tonight
That's it, I can reproduce it using:
/** @var SomeClass */
$x = $this->a->b()->c();
$x->{fail}
I'll take a look at it as soon as possible.
Good that you spotted this bug. I pushed a fix, is the issue now solved for you as well?
It works, thank you :+1:
Hello
This pull request contains the following improvements:
require
-d files that still contain use statements or use absolute class paths.getVariableType
.getVariableType
will no longer assume/** @var FooType $var */
is actually a/** @var FooType */
that applies to the variable below it if the variable below it. (Before, it always assumed that it needed to override it, even if the variable below it was is not$var
.)getVariableType
now supports PHPStorm's/** @var Footype $var */
(and it also still supports IntelliJ's/** @var $var FooType */
).$this
can now be overridden again, it always resolved togetCurrentClass
before.I also added some tests for these cases [1].
[1] https://github.com/hotoiledgoblinsack/php-autocomplete-test/blob/24664493aeb7af113994dd1e067f290977f5eb9d/src/TestNamespace/SomeClass.php#L411