Dynamic typing for code-completion
In PHPStorm is there any way to do dynamic code completion like this.
class MyTestClass{
function sayHello(){
echo "Hello";
}
}
/**
* @param $className
* @return $className
*/
function test($className){
$testValue = new $className();
return $testValue;
}
$object = test('MyTestClass');
$object->sayHello();
i.e. the IDE can see that 'MyTestClass' is being passed into the function, so the return type will be MyTestClass and then be able to do code-completion/inspection on the `$object` ?
If not, are there any plugins available that do something similar?
请先登录再写评论。
Hi there,
No.
Possibly when this ticket gets implemented, it may be possible to acheive this: http://youtrack.jetbrains.com/issue/WI-6027
In meanwhile you have to use PHPDoc comment with type hint: