On 20 March 2024 12:51:15 GMT, Robert Landers <landers.rob...@gmail.com> wrote:
>Oh and there isn't any difference between: > >$x as ?Type > >or > >$x as Type|null I'm not sure if I've misunderstood your example, or you've misunderstood mine. I'm saying that this should be an error, because the value is neither an instance of Foo nor null: $a = 42; $b = $a as Foo|null; Your earlier example implies that would make $b equal null, which feels wrong to me, because it means it wouldn't match this: $a = 42; $b = $a as Foo|Bar; If we want a short-hand for "set to null on error" that should be separate from the syntax for a nullable type. Regards, Rowan Tommins [IMSoP]