Both sides previous revisionPrevious revision | Next revisionBoth sides next revision |
rfc:proper-range-semantics [2023/03/30 13:30] – Version 0.2 girgias | rfc:proper-range-semantics [2023/05/08 09:24] – Clarification nits girgias |
---|
The changes are as follows: | The changes are as follows: |
| |
* If <php>$step</php> is a float but is compatible with ''int'' interpret it as an integer. | * If <php>$step</php> is a float but is compatible with ''int'' (i.e. <php>(float)(int)$step === $step</php>) interpret it as an integer. |
* Introduce and use a proper ZPP check for ''int|float|string'' <php>$start</php> and <php>$end</php> parameters, this will cause <php>TypeError</php>s to be thrown when passing objects, resources, and arrays to <php>range()</php>. It will also cause a deprecation warning to be emitted when passing ''null''. | * Introduce and use a proper ZPP check for ''int|float|string'' <php>$start</php> and <php>$end</php> parameters, this will cause <php>TypeError</php>s to be thrown when passing objects, resources, and arrays to <php>range()</php>. It will also cause a deprecation warning to be emitted when passing ''null''. |
* Throw value errors if <php>$start</php>, <php>$end</php>, or <php>$step</php> is a non-finite float (-INF, INF, NAN). | * Throw value errors if <php>$start</php>, <php>$end</php>, or <php>$step</php> is a non-finite float (-INF, INF, NAN). |
* Throw a <php>ValueError</php> when passing a negative <php>$step</php> for increasing ranges. | * Throw a <php>ValueError</php> when passing a negative <php>$step</php> for increasing ranges. |
* Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> is the empty string, and cast the value to ''0'' | * Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> is the empty string, and cast the value to ''0'' |
* Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> has more than one byte. | * Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> has more than one byte if it is a non-numeric string. |
* Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> is cast to an integer because the other boundary input is a number or numeric string. (e.g. <php>range('5', 'z');</php> or <php>range(5, 'z');</php>) | * Emit an <php>E_WARNING</php> when <php>$start</php> or <php>$end</php> is cast to an integer because the other boundary input is a number or numeric string. (e.g. <php>range('5', 'z');</php> or <php>range(5, 'z');</php>) |
* Emit an <php>E_WARNING</php> when <php>$step</php> is a float when trying to generate a range of characters. | * Emit an <php>E_WARNING</php> when <php>$step</php> is a float when trying to generate a range of characters. |