|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-10 18:19 UTC] felipe@php.net
[2009-06-10 18:36 UTC] headden at karelia dot ru
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 20:00:01 2025 UTC |
Description: ------------ I am using PHP 5.2.8, but I am not 100% sure this bug was removed from actual versions. The bug is that an attempt to access declared private method does not lead to __call() magic method invocation, but instead raises an error due to visibility as if there was no __call() declared at all. According to documentaion this should work the way it works for member variables - i.e. both undeclared and invisible methods should be resolved via __call(). In my version of PHP it works fine for variables (__get/__set work for both undeclared and invisible variables), but it does not work as intended for methods (__call works only for undeclared methods). Reproduce code: --------------- <?php class MyClass { private $v; private function f($a, $b, $c) { echo "f();"; } function __get($name) { echo "get($name)<br/>"; return $this->v; } function __set($name, $v) { echo "set($name)<br/>"; $this->v = $v; } function __call($name, $args) { echo "call($name, ".implode(", ", $args).")<br/>"; } } $o = new MyClass; $o->q = $o->q; // OK (undeclared variable) $o->v = $o->v; // OK (invisible variable) $o->g(1,2,3); // OK (undeclared method) $o->f(1,2,3); // FAILURE (invisible method) ?> Expected result: ---------------- get(q) set(q) get(v) set(v) call(g, 1, 2, 3) call(f, 1, 2, 3) Actual result: -------------- get(q) set(q) get(v) set(v) call(g, 1, 2, 3) Fatal error: Call to private method MyClass::f() from context '' in /.../test.php on line 15