Issues

ZF-10583: Unhelpful exception message thrown when docblock params do not match actual function params

Issue Type: Improvement Created: 2010-10-20T10:40:54.000+0000 Last Updated: 2012-08-03T05:57:59.000+0000 Status: Resolved Fix version(s): - 1.11.0 (02/Nov/10)

Reporter: Ben Ramsey (ramsey) Assignee: Ralph Schindler (ralph) Tags: - Zend_Server_Reflection

Related issues: Attachments: - Zend_Server_Reflection_Function_Abstract.patch

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/…

<pre class="highlight">
$function->getDeclaringClass()->getName()

"getDeclaringClass" is available at ReflectionFunction?

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts