-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
binary_operator_spaces align option does not handle correctly array of array #4395
Comments
Another wrong behaviour This following code $enrichedRecommendableContractType = array_merge(
$recommendableContractType,
['kidAccepted' => false],
['termsAndConditionsAccepted' => false]
); Is fixed to $enrichedRecommendableContractType = array_merge(
$recommendableContractType,
['kidAccepted' => false],
['termsAndConditionsAccepted' => false]
); But this following code is inchanged $enrichedRecommendableContractType = array_merge(
['kidAccepted' => false],
['termsAndConditionsAccepted' => false]
); I expect both code to be untouched |
After more investigation, the rule is made to align the I don't think this should be the behavior for |
Hi, I have the same issue. Maybe, one way to fix it is to consider each array as a scope, like it is done here: #6559 ? |
I think it's already consider as the same scope.
is changed to
But the method which aligns operator are only working on the consecutive lines with the same scope. Because
is expected to be changed to
So the question would be, should be consider |
Should there be a specific rule for array alignment then? |
This is easy to implements VincentLanglet@4bbffd8 But it requires the fixer to works perfectly (or it will considered I don't know how much people are expecting the same behavior, ie
be fixed to
If we introduce a new configuration, it can be weird having an option which is only working for
@julienfalque or @SpacePossum might be good advice on this. |
The question will also arise for enum alignments (It is a bit out off topic here). For example, I'd like my enums to be aligned this way: <?php
enum OrderStatus: string
{
case ESTIMATION = 'estimation';
case DRAFT = 'draft';
case ORDERED = 'ordered';
case DELIVERED = 'delivered';
case PAYED = 'payed';
case CANCELED = 'canceled';
} But this is not possible with the <?php
$someVar = 'xyz';
$a = 123; So at some point, we will need a specific rule for enum alignments. A specific rule for array alignments make sense... EDIT: Question will also arise for |
This is too specific/complicated. There is no context used in the operatorFixer right now.
The only thing that can be done IMHO, is #4396
Array and match will be considered as the same for the same reason. We're just looking for |
The PHP version you are using (
$ php -v
):=> 7.1
PHP CS Fixer version you are using (
$ php-cs-fixer -V
):=> 2.14.2
The command you use to run PHP CS Fixer:
=> php-cs-fixer fix ...
The configuration file you are using, if any:
If applicable, please provide minimum samples of PHP code (as plain text, not screenshots):
Basically, I expect the definition of
align_single_space
andalign_single_space_minimal
to align ALL=>
of an array.The text was updated successfully, but these errors were encountered: