{"action":"opened","issue":{"url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/359","labels_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/359/comments","events_url":"https://api.github.com/repos/PHP-DI/PHP-DI/issues/359/events","html_url":"https://github.com/PHP-DI/PHP-DI/issues/359","id":124339354,"number":359,"title":"Document limitations when using lazy loaded dependencies that involve variadic functions","user":{"login":"holtkamp","id":776405,"avatar_url":"https://avatars.githubusercontent.com/u/776405?v=3","gravatar_id":"","url":"https://api.github.com/users/holtkamp","html_url":"https://github.com/holtkamp","followers_url":"https://api.github.com/users/holtkamp/followers","following_url":"https://api.github.com/users/holtkamp/following{/other_user}","gists_url":"https://api.github.com/users/holtkamp/gists{/gist_id}","starred_url":"https://api.github.com/users/holtkamp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/holtkamp/subscriptions","organizations_url":"https://api.github.com/users/holtkamp/orgs","repos_url":"https://api.github.com/users/holtkamp/repos","events_url":"https://api.github.com/users/holtkamp/events{/privacy}","received_events_url":"https://api.github.com/users/holtkamp/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-12-30T12:00:24Z","updated_at":"2015-12-30T12:00:24Z","closed_at":null,"body":"When using lazy loaded dependencies, I encountered some unexpected behaviour when handing over more parameters to a function than defined in its signature ([variadic functions](https://en.wikipedia.org/wiki/Variadic_function)). \r\n\r\n```php\r\nclass Service\r\n{\r\n\t/**\r\n\t * @param mixed $param1\r\n\t * @param mixed $param2\r\n\t * @param mixed $paramN Can be used to supply additional parameters\r\n\t */\r\n\tpublic function doStuf($param1, $param2){\r\n\t\techo func_num_args();\r\n\t}\r\n}\r\n```\r\n\r\nNow lets try to use this Service when fetched from the dependency injection container\r\n\r\n```php\r\n$dic->get('Service')->doStuff(1, 2, 3); //Prints '3' when not lazy loaded\r\n$dic->get('Service')->doStuff(1, 2, 3); //Prints '2' when lazy loaded\r\n```\r\nI use this approach to inject extra variables when translating messages like: \"User X has logged in on Y\", where X and Y would be 'additional' parameters.\r\n\r\nThis probably has to do with the intermediate proxy classes that are generated. For example from a generated proxy class:\r\n\r\n```php\r\n  /**\r\n     * {@inheritDoc}\r\n     */\r\n    public function doStuf($param1, $param2)\r\n    {\r\n        $this->initializer5683c4a86687a054344119 && $this->initializer5683c4a86687a054344119->__invoke($this->valueHolder5683c4a866860700867865, $this, 'fireEventOnOrder', array('param1' => $param1, 'param2' => $param2), $this->initializer5683c4a86687a054344119);\r\n\r\n        return $this->valueHolder5683c4a866860700867865->fireEventOnOrder($param1, $param2);\r\n    }\r\n```\r\n\r\nWhen looking at https://github.com/Ocramius/ProxyManager/issues/177, I think this behaviour is expected. Therefore I think it should be mentioned in the documentation as a warning..."}}