Topic on Manual talk:Coding conventions

Formating of multiline if statements

2
Nikerabbit (talkcontribs)

What is the reason we recommend different format for ifs compared to functions. Here is what I mean:

function foo(
	$longVarName1,
	$longVarName2,
	$longVarName3,
	$longVarName3
) {
	...
}

$res = $obj->methodWithManyParameters(
	$longVarName1,
	$longVarName2,
	$longVarName3,
	$longVarName4
);

if ( $someLongThing !== $someOtherLongTail ||
	$future > $past ||
	$future === $now
) {
	...
}

# I would use:
if (
	$someLongThing !== $someOtherLongTail ||
	$future > $past ||
	$future === $now
) {
	...
}

It looks inconsistent to me.

Anomie (talkcontribs)

I can't say for sure. But personally, since the if ( prefix is universally short, the first condition doesn't get visually lost like it can if you were to do

$res = $obj->methodWithManyParameters( $longVarName1,
    $longVarName2,
    $longVarName3,
    $longVarName4
);
Reply to "Formating of multiline if statements"