protected __call() question
| From: | Jochem Maas | Date: | Sun, 04 Apr 2004 19:49:44 +0000 |
| Subject: | protected __call() question | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-8929@lists.php.net to get a copy of this message | ||
the following code does not do what I expect, I made this test case after a new version of PHP5 was put on the system I am developing yesterday and some of my code no longer works:
<?
Class CallMe
{
public function setup()
{
$this->fakeMethod();
}
protected function __call($method, $params)
{
echo 'you called CallMe::'.$method."\n";
}
}
echo <<< ___THEEND
EXPECTED RESULT:
-----------------------------------------
you called CallMe::fakeMethod
ACTUAL RESULT:
-----------------------------------------
___THEEND;
$obj = new CallMe();
$obj->setup();
?>
running the script on 'PHP 5.0.0RC2-dev (cli) (built: Apr 4 2004 13:07:13) (DEBUG)' gives me:
<snip>
EXPECTED RESULT:
-----------------------------------------
you called CallMe::fakeMethod
ACTUAL RESULT:
-----------------------------------------
PHP Fatal error: Call to protected method CallMe::__call() from context '' in /var/www/santos/test/call.protected.php on line 7
Fatal error: Call to protected method CallMe::__call() from context '' in /var/www/santos/test/call.protected.php on line 7
</snip>
Have I misunderstood the way PHP5 works?
Or maybe something is broken? does anyone else get an error?
I don't rule out that this could be something specific to the machine I am on, unfortunately I am limited by knowledge and access in determining if this is the case.
Kind Regards,
Jochem.