Konafets / TYPO3SniffPool

This repository contains custom sniffs which are compatible with the PHP_CodeSniffer. Understand this package as a sniff pool which contains all needed custom sniffs for the various TYPO3 projects.
21 stars 10 forks source link

New Sniff: Array-Declaration #30

Closed andygrunwald closed 8 years ago

andygrunwald commented 10 years ago

Create / Add a new sniff for array declaration like the TYPO3-CGL said: Arrays in TYPO3-CGL:

Array declarations use the "array" keyword in lowercase, with no blank between the keyword and the opening bracket. Thus:

$a = array();

array components are declared each on a separate line. Such lines are indented with one more tab than the start of the declaration. The closing bracket is on the same indentation level as the variable. Every line containing an array item ends with a comma. This may be omitted if there are no further elements, at the developer's choice. Example:

$thisIsAnArray = array(
    'foo' => 'bar',
    'baz' => array(
        0 => 1
    )
);

Nested arrays follow the same pattern. This formatting applies even to very small and simple array declarations, e.g.

$a = array(
    0 => 'b',
);

Maybe Squiz.Arrays.ArrayDeclaration fits our needs.

Original tickets: