├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── composer.json └── src └── CodeIgniter4.php /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this library will be documented in this file. 4 | 5 | This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6 | 7 | ## [v1.8.5](https://github.com/CodeIgniter/coding-standard/compare/v1.8.4...v1.8.5) - 2025-05-02 8 | 9 | - Enable `import_symbols` option in `fully_qualified_strict_types` 10 | - Fix `staticMethod.internalClass` error 11 | 12 | ## [v1.8.4](https://github.com/CodeIgniter/coding-standard/compare/v1.8.3...v1.8.4) - 2025-02-23 13 | 14 | - Update badges 15 | - Enable `php_unit_data_provider_method_order` fixer 16 | - Bump php-cs-fixer to v3.70 17 | - Enable `modernize_stripos` option in `modernize_strpos` fixer 18 | 19 | ## [v1.8.3](https://github.com/CodeIgniter/coding-standard/compare/v1.8.2...v1.8.3) - 2025-01-13 20 | 21 | - Bump to php-cs-fixer v3.67 and cs-config v3.25 22 | - Add `@phpstan-ignore` to ignored tags of `comment_to_phpdoc` 23 | - Add `general_attribute_remove` fixer 24 | - Enable `get_class_to_class_keyword` 25 | - Add more elements to `trailing_comma_in_multiline` 26 | 27 | ## [v1.8.2](https://github.com/CodeIgniter/coding-standard/compare/v1.8.1...v1.8.2) - 2024-11-20 28 | 29 | - Add `case` to ordered_class_elements order 30 | - Bump to phpstan 2.0 31 | 32 | ## [v1.8.1](https://github.com/CodeIgniter/coding-standard/compare/v1.8.0...v1.8.1) - 2024-08-05 33 | 34 | - Add `keep_annotations` option for `php_unit_attributes` 35 | - Add `php_unit_assert_new_names` fixer 36 | - Bump dependencies 37 | 38 | ## [v1.8.0](https://github.com/CodeIgniter/coding-standard/compare/v1.7.16...v1.8.0) - 2024-06-16 39 | 40 | - Enable rules for PHP 8.1 (#20) 41 | 42 | ## [v1.7.16](https://github.com/CodeIgniter/coding-standard/compare/v1.7.15...v1.7.16) - 2024-05-18 43 | 44 | - Disable `php_unit_attributes` for now 45 | - Fix cs-config to v3.18 for now 46 | - Disable `ordered_attributes` for PHP <8.0 47 | 48 | ## [v1.7.15](https://github.com/CodeIgniter/coding-standard/compare/v1.7.14...v1.7.15) - 2024-03-24 49 | 50 | - Remove deprecated option of `nullable_type_declaration_for_default_null_value` 51 | 52 | ## [v1.7.14](https://github.com/CodeIgniter/coding-standard/compare/v1.7.13...v1.7.14) - 2024-02-25 53 | 54 | - Bump php-cs-fixer to v3.49 55 | - Enable `string_implicit_backslashes` fixer 56 | - Add/remove property-read and property-write 57 | - Enable `phpdoc_list_type` 58 | - Bump to php-cs-fixer v3.50 59 | - Enable `allow_hidden_params` option 60 | - also align `@phpstan-type` and `@phpstan-var` 61 | - Enable `phpdoc_array_type` 62 | 63 | ## [v1.7.13](https://github.com/CodeIgniter/coding-standard/compare/v1.7.12...v1.7.13) - 2024-01-27 64 | 65 | - Update GHA workflows 66 | - Bump to php-cs-fixer v3.47 67 | - Disable all new rules in v3.47 68 | - Apply new options to `phpdoc_align` fixer 69 | - Bump actions/cache from 3 to 4 (#17) 70 | 71 | ## [v1.7.12](https://github.com/CodeIgniter/coding-standard/compare/v1.7.11...v1.7.12) - 2023-12-29 72 | 73 | - Bump php-cs-fixer to v3.43 74 | - Enable other options of `fully_qualified_strict_types` 75 | - Disable `class_keyword` 76 | - Disable option for `statement_indentation` 77 | - Use default for option of `unary_operator_spaces` 78 | 79 | ## [v1.7.11](https://github.com/CodeIgniter/coding-standard/compare/v1.7.10...v1.7.11) - 2023-10-13 80 | 81 | - Bump to php-cs-fixer v3.35 82 | 83 | ## [v1.7.10](https://github.com/CodeIgniter/coding-standard/compare/v1.7.9...v1.7.10) - 2023-10-01 84 | 85 | - Bump to php-cs-fixer v3.34 86 | - Bump to php-cs-fixer v3.30 87 | - Fix tag name in release 88 | 89 | ## [v1.7.9](https://github.com/CodeIgniter/coding-standard/compare/v1.7.8...v1.7.9) - 2023-09-18 90 | 91 | - Update release.yml 92 | - Add `long_to_shorthand_operator` (#13) 93 | - Bump actions/checkout from 3 to 4 (#12) 94 | 95 | ## [v1.7.8](https://github.com/CodeIgniter/coding-standard/compare/v1.7.7...v1.7.8) - 2023-08-30 96 | 97 | - Add `case_sensitive` option to order fixers 98 | 99 | ## [v1.7.7](https://github.com/CodeIgniter/coding-standard/compare/v1.7.6...v1.7.7) - 2023-08-15 100 | 101 | - Specify force option for `php_unit_data_provider_static` fixer 102 | 103 | ## [v1.7.6](https://github.com/CodeIgniter/coding-standard/compare/v1.7.5...v1.7.6) - 2023-08-15 104 | 105 | - Enable 'php_unit_data_provider_static' 106 | - Add new fixers in php-cs-fixer v3.23 107 | - Add `yield_from_array_to_yields` 108 | - Enable `php_unit_data_provider_name` 109 | - Use all available checked tokens for `no_extra_blank_lines` 110 | - Configure `php_unit_data_provider_return_type` 111 | - Remove parallel.timeout in phpstan.neon.dist 112 | 113 | ## [v1.7.5](https://github.com/CodeIgniter/coding-standard/compare/v1.7.4...v1.7.5) - 2023-07-15 114 | 115 | - Configure new fixers in php-cs-fixer v3.20 116 | 117 | ## [v1.7.4](https://github.com/CodeIgniter/coding-standard/compare/v1.7.3...v1.7.4) - 2023-06-19 118 | 119 | - Bump php-cs-fixer to v3.18 120 | - fix: ruleset deprecated on `v3.18` (#10) 121 | - Add case_sensitive option to ordered_class_elements 122 | - Add missing rules 123 | 124 | ## [v1.7.3](https://github.com/CodeIgniter/coding-standard/compare/v1.7.2...v1.7.3) - 2023-05-05 125 | 126 | - Replace `single_space_after_construct` with `single_space_around_construct` 127 | - Remove deprecated `braces` rules 128 | - Bump php-cs-fixer to v3.16 129 | 130 | ## [v1.7.2](https://github.com/CodeIgniter/coding-standard/compare/v1.7.1...v1.7.2) - 2023-03-05 131 | 132 | - Bump php-cs-fixer to v3.14 133 | 134 | ## [v1.7.1](https://github.com/CodeIgniter/coding-standard/compare/v1.7.0...v1.7.1) - 2022-12-22 135 | 136 | - Fix php-cs-fixer version to 3.13.0 137 | 138 | ## [v1.7.0](https://github.com/CodeIgniter/coding-standard/compare/v1.6.2...v1.7.0) - 2022-11-01 139 | 140 | - Bump php-cs-fixer to v3.13 141 | - Add 'case_sensitive' option to 'general_phpdoc_annotation_remove' 142 | - Add 'closure_fn_spacing' option to 'function_declaration' 143 | 144 | ## [v1.6.2](https://github.com/CodeIgniter/coding-standard/compare/v1.6.1...v1.6.2) - 2022-10-30 145 | 146 | - Grouped `runTestsInSeparateProcess`, `runInSeparateProcess`, `preserveGlobalState` together 147 | 148 | ## [v1.6.1](https://github.com/CodeIgniter/coding-standard/compare/v1.6.0...v1.6.1) - 2022-10-20 149 | 150 | - Changed `@internal` description of class CodeIgniter4 to avoid warnings in phpstorm 151 | 152 | ## [v1.6.0](https://github.com/CodeIgniter/coding-standard/compare/v1.5.0...v1.6.0) - 2022-10-15 153 | 154 | - Bump php-cs-fixer version to v3.12 minimum 155 | - Enable `no_useless_concat_operator` 156 | - Update action workflows 157 | 158 | ## [v1.5.0](https://github.com/CodeIgniter/coding-standard/compare/v1.4.0...v1.5.0) - 2022-09-13 159 | 160 | - Enable `ensure_single_space` option of `whitespace_after_comma_in_array` 161 | - Use the `space_multiple_catch` option of `types_spaces` 162 | - Fix multi-lines 163 | - Add `group_to_single_imports` option to `single_import_per_statement` 164 | - chore: fix editorconfig (#4) 165 | - docs: add CONTRIBUTING.md (#3) 166 | - Enable `date_time_create_from_format_call` 167 | - Add options to `new_with_braces` 168 | - Add `order` option to `phpdoc_order` 169 | - Add the `trailing_comma_single_line` option to `function_declaration` 170 | - Enable `curly_braces_position` 171 | - Enable `single_line_comment_spacing` 172 | - Enable `no_trailing_comma_in_singleline` 173 | - Normalize composer.json 174 | - Add "static analysis" Composer keyword (#2) 175 | - Add `inline_constructor_arguments` option to `class_definition` 176 | - Enable `statement_indentation` 177 | - Enable `no_useless_nullsafe_operator` 178 | - Enable `no_multiple_statements_per_line` 179 | - Enable `control_structure_braces` 180 | - Enable `blank_line_between_import_groups` 181 | - Remove deprecated fixers 182 | - Configure `groups` option in `phpdoc_separation` rule 183 | - Bump php-cs-fixer version 184 | 185 | ## [v1.4.0](https://github.com/CodeIgniter/coding-standard/compare/v1.3.0...v1.4.0) - 2022-02-09 186 | 187 | - Permit use of latest php-cs-fixer v3.6.0 188 | 189 | ## [v1.3.0](https://github.com/CodeIgniter/coding-standard/compare/v1.2.0...v1.3.0) - 2022-01-15 190 | 191 | - Fix GHA workflows 192 | - Bump versions 193 | - PHP 7.4 minimum 194 | - friendsofphp/php-cs-fixer v3.4.0 195 | - phpstan/phpstan v1.0 minimum 196 | - Enable `ordered_class_elements` rule 197 | - Enable `global_namespace_import` rule (#1) 198 | - Use `GITHUB_TOKEN` so that secrets can be passed to PRs 199 | 200 | ## [v1.2.0](https://github.com/CodeIgniter/coding-standard/compare/v1.1.0...v1.2.0) - 2021-10-18 201 | 202 | - Bump `friendsofphp/php-cs-fixer` to v3.2 minimum 203 | - Change behavior of `class_attributes_separation` rule 204 | - Add support for new fixers added in php-cs-fixer v3.2.0 205 | - Enable `no_alternative_syntax` rule 206 | 207 | ## [v1.1.0](https://github.com/CodeIgniter/coding-standard/compare/v1.0.0...v1.1.0) - 2021-08-31 208 | 209 | - Bump to `friendsofphp/php-cs-fixer` v3.1.0 210 | - Fix release script 211 | - Bump to `nexusphp/cs-config` v3.3.0 212 | 213 | ## [v1.0.0](https://github.com/CodeIgniter/coding-standard/releases/tag/v1.0.0) - 2021-08-29 214 | 215 | Initial release. 216 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to CodeIgniter Coding Standard 2 | 3 | CodeIgniter Coding Standard is a community driven project and accepts contributions of 4 | code and documentation from the community. 5 | 6 | If you'd like to contribute, please read the [Contributing to CodeIgniter](https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/README.md) 7 | guide in the [main repository](https://github.com/codeigniter4/CodeIgniter4). 8 | 9 | If you are going to contribute to this repository, please report bugs or send PRs 10 | to this repository instead of the main repository. 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 CodeIgniter Foundation and John Paul E. Balandan, CPA 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeIgniter Coding Standard 2 | 3 | [![Unit Tests](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpunit.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpunit.yml) 4 | [![Coding Standards](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-coding-standards.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-coding-standards.yml) 5 | [![PHPStan Static Analysis](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpstan.yml/badge.svg)](https://github.com/CodeIgniter/coding-standard/actions/workflows/test-phpstan.yml) 6 | [![PHPStan level](https://img.shields.io/badge/PHPStan-max%20level-brightgreen)](phpstan.neon.dist) 7 | [![Coverage Status](https://coveralls.io/repos/github/CodeIgniter/coding-standard/badge.svg?branch=develop)](https://coveralls.io/github/CodeIgniter/coding-standard?branch=develop) 8 | [![Latest Stable Version](http://poser.pugx.org/codeigniter/coding-standard/v)](//packagist.org/packages/codeigniter/coding-standard) 9 | [![License](https://img.shields.io/github/license/codeigniter/coding-standard)](LICENSE) 10 | [![Total Downloads](http://poser.pugx.org/codeigniter/coding-standard/downloads)](//packagist.org/packages/codeigniter/coding-standard) 11 | 12 | This library holds the official coding standards of CodeIgniter based 13 | on [PHP CS Fixer][1] and powered by [Nexus CS Config][2]. 14 | 15 | ## Installation 16 | 17 | You can add this library as a local, per-project dependency to your project 18 | using [Composer](https://getcomposer.org/): 19 | 20 | composer require codeigniter/coding-standard 21 | 22 | If you only need this library during development, for instance to run your project's test suite, 23 | then you should add it as a development-time dependency: 24 | 25 | composer require --dev codeigniter/coding-standard 26 | 27 | ## Setup 28 | 29 | To start, let us create a `.php-cs-fixer.dist.php` file at the root of your project. 30 | 31 | ```php 32 | forProjects(); 38 | 39 | ``` 40 | 41 | This minimal setup will return a default instance of `PhpCsFixer\Config` containing all rules applicable 42 | for the CodeIgniter organization. 43 | 44 | Then, in your terminal, run the following command: 45 | 46 | ```console 47 | $ vendor/bin/php-cs-fixer fix --verbose 48 | ``` 49 | 50 | ## Adding License Headers 51 | 52 | The default setup will not configure a license header in files. License headers can be especially useful 53 | for library authors to assert copyright. To add license headers in your PHP files, you can simply provide 54 | your name and name of library. Optionally, you can also provide your email and starting license year. 55 | 56 | ```diff 57 | forProjects(); 63 | +return Factory::create(new CodeIgniter4())->forLibrary( 64 | + 'CodeIgniter 4 framework', 65 | + 'CodeIgniter Foundation', 66 | + 'admin@codeigniter.com', 67 | + 2021, 68 | +); 69 | 70 | ``` 71 | 72 | ## Providing Overriding Rules and Options 73 | 74 | The list of enabled rules can be found in the [`CodeIgniter\CodingStandard\CodeIgniter4`][3] class. If you 75 | feel the rule is not applicable to you or you want to modify it, you can do so by providing an array of 76 | overriding rules to the second parameter of `Factory::create()`. 77 | 78 | Similarly, you can further modify the `PhpCsFixer\Config` instance returned by using the available options. 79 | All available options are fully supported by [Nexus CS Config][2] and abstracted by simply providing an 80 | array of key-value pairs in the third parameter of `Factory::create()`. 81 | 82 | ```diff 83 | forProjects(); 89 | +return Factory::create(new CodeIgniter4(), [], [ 90 | + 'usingCache' => false, 91 | +])->forProjects(); 92 | 93 | ``` 94 | 95 | You can check out this library's own [`.php-cs-fixer.dist.php`][4] for inspiration on how it is done. 96 | For more detailed documentation on all available options, you can check [here][2]. 97 | 98 | ## Contributing 99 | 100 | All forms of contributions are welcome! 101 | 102 | Since the rules here will be propagated and used within the CodeIgniter organization, all proposed rules 103 | and modifications to existing rules should have a proof-of-concept (POC) PR sent first to 104 | the [CodeIgniter4][5] repository with possible changes to the code styles applied there. Once accepted 105 | there, you can send in a PR here to apply those rules. 106 | 107 | ## License 108 | 109 | This work is open-sourced under the MIT license. 110 | 111 | [1]: https://github.com/FriendsOfPHP/PHP-CS-Fixer 112 | [2]: https://github.com/NexusPHP/cs-config 113 | [3]: src/CodeIgniter4.php 114 | [4]: .php-cs-fixer.dist.php 115 | [5]: https://github.com/codeigniter4/CodeIgniter4 116 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "codeigniter/coding-standard", 3 | "description": "Official Coding Standards for CodeIgniter based on PHP CS Fixer", 4 | "license": "MIT", 5 | "type": "library", 6 | "keywords": [ 7 | "phpcs", 8 | "static analysis" 9 | ], 10 | "authors": [ 11 | { 12 | "name": "John Paul E. Balandan, CPA", 13 | "email": "paulbalandan@gmail.com" 14 | } 15 | ], 16 | "support": { 17 | "forum": "http://forum.codeigniter.com/", 18 | "source": "https://github.com/CodeIgniter/coding-standard", 19 | "slack": "https://codeigniterchat.slack.com" 20 | }, 21 | "require": { 22 | "php": "^8.1", 23 | "ext-tokenizer": "*", 24 | "friendsofphp/php-cs-fixer": "^3.70", 25 | "nexusphp/cs-config": "^3.25" 26 | }, 27 | "require-dev": { 28 | "nexusphp/tachycardia": "^2.3", 29 | "phpstan/phpstan": "^2.0", 30 | "phpunit/phpunit": "^10.5 || ^11.2" 31 | }, 32 | "minimum-stability": "dev", 33 | "prefer-stable": true, 34 | "autoload": { 35 | "psr-4": { 36 | "CodeIgniter\\CodingStandard\\": "src/" 37 | } 38 | }, 39 | "autoload-dev": { 40 | "psr-4": { 41 | "CodeIgniter\\CodingStandard\\Tests\\": "tests/" 42 | } 43 | }, 44 | "config": { 45 | "optimize-autoloader": true, 46 | "preferred-install": "dist", 47 | "sort-packages": true 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/CodeIgniter4.php: -------------------------------------------------------------------------------- 1 | 9 | * 10 | * For the full copyright and license information, please view 11 | * the LICENSE file that was distributed with this source code. 12 | */ 13 | 14 | namespace CodeIgniter\CodingStandard; 15 | 16 | use Nexus\CsConfig\Ruleset\AbstractRuleset; 17 | 18 | /** 19 | * Defines the ruleset used for the CodeIgniter4 organization. 20 | * 21 | * {@internal Use of this class is not covered by the backward compatibility promise for CodeIgniter4.} 22 | */ 23 | final class CodeIgniter4 extends AbstractRuleset 24 | { 25 | public function __construct() 26 | { 27 | $this->name = 'CodeIgniter4 Coding Standards'; 28 | 29 | $this->rules = [ 30 | 'align_multiline_comment' => ['comment_type' => 'phpdocs_only'], 31 | 'array_indentation' => true, 32 | 'array_push' => true, 33 | 'array_syntax' => ['syntax' => 'short'], 34 | 'assign_null_coalescing_to_coalesce_equal' => true, 35 | 'attribute_empty_parentheses' => false, 36 | 'backtick_to_shell_exec' => true, 37 | 'binary_operator_spaces' => [ 38 | 'default' => 'single_space', 39 | 'operators' => [ 40 | '=' => 'align_single_space_minimal', 41 | '=>' => 'align_single_space_minimal', 42 | '||' => 'align_single_space_minimal', 43 | '.=' => 'align_single_space_minimal', 44 | ], 45 | ], 46 | 'blank_line_after_namespace' => true, 47 | 'blank_line_after_opening_tag' => true, 48 | 'blank_line_before_statement' => [ 49 | 'statements' => [ 50 | 'case', 51 | 'continue', 52 | 'declare', 53 | 'default', 54 | 'do', 55 | 'exit', 56 | 'for', 57 | 'foreach', 58 | 'goto', 59 | 'return', 60 | 'switch', 61 | 'throw', 62 | 'try', 63 | 'while', 64 | 'yield', 65 | 'yield_from', 66 | ], 67 | ], 68 | 'blank_line_between_import_groups' => true, 69 | 'blank_lines_before_namespace' => [ 70 | 'min_line_breaks' => 2, 71 | 'max_line_breaks' => 2, 72 | ], 73 | 'braces_position' => [ 74 | 'control_structures_opening_brace' => 'same_line', 75 | 'functions_opening_brace' => 'next_line_unless_newline_at_signature_end', 76 | 'anonymous_functions_opening_brace' => 'same_line', 77 | 'classes_opening_brace' => 'next_line_unless_newline_at_signature_end', 78 | 'anonymous_classes_opening_brace' => 'same_line', 79 | 'allow_single_line_empty_anonymous_classes' => true, 80 | 'allow_single_line_anonymous_functions' => true, 81 | ], 82 | 'cast_spaces' => ['space' => 'single'], 83 | 'class_attributes_separation' => [ 84 | 'elements' => [ 85 | 'const' => 'none', 86 | 'property' => 'none', 87 | 'method' => 'one', 88 | 'trait_import' => 'none', 89 | ], 90 | ], 91 | 'class_definition' => [ 92 | 'multi_line_extends_each_single_line' => true, 93 | 'single_item_single_line' => true, 94 | 'single_line' => true, 95 | 'space_before_parenthesis' => true, 96 | 'inline_constructor_arguments' => true, 97 | ], 98 | 'class_keyword' => false, 99 | 'class_reference_name_casing' => true, 100 | 'clean_namespace' => true, 101 | 'combine_consecutive_issets' => true, 102 | 'combine_consecutive_unsets' => true, 103 | 'combine_nested_dirname' => true, 104 | 'comment_to_phpdoc' => [ 105 | 'ignored_tags' => [ 106 | 'todo', 107 | 'codeCoverageIgnore', 108 | 'codeCoverageIgnoreStart', 109 | 'codeCoverageIgnoreEnd', 110 | 'phpstan-ignore', 111 | 'phpstan-ignore-line', 112 | 'phpstan-ignore-next-line', 113 | ], 114 | ], 115 | 'compact_nullable_type_declaration' => true, 116 | 'concat_space' => ['spacing' => 'one'], 117 | 'constant_case' => ['case' => 'lower'], 118 | 'control_structure_braces' => true, 119 | 'control_structure_continuation_position' => ['position' => 'same_line'], 120 | 'date_time_create_from_format_call' => true, 121 | 'date_time_immutable' => false, 122 | 'declare_equal_normalize' => ['space' => 'none'], 123 | 'declare_parentheses' => true, 124 | 'declare_strict_types' => false, 125 | 'dir_constant' => true, 126 | 'doctrine_annotation_array_assignment' => false, 127 | 'doctrine_annotation_braces' => false, 128 | 'doctrine_annotation_indentation' => false, 129 | 'doctrine_annotation_spaces' => false, 130 | 'echo_tag_syntax' => [ 131 | 'format' => 'short', 132 | 'long_function' => 'echo', 133 | 'shorten_simple_statements_only' => false, 134 | ], 135 | 'elseif' => true, 136 | 'empty_loop_body' => ['style' => 'braces'], 137 | 'empty_loop_condition' => ['style' => 'while'], 138 | 'encoding' => true, 139 | 'ereg_to_preg' => true, 140 | 'error_suppression' => [ 141 | 'mute_deprecation_error' => true, 142 | 'noise_remaining_usages' => false, 143 | 'noise_remaining_usages_exclude' => [], 144 | ], 145 | 'explicit_indirect_variable' => true, 146 | 'explicit_string_variable' => true, 147 | 'final_class' => false, 148 | 'final_internal_class' => [ 149 | 'exclude' => ['no-final'], 150 | 'include' => ['internal'], 151 | 'consider_absent_docblock_as_internal_class' => false, 152 | ], 153 | 'final_public_method_for_abstract_class' => false, 154 | 'fopen_flag_order' => true, 155 | 'fopen_flags' => ['b_mode' => true], 156 | 'full_opening_tag' => true, 157 | 'fully_qualified_strict_types' => [ 158 | 'import_symbols' => true, 159 | 'leading_backslash_in_global_namespace' => false, 160 | 'phpdoc_tags' => [ 161 | 'param', 162 | 'phpstan-param', 163 | 'phpstan-property', 164 | 'phpstan-property-read', 165 | 'phpstan-property-write', 166 | 'phpstan-return', 167 | 'phpstan-var', 168 | 'property', 169 | 'property-read', 170 | 'property-write', 171 | 'psalm-param', 172 | 'psalm-property', 173 | 'psalm-property-read', 174 | 'psalm-property-write', 175 | 'psalm-return', 176 | 'psalm-var', 177 | 'return', 178 | 'throws', 179 | 'var', 180 | ], 181 | ], 182 | 'function_declaration' => [ 183 | 'closure_function_spacing' => 'one', 184 | 'closure_fn_spacing' => 'one', 185 | 'trailing_comma_single_line' => false, 186 | ], 187 | 'function_to_constant' => [ 188 | 'functions' => [ 189 | 'get_called_class', 190 | 'get_class', 191 | 'get_class_this', 192 | 'php_sapi_name', 193 | 'phpversion', 194 | 'pi', 195 | ], 196 | ], 197 | 'general_attribute_remove' => ['attributes' => []], 198 | 'general_phpdoc_annotation_remove' => [ 199 | 'annotations' => [ 200 | 'author', 201 | 'package', 202 | 'subpackage', 203 | ], 204 | 'case_sensitive' => false, 205 | ], 206 | 'general_phpdoc_tag_rename' => [ 207 | 'case_sensitive' => false, 208 | 'fix_annotation' => true, 209 | 'fix_inline' => true, 210 | 'replacements' => ['inheritDocs' => 'inheritDoc'], 211 | ], 212 | 'get_class_to_class_keyword' => true, 213 | 'global_namespace_import' => [ 214 | 'import_constants' => false, 215 | 'import_functions' => false, 216 | 'import_classes' => true, 217 | ], 218 | 'group_import' => false, 219 | 'header_comment' => false, // false by default 220 | 'heredoc_closing_marker' => false, 221 | 'heredoc_indentation' => ['indentation' => 'start_plus_one'], 222 | 'heredoc_to_nowdoc' => true, 223 | 'implode_call' => true, 224 | 'include' => true, 225 | 'increment_style' => ['style' => 'post'], 226 | 'indentation_type' => true, 227 | 'integer_literal_case' => true, 228 | 'is_null' => true, 229 | 'lambda_not_used_import' => true, 230 | 'line_ending' => true, 231 | 'linebreak_after_opening_tag' => true, 232 | 'list_syntax' => ['syntax' => 'short'], 233 | 'logical_operators' => true, 234 | 'long_to_shorthand_operator' => true, 235 | 'lowercase_cast' => true, 236 | 'lowercase_keywords' => true, 237 | 'lowercase_static_reference' => true, 238 | 'magic_constant_casing' => true, 239 | 'magic_method_casing' => true, 240 | 'mb_str_functions' => false, 241 | 'method_argument_space' => [ 242 | 'keep_multiple_spaces_after_comma' => false, 243 | 'on_multiline' => 'ensure_fully_multiline', 244 | 'after_heredoc' => false, 245 | 'attribute_placement' => 'standalone', 246 | ], 247 | 'method_chaining_indentation' => true, 248 | 'modernize_strpos' => ['modernize_stripos' => true], 249 | 'modernize_types_casting' => true, 250 | 'multiline_comment_opening_closing' => true, 251 | 'multiline_string_to_heredoc' => false, 252 | 'multiline_whitespace_before_semicolons' => ['strategy' => 'no_multi_line'], 253 | 'native_constant_invocation' => false, 254 | 'native_function_casing' => true, 255 | 'native_function_invocation' => false, 256 | 'native_type_declaration_casing' => true, 257 | 'new_with_parentheses' => [ 258 | 'named_class' => true, 259 | 'anonymous_class' => true, 260 | ], 261 | 'no_alias_functions' => ['sets' => ['@all']], 262 | 'no_alias_language_construct_call' => true, 263 | 'no_alternative_syntax' => ['fix_non_monolithic_code' => false], 264 | 'no_binary_string' => true, 265 | 'no_blank_lines_after_class_opening' => true, 266 | 'no_blank_lines_after_phpdoc' => true, 267 | 'no_break_comment' => ['comment_text' => 'no break'], 268 | 'no_closing_tag' => true, 269 | 'no_empty_comment' => true, 270 | 'no_empty_phpdoc' => true, 271 | 'no_empty_statement' => true, 272 | 'no_extra_blank_lines' => [ 273 | 'tokens' => [ 274 | 'attribute', 275 | 'break', 276 | 'case', 277 | 'continue', 278 | 'curly_brace_block', 279 | 'default', 280 | 'extra', 281 | 'parenthesis_brace_block', 282 | 'return', 283 | 'square_brace_block', 284 | 'switch', 285 | 'throw', 286 | 'use', 287 | ], 288 | ], 289 | 'no_homoglyph_names' => true, 290 | 'no_leading_import_slash' => true, 291 | 'no_leading_namespace_whitespace' => true, 292 | 'no_mixed_echo_print' => ['use' => 'echo'], 293 | 'no_multiline_whitespace_around_double_arrow' => true, 294 | 'no_multiple_statements_per_line' => true, 295 | 'no_null_property_initialization' => true, 296 | 'no_php4_constructor' => true, 297 | 'no_short_bool_cast' => true, 298 | 'no_singleline_whitespace_before_semicolons' => true, 299 | 'no_space_around_double_colon' => true, 300 | 'no_spaces_after_function_name' => true, 301 | 'no_spaces_around_offset' => ['positions' => ['inside', 'outside']], 302 | 'no_superfluous_elseif' => true, 303 | 'no_superfluous_phpdoc_tags' => [ 304 | 'allow_hidden_params' => true, 305 | 'allow_mixed' => true, 306 | 'allow_unused_params' => true, 307 | 'remove_inheritdoc' => false, 308 | ], 309 | 'no_trailing_comma_in_singleline' => [ 310 | 'elements' => [ 311 | 'arguments', 312 | 'array_destructuring', 313 | 'array', 314 | 'group_import', 315 | ], 316 | ], 317 | 'no_trailing_whitespace' => true, 318 | 'no_trailing_whitespace_in_comment' => true, 319 | 'no_trailing_whitespace_in_string' => true, 320 | 'no_unneeded_braces' => ['namespaces' => true], 321 | 'no_unneeded_control_parentheses' => [ 322 | 'statements' => [ 323 | 'break', 324 | 'clone', 325 | 'continue', 326 | 'echo_print', 327 | 'return', 328 | 'switch_case', 329 | 'yield', 330 | ], 331 | ], 332 | 'no_unneeded_final_method' => ['private_methods' => true], 333 | 'no_unneeded_import_alias' => true, 334 | 'no_unreachable_default_argument_value' => true, 335 | 'no_unset_cast' => true, 336 | 'no_unset_on_property' => false, 337 | 'no_unused_imports' => true, 338 | 'no_useless_concat_operator' => ['juggle_simple_strings' => true], 339 | 'no_useless_else' => true, 340 | 'no_useless_nullsafe_operator' => true, 341 | 'no_useless_return' => true, 342 | 'no_useless_sprintf' => true, 343 | 'no_whitespace_before_comma_in_array' => ['after_heredoc' => true], 344 | 'no_whitespace_in_blank_line' => true, 345 | 'non_printable_character' => ['use_escape_sequences_in_strings' => true], 346 | 'normalize_index_brace' => true, 347 | 'not_operator_with_space' => false, 348 | 'not_operator_with_successor_space' => true, 349 | 'nullable_type_declaration' => ['syntax' => 'question_mark'], 350 | 'nullable_type_declaration_for_default_null_value' => true, 351 | 'numeric_literal_separator' => false, 352 | 'object_operator_without_whitespace' => true, 353 | 'octal_notation' => false, // requires 8.1+ 354 | 'operator_linebreak' => ['only_booleans' => true, 'position' => 'beginning'], 355 | 'ordered_attributes' => ['order' => [], 'sort_algorithm' => 'alpha'], 356 | 'ordered_class_elements' => [ 357 | 'order' => [ 358 | 'use_trait', 359 | 'case', 360 | 'constant', 361 | 'property', 362 | 'method', 363 | ], 364 | 'sort_algorithm' => 'none', 365 | 'case_sensitive' => false, 366 | ], 367 | 'ordered_imports' => [ 368 | 'sort_algorithm' => 'alpha', 369 | 'imports_order' => ['class', 'function', 'const'], 370 | 'case_sensitive' => false, 371 | ], 372 | 'ordered_interfaces' => false, 373 | 'ordered_traits' => false, 374 | 'ordered_types' => [ 375 | 'null_adjustment' => 'always_last', 376 | 'sort_algorithm' => 'alpha', 377 | 'case_sensitive' => false, 378 | ], 379 | 'php_unit_assert_new_names' => true, 380 | 'php_unit_attributes' => [ 381 | 'keep_annotations' => false, 382 | ], 383 | 'php_unit_construct' => [ 384 | 'assertions' => [ 385 | 'assertSame', 386 | 'assertEquals', 387 | 'assertNotEquals', 388 | 'assertNotSame', 389 | ], 390 | ], 391 | 'php_unit_data_provider_method_order' => [ 392 | 'placement' => 'after', 393 | ], 394 | 'php_unit_data_provider_name' => [ 395 | 'prefix' => 'provide', 396 | 'suffix' => '', 397 | ], 398 | 'php_unit_data_provider_return_type' => true, 399 | 'php_unit_data_provider_static' => ['force' => true], 400 | 'php_unit_dedicate_assert' => ['target' => 'newest'], 401 | 'php_unit_dedicate_assert_internal_type' => ['target' => 'newest'], 402 | 'php_unit_expectation' => ['target' => 'newest'], 403 | 'php_unit_fqcn_annotation' => true, 404 | 'php_unit_internal_class' => ['types' => ['normal', 'final']], 405 | 'php_unit_method_casing' => ['case' => 'camel_case'], 406 | 'php_unit_mock' => ['target' => 'newest'], 407 | 'php_unit_mock_short_will_return' => true, 408 | 'php_unit_namespaced' => ['target' => 'newest'], 409 | 'php_unit_no_expectation_annotation' => [ 410 | 'target' => 'newest', 411 | 'use_class_const' => true, 412 | ], 413 | 'php_unit_set_up_tear_down_visibility' => true, 414 | 'php_unit_size_class' => false, 415 | 'php_unit_strict' => [ 416 | 'assertions' => [ 417 | 'assertAttributeEquals', 418 | 'assertAttributeNotEquals', 419 | 'assertEquals', 420 | 'assertNotEquals', 421 | ], 422 | ], 423 | 'php_unit_test_annotation' => ['style' => 'prefix'], 424 | 'php_unit_test_case_static_method_calls' => [ 425 | 'call_type' => 'this', 426 | 'methods' => [], 427 | ], 428 | 'php_unit_test_class_requires_covers' => false, 429 | 'phpdoc_add_missing_param_annotation' => ['only_untyped' => true], 430 | 'phpdoc_align' => [ 431 | 'align' => 'vertical', 432 | 'spacing' => 1, 433 | 'tags' => [ 434 | 'method', 435 | 'param', 436 | 'phpstan-assert', 437 | 'phpstan-assert-if-true', 438 | 'phpstan-assert-if-false', 439 | 'phpstan-param', 440 | 'phpstan-property', 441 | 'phpstan-return', 442 | 'phpstan-type', 443 | 'phpstan-var', 444 | 'property', 445 | 'property-read', 446 | 'property-write', 447 | 'return', 448 | 'throws', 449 | 'type', 450 | 'var', 451 | ], 452 | ], 453 | 'phpdoc_annotation_without_dot' => false, 454 | 'phpdoc_array_type' => true, 455 | 'phpdoc_indent' => true, 456 | 'phpdoc_inline_tag_normalizer' => [ 457 | 'tags' => [ 458 | 'example', 459 | 'id', 460 | 'internal', 461 | 'inheritdoc', 462 | 'inheritdocs', 463 | 'link', 464 | 'source', 465 | 'toc', 466 | 'tutorial', 467 | ], 468 | ], 469 | 'phpdoc_line_span' => [ 470 | 'const' => 'multi', 471 | 'method' => 'multi', 472 | 'property' => 'multi', 473 | ], 474 | 'phpdoc_list_type' => true, 475 | 'phpdoc_no_access' => true, 476 | 'phpdoc_no_alias_tag' => [ 477 | 'replacements' => [ 478 | 'type' => 'var', 479 | 'link' => 'see', 480 | ], 481 | ], 482 | 'phpdoc_no_empty_return' => false, 483 | 'phpdoc_no_package' => true, 484 | 'phpdoc_no_useless_inheritdoc' => true, 485 | 'phpdoc_order' => [ 486 | 'order' => ['param', 'return', 'throws'], 487 | ], 488 | 'phpdoc_order_by_value' => [ 489 | 'annotations' => [ 490 | 'author', 491 | 'covers', 492 | 'coversNothing', 493 | 'dataProvider', 494 | 'depends', 495 | 'group', 496 | 'internal', 497 | 'method', 498 | 'property', 499 | 'property-read', 500 | 'property-write', 501 | 'requires', 502 | 'throws', 503 | 'uses', 504 | ], 505 | ], 506 | 'phpdoc_param_order' => false, 507 | 'phpdoc_readonly_class_comment_to_keyword' => false, 508 | 'phpdoc_return_self_reference' => [ 509 | 'replacements' => [ 510 | 'this' => '$this', 511 | '@this' => '$this', 512 | '$self' => 'self', 513 | '@self' => 'self', 514 | '$static' => 'static', 515 | '@static' => 'static', 516 | ], 517 | ], 518 | 'phpdoc_scalar' => [ 519 | 'types' => [ 520 | 'boolean', 521 | 'callback', 522 | 'double', 523 | 'integer', 524 | 'real', 525 | 'str', 526 | ], 527 | ], 528 | 'phpdoc_separation' => [ 529 | 'groups' => [ 530 | ['immutable', 'psalm-immutable'], 531 | ['param', 'phpstan-param', 'psalm-param'], 532 | ['phpstan-pure', 'psalm-pure'], 533 | ['readonly', 'psalm-readonly'], 534 | ['return', 'phpstan-return', 'psalm-return'], 535 | ['runTestsInSeparateProcess', 'runInSeparateProcess', 'preserveGlobalState'], 536 | ['template', 'phpstan-template', 'psalm-template'], 537 | ['template-covariant', 'phpstan-template-covariant', 'psalm-template-covariant'], 538 | ['phpstan-type', 'psalm-type'], 539 | ['var', 'phpstan-var', 'psalm-var'], 540 | ], 541 | 'skip_unlisted_annotations' => true, 542 | ], 543 | 'phpdoc_single_line_var_spacing' => true, 544 | 'phpdoc_summary' => false, 545 | 'phpdoc_tag_casing' => ['tags' => ['inheritDoc']], 546 | 'phpdoc_tag_type' => ['tags' => ['inheritDoc' => 'inline']], 547 | 'phpdoc_to_comment' => false, 548 | 'phpdoc_to_param_type' => false, 549 | 'phpdoc_to_property_type' => false, 550 | 'phpdoc_to_return_type' => false, 551 | 'phpdoc_trim' => true, 552 | 'phpdoc_trim_consecutive_blank_line_separation' => true, 553 | 'phpdoc_types' => ['groups' => ['simple', 'alias', 'meta']], 554 | 'phpdoc_types_order' => [ 555 | 'null_adjustment' => 'always_last', 556 | 'sort_algorithm' => 'alpha', 557 | 'case_sensitive' => false, 558 | ], 559 | 'phpdoc_var_annotation_correct_order' => true, 560 | 'phpdoc_var_without_name' => true, 561 | 'pow_to_exponentiation' => true, 562 | 'protected_to_private' => true, 563 | 'psr_autoloading' => ['dir' => null], 564 | 'random_api_migration' => [ 565 | 'replacements' => [ 566 | 'getrandmax' => 'mt_getrandmax', 567 | 'rand' => 'mt_rand', 568 | 'srand' => 'mt_srand', 569 | ], 570 | ], 571 | 'regular_callable_call' => true, 572 | 'return_assignment' => true, 573 | 'return_to_yield_from' => false, 574 | 'return_type_declaration' => ['space_before' => 'none'], 575 | 'self_accessor' => false, 576 | 'self_static_accessor' => true, 577 | 'semicolon_after_instruction' => false, 578 | 'set_type_to_cast' => true, 579 | 'short_scalar_cast' => true, 580 | 'simple_to_complex_string_variable' => true, 581 | 'simplified_if_return' => true, 582 | 'simplified_null_return' => false, 583 | 'single_blank_line_at_eof' => true, 584 | 'single_class_element_per_statement' => ['elements' => ['const', 'property']], 585 | 'single_import_per_statement' => ['group_to_single_imports' => true], 586 | 'single_line_after_imports' => true, 587 | 'single_line_comment_spacing' => true, 588 | 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']], 589 | 'single_line_empty_body' => false, 590 | 'single_line_throw' => false, 591 | 'single_quote' => ['strings_containing_single_quote_chars' => false], 592 | 'single_space_around_construct' => [ 593 | 'constructs_contain_a_single_space' => ['yield_from'], 594 | 'constructs_preceded_by_a_single_space' => ['use_lambda'], 595 | 'constructs_followed_by_a_single_space' => [ 596 | 'abstract', 597 | 'as', 598 | 'attribute', 599 | 'break', 600 | 'case', 601 | 'catch', 602 | 'class', 603 | 'clone', 604 | 'comment', 605 | 'const', 606 | 'const_import', 607 | 'continue', 608 | 'do', 609 | 'echo', 610 | 'else', 611 | 'elseif', 612 | 'enum', 613 | 'extends', 614 | 'final', 615 | 'finally', 616 | 'for', 617 | 'foreach', 618 | 'function', 619 | 'function_import', 620 | 'global', 621 | 'goto', 622 | 'if', 623 | 'implements', 624 | 'include', 625 | 'include_once', 626 | 'instanceof', 627 | 'insteadof', 628 | 'interface', 629 | 'match', 630 | 'named_argument', 631 | 'namespace', 632 | 'new', 633 | 'open_tag_with_echo', 634 | 'php_doc', 635 | 'php_open', 636 | 'print', 637 | 'private', 638 | 'protected', 639 | 'public', 640 | 'readonly', 641 | 'require', 642 | 'require_once', 643 | 'return', 644 | 'static', 645 | 'switch', 646 | 'throw', 647 | 'trait', 648 | 'try', 649 | 'type_colon', 650 | 'use', 651 | 'use_lambda', 652 | 'use_trait', 653 | 'var', 654 | 'while', 655 | 'yield', 656 | 'yield_from', 657 | ], 658 | ], 659 | 'single_trait_insert_per_statement' => true, 660 | 'space_after_semicolon' => ['remove_in_empty_for_expressions' => true], 661 | 'spaces_inside_parentheses' => ['space' => 'none'], 662 | 'standardize_increment' => true, 663 | 'standardize_not_equals' => true, 664 | 'statement_indentation' => ['stick_comment_to_next_continuous_control_statement' => false], 665 | 'static_lambda' => true, 666 | 'strict_comparison' => true, 667 | 'strict_param' => true, 668 | 'string_implicit_backslashes' => [ 669 | 'double_quoted' => 'escape', 670 | 'heredoc' => 'escape', 671 | 'single_quoted' => 'ignore', 672 | ], 673 | 'string_length_to_empty' => true, 674 | 'string_line_ending' => true, 675 | 'switch_case_semicolon_to_colon' => true, 676 | 'switch_case_space' => true, 677 | 'switch_continue_to_break' => true, 678 | 'ternary_operator_spaces' => true, 679 | 'ternary_to_elvis_operator' => true, 680 | 'ternary_to_null_coalescing' => true, 681 | 'trailing_comma_in_multiline' => [ 682 | 'after_heredoc' => true, 683 | 'elements' => [ 684 | 'arguments', 685 | 'array_destructuring', 686 | 'arrays', 687 | 'match', 688 | 'parameters', 689 | ], 690 | ], 691 | 'trim_array_spaces' => true, 692 | 'type_declaration_spaces' => ['elements' => ['function', 'property']], 693 | 'types_spaces' => [ 694 | 'space' => 'none', 695 | 'space_multiple_catch' => 'none', 696 | ], 697 | 'unary_operator_spaces' => ['only_dec_inc' => false], 698 | 'use_arrow_functions' => true, 699 | 'visibility_required' => ['elements' => ['const', 'method', 'property']], 700 | 'void_return' => false, // changes method signature 701 | 'whitespace_after_comma_in_array' => ['ensure_single_space' => true], 702 | 'yield_from_array_to_yields' => false, 703 | 'yoda_style' => [ 704 | 'equal' => false, 705 | 'identical' => null, 706 | 'less_and_greater' => false, 707 | 'always_move_variable' => false, 708 | ], 709 | ]; 710 | 711 | $this->requiredPHPVersion = 80100; 712 | 713 | $this->autoActivateIsRiskyAllowed = true; 714 | } 715 | } 716 | --------------------------------------------------------------------------------