From 4ab9d66b530ec798f2b06a551a2cab8797161f5d Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" <51850998+paulbalandan@users.noreply.github.com> Date: Thu, 2 Sep 2021 12:32:07 +0800 Subject: [PATCH] Switch to official coding standard (#5038) * Switch to official coding standard * Update .no-header.php-cs-fixer.dist.php Co-authored-by: Abdul Malik Ikhsan --- .github/workflows/test-phpunit.yml | 2 +- .no-header.php-cs-fixer.dist.php | 16 +- .php-cs-fixer.dist.php | 13 +- admin/framework/composer.json | 5 +- app/Config/Services.php | 19 +- composer.json | 5 +- system/Database/BaseConnection.php | 2 +- system/Email/Email.php | 4 +- system/Session/Session.php | 2 +- system/Test/Mock/MockIncomingRequest.php | 5 - system/Typography/Typography.php | 4 +- tests/system/CLI/CLITest.php | 17 +- .../system/Cache/Handlers/FileHandlerTest.php | 4 +- tests/system/Config/ServicesTest.php | 11 - tests/system/I18n/TimeTest.php | 13 - tests/system/Test/TestCaseTest.php | 10 - utils/PhpCsFixer/CodeIgniter4.php | 540 ------------------ .../Comment/SpaceAfterCommentStartFixer.php | 95 --- 18 files changed, 48 insertions(+), 719 deletions(-) delete mode 100644 utils/PhpCsFixer/CodeIgniter4.php delete mode 100644 utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php diff --git a/.github/workflows/test-phpunit.yml b/.github/workflows/test-phpunit.yml index 35dc86f8b4d1..c093190233cb 100644 --- a/.github/workflows/test-phpunit.yml +++ b/.github/workflows/test-phpunit.yml @@ -123,7 +123,7 @@ jobs: - name: Install dependencies run: | composer update --ansi --no-interaction - composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config + composer remove --ansi --dev --unused -W rector/rector phpstan/phpstan friendsofphp/php-cs-fixer nexusphp/cs-config codeigniter/coding-standard php -r 'file_put_contents("vendor/laminas/laminas-zendframework-bridge/src/autoload.php", "");' env: COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }} diff --git a/.no-header.php-cs-fixer.dist.php b/.no-header.php-cs-fixer.dist.php index 8f7eb0a71cf1..acfdbf48e1b7 100644 --- a/.no-header.php-cs-fixer.dist.php +++ b/.no-header.php-cs-fixer.dist.php @@ -11,10 +11,11 @@ * the LICENSE file that was distributed with this source code. */ +use CodeIgniter\CodingStandard\CodeIgniter4; use Nexus\CsConfig\Factory; +use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer; +use Nexus\CsConfig\FixerGenerator; use PhpCsFixer\Finder; -use Utils\PhpCsFixer\CodeIgniter4; -use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer; $finder = Finder::create() ->files() @@ -22,18 +23,17 @@ __DIR__ . '/admin', __DIR__ . '/app', __DIR__ . '/public', - ]); + ]) + ->notName('#Logger\.php$#'); $overrides = []; $options = [ 'cacheFile' => 'build/.no-header.php-cs-fixer.cache', 'finder' => $finder, - 'customFixers' => [ - new SpaceAfterCommentStartFixer(), - ], - 'customRules' => [ - 'CodeIgniter4/space_after_comment_start' => true, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ + SpaceAfterCommentStartFixer::name() => true, ], ]; diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 95478343a53a..f362a830f99e 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,10 +11,11 @@ * the LICENSE file that was distributed with this source code. */ +use CodeIgniter\CodingStandard\CodeIgniter4; use Nexus\CsConfig\Factory; +use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer; +use Nexus\CsConfig\FixerGenerator; use PhpCsFixer\Finder; -use Utils\PhpCsFixer\CodeIgniter4; -use Utils\PhpCsFixer\Fixer\Comment\SpaceAfterCommentStartFixer; $finder = Finder::create() ->files() @@ -37,11 +38,9 @@ $options = [ 'cacheFile' => 'build/.php-cs-fixer.cache', 'finder' => $finder, - 'customFixers' => [ - new SpaceAfterCommentStartFixer(), - ], - 'customRules' => [ - 'CodeIgniter4/space_after_comment_start' => true, + 'customFixers' => FixerGenerator::create('vendor/nexusphp/cs-config/src/Fixer', 'Nexus\\CsConfig\\Fixer'), + 'customRules' => [ + SpaceAfterCommentStartFixer::name() => true, ], ]; diff --git a/admin/framework/composer.json b/admin/framework/composer.json index d65d30bdbed5..6e3852d2af79 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -15,10 +15,11 @@ "psr/log": "^1.1" }, "require-dev": { + "codeigniter/coding-standard": "^1.1", "fakerphp/faker": "^1.9", - "friendsofphp/php-cs-fixer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.1", "mikey179/vfsstream": "^1.6", - "nexusphp/cs-config": "^3.1", + "nexusphp/cs-config": "^3.3", "phpunit/phpunit": "^9.1", "predis/predis": "^1.1" }, diff --git a/app/Config/Services.php b/app/Config/Services.php index 946be65a11c2..df7c8ad08600 100644 --- a/app/Config/Services.php +++ b/app/Config/Services.php @@ -19,13 +19,14 @@ */ class Services extends BaseService { - // public static function example($getShared = true) - // { - // if ($getShared) - // { - // return static::getSharedInstance('example'); - // } - // - // return new \CodeIgniter\Example(); - // } + /* + * public static function example($getShared = true) + * { + * if ($getShared) { + * return static::getSharedInstance('example'); + * } + * + * return new \CodeIgniter\Example(); + * } + */ } diff --git a/composer.json b/composer.json index 66a38a215e5c..7b9d50b8e620 100644 --- a/composer.json +++ b/composer.json @@ -15,10 +15,11 @@ "psr/log": "^1.1" }, "require-dev": { + "codeigniter/coding-standard": "^1.1", "fakerphp/faker": "^1.9", - "friendsofphp/php-cs-fixer": "^3.0", + "friendsofphp/php-cs-fixer": "^3.1", "mikey179/vfsstream": "^1.6", - "nexusphp/cs-config": "^3.1", + "nexusphp/cs-config": "^3.3", "nexusphp/tachycardia": "^1.0", "phpstan/phpstan": "^0.12.91", "phpunit/phpunit": "^9.1", diff --git a/system/Database/BaseConnection.php b/system/Database/BaseConnection.php index c7bec269c472..70bde67b6d50 100644 --- a/system/Database/BaseConnection.php +++ b/system/Database/BaseConnection.php @@ -1004,7 +1004,7 @@ public function protectIdentifiers($item, bool $prefixSingle = false, ?bool $pro // we have nothing more to do other than escape the item // // NOTE: The ! empty() condition prevents this method - // from breaking when QB isn't enabled. + // from breaking when QB isn't enabled. if (! empty($this->aliasedTables) && in_array($parts[0], $this->aliasedTables, true)) { if ($protectIdentifiers === true) { foreach ($parts as $key => $val) { diff --git a/system/Email/Email.php b/system/Email/Email.php index c07f79d80df6..966c08e6f830 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -1459,8 +1459,8 @@ protected function prepQEncoding($str) if ($this->charset === 'UTF-8') { // Note: We used to have mb_encode_mimeheader() as the first choice - // here, but it turned out to be buggy and unreliable. DO NOT - // re-add it! -- Narf + // here, but it turned out to be buggy and unreliable. DO NOT + // re-add it! -- Narf if (extension_loaded('iconv')) { $output = @iconv_mime_encode('', $str, [ 'scheme' => 'Q', diff --git a/system/Session/Session.php b/system/Session/Session.php index 27ba502aea36..5fc1bda6005e 100644 --- a/system/Session/Session.php +++ b/system/Session/Session.php @@ -565,7 +565,7 @@ public function __set(string $key, $value) public function __get(string $key) { // Note: Keep this order the same, just in case somebody wants to - // use 'session_id' as a session data key, for whatever reason + // use 'session_id' as a session data key, for whatever reason if (isset($_SESSION[$key])) { return $_SESSION[$key]; } diff --git a/system/Test/Mock/MockIncomingRequest.php b/system/Test/Mock/MockIncomingRequest.php index 522965f46998..05c9587d4170 100644 --- a/system/Test/Mock/MockIncomingRequest.php +++ b/system/Test/Mock/MockIncomingRequest.php @@ -15,11 +15,6 @@ class MockIncomingRequest extends IncomingRequest { - // public function populateHeaders() - // { - // // Don't do anything... force the tester to manually set the headers they want. - // } - protected function detectURI($protocol, $baseURL) { // Do nothing... diff --git a/system/Typography/Typography.php b/system/Typography/Typography.php index 9ad2dd3914c8..a5ecebd69ddc 100644 --- a/system/Typography/Typography.php +++ b/system/Typography/Typography.php @@ -155,12 +155,12 @@ public function autoTypography(string $str, bool $reduceLinebreaks = false): str continue; } - // Force a newline to make sure end tags get processed by _format_newlines() + // Force a newline to make sure end tags get processed by _format_newlines() if ($i === $c) { $chunks[$i] .= "\n"; } - // Convert Newlines into

