acquia / coding-standards-php

PHP_CodeSniffer rules (sniffs) for Acquia coding standards
GNU General Public License v2.0
19 stars 13 forks source link

Apply indentation to array contents #71

Closed danepowell closed 3 months ago

danepowell commented 3 months ago

Given the following code:

<?php
$foo = [
    'bar',
];

Running phpcbf removes all indentation:

<?php
$foo = [
'bar',
];

This really mangles multidimensional arrays.

PSR-12 doesn't explicitly mention how arrays should be indented but there is one example that indicates contents should be indented, and I think we can all agree it's common sense.

Upstream issue: https://github.com/squizlabs/PHP_CodeSniffer/issues/1235

Example of this rule applied to ACLI: https://github.com/acquia/cli/commit/4bfe4f46e40cfb970e38dddbf12f638fbdb0795e