per-coding-style
per-coding-style copied to clipboard
Match Expressions operator alignment
Currently, there are no coding style rules for match expression operators. I suggest having the double-arrow operators in alignment, with the option of breaking out of alignment when using more than one conditional expression.
For example, this is not aligned:
$asset_dir = match ($asset_type) {
'style' => 'build/base/css',
'script' => 'build/base/js',
'editor_ui_style' => 'build/blocks/css',
'editor_ui_script' => 'build/blocks/js',
default => 'build/base'
};
The desired alignment:
$asset_dir = match ($asset_type) {
'style' => 'build/base/css',
'script' => 'build/base/js',
'editor_ui_style' => 'build/blocks/css',
'editor_ui_script' => 'build/blocks/js',
default => 'build/base'
};
An example of breaking out of alignment with multiple conditional expressions for a match:
$asset_dir = match ($asset_type) {
'style' => 'build/base/css',
'script' => 'build/base/js',
'editor_ui_style' => 'build/blocks/css',
'editor_ui_script' => 'build/blocks/js',
'expession_1', 'expression_2', 'expression_3' => 'some value',
default => 'build/base'
};