As I mentioned before, it would work the same alike way as if we called function with such type-hint.
FMPOV, one of the most meaningful use-cases would be nullable casts (like casting `?string` into `?float` for example). Regards, Yevhen On Wed, Oct 5, 2022, 8:41 AM Dusk <d...@woofle.net> wrote: > On Oct 4, 2022, at 21:46, Eugene Sidelnyk <zsidel...@gmail.com> wrote: > > $foo = (int|float)$bar; > > As written, I wouldn't know what to expect this to do with a string value > -- would it cast it to int or float? > > Based on the behavior of your second example, the answer appears to be > "float", so this syntax seems to be equivalent to: > > $foo = \is_int($bar) ? $bar : (float) $bar; > > Or, even more concisely: > > $foo = 0+$bar; > > I'd be even less sure what to expect when casting to other union types. > What would the expected result of casting a string to (bool|array|object) > be, for example? I'm not sure there are many meaningful operations which > could be constructed here.