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
http://php.net/func-get-args
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().
I have opened bugs ZF-1865 and ZF-1866 for this issue.
Regards,
Bill Karwin
________________________________
From: cbijlsma [mailto:[EMAIL PROTECTED]
Sent: Monday, August 20, 2007 9:12 AM
To: [email protected]
Subject: [fw-general] Zend_Db_Table_Abstract bug?
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 a 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){
echo("My_Db_Table::__construct()");
$refClass =
Zend_Server_Reflection::reflectClass(get_class($this));
if($config == null){
parent::__construct();
}else{
parent::__construct($config);
}
}
}
________________________________
View this message in context: Zend_Db_Table_Abstract bug?
<http://www.nabble.com/Zend_Db_Table_Abstract-bug--tf4299861s16154.html#
a12238827>
Sent from the Zend Framework mailing list archive
<http://www.nabble.com/Zend-Framework-f15440.html> at Nabble.com.