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');


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?

1 comment
Comment actions Permalink

Hi there,


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:

/** @var MyTestClass $object */

$object = test('MyTestClass');


Please sign in to leave a comment.