From: tater at potatoe dot com
Operating system: OS X 10.2
PHP version: 5CVS-2003-07-21 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: call_user_func on parent method does not use parent private property
Description:
------------
If I call a public function of a base class from a derived class directly,
the base class's function can use private properties of the base class. If
I call it via call_user_func() or call_user_func_array(), it acts like an
overloaded function of the derived class, and doesn't see the private
property (it ends up creating a dynamic property for the object).
One or the other of these is wrong. I'm hoping it's the second one.
Reproduce code:
---------------
<?php
class foo
{
private $a;
private $b;
public function set_a($v) { $this->a = $v; }
public function set_b($v) { $this->b = $v; }
}
class bar extends foo { }
$f = new foo;
$f->set_a(1);
call_user_func(array($f,'set_b'), 2);
$b = new bar;
$b->set_a(1);
call_user_func(array($b,'set_b'), 2);
print_r($f);
print_r($b);
?>
Expected result:
----------------
foo Object
(
[a:private] => 1
[b:private] => 2
)
bar Object
(
[a:private] => 1
[b:private] => 2
)
Actual result:
--------------
foo Object
(
[a:private] => 1
[b:private] => 2
)
bar Object
(
[a:private] => 1
[b:private] =>
[b] => 2
)
--
Edit bug report at http://bugs.php.net/?id=24735&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24735&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24735&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=24735&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=24735&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=24735&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=24735&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=24735&r=support
Expected behavior: http://bugs.php.net/fix.php?id=24735&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=24735&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=24735&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=24735&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24735&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=24735&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=24735&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=24735&r=gnused