Skip to content

Commit

Permalink
Merge pull request #4808 from paulbalandan/array-related-rules
Browse files Browse the repository at this point in the history
Enable rules fixing array notations
  • Loading branch information
paulbalandan authored Jun 10, 2021
2 parents 5c5cfae + 27366b2 commit 995c51f
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 49 deletions.
2 changes: 1 addition & 1 deletion system/Language/en/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
'parentClass' => 'Parent class',
'returnType' => 'Return type',
'tableName' => 'Table name',
'usingCINamespace' => 'Warning: Using the "CodeIgniter" namespace will generate the file in the system directory.'
'usingCINamespace' => 'Warning: Using the "CodeIgniter" namespace will generate the file in the system directory.',
],
'helpArguments' => 'Arguments:',
'helpDescription' => 'Description:',
Expand Down
2 changes: 1 addition & 1 deletion tests/_support/Models/ValidErrorsModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ValidErrorsModel extends Model
'min_length[10]',
'errors' => [
'min_length' => 'Minimum Length Error',
]
],
],
'token' => 'in_list[{id}]',
];
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Commands/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function commandArgsProvider(): array
'reveal as -df "using mixed \'quotes\'\" here\""',
[
'as',
'df' => 'using mixed \'quotes\'" here"'
'df' => 'using mixed \'quotes\'" here"',
],
],
];
Expand Down
2 changes: 1 addition & 1 deletion tests/system/Config/fixtures/RegistrarConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class RegistrarConfig extends \CodeIgniter\Config\BaseConfig
{
public $foo = 'bar';
public $bar = [
'baz'
'baz',
];
}
8 changes: 4 additions & 4 deletions tests/system/Database/Builder/InsertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public function testInsertBatchWithFieldsEndingInNumbers()
$builder = $this->db->table('ip_table');

$data = [
[ 'ip' => '1.1.1.0', 'ip2' => '1.1.1.2' ],
[ 'ip' => '2.2.2.0', 'ip2' => '2.2.2.2' ],
[ 'ip' => '3.3.3.0', 'ip2' => '3.3.3.2' ],
[ 'ip' => '4.4.4.0', 'ip2' => '4.4.4.2' ],
['ip' => '1.1.1.0', 'ip2' => '1.1.1.2'],
['ip' => '2.2.2.0', 'ip2' => '2.2.2.2'],
['ip' => '3.3.3.0', 'ip2' => '3.3.3.2'],
['ip' => '4.4.4.0', 'ip2' => '4.4.4.2'],
];

$this->db->shouldReturn('execute', 1)->shouldReturn('affectedRows', 1);
Expand Down
42 changes: 21 additions & 21 deletions tests/system/Filters/FiltersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ public function testProcessMethodProcessGlobals()
'globals' => [
'before' => [
'foo' => ['bar'], // not excluded
'bar'
'bar',
],
'after' => [
'baz'
'baz',
],
],
];
Expand Down Expand Up @@ -189,10 +189,10 @@ public function testProcessMethodProcessGlobalsWithExcept(array $except)
'globals' => [
'before' => [
'foo' => ['except' => $except],
'bar'
'bar',
],
'after' => [
'baz'
'baz',
],
],
];
Expand All @@ -201,7 +201,7 @@ public function testProcessMethodProcessGlobalsWithExcept(array $except)

$expected = [
'before' => [
'bar'
'bar',
],
'after' => ['baz'],
];
Expand Down Expand Up @@ -283,10 +283,10 @@ public function testProcessMethodProcessesCombined()
'globals' => [
'before' => [
'foog' => ['except' => ['admin/*']],
'barg'
'barg',
],
'after' => [
'bazg'
'bazg',
],
],
'methods' => [
Expand Down Expand Up @@ -515,10 +515,10 @@ public function testBeforeExceptString()
'globals' => [
'before' => [
'foo' => ['except' => 'admin/*'],
'bar'
'bar',
],
'after' => [
'baz'
'baz',
],
],
];
Expand All @@ -527,7 +527,7 @@ public function testBeforeExceptString()

$expected = [
'before' => [
'bar'
'bar',
],
'after' => ['baz'],
];
Expand All @@ -548,10 +548,10 @@ public function testBeforeExceptInapplicable()
'globals' => [
'before' => [
'foo' => ['except' => 'george/*'],
'bar'
'bar',
],
'after' => [
'baz'
'baz',
],
],
];
Expand Down Expand Up @@ -581,11 +581,11 @@ public function testAfterExceptString()
],
'globals' => [
'before' => [
'bar'
'bar',
],
'after' => [
'foo' => ['except' => 'admin/*'],
'baz'
'baz',
],
],
];
Expand All @@ -594,7 +594,7 @@ public function testAfterExceptString()

