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 On Wed, Oct 5, 2022, 4:43 PM juan carlos morales <dev.juan.mora...@gmail.com> wrote: > There is a difference is declaring a function parameter of different > types ... because before hand, when the code calls the function, we > might not be sure about what kind if data the function will receive, > so the function could expect different types, and work the parameter > correctly internally..... nice > > > but ... when casting, on purpose, what use case can apply to it? > > Are you facing a situation where manual union type cast is needed? can > you share it with us? > > thanks >