#49328 [Bgs]: __call is not able to handle private functions in extended classes

From: Date: Sat, 22 Aug 2009 13:47:52 +0000
Subject: #49328 [Bgs]: __call is not able to handle private functions in extended classes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-141390@lists.php.net to get a copy of this message
ID: 49328 User updated by: rayro at gmx dot de Reported By: rayro at gmx dot de Status: Bogus Bug Type: Class/Object related Operating System: Windows XP PHP Version: 5.3.0 New Comment: Addition: The following __call function will also generate an endless loop, and there will be _no output_ if you uncomment Foo::test() here: abstract class Foo { function __call($f, $a) { return $this->{$f}($a[0]); } // private function test() { } } class Bar extends Foo { private function test($a) { var_dump($a); } } $bar = new Bar(); $bar->test('hello'); Previous Comments: ------------------------------------------------------------------------ [2009-08-22 13:34:13] rayro at gmx dot de Well, does Foo::__call has access to Bar::test() if the private function is defined in the abstract class? Although, since 5.3 __call can handle private functions (place __call in Bar), this _should_ be argumented as a bug i think? The access level should not matter while extending? ------------------------------------------------------------------------ [2009-08-22 13:26:39] colder@php.net Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. Foo::__call() doesn't have access to Bar::test() since its private. I can't see see the "problem" here. ------------------------------------------------------------------------ [2009-08-22 12:25:18] rayro at gmx dot de Description: ------------ While public functions will be called on the extended class, private will not. If you define a "test" function in the Foo class, the function on the extended class will be called like expected. Code is self-explaining this "problem"... Reproduce code: --------------- abstract class Foo { function __call($f, $a) { return call_user_func_array(array($this, $f), $a); } // uncomment this: private function test() { } } class Bar extends Foo { private function test($a) { var_dump($a); } } $bar = new Bar(); $bar->test('hello'); Expected result: ---------------- string(5) "hello" Actual result: -------------- endless loop ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49328&edit=1

« previous php.bugs (#141390) next »