[TYPO3-dev] RFC: CGL change regarding return statements

François Suter fsu-lists at cobweb.ch
Fri Mar 11 09:24:32 CET 2011


Hi Andreas,

> as this has been discussed for quite some times now, I want to propose a
> change of our Coding Guidelines regarding the use of return statements.
> Currently, we usually allow only one return statement per method:

As I wrote in Gerrit in reviewing your patch, I think this is not just a 
question of single/multiple return statements. IMO it is a case of using 
exceptions instead of at least some of the early return statements.

One thing we should absolutely avoid IMO is to have mixed return types. 
This still happens in a lot of places in the Core: some method is 
expected to return a string or an array, but returns FALSE when it 
fails. This is bad style. If we are bent on cleaning up the Core, we 
should rather throw exceptions when a problem arises and return 
type-fitting values otherwise.

Throwing exceptions can probably some or all of the early returns.

Cheers

-- 

Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch




More information about the TYPO3-dev mailing list