Bug #66739 [Opn->Nab]: strange behavior
| From: | nikic@php.net | Date: | Thu, 05 May 2016 09:58:52 +0000 |
| Subject: | Bug #66739 [Opn->Nab]: strange behavior | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-200911@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66739&edit=1
ID: 66739
Updated by: nikic@php.net
Reported by: temenb at gmail dot com
Summary: strange behavior
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: ubuntu
PHP Version: 5.4Git-2014-02-18 (Git)
Block user comment: N
Private report: N
New Comment:
So, what's happen here is this: On PHP 5.x we allow scoped calls to incompatible contexts, by
adopting the $this from the incompatible scope. In this instance the A::a1() call in B::b1() will
result the $this of A::a1() being the instance of B. If there is a $this, then static:: refers to
get_class($this). As such you get a return value of B.
In PHP 7.0 we no longer allow calls with incompatible contexts, or rather they are still allowed,
but $this will not be bound. As such the result will be A like for a normal static call.
So, the behavior is correct for the semantics of the respective PHP versions, even though the 5.x
semantics are now obsolete.
Previous Comments:
------------------------------------------------------------------------
[2014-07-09 14:12:19] arjen at react dot com
phpng is listed on 3v4l.org as php 5.7, which is compiled from the phpng branch.
In this branch, it returns AAAAAAAA. All other versions return AAAABAAA
------------------------------------------------------------------------
[2014-06-27 12:42:19] pajoye@php.net
@ arjen at react dot com
phpng is an independent feature branch.
We have branches like for 5.4, 5.5, 5.6 or master. Which one do you use?
------------------------------------------------------------------------
[2014-06-27 12:36:24] arjen at react dot com
Exact output/warnings @ http://3v4l.org/ek1KG
Behaviour changed in 5.7 (phpng).
------------------------------------------------------------------------
[2014-02-19 07:36:02] temenb at gmail dot com
Yes. It's true. not obvious. But php allows to call function this way
------------------------------------------------------------------------
[2014-02-19 02:53:53] coolwust at gmail dot com
B::b1();//b1 is object method
$b->b2();//b2 is static method
I think the syntax you calling the method is not correct
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=66739
--
Edit this bug report at https://bugs.php.net/bug.php?id=66739&edit=1