From 4e6997b1a5a4d44ada31e5b1f34c7c970fdceaec Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 00:42:48 +0800 Subject: [PATCH 1/7] Ensure whitespace after commas in array --- utils/PhpCsFixer/CodeIgniter4.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 28d1eaf066b2..4859c9636f4a 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -77,10 +77,11 @@ 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, + 'whitespace_after_comma_in_array' => true, + 'yoda_style' => [ 'equal' => false, 'identical' => null, 'less_and_greater' => false, From 0fc1b935846e940392f7f3b88c443d9c868936b1 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:04:35 +0800 Subject: [PATCH 2/7] Use short list syntax --- utils/PhpCsFixer/CodeIgniter4.php | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 4859c9636f4a..356de3d67978 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -65,6 +65,7 @@ public function __construct() 'function_to_constant' => true, 'indentation_type' => true, 'line_ending' => true, + 'list_syntax' => ['syntax' => 'short'], 'no_alias_functions' => ['sets' => ['@all']], 'phpdoc_align' => true, 'phpdoc_scalar' => [ From 391ae154311b1780b74203495f694d4b742b26b5 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:06:18 +0800 Subject: [PATCH 3/7] Ensure no trailing comma in single-line array --- utils/PhpCsFixer/CodeIgniter4.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 356de3d67978..f216e9728443 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -61,14 +61,15 @@ 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, - 'list_syntax' => ['syntax' => 'short'], - '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, + 'phpdoc_align' => true, + 'phpdoc_scalar' => [ 'types' => [ 'boolean', 'callback', From f89da5169f60768fc5e23a73c05521442565c723 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:09:06 +0800 Subject: [PATCH 4/7] Remove whitespaces before commas in arrays --- utils/PhpCsFixer/CodeIgniter4.php | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index f216e9728443..46ae32a7ede8 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -68,6 +68,7 @@ public function __construct() '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], 'phpdoc_align' => true, 'phpdoc_scalar' => [ 'types' => [ From cfa91a6ee85b4b7e3a6ad83114bce8585cb2c01a Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:10:46 +0800 Subject: [PATCH 5/7] Ensure arrays use square braces --- utils/PhpCsFixer/CodeIgniter4.php | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 46ae32a7ede8..832aaab88eea 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -69,6 +69,7 @@ public function __construct() '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' => [ From 777eec1121b2825c2a0dbc7e223d1ce3a502d880 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:38:34 +0800 Subject: [PATCH 6/7] Ensure trailing commas in multiline array --- system/Language/en/CLI.php | 2 +- tests/_support/Models/ValidErrorsModel.php | 2 +- tests/system/Commands/CommandTest.php | 2 +- .../Config/fixtures/RegistrarConfig.php | 2 +- tests/system/Filters/FiltersTest.php | 42 +++++++++---------- tests/system/HTTP/ResponseTest.php | 2 +- tests/system/Helpers/FilesystemHelperTest.php | 4 +- tests/system/Language/LanguageTest.php | 4 +- tests/system/View/ParserTest.php | 6 +-- utils/PhpCsFixer/CodeIgniter4.php | 10 +++-- 10 files changed, 39 insertions(+), 37 deletions(-) diff --git a/system/Language/en/CLI.php b/system/Language/en/CLI.php index 8fe504b40283..b7c8bdaba422 100644 --- a/system/Language/en/CLI.php +++ b/system/Language/en/CLI.php @@ -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:', diff --git a/tests/_support/Models/ValidErrorsModel.php b/tests/_support/Models/ValidErrorsModel.php index 97ea3a359a4f..3be93bbf90df 100644 --- a/tests/_support/Models/ValidErrorsModel.php +++ b/tests/_support/Models/ValidErrorsModel.php @@ -25,7 +25,7 @@ class ValidErrorsModel extends Model 'min_length[10]', 'errors' => [ 'min_length' => 'Minimum Length Error', - ] + ], ], 'token' => 'in_list[{id}]', ]; diff --git a/tests/system/Commands/CommandTest.php b/tests/system/Commands/CommandTest.php index d02a4a8157ab..0c546e560919 100644 --- a/tests/system/Commands/CommandTest.php +++ b/tests/system/Commands/CommandTest.php @@ -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"', ], ], ]; diff --git a/tests/system/Config/fixtures/RegistrarConfig.php b/tests/system/Config/fixtures/RegistrarConfig.php index 406f84f280cb..7618ff557d9d 100644 --- a/tests/system/Config/fixtures/RegistrarConfig.php +++ b/tests/system/Config/fixtures/RegistrarConfig.php @@ -4,6 +4,6 @@ class RegistrarConfig extends \CodeIgniter\Config\BaseConfig { public $foo = 'bar'; public $bar = [ - 'baz' + 'baz', ]; } diff --git a/tests/system/Filters/FiltersTest.php b/tests/system/Filters/FiltersTest.php index b590cedad5c2..9b5c748e8c0c 100644 --- a/tests/system/Filters/FiltersTest.php +++ b/tests/system/Filters/FiltersTest.php @@ -140,10 +140,10 @@ public function testProcessMethodProcessGlobals() 'globals' => [ 'before' => [ 'foo' => ['bar'], // not excluded - 'bar' + 'bar', ], 'after' => [ - 'baz' + 'baz', ], ], ]; @@ -189,10 +189,10 @@ public function testProcessMethodProcessGlobalsWithExcept(array $except) 'globals' => [ 'before' => [ 'foo' => ['except' => $except], - 'bar' + 'bar', ], 'after' => [ - 'baz' + 'baz', ], ], ]; @@ -201,7 +201,7 @@ public function testProcessMethodProcessGlobalsWithExcept(array $except) $expected = [ 'before' => [ - 'bar' + 'bar', ], 'after' => ['baz'], ]; @@ -283,10 +283,10 @@ public function testProcessMethodProcessesCombined() 'globals' => [ 'before' => [ 'foog' => ['except' => ['admin/*']], - 'barg' + 'barg', ], 'after' => [ - 'bazg' + 'bazg', ], ], 'methods' => [ @@ -515,10 +515,10 @@ public function testBeforeExceptString() 'globals' => [ 'before' => [ 'foo' => ['except' => 'admin/*'], - 'bar' + 'bar', ], 'after' => [ - 'baz' + 'baz', ], ], ]; @@ -527,7 +527,7 @@ public function testBeforeExceptString() $expected = [ 'before' => [ - 'bar' + 'bar', ], 'after' => ['baz'], ]; @@ -548,10 +548,10 @@ public function testBeforeExceptInapplicable() 'globals' => [ 'before' => [ 'foo' => ['except' => 'george/*'], - 'bar' + 'bar', ], 'after' => [ - 'baz' + 'baz', ], ], ]; @@ -581,11 +581,11 @@ public function testAfterExceptString() ], 'globals' => [ 'before' => [ - 'bar' + 'bar', ], 'after' => [ 'foo' => ['except' => 'admin/*'], - 'baz' + 'baz', ], ], ]; @@ -594,7 +594,7 @@ public function testAfterExceptString() $expected = [ 'before' => [ - 'bar' + 'bar', ], 'after' => ['baz'], ]; @@ -614,11 +614,11 @@ public function testAfterExceptInapplicable() ], 'globals' => [ 'before' => [ - 'bar' + 'bar', ], 'after' => [ 'foo' => ['except' => 'george/*'], - 'baz' + 'baz', ], ], ]; @@ -627,7 +627,7 @@ public function testAfterExceptInapplicable() $expected = [ 'before' => [ - 'bar' + 'bar', ], 'after' => [ 'foo', @@ -814,11 +814,11 @@ public function testMatchesURICaseInsensitively() 'globals' => [ 'before' => [ 'foo' => ['except' => 'Admin/*'], - 'bar' + 'bar', ], 'after' => [ 'foo' => ['except' => 'Admin/*'], - 'baz' + 'baz', ], ], 'filters' => [ @@ -910,7 +910,7 @@ public function testGlobalFilterMatching() $expected = [ 'before' => [ - 'one' + 'one', ], 'after' => [ 'foo', diff --git a/tests/system/HTTP/ResponseTest.php b/tests/system/HTTP/ResponseTest.php index 3537dd7c4740..58cc443fbe30 100644 --- a/tests/system/HTTP/ResponseTest.php +++ b/tests/system/HTTP/ResponseTest.php @@ -231,7 +231,7 @@ public function testSetCache() 'etag' => '12345678', 'last-modified' => $date, 'max-age' => 300, - 'must-revalidate' + 'must-revalidate', ]; $response->setCache($options); diff --git a/tests/system/Helpers/FilesystemHelperTest.php b/tests/system/Helpers/FilesystemHelperTest.php index 84c020b309c9..9b6a6eba6f55 100644 --- a/tests/system/Helpers/FilesystemHelperTest.php +++ b/tests/system/Helpers/FilesystemHelperTest.php @@ -47,7 +47,7 @@ public function testDirectoryMapDefaults() 'faz', ], 'AnEmptyFolder' . DIRECTORY_SEPARATOR => [], - 'simpleFile' + 'simpleFile', ]; $root = vfsStream::setup('root', null, $this->structure); @@ -72,7 +72,7 @@ public function testDirectoryMapShowsHiddenFiles() ], 'AnEmptyFolder' . DIRECTORY_SEPARATOR => [], 'simpleFile', - '.hidden' + '.hidden', ]; $root = vfsStream::setup('root', null, $this->structure); diff --git a/tests/system/Language/LanguageTest.php b/tests/system/Language/LanguageTest.php index 39f9f46019a2..344f08acbf45 100644 --- a/tests/system/Language/LanguageTest.php +++ b/tests/system/Language/LanguageTest.php @@ -117,7 +117,7 @@ public function testGetLineArrayFormatsMessages() $this->lang->setData('books', [ 'bookList' => [ - '{0, number, integer} related books.' + '{0, number, integer} related books.', ], ]); @@ -146,7 +146,7 @@ public function testLangDoesntFormat() $this->lang->setData('books', [ 'bookList' => [ - '{0, number, integer} related books.' + '{0, number, integer} related books.', ], ]); diff --git a/tests/system/View/ParserTest.php b/tests/system/View/ParserTest.php index b37e558af7da..cd371c077535 100644 --- a/tests/system/View/ParserTest.php +++ b/tests/system/View/ParserTest.php @@ -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}"; @@ -324,7 +322,7 @@ public function __construct() $data = [ 'title' => 'Super Heroes', 'powers' => [ - $power + $power, ], ]; diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index 832aaab88eea..ac4af24c185f 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -81,9 +81,13 @@ public function __construct() 'str', ], ], - 'phpdoc_separation' => true, - 'static_lambda' => true, - 'ternary_to_null_coalescing' => true, + 'phpdoc_separation' => true, + 'static_lambda' => true, + 'ternary_to_null_coalescing' => true, + 'trailing_comma_in_multiline' => [ + 'after_heredoc' => true, + 'elements' => ['arrays'], + ], 'whitespace_after_comma_in_array' => true, 'yoda_style' => [ 'equal' => false, From 27366b2f1bda7db719aa8186fa3ce0a9b3168d12 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 10 Jun 2021 01:41:20 +0800 Subject: [PATCH 7/7] Remove extra spaces inside arrays --- tests/system/Database/Builder/InsertTest.php | 8 ++++---- utils/PhpCsFixer/CodeIgniter4.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/system/Database/Builder/InsertTest.php b/tests/system/Database/Builder/InsertTest.php index f732fafda04e..1e5d6463b259 100644 --- a/tests/system/Database/Builder/InsertTest.php +++ b/tests/system/Database/Builder/InsertTest.php @@ -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); diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php index ac4af24c185f..0f9300820cda 100644 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ b/utils/PhpCsFixer/CodeIgniter4.php @@ -88,6 +88,7 @@ public function __construct() 'after_heredoc' => true, 'elements' => ['arrays'], ], + 'trim_array_spaces' => true, 'whitespace_after_comma_in_array' => true, 'yoda_style' => [ 'equal' => false,