[TYPO3-dev] RFC: CGL change regarding return statements
Oliver Klee
typo3-german-01 at oliverklee.de
Fri Mar 11 15:25:58 CET 2011
Hi,
Am 11.03.2011 13:02, schrieb Andreas Wolf:
> I didn't read the guard clause thingy in the CGL. If we now conclude
> that it is included there, I'm fine with that. It should just be added
> to the official docs.
AFAICT, at least the term "guard clause" is not mentioned in the current
CGL.
> I would propose to take Oli's explanation with an example to the CGL
> doc. Maybe we can also add some background information. I would
> volunteer to write that part and submit it to the Doc team.
Great!
Here's a made-up example:
/**
* Finds all Dorcles that match the given UIDs.
*
* @param string $uidList
* comma-separated list of UIDs, may be empty
*
* @return array<Dorcles>
* all Dorcles with the given UIDs, will be empty if no
* models with the given UIDs exist or if $uidList is empty
*/
public function findByUidList($uidList) {
if (!$this->isCommaSeparatedUidList($uidList)) {
throw new InvalidArgumentException('$uidList must be a
comma-separated list of UIDs, but actually is "' . $uidList . '"',
1299853352);
}
if ($uidList === '') {
return array();
}
// here a few lines of code that retrieve the corresponding objects
return $dorcles;
}
Oli
--
Certified TYPO3 Integrator | TYPO3 Security Team Member
More information about the TYPO3-dev
mailing list