如何将 PHP 5.6 可变参数函数参数与 Symfony 2.8 一起使用


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

我有带有可变参数的服务方法:

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

它被编译成容器,如:

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

所以它导致:

严格的标准通知说 callSP() 应该与 XXX''XXX''Service::callSP($namespace, $function, ...$params)

兼容

甚至找不到任何问题。

我想

,某种惰性服务(侦听器或显式lazy: true)会出现这个问题

懒惰服务由ocramius/proxy-manager图书馆操作。

库从 2.0 版开始引入了对可变参数的支持,该版本至少需要 PHP 7.0。

所以我认为这里与 5.6 无关。

链接:

  • https://symfony.com/doc/current/service_container/lazy_services.html
  • https://github.com/Ocramius/ProxyManager/releases/tag/2.0.0
  • https://github.com/Ocramius/ProxyManager/issues/307