[dev] [cvs] commit: framework/Horde/Horde ErrorHandler.php
Chuck Hagenbuch
chuck at horde.org
Fri Mar 6 01:13:53 UTC 2009
Quoting Michael M Slusarz <slusarz at horde.org>:
[snip]
>> That just increases the nesting level, no?
>
> IMHO given an if clause at the bottom of a function especially when
> there is no return value and you are only doing work on one of the
> conditions, that return call is superfluous.
>
> i.e., given $foo as a boolean variable:
>
> function() {
> ...
> if ($foo) {
> return;
> }
> $foo2 = a;
> }
>
> (not so good) vs.
Why not so good? My reading is that you're bailing out as quickly as
possible for irrelevant conditions - not so much for speed as for
leaving the main method body clear (and not deeply indented) from
preliminary checks.
> function() {
> ...
> if (!$foo) {
> $foo2 = a;
> }
> }
>
> (better).
I get that you prefer it, and I don't really feel strongly about this,
but I am curious *why* you think it's better.
>> Also here:
>>
>> - $headers = headers_list();
>> - foreach ($headers as $header) {
>> + foreach (headers_list() as $header) {
>>
>> Is repeated function calls in foreach no longer an issue?
>
> There was never an issue with foreach and repeated function calls, as
> far as I know.
I guess this is for loops. My confusion.
> it is true that you wouldn't be able to do this in PHP 4
It works fine in PHP 4, fwiw.
-chuck
More information about the dev
mailing list