Bug #77154 [Opn]: private property inheritance discussion
| From: | nikic@php.net | Date: | Thu, 15 Nov 2018 10:51:26 +0000 |
| Subject: | Bug #77154 [Opn]: private property inheritance discussion | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-217972@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77154&edit=1
ID: 77154
Updated by: nikic@php.net
Reported by: jpauli@php.net
Summary: private property inheritance discussion
Status: Open
Type: Bug
Package: Class/Object related
Operating System: *
PHP Version: master-Git-2018-11-14 (Git)
-Assigned To:
+Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
@dmitry: What do you think about this? This is a side-effect of the changes to shadow/private
property handling.
Previous Comments:
------------------------------------------------------------------------
[2018-11-15 10:40:19] cmb@php.net
This issue might better be discussed on internals@.
------------------------------------------------------------------------
[2018-11-14 18:42:56] jpauli@php.net
Description:
------------
This behavior is wether right or wrong ; let's debate :
Test script:
---------------
class A {
private static $foo = 'Afoo';
function foo() { return static::$foo; }
}
class B extends A { }
$b = new B;
echo $b->foo();
Expected result:
----------------
PHP <= 7.3 shows :
Fatal error: Uncaught Error: Cannot access property B::$foo in XXXX
PHP-master shows :
the string 'Afoo'
Actual result:
--------------
What should be the right behavior ?
Considering that the same use-case using non-static attribute, and non static classic $this accesses
the attributes just all right in all PHP versions
Should private static attributes be inherited, or not ?
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77154&edit=1