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

Andreas Wolf typo3ml at andreaswolf.info
Fri Mar 11 11:16:28 CET 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi,

Am 11.03.2011 09:58, schrieb Dmitry Dulepov:
> Hi!
> 
> François Suter wrote:
>> 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.
> 
> Good idea! +1.

this was also my initial idea for refactoring t3lib_extFileFunc. I just
didn't want to change existing behaviour that drastically, so I went for
the multiple return statements solution. If we can all agree on using
exceptions, I'm fine with that - I agree that this is the cleaner and
thus better way of handling that stuff.

One question remains for me though: Is it ok to use exceptions where we
"silently" failed and just wrote a log entry before? It was up to the
programmer to check if any t3lib_extFileFunc method returned TRUE or
not, and then display an error (which is also bad, because there was no
way to find out which error occured).

Regards

Andreas
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEAREIAAYFAk159nwACgkQHWtXp155bP+QUQCghGvRebBGSPhMmRIcZ5ZBLDa8
TQwAn3BKfs+hA6URQfXd97UbQrEtBbAK
=Yd4s
-----END PGP SIGNATURE-----




More information about the TYPO3-dev mailing list