Bug #77344 [Com]: Why is it judged to use __call
| From: | Wes dot example at example dot org | Date: | Tue, 25 Dec 2018 01:33:50 +0000 |
| Subject: | Bug #77344 [Com]: Why is it judged to use __call | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-218607@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77344&edit=1
ID: 77344
Comment by: Wes dot example at example dot org
Reported by: hongweichen8888 at sina dot com
Summary: Why is it judged to use __call
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: All
PHP Version: 7.2.13
Block user comment: N
Private report: N
New Comment:
if $this is set, __call is called, otherwise __callStatic
that regardless of what's on the left of the :: operator
using parent:: or A:: is the same from php's perspective in this case
I know it's a bit odd. Perhaps php should have a different way to resolve the parent class than
the static method syntax
Previous Comments:
------------------------------------------------------------------------
[2018-12-25 01:12:27] hongweichen8888 at sina dot com
Description:
------------
When using the __call and __callStatic functionality on a parent class calls to A::method() will use
__call rather than the __callStatic.
Test script:
---------------
class A {
function __call($name, $arguments) {
echo "non-static\n";
}
static function __callStatic($name, $arguments){
echo "static\n";
}
}
class B extends A {
function fun() {
parent::test(); // with calling scope
A::test(); // ?
}
}
$obj = new B();
$obj->fun();
Expected result:
----------------
non-static
static
Actual result:
--------------
non-static
non-static
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77344&edit=1