To me it seams too similar to:

return !$result['success']?? $result; 

Which returns at that point, regardless of the status of $result[’success’];

I think this

if (!$result['success'])
        return $result;

Is short enough and is clear when scanning the code that it will not return 
anything if $result['success’] == true. 

----------------------------------
Daniel Baldwin
541-401-7797



> On Nov 26, 2024, at 8:10 AM, Volodymyr Volynets 
> <volodymyr.volyn...@gmail.com> wrote:
> 
> Hi PHP Mailing list,
> 
> My username is vvolynets.
> 
> I have an idea which will save a lot of code. I am proposing to add":
> 
> return when [condition], [return value];
> 
> This construct will remove a lot of ifs statements after method calls. For 
> example:
> 
> $result = Class->method();
> if (!$result['success']) {
>     return $result;
> }
> 
> This becomes:
> return when !$result['success'], $result;
> 
> Any thoughts?
> 
> Regards
> Volodymyr Volynets

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to