php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33835 wrong method called
Submitted: 2005-07-23 11:28 UTC Modified: 2005-07-23 14:47 UTC
From: julien dot a at laposte dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.4 OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: julien dot a at laposte dot net
New email:
PHP Version: OS:

 

 [2005-07-23 11:28 UTC] julien dot a at laposte dot net
Description:
------------
I saw bug reports about self similar to this bug but i don't really know if both are related so I decided to post it, sorry if it is the same bug.

I tested for this bug on 5.0.4 and on latest 5.1 snapshot and it is still there, if the "func" methods are not private or if they are protected it works as expected and the result is "B::func()" but if they are private the result is not what is expected.

Reproduce code:
---------------
class A{
	private function func(){
		echo "A::func()\n";
	}
	function test(){
		$this->func();
	}
}

class B extends A{
	private function func(){
		echo "B::func()\n";
	}
}

$v= new B();
$v->test();

Expected result:
----------------
B::func()


Actual result:
--------------
A::func()

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-23 14:47 UTC] sniper@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

RTFM: "When an extending class overrides the parents definition of a method, PHP will not call the parent's method."

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 13 09:01:27 2025 UTC