$expected = [
'before' => [
'bar'
'bar',
],
'after' => ['baz'],
];
Expand All @@ -614,11 +614,11 @@ public function testAfterExceptInapplicable()
],
'globals' => [
'before' => [
'bar'
'bar',
],
'after' => [
'foo' => ['except' => 'george/*'],
'baz'
'baz',
],
],
];
Expand All @@ -627,7 +627,7 @@ public function testAfterExceptInapplicable()

$expected = [
'before' => [
'bar'
'bar',
],
'after' => [
'foo',
Expand Down Expand Up @@ -814,11 +814,11 @@ public function testMatchesURICaseInsensitively()
'globals' => [
'before' => [
'foo' => ['except' => 'Admin/*'],
'bar'
'bar',
],
'after' => [
'foo' => ['except' => 'Admin/*'],
'baz'
'baz',
],
],
'filters' => [
Expand Down Expand Up @@ -910,7 +910,7 @@ public function testGlobalFilterMatching()

$expected = [
'before' => [
'one'
'one',
],
'after' => [
'foo',
Expand Down
2 changes: 1 addition & 1 deletion tests/system/HTTP/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public function testSetCache()
'etag' => '12345678',
'last-modified' => $date,
'max-age' => 300,
'must-revalidate'
'must-revalidate',
];

$response->setCache($options);
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Helpers/FilesystemHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function testDirectoryMapDefaults()
'faz',
],
'AnEmptyFolder' . DIRECTORY_SEPARATOR => [],
'simpleFile'
'simpleFile',
];

$root = vfsStream::setup('root', null, $this->structure);
Expand All @@ -72,7 +72,7 @@ public function testDirectoryMapShowsHiddenFiles()
],
'AnEmptyFolder' . DIRECTORY_SEPARATOR => [],
'simpleFile',
'.hidden'
'.hidden',
];

$root = vfsStream::setup('root', null, $this->structure);
Expand Down
4 changes: 2 additions & 2 deletions tests/system/Language/LanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function testGetLineArrayFormatsMessages()

$this->lang->setData('books', [
'bookList' => [
'{0, number, integer} related books.'
'{0, number, integer} related books.',
],
]);

Expand Down Expand Up @@ -146,7 +146,7 @@ public function testLangDoesntFormat()

$this->lang->setData('books', [
'bookList' => [
'{0, number, integer} related books.'
'{0, number, integer} related books.',
],
]);

Expand Down
6 changes: 2 additions & 4 deletions tests/system/View/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,7 @@ public function toArray(bool $onlyChanged = false, bool $cast = true, bool $recu

$data = [
'title' => 'Super Heroes',
'powers' => [
$power
],
'powers' => [$power],
];

$template = "{title}\n{powers} {foo} {bar} {bobbles}{name} {/bobbles}{/powers}";
Expand Down Expand Up @@ -324,7 +322,7 @@ public function __construct()
$data = [
'title' => 'Super Heroes',
'powers' => [
$power
$power,
],
];

Expand Down
32 changes: 21 additions & 11 deletions utils/PhpCsFixer/CodeIgniter4.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ public function __construct()
'position_after_control_structures' => 'same',
'position_after_functions_and_oop_constructs' => 'next',
],
'cast_spaces' => ['space' => 'single'],
'function_to_constant' => true,
'indentation_type' => true,
'line_ending' => true,
'no_alias_functions' => ['sets' => ['@all']],
'phpdoc_align' => true,
'phpdoc_scalar' => [
'cast_spaces' => ['space' => 'single'],
'function_to_constant' => true,
'indentation_type' => true,
'line_ending' => true,
'list_syntax' => ['syntax' => 'short'],
'no_alias_functions' => ['sets' => ['@all']],
'no_trailing_comma_in_singleline_array' => true,
'no_whitespace_before_comma_in_array' => ['after_heredoc' => true],
'normalize_index_brace' => true,
'phpdoc_align' => true,
'phpdoc_scalar' => [
'types' => [
'boolean',
'callback',
Expand All @@ -77,10 +81,16 @@ public function __construct()
'str',
],
],
'phpdoc_separation' => true,
'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'yoda_style' => [
'phpdoc_separation' => true,
'static_lambda' => true,
'ternary_to_null_coalescing' => true,
'trailing_comma_in_multiline' => [
'after_heredoc' => true,
'elements' => ['arrays'],
],
'trim_array_spaces' => true,
'whitespace_after_comma_in_array' => true,
'yoda_style' => [
'equal' => false,
'identical' => null,
'less_and_greater' => false,
Expand Down

0 comments on commit 995c51f

Please sign in to comment.