rfc:nullable-casting
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:nullable-casting [2019/03/26 07:51] – reorder, reword guilliamxavier | rfc:nullable-casting [2019/04/21 09:03] (current) – Add Discussion section guilliamxavier | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Date: 2019-03-17 | * Date: 2019-03-17 | ||
* Author: David Rodrigues (david.proweb@gmail.com), | * Author: David Rodrigues (david.proweb@gmail.com), | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
Line 15: | Line 15: | ||
===== Motivating Example ===== | ===== Motivating Example ===== | ||
- | In strict type-checking mode (< | + | In strict type-checking mode (< |
<PHP> | <PHP> | ||
Line 167: | Line 167: | ||
* **Accept nullable casting?**: Simple vote (Yes / No), requiring a 2/3 majority to pass. | * **Accept nullable casting?**: Simple vote (Yes / No), requiring a 2/3 majority to pass. | ||
- | * **Additionally accept nullable settype()? | + | * **Additionally accept nullable settype()? |
* **How to handle settype($x, "? | * **How to handle settype($x, "? | ||
+ | |||
+ | (The voting period would be two weeks) | ||
===== Patches and Tests ===== | ===== Patches and Tests ===== | ||
* Working prototype: https:// | * Working prototype: https:// | ||
+ | |||
+ | ===== Discussion ===== | ||
+ | |||
+ | ==== "Not 100% needed" | ||
+ | |||
+ | Current alternatives: | ||
+ | * Use a test (ternary conditional operator or '' | ||
+ | * Write (and [auto]load) custom casting functions | ||
+ | * Disable (i.e. do not enable) strict typing mode in the concerned file //(not strictly equivalent, e.g. for '' | ||
+ | |||
+ | ==== "A cast where you can't be sure of what you'll get back" ==== | ||
+ | |||
+ | "I understand the use-case for when you want to pass something to a nullable parameter, but if you think about this cast in isolation, it hardly makes sense." | ||
+ | |||
+ | ==== "What about e.g. nullable_intval()?" | ||
+ | |||
+ | But we're missing " | ||
+ | |||
+ | ==== Fallible Casting ==== | ||
+ | |||
+ | One might expect to also have e.g. '' | ||
+ | |||
+ | ==== Alternative syntax ==== | ||
+ | |||
+ | E.g. "'' | ||
===== References ===== | ===== References ===== | ||
- | * [[http:// | + | * PHP Manual: |
- | * [[http:// | + | * PHP RFC: [[rfc: |
- | * [[rfc: | + | |
- | * [[rfc: | + | |
* Initial idea and discussion: https:// | * Initial idea and discussion: https:// | ||
+ | * Annoucement and discussion: https:// |
rfc/nullable-casting.1553586699.txt.gz · Last modified: 2019/03/26 07:51 by guilliamxavier