ZF-1865: Declare param in find() function to match docblock @param


cbijlsma writes:

I have a class that extends Zend_Db_Table_Abstract. Just before calling the {{parent::__construct()}} method, I make a call to {{Zend_Server_Reflection::reflectClass(get_class($this))}}.

When I do so, I get

fatal error: Fatal error: Call to a member function isOptional() on a non-object 
in /opt/zf/library/Zend/Server/Reflection/Function/Abstract.php on line 348 

It appears that this happens when the function {{Zend_Db_Table_Abstract::find()}} is evaluated by the {{_reflect()}} method in the class above. While looking for a solution I found this message on the ZF Issue Tracker, but it doesn't seem to be the exact same case. Further looking on any forum doesn't give me any helpful results, too.

FYI: I'm using the ZF 1.0.1 in combination with PHP 5.2.3-1+b1. Below this the code I think is relevant.

class My_Db_Table extends Zend_Db_Table_Abstract { 
    public function __construct($config = null){

    $refClass = Zend_Server_Reflection::reflectClass(get_class($this));

        if($config == null){


Okay, I see what's going on. The declaration of Zend_Db_Table_Abstract::find() is as follows:

 * @param  mixed                         The value(s) of the primary key.
 * @return Zend_Db_Table_Rowset_Abstract Row(s) matching the criteria.
 * @throws Zend_Db_Table_Exception
public function find()

It is documented that a function can declare an empty parameter list, but read its parameters with {{func_get_args()}}. See code example at

However, Zend_Server_Reflection has some logic that inspects the docblock and assumes that every {{@param}} tag corresponds to a parameter that is declared in the function signature, and therefore represented in the reflection object.

So we must solve this with one of the following solutions:

  1. Declare parameters in function signatures. For functions with variable number of parameters, make sure that at least the {{@param}} tags in the docblock match the declared function parameters.

  2. Remove {{@param}} tags from docblocks of functions with variable arguments.

  3. Change the logic in Zend_Server_Reflection to double-check that the parameter is encoded in the reflection data before trying to dereference it.

I'd prefer solution #1, and it wouldn't hurt to do the double-checking as well (#3).

I grepped through the ZF library for other cases where the docblock documents a {{@param}} but the function prototype doesn't declare any params. There is only one other such case, in {{Zend_View_Helper_DeclareVars::declareVars()}}.

Fixed in revision 6162.

Updating Fix Version to follow issue tracker conventions.