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. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php