coding-standard
coding-standard copied to clipboard
Enforce ternary symbol placement
I was wondering if there is a sniff that can enforce placement of the ? and : symbols.
Given the following snippet:
$class = array_key_exists($foo, 'bar') ?
$foo['bar']['class'] :
Default::class;
I would like to enforce them being placed in front of each line (only in multi-line statements):
$class = array_key_exists($foo, 'bar')
? $foo['bar']['class']
: Default::class;
Such rule can be generalized for any operator.
$message .= $spaces
. $line
. ($key === $lastLine ? '' : PHP_EOL);
$number = $n1
+ $n2
+ $n3;