Home » Php » How to use PHP 5.6 variadic function arguments with Symfony 2.8?

How to use PHP 5.6 variadic function arguments with Symfony 2.8?

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have service method with variadic arguments:

public function callSP($namespace, $function, ...$params) {}

which is compiled into container like :

public function callSP($namespace, $function, $params = null)

so it causes :

Strict Standards notice saying that callSP() should be compatible with XXX\XXX\Service::callSP($namespace, $function, …$params)

Can’t find even any questions about that.

How to&Answers:

I suppose, that problem occures for some kind of lazy service (listener, or explicit lazy: true)

Lazy services are operated with ocramius/proxy-manager library.

This library introduced support for variadic parameters since version 2.0, which requires at least PHP 7.0.

So I think there is nothing to do with 5.6 here.

Links: