forked from barryvdh/laravel-ide-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CODESTYLE] Replace phpcs with php-cs-fixer (barryvdh#1030)
* composer require --dev friendsofphp/php-cs-fixer:^2 * php-cs-fixer: ignore cache and custom local config file * php-cs-fixer: initial config * php-cs-fixer: replace commands in composer * php-cs-fixer: add PSR12 "as good as it currently gets" * php-cs-fixer: apply PSR12 to codebase * tests: add workaround to keep unused imports for snapshot testing * php-cs-fixer: apply no_unused_imports * php-cs-fixer: apply array_syntax short * php-cs-fixer: apply single_quote * php-cs-fixer: switch ordered_imports sort_algorithm to alpha Let's be opinionated here for consistency * php-cs-fixer: split between non-tests and tests and share config * php-cs-fixer: apply declare_strict_types for tests * php-cs-fixer: apply fully_qualified_strict_types * php-cs-fixer: apply space_after_semicolon * php-cs-fixer: apply trailing_comma_in_multiline_array * php-cs-fixer: apply trim_array_spaces * php-cs-fixer: apply unary_operator_spaces * php-cs-fixer: apply whitespace_after_comma_in_array * php-cs-fixer: apply native_function_invocation * php-cs-fixer: apply concat_space * grumphp: reflect we're using phpcsfixer now * composer remove --dev squizlabs/php_codesniffer * gha: simplify fix-style approach Not really necessary to remove packages and then manually prevent unrelated commits creeping in Co-authored-by: Barry vd. Heuvel <[email protected]>
- Loading branch information
Showing
55 changed files
with
308 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
.phpunit.result.cache | ||
|
||
/.idea | ||
/.php_cs | ||
/.php_cs.cache | ||
/.php_cs.tests.cache | ||
/composer.lock | ||
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
// Share common rules between non-test and test files | ||
return [ | ||
// PSR12 from https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/4943 | ||
'@PSR2' => true, | ||
'blank_line_after_opening_tag' => true, | ||
'braces' => [ | ||
// Not-yet-implemented | ||
// 'allow_single_line_anonymous_class_with_empty_body' => true, | ||
], | ||
'compact_nullable_typehint' => true, | ||
'declare_equal_normalize' => true, | ||
'lowercase_cast' => true, | ||
'lowercase_static_reference' => true, | ||
'new_with_braces' => true, | ||
'no_blank_lines_after_class_opening' => true, | ||
'no_leading_import_slash' => true, | ||
'no_whitespace_in_blank_line' => true, | ||
'ordered_class_elements' => [ | ||
'order' => [ | ||
'use_trait', | ||
], | ||
], | ||
'ordered_imports' => [ | ||
'imports_order' => [ | ||
'class', | ||
'function', | ||
'const', | ||
], | ||
'sort_algorithm' => 'alpha', | ||
], | ||
'return_type_declaration' => true, | ||
'short_scalar_cast' => true, | ||
'single_blank_line_before_namespace' => true, | ||
'single_trait_insert_per_statement' => true, | ||
'ternary_operator_spaces' => true, | ||
'visibility_required' => [ | ||
'elements' => [ | ||
'const', | ||
'method', | ||
'property', | ||
], | ||
], | ||
|
||
// Further quality-of-life improvements | ||
'array_syntax' => [ | ||
'syntax' => 'short', | ||
], | ||
'concat_space' => [ | ||
'spacing' => 'one', | ||
], | ||
'fully_qualified_strict_types' => true, | ||
'native_function_invocation' => [ | ||
'include' => [], | ||
'strict' => true, | ||
], | ||
'no_unused_imports' => true, | ||
'single_quote' => true, | ||
'space_after_semicolon' => true, | ||
'trailing_comma_in_multiline_array' => true, | ||
'trim_array_spaces' => true, | ||
'unary_operator_spaces' => true, | ||
'whitespace_after_comma_in_array' => true, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__) | ||
->exclude('tests'); | ||
|
||
$config = require __DIR__ . '/.php_cs.common.php'; | ||
|
||
return PhpCsFixer\Config::create() | ||
->setFinder($finder) | ||
->setRules($config) | ||
->setRiskyAllowed(true) | ||
->setCacheFile(__DIR__ . '/.php_cs.cache'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
$finder = PhpCsFixer\Finder::create() | ||
->in(__DIR__ . '/tests') | ||
->exclude('__snapshots__'); | ||
|
||
$config = require __DIR__ . '/.php_cs.common.php'; | ||
|
||
// Additional rules for tests | ||
$config = array_merge( | ||
$config, | ||
[ | ||
'declare_strict_types' => true, | ||
] | ||
); | ||
|
||
return PhpCsFixer\Config::create() | ||
->setFinder($finder) | ||
->setRules($config) | ||
->setRiskyAllowed(true) | ||
->setCacheFile(__DIR__ . '/.php_cs.tests.cache'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.