Req #64286 [Opn->Nab]: Magic __call() not work through inheritance
| From: | johannes@php.net | Date: | Sat, 23 Feb 2013 17:12:54 +0000 |
| Subject: | Req #64286 [Opn->Nab]: Magic __call() not work through inheritance | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-177359@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64286&edit=1
ID: 64286
Updated by: johannes@php.net
Reported by: joaner1206 at gmail dot com
Summary: Magic __call() not work through inheritance
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
Package: Scripting Engine problem
Operating System: Linux 2.6
PHP Version: ä¸çè¾¹é
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
superTest has no access to private elements from any other class.
Previous Comments:
------------------------------------------------------------------------
[2013-02-23 17:05:47] joaner1206 at gmail dot com
Description:
------------
When the magic __call() form extends,It can't call the private or protected
function of child class, and worse, it would have been to call its own.
But I watch others magic like __set(), __get(), they will not be affected for
work in child.
Test script:
---------------
class superTest {
public function __call($func, $param) {
echo "Is __call", PHP_EOL;
$this->$func($param);
}
}
final class test extends superTest {
private function hello($i) {
echo "hello,world - $i[0]", PHP_EOL;
}
/** It will call hello() , only once, everything is fine
public function __call($func, $param) {
echo "Is __call in Child", PHP_EOL;
$this->$func($param);
} */
}
$test = new test();
$test->hello(1);
Expected result:
----------------
Is __call
Hello,world - 1
Actual result:
--------------
Is __call
Is __call
Is __call
Is __call
Is __call
Is __call
Is __call
...
// stack exception
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64286&edit=1