|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-07 14:28 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 08:00:01 2025 UTC |
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