Custom class detection

Hi,
There is special function in our project which takes class name as argument and return instance of this class. And PHPStorm can't determine, of which class this instance is.
I.g.:
$c = class( 'test' ); // $c - instance of class test.
In this case PhpStorm can't determine that $c - is instance of test class and code completition desn't work.
Is there any opportunity to say to PHPStorm, that argument of function 'class' is a class name and result of function invocation is instance of this class? It's needs for method/fields detection and code completion.
Thank you.

2 comments
Comment actions Permalink

Hi there,

Few choices:

1)

/** @var test $c */

$c = class( 'test' );


2) Install and use DynamicReturnType plugin

3) http://youtrack.jetbrains.com/issue/WI-4478 and related some tickets

4) If you could replace your class() function by some static class (e.g. Factory::make() or whatever you will name it) then such approach is already supported: http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Advanced+Metadata

0
Comment actions Permalink

Ок, thank you, Andriy.

0

Please sign in to leave a comment.