ZF-10583: Unhelpful exception message thrown when docblock params do not match actual function params
Description
When implementing a server (in our case using Zend_AMF), if the number of parameters listed in the docblock (@param) of your class methods do not match the number of parameters in the actual function definition, then the following exception is thrown:
bq. Variable number of arguments is not supported for services (except optional parameters). Number of function arguments must correspond to actual number of arguments described in a docblock.
This exception is thrown from line 340 (revision 23180) of library/Zend/Server/Reflection/Function/Abstract.php.
In short, it took me quite a while to find the actual offending class and method that was generating this exception. This is because the exception message is unhelpful. I have created a patch to make this a more helpful message. I'm attaching the patch to this issue.
Comments
Posted by Ben Ramsey (ramsey) on 2010-10-20T10:45:27.000+0000
The attached patch will change the exception message to read:
bq. Variable number of arguments is not supported for services (except optional parameters). Number of function arguments in AMF_Foo::barMethod() must correspond to actual number of arguments described in the docblock.
Posted by Ralph Schindler (ralph) on 2010-10-20T11:35:21.000+0000
Fixed in r23182 in trunk & r23183 in release 1.11 branch. Thanks!
Posted by Kazusuke Sasezaki (sasezaki) on 2012-08-03T05:57:59.000+0000
Hi Ralph. I'm wondering your fix. http://framework.zend.com/code/diff.php/…
"getDeclaringClass" is available at ReflectionFunction?