Bug #61025 [Opn]: __invoke() visibility not honored

From: Date: Thu, 07 Mar 2013 03:20:30 +0000
Subject: Bug #61025 [Opn]: __invoke() visibility not honored
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-177632@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=61025&edit=1 ID: 61025 Updated by: laruence@php.net Reported by: jpauli@php.net Summary: __invoke() visibility not honored Status: Open Type: Bug Package: Class/Object related Operating System: *nix PHP Version: 5.3.10 Block user comment: N Private report: N New Comment: I don't think this need to be fixed in this way, like __call: ```php <?php class Bar { private function __call($name, $value) { return __CLASS__; } } $b = new Bar; $b->__call("name", NULL); ``` works well, but with an warning: ``` Warning: The magic method __call() must have public visibility and cannot be static ``` I am not sure whether this is a bug, or just need document. Previous Comments: ------------------------------------------------------------------------ [2013-03-06 16:58:22] reeze@php.net Hi, I made a patch again 5.5. how about fix it in 5.5? ------------------------------------------------------------------------ [2012-07-30 02:22:11] willfitch@php.net johannes - I can commit a fix for this, but at what point should it be introduced? ------------------------------------------------------------------------ [2012-02-10 22:34:44] johannes@php.net Yes, the current behavior is wrong. I don't think it should be fixed in 5.3 though as the fix might break existing code. ------------------------------------------------------------------------ [2012-02-09 09:17:23] jpauli@php.net Description: ------------ __invoke() visibility is not honored when indirectly called as $obj(). It is, when directly called, via $obj->__invoke(); Please, note as well that declaring __invoke() as static works as well, I think it shouldn't (nonsense) Test script: --------------- <?php class Bar { private function __invoke() { return __CLASS__; } } $b = new Bar; echo $b(); /* this works as expected : Fatal Error */ /* echo $b->__invoke(); */ Expected result: ---------------- Call to private method Bar::__invoke() from context ... Actual result: -------------- Bar ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=61025&edit=1

« previous php.bugs (#177632) next »