#48714 [Opn]: When calling parent class method, self is responding

[email protected] ("sebcorne at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
 ID:               48714
 User updated by:  sebcorne at gmail dot com
 Reported By:      sebcorne at gmail dot com
 Status:           Open
 Bug Type:         Scripting Engine problem
 Operating System: Windows
 PHP Version:      5.3.0RC4
 New Comment:

class base
{
	static public function __callstatic($name, $arguments)
	{
		echo get_called_class() . "::$name() is called \n\n";
	}
	public function __call($name, $arguments)
	{
		echo get_called_class() . "->$name() is called \n\n";
	}
}



give the same result.
but without "__call()", it's ok.

if "$this" exists in inheritance, "__call()" (of $this) is called
instead of "__callstatic()"


Previous Comments:
------------------------------------------------------------------------

[2009-06-29 09:17:57] sebcorne at gmail dot com

Description:
------------
Tested on php5.3.0-alpha3 (must be tested on last snap)

When calling parent class method, self is responding

(sorry for my bad english)

Reproduce code:
---------------
class base
{
	public function __call($name, $arguments)
	{
		echo get_called_class() . "->$name() is called \n\n";
	}
}


class A extends base
{
	public function parent_automatic()
	{
		$parentclass = get_parent_class($this);
		echo get_class($this) . '->'. __FUNCTION__ ."() call
$parentclass::test() \n";
		$parentclass::test();
	}
	
	public function parent_manual()
	{
		echo get_class($this) . '->'. __FUNCTION__ ."() call A::test() \n";
		A::test();
	}
}


class B extends A {}



$b = new B;
$b->parent_automatic();
$b->parent_manual();


Expected result:
----------------
B->parent_automatic() call A::test() 
A->test() is called 

B->parent_manual() call A::test() 
A->test() is called 


Actual result:
--------------
B->parent_automatic() call A::test() 
B->test() is called 

B->parent_manual() call A::test() 
B->test() is called 



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48714&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.