Bug #69933 [Opn->Csd]: Reflection API no longer allows to override static properties

From: Date: Mon, 28 Mar 2016 07:32:18 +0000
Subject: Bug #69933 [Opn->Csd]: Reflection API no longer allows to override static properties
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-200176@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69933&edit=1

 ID:                 69933
 Updated by:         krakjoe@php.net
 Reported by:        maf dot michal at gmail dot com
 Summary:            Reflection API no longer allows to override static
                     properties
-Status:             Open
+Status:             Closed
 Type:               Bug
 Package:            Reflection related
 Operating System:   unix
 PHP Version:        7.0Git-2015-06-25 (snap)
-Assigned To:        
+Assigned To:        krakjoe
 Block user comment: N
 Private report:     N

 New Comment:

This was fixed in 7.0.1, someone forgot to update the bug.


Previous Comments:
------------------------------------------------------------------------
[2015-10-12 20:09:38] j dot tvr at centrum dot cz

Could someone look into this?

------------------------------------------------------------------------
[2015-09-19 20:08:19] j dot tvr at centrum dot cz

I spent some time playing with this bug and it turned out to be worse problem that it originally
seemed. Changing value of static property with reflection **permanently breaks the inheritance
chain**.

https://3v4l.org/T43Sh

------------------------------------------------------------------------
[2015-08-23 15:42:30] j dot tvr at centrum dot cz

https://3v4l.org/nvhZQ

------------------------------------------------------------------------
[2015-06-26 18:47:38] maf dot michal at gmail dot com

proof: https://travis-ci.org/majkel89/php7-bug

------------------------------------------------------------------------
[2015-06-26 18:41:56] maf dot michal at gmail dot com

<?php
class Base {
    protected static $prop = 'BASE';
    public function getProp() {
        return static::$prop;
    }
}
class Mock extends Base { }

$obj = new Mock;
$excepted = 'REFLECTED';

$property = new ReflectionProperty('Base', 'prop');
$property->setAccessible(true);
$property->setValue($excepted);

$actual = $obj->getProp();
echo "Schould be {$excepted} and is {$actual}\n";
// exit($actual !== $excepted ? 1 : 0);
?>

------------------------------------------------------------------------


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=69933


--
Edit this bug report at https://bugs.php.net/bug.php?id=69933&edit=1


Thread (8 messages)

« previous php.bugs (#200176) next »