Bug #77154 [Opn]: private property inheritance discussion

From: Date: Thu, 15 Nov 2018 10:40:19 +0000
Subject: Bug #77154 [Opn]: private property inheritance discussion
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217970@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:         cmb@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)
 Block user comment: N
 Private report:     N

 New Comment:

This issue might better be discussed on internals@.


Previous Comments:
------------------------------------------------------------------------
[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


Thread (5 messages)

« previous php.bugs (#217970) next »