php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #22004 Overload extension and _call() breaks classes.
Submitted: 2003-02-01 19:33 UTC Modified: 2003-04-14 23:03 UTC
Votes:5
Avg. Score:4.6 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:0 (0.0%)
From: tuupola at appelsiini dot net Assigned:
Status: Closed Package: Class/Object related
PHP Version: 4.3.0 OS: Solaris 8
Private report: No CVE-ID:
 [2003-02-01 19:33 UTC] tuupola at appelsiini dot net
If a class is overloaded and it uses __call() the 
overloaded class cannot return anything from its methods. 
Example code:

<?php
class Foo {

    var $bar = 'barvalue';

    function Foo() {
    }

    function getBar() {
       return($this->bar);
    }

    function printBar() {
       print($this->bar);
       return('foo');
    }

    function getAny() {
        return('Any');
    }

    function __call($method,$params,&$return) {
        $return=$method($params[0]);
        return(true);
    }
}

overload('Foo');

$f = new Foo();

print '$f->getBar(): ' . $f->getBar() . "\n";
print '$f->printBar(): '; print $f->printBar(); print "\n";
print '$f->bar: ' . $f->bar . "\n";
print '$f->getAny(): ' . $f->getAny() . "\n";
?>

output is:

$f->getBar(): 
$f->printBar(): barvalue
$f->bar: barvalue
$f->getAny(): 

after removing the function __call() from the class it 
works as expected. Output is then:

$f->getBar(): barvalue
$f->printBar(): barvaluefoo
$f->bar: barvalue
$f->getAny(): Any





Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-14 23:03 UTC] shane@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at http://snaps.php.net/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.

just commited fix that makes this code work.
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 10:02:09 2014 UTC