Re: Request for RFC Karma – khaledalamxy z
| From: | Ilija Tovilo | Date: | Mon, 30 Jun 2025 13:41:35 +0000 |
| Subject: | Re: Request for RFC Karma – khaledalamxy z | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127798@lists.php.net to get a copy of this message | ||
Hi Khaled
On Mon, Jun 30, 2025 at 1:03 AM Khaled Alam <khaledalam.net@gmail.com> wrote:
>
> I’d like to request RFC karma to create a new proposal titled "Fail-Fast Assertion
> Operator (=>!)".
>
> $name =>! die("Missing name");
> This is equivalent to:
> if (!$name) {
> die("Missing name");
> }
As mentioned by the other responses, given that throw is an expression
you can already achieve this through various operators:
// Throw is $name is null
$name ?? throw new Exception();
// Throw if $name is empty
$name ?: throw new Exception();
// Throw if $name is falsy
$name || throw new Exception();
$name or throw new Exception();
// Throw if $name is truthy
$name && throw new Exception();
$name and throw new Exception();
It's not clear in what way your proposal is different. Hence, I'm
pausing the granting of RFC karma until these details are clarified.
Cheers