rfc:arithmetic_operator_type_checks
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:arithmetic_operator_type_checks [2020/04/01 13:54] – created nikic | rfc:arithmetic_operator_type_checks [2020/05/05 14:12] (current) – nikic | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Stricter type checks for arithmetic/ | ====== PHP RFC: Stricter type checks for arithmetic/ | ||
- | * Date: 2020-04-01 | + | * Date: 2020-04-02 |
* Author: Nikita Popov < | * Author: Nikita Popov < | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.0 | * Target Version: PHP 8.0 | ||
* Implementation: | * Implementation: | ||
Line 14: | Line 14: | ||
<PHP> | <PHP> | ||
var_dump([] % [42]); | var_dump([] % [42]); | ||
- | // int(1) | + | // int(0) |
// WTF? | // WTF? | ||
</ | </ | ||
Line 65: | Line 65: | ||
Using an array, resource or object in an arithmetic/ | Using an array, resource or object in an arithmetic/ | ||
+ | |||
+ | ===== Future Scope ===== | ||
+ | |||
+ | In the future, we may wish to go one step further: | ||
+ | |||
+ | * Make non-numeric string operands throwing. Non-numeric here means not starting with a digit (optionally preceded by whitespace). This would not apply to operators that have special behavior for strings (string increment and bitwise and/ | ||
+ | * Make overflowing float values throwing for operators that expect an integer ('' | ||
+ | |||
+ | This would have the advantage of aligning the semantics with parameter type checks in coercive mode, for the types '' | ||
+ | |||
+ | I'm leaving this potential improvement out of this RFC, because it requires more consideration regarding backwards compatibility and overall language integration. | ||
===== Vote ===== | ===== Vote ===== | ||
- | Yes/No. | + | Voting started 2020-04-16 and ends 2020-04-30. |
+ | <doodle title=" | ||
+ | * yes | ||
+ | * no | ||
+ | </ |
rfc/arithmetic_operator_type_checks.1585749295.txt.gz · Last modified: 2020/04/01 13:54 by nikic