Skip to content

Commit 798c40a

Browse files
authored
[RFC] Define proper semantics for range() function (php#10826)
RFC: https://wiki.php.net/rfc/proper-range-semantics
1 parent ea8f934 commit 798c40a

27 files changed

+1767
-1318
lines changed

UPGRADING

+22-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,27 @@ PHP 8.3 UPGRADE NOTES
5252
. C functions that have a return type of void now return null instead of
5353
returning the following object object(FFI\CData:void) { }
5454

55+
- Standard:
56+
. The range() function has had various changes:
57+
* A TypeError is now thrown when passing objects, resources, or arrays
58+
as the boundary inputs
59+
* A more descriptive ValueError is thrown when passing 0 for $step
60+
* A ValueError is now thrown when using a negative $step for increasing ranges
61+
* If $step is a float that can be interpreted as an int, it is now done so
62+
* A ValueError is now thrown if any argument is infinity or NAN
63+
* An E_WARNING is now emitted if $start or $end is the empty string.
64+
The value continues to be cast to the value 0.
65+
* An E_WARNING is now emitted if $start or $end has more than one byte,
66+
only if it is a non-numeric string.
67+
* An E_WARNING is now emitted if $start or $end is cast to an integer
68+
because the other boundary input is a number. (e.g. range(5, 'z');)
69+
* An E_WARNING is now emitted if $step is a float when trying to generate
70+
a range of characters, except if both boundary inputs are numeric strings
71+
(e.g. range('5', '9', 0.5); does not produce a warning)
72+
* range() now produce a list of characters if one of the boundary inputs is
73+
a string digit instead of casting the other input to int
74+
(e.g. range('5', 'z');)
75+
5576
========================================
5677
2. New Features
5778
========================================
@@ -117,7 +138,7 @@ PHP 8.3 UPGRADE NOTES
117138
as it was not used internally anyway from PHP 7.x.
118139

119140
- Intl:
120-
. datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone)
141+
. datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone)
121142
now returns true on success, previously null was returned.
122143
. IntlBreakiterator::setText() now returns false on failure, previously
123144
null was returned.

0 commit comments

Comments
 (0)