From: stochnagara at hotmail dot com
Operating system: windows xp
PHP version: 5.0.4
PHP Bug Type: Class/Object related
Bug description: Wrong private method virtual behaviour
Description:
------------
When a private method is overriden and the visibility is increased to
public or protected, then this method loses its non-virtual behaviour in
methods of classes where the method is private.
So in the example bellow ext2::abc is called instead of base::abc and
ext::abc. Also when the function prototype is different warning appear.
Reproduce code:
---------------
class base {
public function test() { $this->abc(); }
public function test2() { $this->abc(); }
private function abc() { echo "base::abc<br/>"; }
}
class ext extends base {
public function test2() { $this->abc(null); }
private function abc ($param1) { echo "ext::abc<br/>"; }
}
class ext2 extends ext {
protected function abc ($param1, $param2) { echo "ext2::abc<br/>"; }
}
$base = new base();
$base->test(); $base->test2();
$ext = new ext();
$ext->test(); $ext->test2();
$ext2 = new ext2();
$ext2->test(); $ext2->test2();
Expected result:
----------------
base::abc
base::abc
base::abc
ext::abc
base::abc
ext::abc
Actual result:
--------------
base::abc
base::abc
base::abc
ext::abc
Warning: Missing argument 1 for ext2::abc() in c:\program files\apache
group\Apache\htdocs\php5\pproject4\test.php on line 12
Warning: Missing argument 2 for ext2::abc() in c:\program files\apache
group\Apache\htdocs\php5\pproject4\test.php on line 12
ext2::abc
Warning: Missing argument 2 for ext2::abc() in c:\program files\apache
group\Apache\htdocs\php5\pproject4\test.php on line 12
ext2::abc
--
Edit bug report at http://bugs.php.net/?id=34018&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=34018&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=34018&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=34018&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=34018&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=34018&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=34018&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=34018&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=34018&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=34018&r=support
Expected behavior: http://bugs.php.net/fix.php?id=34018&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=34018&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=34018&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=34018&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=34018&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=34018&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=34018&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=34018&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=34018&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=34018&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=34018&r=mysqlcfg