├── .php-cs-fixer.dist.php ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── UPGRADE.md ├── composer.json ├── config └── .php-cs-fixer.dist.php └── src ├── Config.php └── ServiceProvider.php /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | setFinder( 7 | PhpCsFixer\Finder::create()->in(__DIR__) 8 | ); 9 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes will be documented in this file. 4 | 5 | Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. 6 | 7 | ## Unreleased 8 | 9 | ### Added 10 | ### Changed 11 | ### Removed 12 | 13 | ## 2.18.0 14 | ### Changed 15 | 16 | - Support Laravel 12 17 | - Add no_unneeded_import_alias rule (see [laravel/pint#334](https://github.com/laravel/pint/pull/334)) 18 | 19 | ## 2.17.0 20 | ### Changed 21 | 22 | - Enforce single_line_command_spacing rule (see [laravel/pint#315](https://github.com/laravel/pint/pull/315)) 23 | 24 | ## 2.16.0 25 | ### Changed 26 | 27 | - Enforce snake_case methods for PHPUnit method (see [laravel/pint#300](https://github.com/laravel/pint/pull/300)) 28 | - Enforce visibility for PHPUnit setUp and tearDown methods (see [laravel/pint#301](https://github.com/laravel/pint/pull/301)) 29 | 30 | ## 2.15.0 31 | ### Changed 32 | 33 | - Add/Configure new_with_parentheses rule (see [laravel/pint#285](https://github.com/laravel/pint/pull/285)) 34 | 35 | ## 2.14.0 36 | ### Changed 37 | 38 | - Enable single_line_empty_body rule (see [laravel/pint#277](https://github.com/laravel/pint/pull/277)) 39 | 40 | ## 2.13.0 41 | ### Changed 42 | 43 | - Replace custom phpdoc_align rule with php-cs-fixer option (see [laravel/pint#242](https://github.com/laravel/pint/pull/242)) 44 | 45 | ## 2.12.0 46 | ### Changed 47 | 48 | - Adds support for Laravel 11 49 | 50 | ## 2.11.0 51 | ### Changed 52 | 53 | - Disables fully_qualified_strict_types (see [laravel/pint#240](https://github.com/laravel/pint/pull/240)) 54 | 55 | ## 2.10.0 56 | ### Changed 57 | 58 | - Change default for nullable_type_declaration_for_default_null_value (see [laravel/pint#236](https://github.com/laravel/pint/pull/236)) 59 | 60 | ## 2.9.0 61 | ### Changed 62 | 63 | - Replace deprecated rules (see [laravel/pint#224](https://github.com/laravel/pint/pull/224)) 64 | 65 | ## 2.8.1 66 | ### Changed 67 | 68 | - Fixes non yoda_style rule moving variables (see [laravel/pint#213](https://github.com/laravel/pint/pull/213)) 69 | 70 | ## 2.7.0 71 | ### Changed 72 | 73 | - Orders interfaces and traits (see [laravel/pint#206](https://github.com/laravel/pint/pull/206)) 74 | - Sort fixers by name (see [laravel/pint#207](https://github.com/laravel/pint/pull/207)) 75 | 76 | ## 2.6.0 77 | ### Changed 78 | 79 | - Improves imports when using functions (see [laravel/pint#205](https://github.com/laravel/pint/pull/205)) 80 | 81 | ## 2.5.1 82 | 83 | ### Fixed 84 | 85 | - Remove deprecated function_typehint_space rule (see [laravel/pint#197](https://github.com/laravel/pint/pull/197)) 86 | 87 | ## 2.5.0 88 | 89 | ### Added 90 | 91 | - Bump PHP-CS-Fixer to `^3.21` 92 | - Enable nullable_type_declaration_for_default_null_value fixer (see [laravel/pint#192](https://github.com/laravel/pint/pull/192)) 93 | - Enable nullable_type_declaration fixer (see [laravel/pint#193](https://github.com/laravel/pint/pull/193)) 94 | - Enable type_declaration_spaces fixer (see [laravel/pint#194](https://github.com/laravel/pint/pull/194)) 95 | 96 | 97 | ## 2.4.1 98 | 99 | ### Changed 100 | 101 | - Bump PHP-CS-Fixer to `^3.18` 102 | - Replace deprecated rule [`single_blank_line_before_namespace`](https://cs.symfony.com/doc/rules/namespace_notation/single_blank_line_before_namespace.html) with newer [`blank_lines_before_namespace`](https://cs.symfony.com/doc/rules/namespace_notation/blank_lines_before_namespace.html) 103 | 104 | ## 2.4.0 105 | 106 | ### Changed 107 | 108 | - Enable statement_indentation fixer (see [laravel/pint#178](https://github.com/laravel/pint/pull/178)) 109 | 110 | ## 2.3.0 111 | 112 | ### Added 113 | 114 | - Enable method_chaining_indentation fixer 115 | 116 | ## 2.2.0 117 | 118 | ### Changed 119 | 120 | - Replace deprecated braces rule 121 | 122 | ## 2.1.0 123 | 124 | ### Added 125 | 126 | - Enable self_static_accessor fixer 127 | 128 | ## 2.0.1 129 | 130 | ### Changed 131 | 132 | - Updated texts in the documentation 133 | 134 | ### Fixed 135 | 136 | - Include `php-cs-fixer.dist.php` again 137 | 138 | ### Removed 139 | 140 | - Removed Grouping of Rules `@Laravel` and `@Laravel:risky` 141 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Julius Kiekbusch 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 13 | > all 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 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | Laravel Code Style 3 |

