Search code examples
phpphpstorm

PhpStorm meta and multiple factory arguments


I've been trying to setup the .phpstorm.meta.php file for factory methods but I can't get it to fully work. It works for factory methods that only takes 1 argument, but if there are 2 or more arguments, it doesn't work.

So basically, all factory methods that takes more than 1 argument is affected, especially splat arguments i.e factory(string $className, ...$ctorArgs).

Here is an example of my meta file;

<?php
namespace PHPSTORM_META {
    override(
        \ContainerInterface::make(0),
        map([
            '' => '@',
        ])
    );
}

This is the signature;

<?php
interface ContainerInterface{
    /* @return mixed */
    public function make (string $className, ...$ctorArgs);
}

And here is an example of expected/results;

<?php
$container->make(MyClass::class, "hello", "world")-> // Nothing is indicated here, should indicate MyClass props/methods

Am I doing something wrong here?


Solution

  • This is apparently a known bug; https://youtrack.jetbrains.com/issue/WI-38403