Question on PhpStorm Advanced Metadata

Assume the following code/files


namespace PHPSTORM_META {                                                 // we want to avoid the pollution

$STATIC_METHOD_TYPES = [                                              // we make sections for scopes

    \Load::Component('') => [                                      // call to match

        'Filter' instanceof \FilterComponent,

    \Component::component('') => [

        'Filter' instanceof \FilterComponent,






FilterComponent extends Component

    function getDate($returnStyle = null){

        $date = strtotime('Today');
        if ($returnStyle == 'mysql') {
            return date('Y-m-d 00:00:00', $date);
        } else if($returnStyle
== 'java') {
            return date('Y-m-d\T00:00:00', $date);
        } else {
            return $date;





class Component {
    protected function component($objName){
        return Load::component($objName, $this->controller);



class TestComponent extends Component {

    function test() {

        $date = $this->component('Filter')->getDate('java');
        $date = Load::component('Filter')->getDate('java');



In the testUsage.php file, the first call in the test function, $this->component('Filter')->getDate('java'); PhpStorm will say "cannot find declaration to go to" for getDate()

However it will work in the 2nd call, Load::component('Filter')->getDate('java');

Is there any possible way for me to get this to work with the 1st call?

Comment actions Permalink

Hi there,

ATM PhpStorm supports static factories only (


I'm not sure about "
(how exactly it will work/what syntax has to be used) but such support for not-static factories was added in most recent v9 EAP build. Unfortunately there is no documentation yet available (but expected soon).

In any case -- it will be supported in v9 when it will be released (some point in July).
Comment actions Permalink

Actually -- documentation was updated:

Just those example metadata file uses truff like "$factory->component()" while you have "$this->component()" -- not sure how it supposed to be declared here...


Please sign in to leave a comment.