php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50515 return() in short-circuit / lazy evaluation
Submitted: 2009-12-18 10:26 UTC Modified: 2009-12-18 11:20 UTC
From: ntpt at seznam dot cz Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.12 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ntpt at seznam dot cz
New email:
PHP Version: OS:

 

 [2009-12-18 10:26 UTC] ntpt at seznam dot cz
Description:
------------
please allow return() in lazy evaluation /short-circuit syntax like

$result=do_something($blah) or die('nothing done'); // this works

but

$result=do_something($blah) or return(false) ; // does NOT work

I thing it is prety legitimate not only to call die() if do_something() return false, but in this case return() from function or include() as well. I thing it is more cleaner and readable then bunch of

$result=do_something($blah)
if ($result==false){
return false;}
// use you result here

Maybe even codeblock after "or" is worth of considerations

$result=do_something($blah) or { // codeblock, do what you want here 
}
 
 


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-18 11:20 UTC] jani@php.net
Never happens.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Jan 25 05:03:35 2022 UTC