array.items-linebreakfixable
Break array items into multiple lines or group them into a single line based on the position of the first item
Examples
- Examples of correct code for this rule using default options
Array items are on separate lines
php
<?php
$months = array(
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
"november",
"december",
);
$seasons = array(
"summer",
"winter",
"spring",
"autumn",
);
$array = array(
"foo" => "bar",
"bar" => "foo",
100 => -100,
-100 => 100,
);
$bigone = [
'name' => 'bigone',
'children' => [
'1a' => 'child',
'11b' => 'child',
'111c' => 'child',
'children' => [
'child' => 'aaa',
],
],
'short_name' => 'big'
];
Arrays items are on the same line
php
<?php
$array = array("foo", "bar", "hello", "world");
$seasons = array("summer","winter","spring","autumn");
$months = array("january","february","march","april","may","june","july","august","september","october","november","december");
$args = array('"' . $this->id . '"', (int) $has_sessions,);
- Examples of incorrect code for this rule using default options
Array items do not have consistent line breaks
php
<?php
$months = array( "january",
"february",
"march", "april",
"may",
"june", "july", "august", "september",
"october",
"november", "december",
);
$seasons = array( "summer", "winter",
"spring", "autumn",
);
$array = array( "foo" => "bar",
"bar" => "foo",
100 => -100, -100 => 100,
);
$bigone = ['name' => 'bigone',
'children' => [
'1a' => 'child', '11b' => 'child',
'111c' => 'child',
'children' => [ 'child' => 'aaa',
],
],'short_name' => 'big'
];