> Le 5 oct. 2022 à 19:53, Eugene Sidelnyk <zsidel...@gmail.com> a écrit :
> 
> I used to have an awkward feeling when it was necessary to convert the 
> nullable integer into a nullable string. It would be kind of ternary operator 
> anyway. Either `$b = (null !== $a) ? (string)$a : null;` or `$b = (string)$a 
> ?: null;`. 
> 
> A lot easier to read would it be if written this way: `$b = (?string)$a;`. 
> The intentions are clear when doing explicit type-cast.
> 
> Currently, I don't see any other situations when this feature may be useful
> 
> 
> Thank you 

There has been some discussion and interest around nullable casting (which, 
contrarily to union type casting, has only one possible and obvious semantics), 
see https://wiki.php.net/rfc/nullable-casting 
<https://wiki.php.net/rfc/nullable-casting> and the two discussion threads 
linked in the bottom of the page. However, the RFC seems to be inactive for now,

—Claude

Reply via email to