Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[CS] Remove aligned "=>" #12284

@webmozart

Description

@webmozart

I would like to remove all aligned => symbols from our code base and add a corresponding rule to our coding conventions:

Before:

$resolver->setDefaults(array(
    'data_class'            => $dataClass,
    'empty_data'            => $emptyData,
    'trim'                  => true,
    'required'              => true,
    'read_only'             => false,
    // ... snip ...
    'action'                => '',
    'attr'                  => $defaultAttr,
    'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
));

After:

$resolver->setDefaults(array(
    'data_class' => $dataClass,
    'empty_data' => $emptyData,
    'trim' => true,
    'required' => true,
    'read_only' => false,
    // ... snip ...
    'action' => '',
    'attr' => $defaultAttr,
    'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.',
));

Although the first version looks nicer, it is:

  • more difficult to maintain, because whole arrays have to be adjusted when the length of the longest key changes;
  • more difficult to review PRs, since their diffs contain lines which are unrelated to the PR apart from whitespace changes;
  • and most importantly, very difficult to use git blame. If you want to find out when/why "read_only" was set to false. You will have to follow a chain of commits that only changed whitespace (and use git blame on those commits again) before you find the commit that actually changed the line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementGood first issueIdeal for your first contribution! (some Symfony experience may be required)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions