Plugin-php: Align arrow in arrays ?

Created on 23 Feb 2018  路  20Comments  路  Source: prettier/plugin-php

I took the habit of aligning all the arrows in a array.
Phpstorm do that automatically, and I find that a lot clearer.

-        'description'  => 'description',
-        'excerpt'      => 'extrait',
-        'date'         => 'date',
-        'time'         => 'heure',
-        'available'    => 'disponible',
-        'size'         => 'taille',
-        'already_paid' => 'd茅j脿 pay茅',
-    ],
+        'description' => 'description',
+        'excerpt' => 'extrait',
+        'date' => 'date',
+        'time' => 'heure',
+        'available' => 'disponible',
+        'size' => 'taille',
+        'already_paid' => 'd茅j脿 pay茅'
+   ]

What do you think about that?

enhancement needs investigation

Most helpful comment

@mathieutu by default no align, we should keep open issue and get community opinion

  • :+1: Add option
  • :-1: Don't add option

All 20 comments

@mathieutu by default no align, we should keep open issue and get community opinion

  • :+1: Add option
  • :-1: Don't add option

in my team we agreed not to align, one advantage is that there is less noise in git diffs.

@nicoder thanks for response, feel free to write you opinion, just don't forget vote

Adding an option don't force you to use it! 馃槈

sure, I did not see you mentioning an option at the beginning, then @evilebottnawi chimed in :)

Please also see #120 :smile:

I'd suggest we follow the advice here https://github.com/prettier/plugin-php/issues/120#issuecomment-368058086 and not implement alignment.

Closing since there seems to be consensus :smile:

@czosel very early to close, WordPress is very big community, without this option they can't adapt prettier

php != js :smile:

I don't think that this should be a blocker for any given codebase. But we can leave the issue open if you like!

@czosel let's leave open :+1:

I think I'll still use prettier without that, but I will stay very sad.. 馃槩

馃槆

@mathieutu After stable release we will consider an option, you can help us by applying the prettier on your code base and create issue about problems :+1:

@evilebottnawi Yeah I'm actually doing it, and I've already opened several issues.

As someone who has always aligned my arrows and everything else as well, I'd vote no on this one, and probably even no on providing an option for it. I love my aligned arrows but the problem is that I've found that even how to align things causes disagreement among developers. As a relevant example, we have a large number of definitions of multi-dimensional arrays. I understand this is not the norm, but I'm sure we're not the only ones who run into this. How do you line up something like this (actual code snippet from our code base)?

        return [
            'status_id'     => [
                'class'         => 'status',
                'parent_class'  => status::class,
                'validators' => [ 'required' ],
            ],
            'created_by_id' => [
                'class'         => 'created_by_membership',
            ],
            'customer_id'   => [
                'class'         => 'belongs_to',
                'parent_class'  => customer::class,
                'multi_tenant'  => true,
            ],
            'job_id'        => [
                'class'         => 'belongs_to',
                'parent_class'  => job::class,
                'multi_tenant'  => true,
            ],
            'total'         => [
                'class'         => 'price',
                'editable'      => false,
            ],
            'total_man_minutes' => [
                'class'         => 'integer',
            ],
            'fully_quoted'  => [
                'class'         => 'yes_no',
                'editable'      => false,
            ],
            'vendor_approved' => [
                'class'         => 'yes_no',
                'editable'      => false,
            ],
            'created'       => [
                'class'         => 'created',
            ],
            'updated'       => [
                'class'         => 'updated',
            ],
            'tasks'         => [
                'class'         => 'has_many_writeable',
                'child_class'   => estimate_task::class,
            ],
        ]

For which I see two problems: the "business" question of "What does it mean to line up nested data structures?" and then the code to actually do that. I'm sure it isn't an impossible problem, but especially at this phase of the process I don't think it should be a high priority. It wouldn't surprise me if you ended up with a couple options (even prettier has one or two), and this might be a good one to choose, but it is definitely a less is more sort of situation, and I'm okay with not having any options at all at the beginning.

I'm closing this, as you all convinced me 馃構...

And some reading to take away about that: http://mnapoli.fr/approaching-coding-style-rationally/

or we can leave it open for later and other users, if you want @evilebottnawi..

@mathieutu let's left open

Closing due to inactivity.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

czosel picture czosel  路  4Comments

hackel picture hackel  路  3Comments

aboyton picture aboyton  路  4Comments

alexander-akait picture alexander-akait  路  5Comments

mgrip picture mgrip  路  3Comments