> Le 22 mars 2024 à 16:18, Rowan Tommins [IMSoP] <imsop....@rwec.co.uk> a écrit 
> :
> 
> $optionalExpiryDateTime = $expiry as ?DateTimeInterface else 
> some_other_function($expiry);
> assert($optionalExpiryDateTime is ?DateTimeInterface); // cannot fail, 
> already asserted by the "as"

I think that the `is` operator is all we need; the `as` operator adds syntax 
complexity for little gain. Compare:

$optionalExpiryDateTime = $expiry as ?DateTimeInterface else 
some_other_function($expiry);

vs

$optionalExpiryDateTime = $expiry is ?DateTimeInterface ? $expiry : 
some_other_function($expiry);

—Claude

Reply via email to