Skip to content

Match Expressions operator alignment #92

Open
@jacobcassidy

Description

@jacobcassidy

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'
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions