|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-12-21 02:26 UTC] ebypdx at comcast dot net
Description:
------------
in the most simple case, create a class with no methods except __call() and overload it. start calling methods on an instance of that class. the first method call will hit __call() and finish correctly. any subsequent method calls will fail to hit __call(), resulting instead in a fatal error.
if this is indeed a bug... i realize due to the experimental nature of overloading in 4.3, that this may never work again. my deepest thanks to anybody who can address this.
Reproduce code:
---------------
<?php
class BaseOverloader {
function BaseOverloader() {}
function __call($method, $args, &$returnValue) {
echo "Call to ".get_class($this)."->$method <br/>";
$returnValue = "return";
return true;
}
}
overload("BaseOverloader");
$c = new BaseOverloader();
$c->firstCall();
$c->secondCall();
?>
Expected result:
----------------
Call to BaseOverloader->firstcall
Call to BaseOverloader->secondcall
Actual result:
--------------
Call to baseoverloader->firstcall
Fatal error: Call to a member function on a non-object in /export/vol01/opt/web/neby/partner.newedgenetworks.com/overloaded.php on line 13
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 11:00:01 2025 UTC |
in Zend/zend_execute.c about line 997: remove this line PZVAL_UNLOCK(T->EA.data.overloaded_element.object); about line 1579: remove this line EX(object).ptr->refcount++; you have to copy & paste the whole link for it to work / rather than just pressing on it.A "not real" solution about the "Call to a member function on a non-object" Try this: // Only to avoid the problem... class Dummy { function Dummy() { } } $toto =& new Dummy(); class BaseOverloader { function BaseOverloader() {} function __call($method, $args, &$returnValue) { echo "Call to ".get_class($this)."->$method <br/>"; $returnValue = "return"; return true; } } overload("BaseOverloader"); $toto = new BaseOverloader(); $toto->firstCall(); $toto->secondCall(); Then you got: Call to baseoverloader->firstcall Call to baseoverloader->secondcall Weird, no?!?