Bug #70437 [Opn]: Changes to static properties in trait methods are not reflected in the class
| From: | nikic@php.net | Date: | Mon, 07 Sep 2015 03:53:35 +0000 |
| Subject: | Bug #70437 [Opn]: Changes to static properties in trait methods are not reflected in the class | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195823@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70437&edit=1
ID: 70437
Updated by: nikic@php.net
Reported by: davey@php.net
Summary: Changes to static properties in trait methods are
not reflected in the class
Status: Open
Type: Bug
Package: Scripting Engine problem
Operating System: OSX/Linux
PHP Version: 7.0.0RC2
Block user comment: N
Private report: N
New Comment:
Imho the bug here is that we allow calls to static methods on traits. I don't think that's
supposed to work and we should add this forgotten check in PHP 7.
Previous Comments:
------------------------------------------------------------------------
[2015-09-06 14:32:49] davey@php.net
Description:
------------
If you have a trait that defines a static property, and you modify said property from within a trait
inherited method, the modifications are done to a trait instance of the property, as opposed to the
inherited-from-trait static property within the class.
The behavior differs slightly in PHP 5.4.7 - 5.5.29 in that if the methods are instance methods,
then they will correctly modify the inherited-from-trait static property, but are broken for static
methods. 5.6.0+ has the same behavior for static and instance methods.
Test script:
---------------
Static methods: https://3v4l.org/UZ6gq
Instance methods: https://3v4l.org/piUFm
Expected result:
----------------
Should modify the inherited-from-trait static property within the class
Actual result:
--------------
Modifies a trait-specific copy of the static property
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70437&edit=1