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

Issue Type: Bug Created: 2007-08-20T12:14:02.000+0000 Last Updated: 2008-01-23T18:28:46.000+0000 Status: Resolved Fix version(s): - 1.0.2 (25/Sep/07)

Reporter: Bill Karwin (bkarwin) Assignee: Bill Karwin (bkarwin) Tags: - Zend_Db_Table

Related issues: - ZF-1866



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

<pre class="highlight">
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.

<pre class="highlight">
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){


Posted by Bill Karwin (bkarwin) on 2007-08-20T12:21:33.000+0000

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

<pre class="highlight">
 * @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().

Posted by Bill Karwin (bkarwin) on 2007-08-20T18:28:54.000+0000

Fixed in revision 6162.

Posted by Wil Sinclair (wil) on 2008-01-23T18:28:46.000+0000

Updating Fix Version to follow issue tracker conventions.

Have you found an issue?

See the Overview section for more details.


© 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.