All problems shown in my previous posts have been fixed in the build 5981 and 5982, but
there are still many situations when the code completion fails.
Relative definitions do not work when child class is in different namespace.
namespace Alpha
{
class Foo
{
public function testA();
}
class TestClass
{
/** @var \Alpha\Foo */
public $a;
/** @var Foo */
public $b;
}
$testClass = new TestClass();
$testClass->a->testA(); // OK
$testClass->b->testA(); // OK
}
namespace Beta
{
class Foo
{
public function testB();
}
class Child extends \Alpha\TestClass {}
$child = new Child();
$child->a->testA(); // OK
$child->b->testA(); // fails - suggests testB instead of testA
}
|
Interfaces are not supported
namespace /* global namespace */
{
interface TestInterface
{
public function someMethod();
}
}
namespace Alpha
{
use Beta\Alpha as NamespaceAlias;
use Beta\Alpha\TestInterface as InterfaceAlias;
interface TestInterface
{
public function anotherMethod();
}
class Foo
{
/** @var TestInterface */
public $a;
/** @var \TestInterface */
public $b;
/** @var \Alpha\TestInterface */
public $c;
/** @var \Beta\Alpha\TestInterface */
public $d;
/** @var NamespaceAlias\TestInterface */
public $e;
/** @var InterfaceAlias */
public $f;
/** @var \Alpha\TestInterface|\Beta\Alpha\TestInterface|NULL */
public $g;
}
$foo = new Foo(); // OK
$foo->a->anotherMethod(); // fails - suggests someMethod instead of anotherMethod
$foo->b->someMethod(); // OK
$foo->c->anotherMethod(); // fails
$foo->d->anotherMethodForBeta(); // fails
$foo->e->anotherMethodForBeta(); // fails
$foo->f->anotherMethodForBeta(); // fails
$foo->g->anotherMethod(); // fails
$foo->g->anotherMethodForBeta(); // fails
}
namespace Beta\Alpha
{
interface TestInterface
{
public function anotherMethodForBeta();
}
} |
@property does not work as well as @var
namespace
{
class Foo
{
public function testA();
}
}
namespace Alpha
{
use Beta\Alpha as NamespaceAlias;
use Beta\Alpha\Foo as FooAlias;
class Foo
{
public function testB();
}
/**
* @property Foo $a
* @property \Foo $b fails
* @property \Alpha\Foo $c
* @property \Beta\Alpha\Foo $d
* @property FooAlias $e fails
* @property NamespaceAlias\Foo $f fails
* @property Sub\Foo $g
*/
class TestClass
{
/** @var FooAlias */
public $e2;
/** @var NamespaceAlias\Foo */
public $f2;
}
$testClass = new TestClass(); // OK
$testClass->a->testB(); // OK
$testClass->b->testA(); // fails - suggests testB intead of testA
$testClass->c->testB(); // OK
$testClass->d->testD(); // OK
$testClass->e->testD(); // fails
$testClass->e2->testD(); // OK
$testClass->f->testD(); // fails
$testClass->f2->testD(); // OK
$testClass->g->testC(); // OK
}
namespace Alpha\Sub
{
class Foo
{
public function testC();
}
}
namespace Beta\Alpha
{
class Foo
{
public function testD();
}
} |