php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64286 Magic __call() not work through inheritance
Submitted: 2013-02-23 17:05 UTC Modified: 2013-02-23 17:12 UTC
From: joaner1206 at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 不着边际 OS: Linux 2.6
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joaner1206 at gmail dot com
New email:
PHP Version: OS:

 

 [2013-02-23 17:05 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-02-23 17:12 UTC] johannes@php.net
-Status: Open +Status: Not a bug
 [2013-02-23 17:12 UTC] johannes@php.net
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.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 13:01:30 2024 UTC