rfc:allow_null
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:allow_null [2022/02/08 15:31] – craigfrancis | rfc:allow_null [2022/04/05 17:49] (current) – superseded craigfrancis | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Allow NULL ====== | ====== PHP RFC: Allow NULL ====== | ||
- | * Version: 1.2 | + | * Version: 1.3 |
* Voting Start: ? | * Voting Start: ? | ||
* Voting End: ? | * Voting End: ? | ||
* RFC Started: 2021-12-23 | * RFC Started: 2021-12-23 | ||
- | * RFC Updated: | + | * RFC Updated: |
* Author: Craig Francis, craig# | * Author: Craig Francis, craig# | ||
* Status: Draft | * Status: Draft | ||
Line 11: | Line 11: | ||
* GitHub Repo: https:// | * GitHub Repo: https:// | ||
* Implementation: | * Implementation: | ||
+ | |||
+ | ---- | ||
+ | |||
+ | This RFC has been superseded by [[https:// | ||
+ | |||
+ | ---- | ||
===== Introduction ===== | ===== Introduction ===== | ||
PHP 8.1 introduced " | PHP 8.1 introduced " | ||
+ | |||
+ | This has introduced an inconstancy when not using // | ||
In PHP //NULL// is often used to represent something; e.g. when a // | In PHP //NULL// is often used to represent something; e.g. when a // | ||
Line 49: | Line 57: | ||
xmlwriter_text($writer, | xmlwriter_text($writer, | ||
</ | </ | ||
- | |||
- | Where //NULL// has the advantage of falling back to being treated like an empty string. | ||
Developers also use //NULL// to skip certain parameters, e.g. // | Developers also use //NULL// to skip certain parameters, e.g. // | ||
+ | |||
+ | Where //NULL// has always been coerced into an empty string, the integer 0, the boolean false, etc. | ||
Currently the deprecation notices only affect those using PHP 8.1 with // | Currently the deprecation notices only affect those using PHP 8.1 with // | ||
- | Developers using // | + | Developers using // |
- | And while individual changes are easy, there are many of them, are difficult to find, and often pointless, e.g. | + | And while individual changes are easy, there are many of them (time consuming), difficult to find, and often pointless, e.g. |
* urlencode(strval($name)); | * urlencode(strval($name)); | ||
Line 66: | Line 74: | ||
To find these issues, developers need to either - use these deprecation notices, or use very strict Static Analysis (one that can determine when a variable can be //NULL//; e.g. Psalm at [[https:// | To find these issues, developers need to either - use these deprecation notices, or use very strict Static Analysis (one that can determine when a variable can be //NULL//; e.g. Psalm at [[https:// | ||
- | ===== Proposal ===== | + | It's worth noting that some parameters, like // |
- | Update **some** internal function parameters to accept (or be tolerant to) //NULL//. | + | ===== Proposal ===== |
- | This needs to be done before the eventual end of the deprecation period, and // | + | There are 3 possible approaches: |
- | While this is in Draft, the [[https:// | + | - NULL triggers a Fatal Error with strict_types=1, otherwise allow coercion (like how integers can be coerced to a string). |
+ | | ||
+ | - NULL triggers a Fatal Error for everyone (forget about backwards compatibility). | ||
- | Only the parameters in **bold** would be changed. | + | This needs to be done before the eventual end of the deprecation period, and // |
- | [[https:// | + | If we choose to " |
There is also a [[https:// | There is also a [[https:// | ||
Line 119: | Line 129: | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
- | Some function parameters could be updated to complain when an Empty String or //NULL// is provided; e.g. //$method// in // | + | Some function parameters could be updated to complain when an //NULL// **or** //Empty String// is provided; e.g. //$method// in // |
===== Voting ===== | ===== Voting ===== |
rfc/allow_null.1644334281.txt.gz · Last modified: 2022/02/08 15:31 by craigfrancis