Wrapping long if statements
| From: | Jesper Veggerby Hansen | Date: | Mon, 15 Nov 2004 09:59:44 +0000 |
| Subject: | Wrapping long if statements | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-34391@lists.php.net to get a copy of this message | ||
Hi Guys,
Been looking a bit on CS and was wondering how you would wrap a very long if-statement (line-length) while still maintaining readability. Fx.
if (($a == 0) and ($b == 0) and ($c == 0) and ($d == 0) and ($e == 0)) {
// do something} I think if you wrap it to something like this it makes it a lot less readable since the indention of the conditions are the same as the statements to within the if-statement, i.e.: if (($a == 0) and ($b == 0) and ($c == 0) and
($d == 0) and ($e == 0)) {
// do something
}
Now while I'm at it, how would you wrap a trinary-operator statement, i.e.
$i = ($a ? $b : $c);
(Assuming it's long), would you go for:
$i = ($a ?
$b :
$c
);
or
$i = (
$a ?
$b :
$c
);
or
$i = (
$a
? $b
: $c
);
or ...
Any ideas/suggestions/RTFM's(with ref :))?
regards
Jesper