Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm meta and multiple factory arguments

Tags:

php

phpstorm

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?

like image 771
Daniel Avatar asked Feb 02 '26 02:02

Daniel


1 Answers

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

like image 111
Daniel Avatar answered Feb 03 '26 16:02

Daniel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!