rfc:allow_null

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:allow_null [2022/01/21 00:02] craigfrancisrfc:allow_null [2022/02/08 14:43] – Add example changes craigfrancis
Line 62: Line 62:
 This also applies to those developers not using //strict_types=1//, which is excessive. This also applies to those developers not using //strict_types=1//, which is excessive.
  
-And while the individual changes are easy there are many of them, they are difficult to find, and often pointless (e.g. //urlencode(strval($name))//).+While individual changes are easythere are many of them, difficult to find, and often pointlesse.g. 
 + 
 +  * urlencode(strval($name))
 +  * urlencode((string$name); 
 +  * urlencode($name ?? '');
  
 Without the changes below, developers will 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://psalm.dev/docs/running_psalm/error_levels/|level 3]], with no baseline). Without the changes below, developers will 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://psalm.dev/docs/running_psalm/error_levels/|level 3]], with no baseline).
Line 133: Line 137:
 ===== Implementation ===== ===== Implementation =====
  
-TODO+https://github.com/craigfrancis/php-src/compare/master...allow-null 
 + 
 +This patch currently defines //Z_PARAM_STR_ALLOW_NULL//
 + 
 +It works a bit like //Z_PARAM_STR_OR_NULL//, but it will return an empty string instead of //NULL//. 
 + 
 +It's a fairly easy drop in replacement for //Z_PARAM_STR//, which is used by functions like [[https://github.com/php/php-src/blob/7b90ebeb3f954123915f6d62fb7b2cd3fdf3c6ec/ext/standard/html.c#L1324|htmlspecialchars()]].
  
 ===== Rejected Features ===== ===== Rejected Features =====
rfc/allow_null.txt · Last modified: 2022/04/05 17:49 by craigfrancis