File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,28 @@ PHP 8.1 UPGRADE NOTES
37
37
// is deprecated
38
38
39
39
RFC: https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg
40
+ . When a method using static variables is inherited, the inherited method
41
+ will now initialize the static variables to their original values, rather
42
+ than the values at the time of inheritance:
43
+
44
+ class A {
45
+ public function counter() {
46
+ static $counter = 0;
47
+ $counter++;
48
+ return $counter;
49
+ }
50
+ }
51
+
52
+ var_dump((new A)->counter()); // int(1)
53
+
54
+ eval('class B extends A {}'); // eval() to prevent early binding.
55
+
56
+ var_dump((new B)->counter()); // int(1), previously int(2)
57
+ var_dump((new A)->counter()); // int(2)
58
+ var_dump((new B)->counter()); // int(2), previously int(3)
59
+
60
+ Previously the behavior would be different depending on whether A::counter()
61
+ was called before class B was declared, or after it was declared.
40
62
41
63
- Fileinfo:
42
64
. The fileinfo functions now accept and return, respectively, finfo objects
You can’t perform that action at this time.
0 commit comments