Skip to content

[RFC] Define proper semantics for range() function #10826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Jun 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ PHP 8.3 UPGRADE NOTES
. C functions that have a return type of void now return null instead of
returning the following object object(FFI\CData:void) { }

- Standard:
. The range() function has had various changes:
* A TypeError is now thrown when passing objects, resources, or arrays
as the boundary inputs
* A more descriptive ValueError is thrown when passing 0 for $step
* A ValueError is now thrown when using a negative $step for increasing ranges
* If $step is a float that can be interpreted as an int, it is now done so
* A ValueError is now thrown if any argument is infinity or NAN
* An E_WARNING is now emitted if $start or $end is the empty string.
The value continues to be cast to the value 0.
* An E_WARNING is now emitted if $start or $end has more than one byte,
only if it is a non-numeric string.
* An E_WARNING is now emitted if $start or $end is cast to an integer
because the other boundary input is a number. (e.g. range(5, 'z');)
* An E_WARNING is now emitted if $step is a float when trying to generate
a range of characters, except if both boundary inputs are numeric strings
(e.g. range('5', '9', 0.5); does not produce a warning)
* range() now produce a list of characters if one of the boundary inputs is
a string digit instead of casting the other input to int
(e.g. range('5', 'z');)

========================================
2. New Features
========================================
Expand Down Expand Up @@ -113,7 +134,7 @@ PHP 8.3 UPGRADE NOTES
. Changed DOMCharacterData::appendData() tentative return type to true.

- Intl:
. datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone)
. datefmt_set_timezone (and its alias IntlDateformatter::setTimeZone)
now returns true on success, previously null was returned.
. IntlBreakiterator::setText() now returns false on failure, previously
null was returned.
Expand Down
Loading