php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38497 Overloading does not work with extended classes (__call() never called)
Submitted: 2006-08-18 11:18 UTC Modified: 2006-09-16 13:13 UTC
From: alessio dot bazzica at gmail dot com Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.1.5 OS: Mac OS X
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alessio dot bazzica at gmail dot com
New email:
PHP Version: OS:

 

 [2006-08-18 11:18 UTC] alessio dot bazzica at gmail dot com
Description:
------------
An istance of an extended class with __call() function defined  
never calls function members by __call() (view example). I 
don't know if this is regular or if this could be a bug.
I have this problem both on a 5.0.4 and on a 5.1.4 on Mac OS X 
(5.1.4 is most recent version for OS X). 

Reproduce code:
---------------
http://webapp.altervista.org/php_ovrldext_test.zip

Expected result:
----------------
All test should pass.

Actual result:
--------------
Calling an overloaded method for an extended class php run un-
overloaded function defined in parent class (second test 
fails).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-18 11:25 UTC] alessio dot bazzica at gmail dot com
Link does not work; cut and paste URL to download zip file containing test.php (http://webapp.altervista.org/php_ovrldext_test.zip).
 [2006-08-21 08:23 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-08-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2006-09-14 20:31 UTC] alessio dot bazzica at gmail dot com
Please download a zip file containing my test case script at 
http://webapp.altervista.org/php_ovrldext_test.zip. Recently I 
tried to run the script on other enviroments and there is the 
same problem. Thank you, Alessio
 [2006-09-14 20:52 UTC] tony2001@php.net
Childs DO inherit parent's methods.
No bug here, this is expected and well documented.
 [2006-09-15 09:30 UTC] alessio dot bazzica at gmail dot com
Sorry, maybe I didn't explain the problem clearly. Sure 
child classes inherit parent's methods but my problem is 
another. I need to overload ParentClass::DoSomething() so I 
defined ChildClass::__call($method, $args) to call 
ChildClass::DoSomething_OVERLOAD() instead of 
ChildClass::DoSomething() (if $method is 'DoSomething'). It 
seems that PHP invoke DoSomething() before __call() on child 
class. In this case it is ALWAYS impossible to overload a 
parent method. My question is: "PHP denies parent method 
overloading or this could be a bug???". Thank you, Alessio
 [2006-09-16 07:58 UTC] johannes@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

__call() is only called for undefined methods, DoSomething() is defined in your class.
 [2006-09-16 13:13 UTC] alessio dot bazzica at gmail dot com
Ok, thank you for the support. Since in other languages (such 
as C++ or Java) it's possible to overload a defined parent 
class method, I'm proposing to emphasize the fact that in PHP 
there is no way to do this kind of overload (eventually you 
could add this notice in language.oop5.overloading.html).
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 16 10:01:29 2025 UTC