Re: Confusing performance of the magic method __call

From: Date: Wed, 04 Aug 2010 02:21:20 +0000
Subject: Re: Confusing performance of the magic method __call
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-49201@lists.php.net to get a copy of this message
I was working with PHP 5.2.9 with error_report=E_ALL and display_errors=On and got no error at all. Just now I tried it under PHP 5.3.0 and got the warning. Sometimes although I declared the magic method __call(), I want to prevent it from being called outside the class. Could someone be kindly enough to tell me why it must be public? Thanks. ----- Original Message ----- From: Victor Bolshov To: Shijiang Cc: PHP internals Sent: Tuesday, August 03, 2010 7:15 PM Subject: Re: [PHP-DEV] Confusing performance of the magic method __call Shijiang, did you notice the -- Warning: The magic method __call() must have public visibility and cannot be static in Command line code on line 1 -- ??? 2010/8/3 Shijiang <shijiang@staff.sina.com.cn> Hi, In the following sample code, I expected that the magic method __call only works within the class Test. But it seems that the access control keyword private lost its efficacy when working together with the magic method __call. <?php class Test{ private function __call($name,$params){ echo $name,"\n"; echo $params[0]; } public function bar(){ $this->kakaka('afaafaf'); } } $foo=new Test; $foo->bar('sfsfss'); $foo->nothing('works'); // this also works without any errors. ?> IMHO, since the function __call is a method of a class, it should obey the visibility rules. Cheers. -- С уважением, Виктор

« previous php.internals (#49201) next »