Skip to content

Commit b1c2609

Browse files
committed
Fix UPGRADING and add iterable|object type redundancy test
1 parent 6622c54 commit b1c2609

6 files changed

+77
-8
lines changed

UPGRADING

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ PHP 8.2 UPGRADE NOTES
1919
1. Backward Incompatible Changes
2020
========================================
2121

22+
- Core:
23+
. The iterable type is now a built-in compile time alias for array|Traversable.
24+
Error messages relating to iterable will therefore now use array|Traversable.
25+
Type Reflection is preserved for single iterable (and ?iterable) to produce
26+
a ReflectionNamedType with name iterable, however usage of iterable in
27+
union types will be converted to array|Traversable.
28+
This change also impacts the compile time type redundancy check, since
29+
types of the form object|iterable will now emit a compile time error:
30+
"Fatal error: Type Traversable|object|array| contains both object and a class type, which is redundant"
31+
However, types of the form array|iterable are not affected since they
32+
were already throwing a compile time redundancy error.
33+
2234
- Date:
2335
. DateTime::createFromImmutable() now has a tentative return type of static,
2436
previously it was DateTime.
@@ -231,7 +243,7 @@ PHP 8.2 UPGRADE NOTES
231243

232244
- OpenSSL:
233245
. openssl_cipher_key_length(): Returns a key length for the supplied
234-
cipher.
246+
cipher.
235247

236248
- Reflection:
237249
. ReflectionFunction::isAnonymous()
@@ -400,6 +412,10 @@ PHP 8.2 UPGRADE NOTES
400412
. CURL_VERSION_UNICODE (libcurl >= 7.72.0)
401413
. CURL_VERSION_ZSTD (libcurl >= 7.72.0)
402414

415+
- DBA
416+
. DBA_LMDB_USE_SUB_DIR
417+
. DBA_LMDB_NO_SUB_DIR
418+
403419
- Filter
404420
. FILTER_FLAG_GLOBAL_RANGE
405421

@@ -538,13 +554,6 @@ PHP 8.2 UPGRADE NOTES
538554
which is mostly when the CLI finishes. It is however still possible to
539555
explicitly close those streams using fclose and similar.
540556

541-
- Core:
542-
. The iterable type is now a built-in compile time alias for array|Traversable.
543-
Error messages relating to iterable will therefore now use array|Traversable.
544-
Type Reflection is preserved for single iterable (and ?iterable) to produce
545-
a ReflectionNamedType with name iterable, however usage of iterable in
546-
union types will be converted to array|Traversable
547-
548557
========================================
549558
14. Performance Improvements
550559
========================================
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
iterable type with array should be redundant
3+
--FILE--
4+
<?php
5+
6+
function bar(): array|iterable|null {
7+
return null;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Duplicate type array is redundant in %s on line %d
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
iterable type with array should be redundant
3+
--FILE--
4+
<?php
5+
6+
function bar(): iterable|array|null {
7+
return null;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Duplicate type array is redundant in %s on line %d
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
iterable type with second iterable should be redundant
3+
--FILE--
4+
<?php
5+
6+
function bar(): iterable|iterable|null {
7+
return null;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Duplicate type array is redundant in %s on line %d
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
iterable type with object should be redundant
3+
--FILE--
4+
<?php
5+
6+
function bar(): iterable|object|null {
7+
return null;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Type Traversable|object|array|null contains both object and a class type, which is redundant in %s on line %d
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
iterable type with object should be redundant
3+
--FILE--
4+
<?php
5+
6+
function bar(): object|iterable|null {
7+
return null;
8+
}
9+
10+
?>
11+
--EXPECTF--
12+
Fatal error: Type Traversable|object|array|null contains both object and a class type, which is redundant in %s on line %d

0 commit comments

Comments
 (0)