rfc:null_coercion_consistency
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Next revisionBoth sides next revision | ||
rfc:null_coercion_consistency [2022/05/07 08:53] – Example tweaks craigfrancis | rfc:null_coercion_consistency [2022/05/09 10:53] – Update Backward Incompatible Changes (thanks Mel) craigfrancis | ||
---|---|---|---|
Line 315: | Line 315: | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | None | + | While the intention of this RFC is to avoid a BC break; for user defined functions to be updated to also coerce NULL (instead of throwing a Type Error), it's possible some code may rely on that behaviour, for example: |
+ | |||
+ | <code php> | ||
+ | function my_function(string $my_string) { | ||
+ | var_dump($my_string); | ||
+ | } | ||
+ | |||
+ | try { | ||
+ | my_function(' | ||
+ | my_function(1); | ||
+ | my_function(1.2); | ||
+ | my_function(true); | ||
+ | my_function(false); | ||
+ | my_function(NULL); | ||
+ | } catch (TypeError $e) { | ||
+ | // Do something important? | ||
+ | } | ||
+ | </ | ||
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== |
rfc/null_coercion_consistency.txt · Last modified: 2023/10/18 11:57 by craigfrancis