php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34847 Overloading __call() does nothing on an extended class
Submitted: 2005-10-13 04:49 UTC Modified: 2005-10-13 05:25 UTC
From: junk at thinkof dot net Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.5 OS: OSX 10.4.2
Private report: No CVE-ID: None
 [2005-10-13 04:49 UTC] junk at thinkof dot net
Description:
------------
Overloading the function __call() results in __call() not be executed when a class is extended.  Having the __call() overload in the parent, child or both makes no difference.

Reproduce code:
---------------
<?php
class extendable {	
	function blah (){
		print 'blah';
	}
}
class extendee extends extendable {
	function __call ($method, $args){
		print $method;
	}
}
$test = new extendee ();
$test->blah ();
?>
<?php
class extendable {	
	function __call ($method, $args){
		print $method;
	}
	function blah (){
		print 'blah';
	}
}
class extendee extends extendable {
}
$test = new extendee ();
$test->blah ();
?>
<?php
class b {	
	function blah (){
		print "In method: blah";
	}
}
class a extends b {
	function __call ($method, $args){
		print '__call(): '.$method;
	}
}
$test = new a ();
$test->blah ();
?>

Expected result:
----------------
__call():blah
In method: blah

Actual result:
--------------
In method: blah

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-13 04:52 UTC] junk at thinkof dot net
Sorry, the reproduce code got scrambled a bit.  It should be:


<?php
class b {	
	function blah (){
		print "In method: blah";
	}
}
class a extends b {
	function __call ($method, $args){
		print '__call(): '.$method;
	}
}
$test = new a ();
$test->blah ();
?>

Expected result:
----------------
__call():blah
In method: blah

Actual result:
--------------
In method: blah
 [2005-10-13 05:25 UTC] junk at thinkof dot net
I was reading this wrong.  This is my bad, sorry all.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 05:01:27 2024 UTC