ID: 20882
Comment by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Linux debian woody
PHP Version: 4.3.0RC2
New Comment:
I have found the same problem, but it fires only if child class has
__construct(). Look at this code:
error_reporting(E_ALL);
class Base {
function __construct() {
print "Base::Construct()\n";
}
function __get($name) {
return $this->{"__get$name"}();
}
function __set($name, $value) {
return $this->{"__set$name"}($value);
}
}
class Child extends Base {
function __construct() {
parent::__construct();
}
function __getFoo() {
return 'zoo';
}
}
$q = new Child();
// where we get an Notice: Undefined property: foo
print $q->foo;
-----------------------------------
Sample without the problem:
error_reporting(E_ALL);
class Base {
function __construct() {
print "Base::Construct()\n";
}
function __get($name) {
return $this->{"__get$name"}();
}
function __set($name, $value) {
return $this->{"__set$name"}($value);
}
}
class Child extends Base {
function __getFoo() {
return 'zoo';
}
}
$q = new Child();
// prints 'zoo', all is OK
print $q->foo;
-------------------------------------
Moveover, the Child class inherites __get, __set from Base in both
cases above.
$q = new Child();
print_r(get_class_methods(get_class($q)));
result is
Array ( [0] => __construct [1] => __getfoo [2] => __get [3] => __set )
--
BR,
Matrix
Previous Comments:
------------------------------------------------------------------------
[2002-12-07 16:05:31] [EMAIL PROTECTED]
// like everyday
error_reporting(E_ALL);
class Foo
{
function __get($var)
{
// ... some code to retrieve var
}
};
overload('Foo'); // activate overload
$f = new Foo();
echo $f->bar; // issued a NOTICE ERROR (unknown
// property)
Of course we can't declare a var $bar in Foo as
overload (for an obscure reason and unlike any other
language) only works if $bar does not exists in Foo.
Don't ask me to remove error_reporting line, i won't and
i'm sure you know why :)
ZendEngine2 has the same problem, __get, __set, __call are
just unusable. They need to be activated even if the target
property or function exists.
Thank for thinking about that, and thousands thanks if you
correct it.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=20882&edit=1