#29268 [Opn->Fbk]: __autoload() not called with reflectionProperty->getClass()
| From: | sniper@php.net | Date: | Sun, 06 Mar 2005 19:51:29 +0000 |
| Subject: | #29268 [Opn->Fbk]: __autoload() not called with reflectionProperty->getClass() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-74965@lists.php.net to get a copy of this message | ||
ID: 29268
Updated by: sniper@php.net
Reported By: david at jool dot nl
-Status: Open
+Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: winXP
PHP Version: 5.0.0
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-01-15 17:59:58] david at jool dot nl
A possible solution might be to also check if zend_fetch_class() also
returns null, next to zend_hash_find().
I'm not able to compile it myself, but the fix might be to change line
1703 in zend_reflection_api.c from
if (zend_hash_find(EG(class_table), lcname,
param->arg_info->class_name_len + 1, (void **) &pce) == FAILURE) {
to
if (zend_hash_find(EG(class_table), lcname,
param->arg_info->class_name_len + 1, (void **) &pce) == FAILURE
&& zend_fetch_class(lcname, (param->arg_info->class_name_len + 1),
ZEND_FETCH_CLASS_AUTO TSRMLS_CC) == NULL) {
------------------------------------------------------------------------
[2005-01-15 17:21:06] david at jool dot nl
I took another look at the bug and found out it's more a
reflectionProperty bug:
-- File 'A.class.php'
<?PHP
class A{
}
?>
-- File test.php in the same directory
<?php
/** autoload functie voor PHP5 */
function __autoload($classname) {
if(file_exists("$classname.class.php"))
include("$classname.class.php");
}
//When you include the following line, it works
//include("A.class.php");
class B{
public function doit(A $a){
}
}
$ref = new reflectionMethod('B','doit');
$parameters = $ref->getParameters();
foreach($parameters as $parameter){
//the following line give the error
$class = $parameter->getClass();
echo $class->name;
}
?>
--Expected result
'A'
-- Actual result
Fatal error: Uncaught exception 'ReflectionException' with message
'Class A does not exist'
------------------------------------------------------------------------
[2004-07-19 23:12:11] david at jool dot nl
Description:
------------
When creating a new instance of a class inside eval() the __autoload
function isn't called.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=29268&edit=1