1.2.835. No Reference For Static Property¶
Static properties used to behave independently when set to a reference value. This was fixed in PHP 7.3.
According to the PHP 7.3 changelog :
In PHP, static properties are shared between inheriting classes, unless the static property is explicitly overridden in a child class. However, due to an implementation artifact it was possible to separate the static properties by assigning a reference. This loophole has been fixed.
<?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)
?>
See also PHP 7.3 UPGRADE NOTES.
1.2.835.1. Connex PHP features¶
1.2.835.1.1. Specs¶
Short name |
Php/NoReferenceForStaticProperty |
Rulesets |
All, Changed Behavior, CompatibilityPHP53, CompatibilityPHP54, CompatibilityPHP55, CompatibilityPHP56, CompatibilityPHP70, CompatibilityPHP71, CompatibilityPHP72 |
Exakat since |
1.4.9 |
PHP Version |
With PHP 7.3 and older |
Severity |
Major |
Time To Fix |
Slow (1 hour) |
Changed Behavior |
PHP 7.3 - More |
Precision |
Very high |
Available in |