Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jlrdw's avatar
Level 75

callStatic

I use callStatic at times and for a return I use

return call_user_func_array(array($instance, $method), $args);

However I see that Taylor uses

return $instance->$method(...$args);

I have tried that also and it works as a replacement for the first. I have tried to find information on (...$args) in the php manual. I for some reason can't locate the second return used in place of first return statement.

Can someone who may know where that reference is give me a link, thanks.

Also when used like

$instance->$method    //with arrow ->

is it expecting a non static method or does that matter?

0 likes
3 replies
ejdelmonico's avatar
Level 53

@jlrdw Maybe here http://php.net/manual/en/migration70.new-features.php Just found what you may be looking for. It's kind of like the JS spread operator.

In PHP 5.6 and later, argument lists may include the ... token to denote that the function accepts a variable number of arguments. The arguments will be passed into the given variable as an array;

http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration

jlrdw's avatar
Level 75

@ejdelmonico thanks, I admit some of the php manual examples are hard to follow, thankfully for us Taylor knew what to do. I just thought the (...) was only a new replacement for my first example above. Now I see.

ejdelmonico's avatar

@jlrdw Yea, that was a new one for me. I do about 75% of my dev work in JS so I am only intermediate at PHP. I also do a little bit in Go, C, Python and Swift. Anyways, take care.

Please or to participate in this conversation.