ID:               48523
 User updated by:  headden at karelia dot ru
 Reported By:      headden at karelia dot ru
-Status:           Feedback
+Status:           Open
 Bug Type:         Class/Object related
 Operating System: FreeBSD 7.0
 PHP Version:      5.2.9
 New Comment:

I can't reproduce it either with Win32 snapshot for 5.2.10RC2-dev.
Looks like this bug was indeed removed between 5.2.8 and (5.2.9 or
5.2.10). The issue can be closed now, or for extreme clarity it can be
tested against 5.2.9 snapshot as this version is still being bugtracked.


Previous Comments:
------------------------------------------------------------------------

[2009-06-10 18:19:20] fel...@php.net

Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

I can't reproduce it.

------------------------------------------------------------------------

[2009-06-10 18:05:56] headden at karelia dot ru

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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=48523&edit=1

Reply via email to