Re: Proposal: AS assertions

From: Date: Fri, 22 Mar 2024 17:38:24 +0000
Subject: Re: Proposal: AS assertions
References: 1 2 3 4 5 6 7 8 9 10 11 12  Groups: php.internals 
Request: Send a blank email to internals+get-122730@lists.php.net to get a copy of this message
> Le 22 mars 2024 à 16:18, Rowan Tommins [IMSoP] <imsop.php@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

« previous php.internals (#122730) next »