@@ -49,7 +49,7 @@ PHP 8.0 UPGRADE NOTES
49
49
parameter consistent with isset() and normal array access. All key types now
50
50
use the usual coercions and array/object keys throw a TypeError.
51
51
. Any array that has a number n as its first numeric key will use n+1 for
52
- its next implicit key. Even if n is negative.
52
+ its next implicit key, even if n is negative.
53
53
RFC: https://wiki.php.net/rfc/negative_array_index
54
54
. The default error_reporting level is now E_ALL. Previously it excluded
55
55
E_NOTICE and E_DEPRECATED.
@@ -91,7 +91,7 @@ PHP 8.0 UPGRADE NOTES
91
91
. The precedence of the concatenation operator has changed relative to
92
92
bitshifts and addition as well as subtraction.
93
93
RFC: https://wiki.php.net/rfc/concatenation_precedence
94
- . Arguments with a default- value that resolves to null at run-time will no
94
+ . Arguments with a default value that resolves to null at runtime will no
95
95
longer implicitly mark the argument type as nullable. Either use an explicit
96
96
nullable type, or an explicit null default value instead.
97
97
@@ -121,7 +121,7 @@ PHP 8.0 UPGRADE NOTES
121
121
* Attempting to access an array index of a non-array.
122
122
* Attempting to convert an array to string.
123
123
* Attempting to use a resource as an array key.
124
- * Attempting to use null, a boolean or a float as a string offset.
124
+ * Attempting to use null, a boolean, or a float as a string offset.
125
125
* Attempting to read an out-of-bounds string offset.
126
126
* Attempting to assign an empty string to a string offset.
127
127
@@ -134,7 +134,7 @@ PHP 8.0 UPGRADE NOTES
134
134
. Uncaught exceptions now go through "clean shutdown", which means that
135
135
destructors will be called after an uncaught exception.
136
136
. Compile time fatal error "Only variables can be passed by reference" has
137
- been delayed until run-time and converted to "Cannot pass parameter by
137
+ been delayed until runtime and converted to "Cannot pass parameter by
138
138
reference" exception.
139
139
. Some "Only variables should be passed by reference" notices have been
140
140
converted to "Cannot pass parameter by reference" exception.
@@ -150,13 +150,6 @@ PHP 8.0 UPGRADE NOTES
150
150
151
151
The name shown above is still followed by a null byte and and a unique
152
152
suffix.
153
- . Declaring a required parameter after an optional one is deprecated. As an
154
- exception, declaring a parameter of the form "Type $param = null" before
155
- a required one continues to be allowed, because this pattern was sometimes
156
- used to achieve nullable types in older PHP versions.
157
-
158
- function test($a = [], $b) {} // Deprecated
159
- function test(Foo $a = null, $b) {} // Allowed
160
153
. Non-absolute trait method references in trait alias adaptations are now
161
154
required to be unambiguous:
162
155
@@ -239,9 +232,8 @@ PHP 8.0 UPGRADE NOTES
239
232
"Illegal string offset 'string'" for illegal string offsets. The behavior
240
233
of explicit casts to int/float from strings has not been changed.
241
234
RFC: https://wiki.php.net/rfc/saner-numeric-strings
242
- . Magic Methods will now have their arguments and return types
243
- checked if they have them declared. The signatures should
244
- match the following list:
235
+ . Magic Methods will now have their arguments and return types checked if
236
+ they have them declared. The signatures should match the following list:
245
237
246
238
__call(string $name, array $arguments): mixed
247
239
__callStatic(string $name, array $arguments): mixed
@@ -327,7 +319,7 @@ PHP 8.0 UPGRADE NOTES
327
319
gmp_random_bits() should be used instead.
328
320
329
321
- Iconv:
330
- . iconv() implementations which do not properly set errno in case of errors,
322
+ . iconv() implementations which do not properly set errno in case of errors
331
323
are no longer supported.
332
324
333
325
- Intl:
@@ -378,7 +370,7 @@ PHP 8.0 UPGRADE NOTES
378
370
. The $is_hex parameter, which was not used internally, has been removed from
379
371
mb_decode_numericentity().
380
372
. The legacy behavior of passing the encoding as the third argument instead
381
- of an offset for the mb_strrpos() function has been removed, provide an
373
+ of an offset for the mb_strrpos() function has been removed; provide an
382
374
explicit 0 offset with the encoding as the fourth argument instead.
383
375
. The ISO_8859-* character encoding aliases have been replaced by ISO8859-*
384
376
aliases for better interoperability with the iconv extension. The mbregex
@@ -549,10 +541,10 @@ PHP 8.0 UPGRADE NOTES
549
541
. Specifying out of range rounds for sha256/sha526 crypt() will now fail with
550
542
*0 instead of clamping to the closest limit. This matches glibc behavior.
551
543
. The result of sorting functions may have changed, if the array contains
552
- equal-comparing elements.
553
- . Sort comparison functions return true/ false will now throw a deprecation
554
- warning and should be replaced with an implementation return an integer
555
- smaller than, equal to, or greater than zero.
544
+ elements that compare as equal .
545
+ . Sort comparison functions that return true or false will now throw a
546
+ deprecation warning, and should be replaced with an implementation
547
+ that returns an integer less than, equal to, or greater than zero.
556
548
557
549
// Replace
558
550
usort($array, fn($a, $b) => $a > $b);
@@ -565,8 +557,8 @@ PHP 8.0 UPGRADE NOTES
565
557
This was already the case for most, but not all, functions previously.
566
558
. The HTTP stream wrapper as used by functions like file_get_contents()
567
559
now advertises HTTP/1.1 rather than HTTP/1.0 by default. This does not
568
- change the behaviour of the client, but may cause servers to respond
569
- differently. To retain the old behaviour , set the 'protocol_version'
560
+ change the behavior of the client, but may cause servers to respond
561
+ differently. To retain the old behavior , set the 'protocol_version'
570
562
stream context option, e.g.
571
563
572
564
$ctx = stream_context_create(['http' => ['protocol_version' => '1.0']]);
@@ -614,8 +606,8 @@ PHP 8.0 UPGRADE NOTES
614
606
objects instead of resources.
615
607
616
608
- Zip:
617
- . ZipArchive::OPSYS_Z_CPM have been removed, should use ZipArchive::OPSYS_CPM
618
- (this name was a typo) .
609
+ . ZipArchive::OPSYS_Z_CPM has been removed (this name was a typo). Use
610
+ ZipArchive::OPSYS_CPM instead .
619
611
620
612
- Zlib:
621
613
. gzgetss() has been removed.
@@ -787,6 +779,13 @@ PHP 8.0 UPGRADE NOTES
787
779
========================================
788
780
789
781
- Core:
782
+ . Declaring a required parameter after an optional one is deprecated. As an
783
+ exception, declaring a parameter of the form "Type $param = null" before
784
+ a required one continues to be allowed, because this pattern was sometimes
785
+ used to achieve nullable types in older PHP versions.
786
+
787
+ function test($a = [], $b) {} // Deprecated
788
+ function test(Foo $a = null, $b) {} // Allowed
790
789
. Calling get_defined_functions() with $exclude_disabled explicitly set to
791
790
false is deprecated. get_defined_functions() will never include disabled
792
791
functions.
0 commit comments