[TYPO3-dev] RFC: CGL change regarding return statements
Dmitry Dulepov
dmitry.dulepov at gmail.com
Fri Mar 11 09:12:58 CET 2011
Hi!
Ernesto Baschny [cron IT] wrote:
> I see no conflict with your proposal and what we already say in the CGL.
> There is no limitation of "only one return" in the validation part as we
> have it written down already: there can be several, which makes exactly
> what you are trying to do more readable.
The question is what the word "validation" means. The following is validation:
function sendMail($emailAddress) {
if (!t3lib_div::validEmail($emailAddress)) {
return false;
}
...
}
The following is NOT validation but business logic:
function foo($shouldRun) {
if ($shouldRun) {
// run here
}
}
In the first case early return is fine, in the second it should not happen
according to CGL. Possibly we should add this to CGL.
--
Dmitry Dulepov
TYPO3 core&security team member
E-mail: dmitry.dulepov at typo3.org
Web: http://dmitry-dulepov.com/
More information about the TYPO3-dev
mailing list