and
tags + // Convert Newlines into

and
tags $str .= $this->formatNewLines($chunks[$i]); } diff --git a/tests/system/CLI/CLITest.php b/tests/system/CLI/CLITest.php index 51dbe3611684..68008ccc1e4d 100644 --- a/tests/system/CLI/CLITest.php +++ b/tests/system/CLI/CLITest.php @@ -75,14 +75,15 @@ public function testWait() // The problem: if the block below is enabled, the phpunit tests // go catatonic when it is executed, presumably because of // the CLI::input() waiting for a key press - // // test the press any key to continue... - // stream_filter_register('CLITestKeyboardFilter', 'CodeIgniter\CLI\CLITestKeyboardFilter'); - // $spoofer = stream_filter_append(STDIN, 'CLITestKeyboardFilter'); - // $time = time(); - // CLITestKeyboardFilter::$spoofed = ' '; - // CLI::wait(0); - // stream_filter_remove($spoofer); - // $this->assertEquals(0, time() - $time); + // + // // test the press any key to continue... + // stream_filter_register('CLITestKeyboardFilter', 'CodeIgniter\CLI\CLITestKeyboardFilter'); + // $spoofer = stream_filter_append(STDIN, 'CLITestKeyboardFilter'); + // $time = time(); + // CLITestKeyboardFilter::$spoofed = ' '; + // CLI::wait(0); + // stream_filter_remove($spoofer); + // $this->assertEquals(0, time() - $time); } public function testIsWindows() diff --git a/tests/system/Cache/Handlers/FileHandlerTest.php b/tests/system/Cache/Handlers/FileHandlerTest.php index ea5a095631e0..bfd379ae9d8f 100644 --- a/tests/system/Cache/Handlers/FileHandlerTest.php +++ b/tests/system/Cache/Handlers/FileHandlerTest.php @@ -221,8 +221,8 @@ public function testDecrement() $this->fileHandler->save(self::$key1, 10); $this->fileHandler->save(self::$key2, 'value'); - // Line following commented out to force the cache to add a zero entry for key3 - // $this->fileHandler->save(self::$key3, 0); + // Line following commented out to force the cache to add a zero entry for key3 + // $this->fileHandler->save(self::$key3, 0); $this->assertSame(9, $this->fileHandler->decrement(self::$key1, 1)); $this->assertFalse($this->fileHandler->decrement(self::$key2, 1)); diff --git a/tests/system/Config/ServicesTest.php b/tests/system/Config/ServicesTest.php index 44d65b1ebfc7..6733ee06fff6 100644 --- a/tests/system/Config/ServicesTest.php +++ b/tests/system/Config/ServicesTest.php @@ -147,17 +147,6 @@ public function testNewImage() $this->assertInstanceOf(ImageHandlerInterface::class, $actual); } - // public function testNewMigrationRunner() - // { - // //FIXME - docs aren't clear about setting this up to just make sure that the service - // // returns a MigrationRunner - // $config = new \Config\Migrations(); - // $db = new \CodeIgniter\Database\MockConnection([]); - // $this->expectException('InvalidArgumentException'); - // $actual = Services::migrations($config, $db); - // $this->assertInstanceOf(\CodeIgniter\Database\MigrationRunner::class, $actual); - // } - // public function testNewNegotiatorWithNullConfig() { $actual = Services::negotiator(null); diff --git a/tests/system/I18n/TimeTest.php b/tests/system/I18n/TimeTest.php index 70b5ca05fbd7..2da8e5accbf3 100644 --- a/tests/system/I18n/TimeTest.php +++ b/tests/system/I18n/TimeTest.php @@ -643,19 +643,6 @@ public function testToFormattedDateString() $this->assertSame('May 10, 2017', $time->toFormattedDateString()); } - /** - * Unfortunately, ubuntu 14.04 (on TravisCI) fails this test and - * shows a numeric version of the month instead of the textual version. - * Confirmed on CentOS 7 as well. - * Example: format 'MMM' for November returns 'M02' instead of 'Nov' - * Not sure what the fix is just yet.... - */ - // public function testToFormattedDateString() - // { - // $time = Time::parse('February 10, 2017', 'America/Chicago'); - // $this->assertEquals('Feb 10, 2017', $time->toFormattedDateString()); - // } - public function testToTimeString() { $time = Time::parse('January 10, 2017 13:20:33', 'America/Chicago'); diff --git a/tests/system/Test/TestCaseTest.php b/tests/system/Test/TestCaseTest.php index a2c798d21cc6..5db2832fa12d 100644 --- a/tests/system/Test/TestCaseTest.php +++ b/tests/system/Test/TestCaseTest.php @@ -22,15 +22,6 @@ */ final class TestCaseTest extends CIUnitTestCase { - // protected function tearDown(): void - // { - // $buffer = ob_clean(); - // if (ob_get_level() > 0) - // { - // ob_end_clean(); - // } - // } - // public function testGetPrivatePropertyWithObject() { $obj = new __TestForReflectionHelper(); @@ -86,7 +77,6 @@ public function testPHPUnitHeadersEmitted() $response->send(); ob_end_clean(); - // Did PHPunit do its thing? $this->assertHeaderEmitted('Content-type: text/html;'); $this->assertHeaderNotEmitted('Set-Cookie: foo=bar;'); } diff --git a/utils/PhpCsFixer/CodeIgniter4.php b/utils/PhpCsFixer/CodeIgniter4.php deleted file mode 100644 index 05e83b544270..000000000000 --- a/utils/PhpCsFixer/CodeIgniter4.php +++ /dev/null @@ -1,540 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace Utils\PhpCsFixer; - -use Nexus\CsConfig\Ruleset\AbstractRuleset; - -/** - * Defines the ruleset used for the CodeIgniter4 organization. - * - * @internal - */ -final class CodeIgniter4 extends AbstractRuleset -{ - public function __construct() - { - $this->name = 'CodeIgniter4 Revised Coding Standards'; - - $this->rules = [ - 'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], - 'array_indentation' => true, - 'array_push' => true, - 'array_syntax' => ['syntax' => 'short'], - 'backtick_to_shell_exec' => true, - 'binary_operator_spaces' => [ - 'default' => 'single_space', - 'operators' => [ - '=' => 'align_single_space_minimal', - '=>' => 'align_single_space_minimal', - '||' => 'align_single_space_minimal', - '.=' => 'align_single_space_minimal', - ], - ], - 'blank_line_after_namespace' => true, - 'blank_line_after_opening_tag' => true, - 'blank_line_before_statement' => [ - 'statements' => [ - 'case', - 'continue', - 'declare', - 'default', - 'do', - 'exit', - 'for', - 'foreach', - 'goto', - 'return', - 'switch', - 'throw', - 'try', - 'while', - 'yield', - 'yield_from', - ], - ], - 'braces' => [ - 'allow_single_line_anonymous_class_with_empty_body' => true, - 'allow_single_line_closure' => true, - 'position_after_anonymous_constructs' => 'same', - 'position_after_control_structures' => 'same', - 'position_after_functions_and_oop_constructs' => 'next', - ], - 'cast_spaces' => ['space' => 'single'], - 'class_attributes_separation' => [ - 'elements' => [ - 'method' => 'one', - ], - ], - 'class_definition' => [ - 'multi_line_extends_each_single_line' => true, - 'single_item_single_line' => true, - 'single_line' => true, - 'space_before_parenthesis' => true, - ], - 'clean_namespace' => true, - 'combine_consecutive_issets' => true, - 'combine_consecutive_unsets' => true, - 'combine_nested_dirname' => true, - 'comment_to_phpdoc' => [ - 'ignored_tags' => [ - 'todo', - 'codeCoverageIgnore', - 'codeCoverageIgnoreStart', - 'codeCoverageIgnoreEnd', - 'phpstan-ignore-line', - 'phpstan-ignore-next-line', - ], - ], - 'compact_nullable_typehint' => true, - 'concat_space' => ['spacing' => 'one'], - 'constant_case' => ['case' => 'lower'], - 'date_time_immutable' => false, - 'declare_equal_normalize' => ['space' => 'none'], - 'declare_parentheses' => true, - 'declare_strict_types' => false, - 'dir_constant' => true, - 'doctrine_annotation_array_assignment' => false, - 'doctrine_annotation_braces' => false, - 'doctrine_annotation_indentation' => false, - 'doctrine_annotation_spaces' => false, - 'echo_tag_syntax' => [ - 'format' => 'short', - 'long_function' => 'echo', - 'shorten_simple_statements_only' => false, - ], - 'elseif' => true, - 'empty_loop_body' => ['style' => 'braces'], - 'encoding' => true, - 'ereg_to_preg' => true, - 'error_suppression' => [ - 'mute_deprecation_error' => true, - 'noise_remaining_usages' => false, - 'noise_remaining_usages_exclude' => [], - ], - 'escape_implicit_backslashes' => [ - 'double_quoted' => true, - 'heredoc_syntax' => true, - 'single_quoted' => false, - ], - 'explicit_indirect_variable' => true, - 'explicit_string_variable' => true, - 'final_class' => false, - 'final_internal_class' => [ - 'annotation_exclude' => ['@no-final'], - 'annotation_include' => ['@internal'], - 'consider_absent_docblock_as_internal_class' => false, - ], - 'final_public_method_for_abstract_class' => false, - 'fopen_flag_order' => true, - 'fopen_flags' => ['b_mode' => true], - 'full_opening_tag' => true, - 'fully_qualified_strict_types' => true, - 'function_declaration' => ['closure_function_spacing' => 'one'], - 'function_to_constant' => [ - 'functions' => [ - 'get_called_class', - 'get_class', - 'get_class_this', - 'php_sapi_name', - 'phpversion', - 'pi', - ], - ], - 'function_typehint_space' => true, - 'general_phpdoc_annotation_remove' => [ - 'annotations' => [ - 'author', - 'package', - 'subpackage', - ], - ], - 'general_phpdoc_tag_rename' => [ - 'case_sensitive' => false, - 'fix_annotation' => true, - 'fix_inline' => true, - 'replacements' => ['inheritDocs' => 'inheritDoc'], - ], - 'global_namespace_import' => false, - 'group_import' => false, - 'header_comment' => false, // false by default - 'heredoc_indentation' => ['indentation' => 'start_plus_one'], - 'heredoc_to_nowdoc' => true, - 'implode_call' => true, - 'include' => true, - 'increment_style' => ['style' => 'post'], - 'indentation_type' => true, - 'is_null' => true, - 'lambda_not_used_import' => true, - 'line_ending' => true, - 'linebreak_after_opening_tag' => true, - 'list_syntax' => ['syntax' => 'short'], - 'logical_operators' => true, - 'lowercase_cast' => true, - 'lowercase_keywords' => true, - 'lowercase_static_reference' => true, - 'magic_constant_casing' => true, - 'magic_method_casing' => true, - 'mb_str_functions' => false, - 'method_argument_space' => [ - 'after_heredoc' => false, - 'keep_multiple_spaces_after_comma' => false, - 'on_multiline' => 'ensure_fully_multiline', - ], - 'method_chaining_indentation' => true, - 'modernize_types_casting' => true, - 'multiline_comment_opening_closing' => true, - 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], - 'native_constant_invocation' => false, - 'native_function_casing' => true, - 'native_function_invocation' => false, - 'native_function_type_declaration_casing' => true, - 'new_with_braces' => true, - 'no_alias_functions' => ['sets' => ['@all']], - 'no_alias_language_construct_call' => true, - 'no_alternative_syntax' => false, - 'no_binary_string' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_before_namespace' => false, // conflicts with `single_blank_line_before_namespace` - 'no_break_comment' => ['comment_text' => 'no break'], - 'no_closing_tag' => true, - 'no_empty_comment' => true, - 'no_empty_phpdoc' => true, - 'no_empty_statement' => true, - 'no_extra_blank_lines' => ['tokens' => ['extra']], - 'no_homoglyph_names' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_mixed_echo_print' => ['use' => 'echo'], - 'no_multiline_whitespace_around_double_arrow' => true, - 'no_null_property_initialization' => true, - 'no_php4_constructor' => true, - 'no_short_bool_cast' => true, - 'no_singleline_whitespace_before_semicolons' => true, - 'no_spaces_after_function_name' => true, - 'no_spaces_around_offset' => ['positions' => ['inside', 'outside']], - 'no_spaces_inside_parenthesis' => true, - 'no_superfluous_elseif' => true, - 'no_superfluous_phpdoc_tags' => [ - 'allow_mixed' => true, - 'allow_unused_params' => true, - 'remove_inheritdoc' => false, - ], - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_trailing_whitespace' => true, - 'no_trailing_whitespace_in_comment' => true, - 'no_trailing_whitespace_in_string' => true, - 'no_unneeded_control_parentheses' => [ - 'statements' => [ - 'break', - 'clone', - 'continue', - 'echo_print', - 'return', - 'switch_case', - 'yield', - ], - ], - 'no_unneeded_curly_braces' => ['namespaces' => true], - 'no_unneeded_final_method' => ['private_methods' => true], - 'no_unreachable_default_argument_value' => true, - 'no_unset_cast' => true, - 'no_unset_on_property' => false, - 'no_unused_imports' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'no_useless_sprintf' => true, - 'no_whitespace_before_comma_in_array' => ['after_heredoc' => true], - 'no_whitespace_in_blank_line' => true, - 'non_printable_character' => ['use_escape_sequences_in_strings' => true], - 'normalize_index_brace' => true, - 'not_operator_with_space' => false, - 'not_operator_with_successor_space' => true, - 'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => true], - 'object_operator_without_whitespace' => true, - 'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'], - 'ordered_class_elements' => false, - 'ordered_imports' => [ - 'sort_algorithm' => 'alpha', - 'imports_order' => ['class', 'function', 'const'], - ], - 'ordered_interfaces' => false, - 'ordered_traits' => false, - 'php_unit_construct' => [ - 'assertions' => [ - 'assertSame', - 'assertEquals', - 'assertNotEquals', - 'assertNotSame', - ], - ], - 'php_unit_dedicate_assert' => ['target' => 'newest'], - 'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'], - 'php_unit_expectation' => ['target' => 'newest'], - 'php_unit_fqcn_annotation' => true, - 'php_unit_internal_class' => ['types' => ['normal', 'final']], - 'php_unit_method_casing' => ['case' => 'camel_case'], - 'php_unit_mock' => ['target' => 'newest'], - 'php_unit_mock_short_will_return' => true, - 'php_unit_namespaced' => ['target' => 'newest'], - 'php_unit_no_expectation_annotation' => [ - 'target' => 'newest', - 'use_class_const' => true, - ], - 'php_unit_set_up_tear_down_visibility' => true, - 'php_unit_size_class' => false, - 'php_unit_strict' => [ - 'assertions' => [ - 'assertAttributeEquals', - 'assertAttributeNotEquals', - 'assertEquals', - 'assertNotEquals', - ], - ], - 'php_unit_test_annotation' => ['style' => 'prefix'], - 'php_unit_test_case_static_method_calls' => [ - 'call_type' => 'this', - 'methods' => [], - ], - 'php_unit_test_class_requires_covers' => false, - 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], - 'phpdoc_align' => [ - 'align' => 'vertical', - 'tags' => [ - 'method', - 'param', - 'property', - 'return', - 'throws', - 'type', - 'var', - ], - ], - 'phpdoc_annotation_without_dot' => false, - 'phpdoc_indent' => true, - 'phpdoc_inline_tag_normalizer' => [ - 'tags' => [ - 'example', - 'id', - 'internal', - 'inheritdoc', - 'inheritdocs', - 'link', - 'source', - 'toc', - 'tutorial', - ], - ], - 'phpdoc_line_span' => [ - 'const' => 'multi', - 'method' => 'multi', - 'property' => 'multi', - ], - 'phpdoc_no_access' => true, - 'phpdoc_no_alias_tag' => [ - 'replacements' => [ - 'property-read' => 'property', - 'property-write' => 'property', - 'type' => 'var', - 'link' => 'see', - ], - ], - 'phpdoc_no_empty_return' => false, - 'phpdoc_no_package' => true, - 'phpdoc_no_useless_inheritdoc' => true, - 'phpdoc_order' => true, - 'phpdoc_order_by_value' => [ - 'annotations' => [ - 'author', - 'covers', - 'coversNothing', - 'dataProvider', - 'depends', - 'group', - 'internal', - 'method', - 'property', - 'property-read', - 'property-write', - 'requires', - 'throws', - 'uses', - ], - ], - 'phpdoc_return_self_reference' => [ - 'replacements' => [ - 'this' => '$this', - '@this' => '$this', - '$self' => 'self', - '@self' => 'self', - '$static' => 'static', - '@static' => 'static', - ], - ], - 'phpdoc_scalar' => [ - 'types' => [ - 'boolean', - 'callback', - 'double', - 'integer', - 'real', - 'str', - ], - ], - 'phpdoc_separation' => true, - 'phpdoc_single_line_var_spacing' => true, - 'phpdoc_summary' => false, - 'phpdoc_tag_casing' => ['tags' => ['inheritDoc']], - 'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']], - 'phpdoc_to_comment' => false, - 'phpdoc_to_param_type' => false, - 'phpdoc_to_property_type' => false, - 'phpdoc_to_return_type' => false, - 'phpdoc_trim' => true, - 'phpdoc_trim_consecutive_blank_line_separation' => true, - 'phpdoc_types' => ['groups' => ['simple', 'alias', 'meta']], - 'phpdoc_types_order' => [ - 'null_adjustment' => 'always_last', - 'sort_algorithm' => 'alpha', - ], - 'phpdoc_var_annotation_correct_order' => true, - 'phpdoc_var_without_name' => true, - 'pow_to_exponentiation' => true, - 'protected_to_private' => true, - 'psr_autoloading' => ['dir' => null], - 'random_api_migration' => [ - 'replacements' => [ - 'getrandmax' => 'mt_getrandmax', - 'rand' => 'mt_rand', - 'srand' => 'mt_srand', - ], - ], - 'regular_callable_call' => true, - 'return_assignment' => true, - 'return_type_declaration' => ['space_before' => 'none'], - 'self_accessor' => false, - 'self_static_accessor' => true, - 'semicolon_after_instruction' => false, - 'set_type_to_cast' => true, - 'short_scalar_cast' => true, - 'simple_to_complex_string_variable' => true, - 'simplified_if_return' => true, - 'simplified_null_return' => false, - 'single_blank_line_at_eof' => true, - 'single_blank_line_before_namespace' => true, - 'single_class_element_per_statement' => ['elements' => ['const', 'property']], - 'single_import_per_statement' => true, - 'single_line_after_imports' => true, - 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], - 'single_line_throw' => false, - 'single_quote' => ['strings_containing_single_quote_chars' => false], - 'single_space_after_construct' => [ - 'constructs' => [ - 'abstract', - 'as', - 'attribute', - 'break', - 'case', - 'catch', - 'class', - 'clone', - 'comment', - 'const', - 'const_import', - 'continue', - 'do', - 'echo', - 'else', - 'elseif', - 'extends', - 'final', - 'finally', - 'for', - 'foreach', - 'function', - 'function_import', - 'global', - 'goto', - 'if', - 'implements', - 'include', - 'include_once', - 'instanceof', - 'insteadof', - 'interface', - 'match', - 'named_argument', - 'new', - 'open_tag_with_echo', - 'php_doc', - 'php_open', - 'print', - 'private', - 'protected', - 'public', - 'require', - 'require_once', - 'return', - 'static', - 'throw', - 'trait', - 'try', - 'use', - 'use_lambda', - 'use_trait', - 'var', - 'while', - 'yield', - 'yield_from', - ], - ], - 'single_trait_insert_per_statement' => true, - 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], - 'standardize_increment' => true, - 'standardize_not_equals' => true, - 'static_lambda' => true, - 'strict_comparison' => true, - 'strict_param' => true, - 'string_line_ending' => true, - 'switch_case_semicolon_to_colon' => true, - 'switch_case_space' => true, - 'switch_continue_to_break' => true, - 'ternary_operator_spaces' => true, - 'ternary_to_elvis_operator' => true, - 'ternary_to_null_coalescing' => true, - 'trailing_comma_in_multiline' => [ - 'after_heredoc' => true, - 'elements' => ['arrays'], - ], - 'trim_array_spaces' => true, - 'types_spaces' => ['space' => 'none'], - 'unary_operator_spaces' => true, - 'use_arrow_functions' => false, // requires PHP7.4+ - 'visibility_required' => ['elements' => ['const', 'method', 'property']], - 'void_return' => false, // changes method signature - 'whitespace_after_comma_in_array' => true, - 'yoda_style' => [ - 'equal' => false, - 'identical' => null, - 'less_and_greater' => false, - 'always_move_variable' => false, - ], - ]; - - $this->requiredPHPVersion = 70300; - - $this->autoActivateIsRiskyAllowed = true; - } -} diff --git a/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php b/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php deleted file mode 100644 index d7322c32d308..000000000000 --- a/utils/PhpCsFixer/Fixer/Comment/SpaceAfterCommentStartFixer.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view - * the LICENSE file that was distributed with this source code. - */ - -namespace Utils\PhpCsFixer\Fixer\Comment; - -use PhpCsFixer\AbstractFixer; -use PhpCsFixer\FixerDefinition\CodeSample; -use PhpCsFixer\FixerDefinition\FixerDefinition; -use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; -use PhpCsFixer\Preg; -use PhpCsFixer\Tokenizer\Token; -use PhpCsFixer\Tokenizer\Tokens; -use SplFileInfo; - -/** - * @internal - */ -final class SpaceAfterCommentStartFixer extends AbstractFixer -{ - /** - * {@inheritDoc} - */ - public function getName(): string - { - return 'CodeIgniter4/' . parent::getName(); - } - - /** - * {@inheritDoc} - */ - public function getDefinition(): FixerDefinitionInterface - { - return new FixerDefinition( - 'There should be a single whitespace after the comment start', - [new CodeSample("isTokenKindFound(T_COMMENT); - } - - /** - * {@inheritDoc} - * - * Must run after NoEmptyCommentFixer - */ - public function getPriority(): int - { - return 3; - } - - /** - * {@inheritDoc} - */ - protected function applyFix(SplFileInfo $file, Tokens $tokens): void - { - for ($index = 1, $count = $tokens->count(); $index < $count; $index++) { - /** @var Token $token */ - $token = $tokens[$index]; - - if (! $token->isGivenKind(T_COMMENT)) { - continue; - } - - $comment = $token->getContent(); - - if (substr($comment, 0, 2) !== '//') { - continue; - } - - if (Preg::match('/^\/\/(?!\s+)(.+)/', $comment, $matches) !== 1) { - continue; - } - - if (Preg::match('/\-+/', $matches[1]) === 1 || Preg::match('/\=+/', $matches[1]) === 1) { - continue; - } - - $tokens[$index] = new Token([T_COMMENT, '// ' . $matches[1]]); - } - } -}