4 | 5 |

6 | Combine Custom Fixers with the ruleset of Laravel Pint 7 |

8 | 9 |

10 | GitHub Workflow Status 11 | Downloads Total 12 | License Type 13 | Latest released version 14 |

15 | 16 |

17 | Supports Laravel 9.x and 10.x 18 | Supports PHP 8.0, 8.1 and 8.2 19 |

20 | 21 | ## Introduction 22 | 23 | This package provides automatic code style checking and formatting for Laravel applications and packages using the same ruleset as [Laravel Pint](https://github.com/laravel/pint). This package is built on top of [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer) and therefor gives you the ability to add custom fixers. (which is one of the shortcomings of Laravel Pint) 24 | 25 | ## Installation 26 | 27 | ```shell 28 | composer require jubeki/laravel-code-style --dev 29 | ``` 30 | 31 | Once the package is installed you should publish the configuration. 32 | 33 | ```shell 34 | php artisan vendor:publish --provider="Jubeki\LaravelCodeStyle\ServiceProvider" 35 | ``` 36 | 37 | Publishing the config will add a `.php-cs-fixer.dist.php` configuration file to the root of your project. You may customize this file as needed and then commit it to your version control system. 38 | 39 | A cache file will be written to `.php-cs-fixer.cache` in the project root the first time you run the fixer. You should ignore this file so it is not added to your version control system. 40 | 41 | ```shell 42 | echo '.php-cs-fixer.cache' >> .gitignore 43 | ``` 44 | 45 | ## Usage 46 | 47 | Once the package is installed you can check and fix your code formatting with the on subcommand of `vendor/bin/php-cs-fixer`. 48 | 49 | ### Automatically fix the code style 50 | 51 | To automatically fix the code style of your project you may use the following command: 52 | 53 | ```shell 54 | vendor/bin/php-cs-fixer fix 55 | ``` 56 | 57 | By default only the file names of every file fixed will be shown. To see a full diff of every change append the `--diff` flag. 58 | 59 | ### Checking for code style violations 60 | 61 | If you would like to check the formatting without actually altering any files you should use the `fix` command with the `--dry-run` flag. 62 | 63 | ```shell 64 | vendor/bin/php-cs-fixer fix --dry-run --diff 65 | ``` 66 | 67 | In dry-run mode any violations will [cause the command to return a non-zero exit code](https://github.com/FriendsOfPhp/PHP-CS-Fixer#exit-code). You can use this command to fail a CI build or git commit hook. 68 | 69 | ### Composer script 70 | 71 | To make checking and fixing code style easier for contributors to your project it's recommended to add the commands as a [composer script](https://getcomposer.org/doc/articles/scripts.md): 72 | 73 | ```json 74 | { 75 | "scripts": { 76 | "check-style": "php-cs-fixer fix --dry-run --diff", 77 | "fix-style": "php-cs-fixer fix" 78 | } 79 | } 80 | ``` 81 | 82 | ### More Options 83 | 84 | For a complete list of options please consult the [PHP-CS-Fixer documentation](https://github.com/FriendsOfPhp/PHP-CS-Fixer#usage). 85 | 86 | ## Configuration 87 | 88 | The default configuration is published as `.php-cs-fixer.dist.php` in the project root. You can customize this file to change options such as the paths searched or the fixes applied. 89 | 90 | ### Paths 91 | 92 | You can change the paths searched for PHP files by chaining method calls onto the `PhpCsFixer\Finder` instance being passed to the `Jubeki\LaravelCodeStyle\Config::setFinder` method. 93 | 94 | For example, to search the `examples` directory you would append `->in('examples')`: 95 | 96 | ```php 97 | setFinder( 103 | PhpCsFixer\Finder::create() 104 | ->in(app_path()) 105 | // ... 106 | ->in('examples') 107 | ) 108 | // ... 109 | 110 | ``` 111 | 112 | The default paths are setup for a Laravel application. If you are writing a package the path helper functions will not available and you will need to change the paths as necessary, i.e. `PhpCsFixer\Finder::create()->in(__DIR__)`. 113 | 114 | For a complete list of options refer to the [Symfony Finder documentation](https://symfony.com/doc/current/components/finder.html). 115 | 116 | ### Rules 117 | 118 | By default only the Laravel Pint preset is enabled. This preset enforces many different rules which can be found in [Jubeki\LaravelCodeStyle\Config](src/Config.php) 119 | 120 | It is possible to override a specific rule from the preset. For example, you could disable the `no_unused_imports` rule like this: 121 | 122 | ```php 123 | return (new Jubeki\LaravelCodeStyle\Config()) 124 | ->setFinder( 125 | // ... 126 | ) 127 | ->setRules([ 128 | 'no_unused_imports' => false, 129 | ]); 130 | ``` 131 | 132 | For a complete list of available rules please refer to the [php-cs-fixer documentation](https://github.com/FriendsOfPhp/PHP-CS-Fixer#usage). 133 | 134 | ## Releases 135 | 136 | A major version bump only occurs should there be a big change to the Laravel Pint project. 137 | 138 | Otherwise each rule change according to Laravel Pint is only a minor version bump. (This means there can be rules added, changed or removed). 139 | 140 | ## Changelog 141 | 142 | Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. 143 | 144 | ## Testing 145 | 146 | ``` bash 147 | $ composer test 148 | ``` 149 | 150 | ## Contributing 151 | 152 | Please see [CONTRIBUTING](./.github/CONTRIBUTING.md) for details. 153 | 154 | ## Credits 155 | 156 | - [Julius Kiekbusch](https://github.com/Jubeki) 157 | - [Matt Allan](https://github.com/matt-allan) (Original Creator) 158 | - [All Contributors](../../contributors) 159 | 160 | ## License 161 | 162 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 163 | -------------------------------------------------------------------------------- /UPGRADE.md: -------------------------------------------------------------------------------- 1 | # Upgrade Guide from 1.x to 2.x 2 | 3 | This major version is for changing the preset from StyleCI to Laravel Pint. 4 | 5 | ## Update `composer.json` 6 | 7 | Change the version constraints of `jubeki/laravel-code-style` to `^2.0`. 8 | 9 | ## Update `.php-cs-fixer.dist.php` 10 | 11 | There are some small changes to the configuration of PHP-CS-Fixer. 12 | 13 | It is no longer possible to set `@Laravel` or `@Laravel:risky`. Instead the rules from Laravel Pint will be enabled by default. You can still overwrite the rules with new values as before. 14 | 15 | The default Configuration looks like this now: 16 | 17 | ```php 18 | setFinder( 25 | PhpCsFixer\Finder::create() 26 | ->notName('*.blade.php') 27 | ->in(app_path()) 28 | ->in(config_path()) 29 | ->in(database_path('factories')) 30 | ->in(database_path('migrations')) 31 | ->in(database_path('seeders')) 32 | ->in(lang_path()) 33 | ->in(base_path('routes')) 34 | ->in(base_path('tests')) 35 | ) 36 | ->setRules([ 37 | // Here you can adjust the rules as much as needed 38 | ]); 39 | ``` 40 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jubeki/laravel-code-style", 3 | "description": "Combine Custom Fixers with the ruleset of Laravel Pint to fix your code style in Laravel Applications/Packages.", 4 | "type": "library", 5 | "license": "MIT", 6 | "homepage": "https://github.com/Jubeki/laravel-code-style", 7 | "authors": [ 8 | { 9 | "name": "Julius Kiekbusch", 10 | "email": "contact@julius-kiekbusch.de" 11 | }, 12 | { 13 | "name": "Matt Allan", 14 | "email": "matt@mattallan.me" 15 | } 16 | ], 17 | "keywords": [ 18 | "laravel", 19 | "pint", 20 | "code-style", 21 | "php-cs-fixer", 22 | "custom-fixers" 23 | ], 24 | "autoload": { 25 | "psr-4": { 26 | "Jubeki\\LaravelCodeStyle\\": "src" 27 | } 28 | }, 29 | "require": { 30 | "php": "^8.0", 31 | "friendsofphp/php-cs-fixer": "^3.47", 32 | "illuminate/support": "^9.34 || ^10.0 || ^11.0 || ^12.0" 33 | }, 34 | "require-dev": { 35 | "orchestra/testbench": "^8.0 || ^9.0 || ^10.0", 36 | "phpunit/phpunit": "^10.4.1 || ^11.0" 37 | }, 38 | "extra": { 39 | "laravel": { 40 | "providers": [ 41 | "Jubeki\\LaravelCodeStyle\\ServiceProvider" 42 | ] 43 | } 44 | }, 45 | "scripts": { 46 | "test": [ 47 | "rm -rf laravel", 48 | "git clone https://github.com/laravel/laravel.git --single-branch --depth 1", 49 | "phpunit" 50 | ], 51 | "check-style": "php-cs-fixer fix --dry-run --diff", 52 | "fix-style": "php-cs-fixer fix" 53 | }, 54 | "config": { 55 | "sort-packages": true 56 | }, 57 | "minimum-stability": "dev", 58 | "prefer-stable": true 59 | } 60 | -------------------------------------------------------------------------------- /config/.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | setFinder( 8 | PhpCsFixer\Finder::create() 9 | ->notName('*.blade.php') 10 | ->in(app_path()) 11 | ->in(config_path()) 12 | ->in(database_path('factories')) 13 | ->in(database_path('migrations')) 14 | ->in(database_path('seeders')) 15 | ->in(lang_path()) 16 | ->in(base_path('routes')) 17 | ->in(base_path('tests')) 18 | ) 19 | ->setRules([ 20 | // Here you can adjust the rules as much as needed 21 | ]); 22 | -------------------------------------------------------------------------------- /src/Config.php: -------------------------------------------------------------------------------- 1 | true, 18 | 'array_syntax' => ['syntax' => 'short'], 19 | 'binary_operator_spaces' => [ 20 | 'default' => 'single_space', 21 | ], 22 | 'blank_line_after_namespace' => true, 23 | 'blank_line_after_opening_tag' => true, 24 | 'blank_line_before_statement' => [ 25 | 'statements' => [ 26 | 'continue', 27 | 'return', 28 | ], 29 | ], 30 | 'blank_line_between_import_groups' => true, 31 | 'blank_lines_before_namespace' => true, 32 | 'braces_position' => [ 33 | 'control_structures_opening_brace' => 'same_line', 34 | 'functions_opening_brace' => 'next_line_unless_newline_at_signature_end', 35 | 'anonymous_functions_opening_brace' => 'same_line', 36 | 'classes_opening_brace' => 'next_line_unless_newline_at_signature_end', 37 | 'anonymous_classes_opening_brace' => 'next_line_unless_newline_at_signature_end', 38 | 'allow_single_line_empty_anonymous_classes' => false, 39 | 'allow_single_line_anonymous_functions' => false, 40 | ], 41 | 'cast_spaces' => true, 42 | 'class_attributes_separation' => [ 43 | 'elements' => [ 44 | 'const' => 'one', 45 | 'method' => 'one', 46 | 'property' => 'one', 47 | 'trait_import' => 'none', 48 | ], 49 | ], 50 | 'class_definition' => [ 51 | 'multi_line_extends_each_single_line' => true, 52 | 'single_item_single_line' => true, 53 | 'single_line' => true, 54 | ], 55 | 'clean_namespace' => true, 56 | 'compact_nullable_type_declaration' => true, 57 | 'concat_space' => [ 58 | 'spacing' => 'none', 59 | ], 60 | 'constant_case' => ['case' => 'lower'], 61 | 'control_structure_braces' => true, 62 | 'control_structure_continuation_position' => [ 63 | 'position' => 'same_line', 64 | ], 65 | 'declare_equal_normalize' => true, 66 | 'declare_parentheses' => true, 67 | 'elseif' => true, 68 | 'encoding' => true, 69 | 'full_opening_tag' => true, 70 | 'fully_qualified_strict_types' => false, 71 | 'function_declaration' => true, 72 | 'general_phpdoc_tag_rename' => true, 73 | 'heredoc_to_nowdoc' => true, 74 | 'include' => true, 75 | 'increment_style' => ['style' => 'post'], 76 | 'indentation_type' => true, 77 | 'integer_literal_case' => true, 78 | 'lambda_not_used_import' => true, 79 | 'line_ending' => true, 80 | 'linebreak_after_opening_tag' => true, 81 | 'list_syntax' => true, 82 | 'lowercase_cast' => true, 83 | 'lowercase_keywords' => true, 84 | 'lowercase_static_reference' => true, 85 | 'magic_constant_casing' => true, 86 | 'magic_method_casing' => true, 87 | 'method_argument_space' => [ 88 | 'on_multiline' => 'ignore', 89 | ], 90 | 'method_chaining_indentation' => true, 91 | 'multiline_whitespace_before_semicolons' => [ 92 | 'strategy' => 'no_multi_line', 93 | ], 94 | 'native_function_casing' => true, 95 | 'native_type_declaration_casing' => true, 96 | 'new_with_parentheses' => [ 97 | 'named_class' => false, 98 | 'anonymous_class' => false, 99 | ], 100 | 'no_alias_functions' => true, 101 | 'no_alias_language_construct_call' => true, 102 | 'no_alternative_syntax' => true, 103 | 'no_binary_string' => true, 104 | 'no_blank_lines_after_class_opening' => true, 105 | 'no_blank_lines_after_phpdoc' => true, 106 | 'no_closing_tag' => true, 107 | 'no_empty_phpdoc' => true, 108 | 'no_empty_statement' => true, 109 | 'no_extra_blank_lines' => [ 110 | 'tokens' => [ 111 | 'extra', 112 | 'throw', 113 | 'use', 114 | ], 115 | ], 116 | 'no_leading_import_slash' => true, 117 | 'no_leading_namespace_whitespace' => true, 118 | 'no_mixed_echo_print' => [ 119 | 'use' => 'echo', 120 | ], 121 | 'no_multiline_whitespace_around_double_arrow' => true, 122 | 'no_multiple_statements_per_line' => true, 123 | 'no_short_bool_cast' => true, 124 | 'no_singleline_whitespace_before_semicolons' => true, 125 | 'no_space_around_double_colon' => true, 126 | 'no_spaces_after_function_name' => true, 127 | 'no_spaces_around_offset' => [ 128 | 'positions' => ['inside', 'outside'], 129 | ], 130 | 'no_superfluous_phpdoc_tags' => [ 131 | 'allow_mixed' => true, 132 | 'allow_unused_params' => true, 133 | ], 134 | 'no_trailing_comma_in_singleline' => true, 135 | 'no_trailing_whitespace' => true, 136 | 'no_trailing_whitespace_in_comment' => true, 137 | 'no_unneeded_control_parentheses' => [ 138 | 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'], 139 | ], 140 | 'no_unneeded_braces' => true, 141 | 'no_unneeded_import_alias' => true, 142 | 'no_unreachable_default_argument_value' => true, 143 | 'no_unset_cast' => true, 144 | 'no_unused_imports' => true, 145 | 'no_useless_return' => true, 146 | 'no_whitespace_before_comma_in_array' => true, 147 | 'no_whitespace_in_blank_line' => true, 148 | 'normalize_index_brace' => true, 149 | 'not_operator_with_successor_space' => true, 150 | 'nullable_type_declaration' => true, 151 | 'nullable_type_declaration_for_default_null_value' => true, 152 | 'object_operator_without_whitespace' => true, 153 | 'ordered_imports' => ['sort_algorithm' => 'alpha', 'imports_order' => ['const', 'class', 'function']], 154 | 'ordered_interfaces' => true, 155 | 'ordered_traits' => true, 156 | 'php_unit_method_casing' => ['case' => 'snake_case'], 157 | 'php_unit_set_up_tear_down_visibility' => true, 158 | 'phpdoc_align' => [ 159 | 'align' => 'left', 160 | 'spacing' => [ 161 | 'param' => 2, 162 | ], 163 | ], 164 | 'phpdoc_indent' => true, 165 | 'phpdoc_inline_tag_normalizer' => true, 166 | 'phpdoc_no_access' => true, 167 | 'phpdoc_no_package' => true, 168 | 'phpdoc_no_useless_inheritdoc' => true, 169 | 'phpdoc_order' => [ 170 | 'order' => ['param', 'return', 'throws'], 171 | ], 172 | 'phpdoc_scalar' => true, 173 | 'phpdoc_separation' => [ 174 | 'groups' => [ 175 | ['deprecated', 'link', 'see', 'since'], 176 | ['author', 'copyright', 'license'], 177 | ['category', 'package', 'subpackage'], 178 | ['property', 'property-read', 'property-write'], 179 | ['param', 'return'], 180 | ], 181 | ], 182 | 'phpdoc_single_line_var_spacing' => true, 183 | 'phpdoc_summary' => false, 184 | 'phpdoc_tag_type' => [ 185 | 'tags' => [ 186 | 'inheritdoc' => 'inline', 187 | ], 188 | ], 189 | 'phpdoc_to_comment' => false, 190 | 'phpdoc_trim' => true, 191 | 'phpdoc_types' => true, 192 | 'phpdoc_var_without_name' => true, 193 | 'psr_autoloading' => false, 194 | 'return_type_declaration' => ['space_before' => 'none'], 195 | 'self_accessor' => false, 196 | 'self_static_accessor' => true, 197 | 'short_scalar_cast' => true, 198 | 'simplified_null_return' => false, 199 | 'single_blank_line_at_eof' => true, 200 | 'single_class_element_per_statement' => [ 201 | 'elements' => ['const', 'property'], 202 | ], 203 | 'single_import_per_statement' => true, 204 | 'single_line_after_imports' => true, 205 | 'single_line_comment_spacing' => true, 206 | 'single_line_comment_style' => [ 207 | 'comment_types' => ['hash'], 208 | ], 209 | 'single_line_empty_body' => true, 210 | 'single_quote' => true, 211 | 'single_space_around_construct' => true, 212 | 'space_after_semicolon' => true, 213 | 'spaces_inside_parentheses' => true, 214 | 'standardize_not_equals' => true, 215 | 'statement_indentation' => true, 216 | 'switch_case_semicolon_to_colon' => true, 217 | 'switch_case_space' => true, 218 | 'ternary_operator_spaces' => true, 219 | 'trailing_comma_in_multiline' => ['elements' => ['arrays']], 220 | 'trim_array_spaces' => true, 221 | 'type_declaration_spaces' => true, 222 | 'types_spaces' => true, 223 | 'unary_operator_spaces' => true, 224 | 'visibility_required' => [ 225 | 'elements' => ['method', 'property'], 226 | ], 227 | 'whitespace_after_comma_in_array' => true, 228 | 'yoda_style' => [ 229 | 'always_move_variable' => false, 230 | 'equal' => false, 231 | 'identical' => false, 232 | 'less_and_greater' => false, 233 | ], 234 | ]; 235 | 236 | public function __construct($name = 'Laravel') 237 | { 238 | parent::__construct($name); 239 | 240 | $this->setRules(); 241 | $this->setRiskyAllowed(true); 242 | } 243 | 244 | public function setRules(array $rules = []): ConfigInterface 245 | { 246 | return parent::setRules( 247 | array_merge(self::RULE_DEFINITIONS, $rules) 248 | ); 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/ServiceProvider.php: -------------------------------------------------------------------------------- 1 | publishes([ 14 | __DIR__.'/../config/.php-cs-fixer.dist.php' => base_path('.php-cs-fixer.dist.php'), 15 | ], 'config'); 16 | } 17 | } 18 | --------------------------------------------------------------------------------