Static Properties With References

Static properties are shared between inheriting classes. However, due to an implementation artifact, it was possible to separate the static properties by assigning a reference. This loophole has been fixed in PHP 7.3.

PHP code

<?php

    class Test {
        public static $x = 0;
    }
    class Test2 extends Test { }

    Test2::$x = &$x;
    $x = 1;

    var_dump(Test::$x, Test2::$x);
    // Previously: int(0), int(1)
    // Now: int(1), int(1)

?>

Before

int(0)
int(1)

After

int(1)
int(1)

PHP version change

This behavior changed in 7.3