Skip to content

Commit

Permalink
Bump php-cs-fixer to v3.0 (#16)
Browse files Browse the repository at this point in the history
-  Bump php cs fixer to v3.0
-  Update rules
-  Rename .php_cs to .php-cs-fixer.php
-  Add visibility_required only for properties and methods
-  Add empty line
-  Update CODEOWNERS
- Update .gitignore
  • Loading branch information
pedropacheco-kununu authored Aug 19, 2021
1 parent 08f2c32 commit 1bf65df
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
* @tiagopinheiro-kununu @hugo-goncalves-kununu @joaoalves-kununu
* @hugo-goncalves-kununu @joaoalves-kununu

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
composer.lock
composer.phar
vendor/
/.php_cs.cache
.php-cs-fixer.php.cache
.php_cs.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"require": {
"php": ">=7.1.0",
"composer-plugin-api": "^1.1 | ^2.0",
"friendsofphp/php-cs-fixer": "^2.15"
"friendsofphp/php-cs-fixer": "^3.0"
},
"extra": {
"class": "Kununu\\Scripts\\PHP\\CodeStandards\\ScriptsPlugin"
Expand Down
2 changes: 1 addition & 1 deletion src/PHP/CodeStandards/Command/PHPCsFixerGitHookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output): void
$this->addLinkToGitFolder(
$gitPath,
sprintf('%s/kununu/scripts/src/PHP/CodeStandards/Scripts/php_cs', $vendorDir),
'.php_cs'
'.php-cs-fixer.php'
);

// Add php-cs-fixer bin to be available on .git folder.
Expand Down
2 changes: 1 addition & 1 deletion src/PHP/CodeStandards/Scripts/git-pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '*.php')

if [ -n "$CHANGED_FILES" ]; then
KUNUNU_BIN_PATH="$(git rev-parse --show-toplevel)/.git/kununu"
PHP_CS_CONFIG="$KUNUNU_BIN_PATH/.php_cs"
PHP_CS_CONFIG="$KUNUNU_BIN_PATH/.php-cs-fixer.php"
PHP_CS_FIXER="$KUNUNU_BIN_PATH/php-cs-fixer"

if ! [ -f "$PHP_CS_CONFIG" ]; then
Expand Down
22 changes: 11 additions & 11 deletions src/PHP/CodeStandards/Scripts/php_cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

// Usage
// php-cs-fixer fix . --diff --dry-run --config=<path>/.php_cs -> [--dry-run (don't apply changes)] [--diff show differences]
// php-cs-fixer fix application/ --config=<path>/.php_cs -> it will apply changes to all php files
// php-cs-fixer fix application/Bootstrap.php --config=<path>/.php_cs -> it will apply only changes to a file or directory
// php-cs-fixer fix . --diff --dry-run --config=<path>/.php-cs-fixer.php -> [--dry-run (don't apply changes)] [--diff show differences]
// php-cs-fixer fix application/ --config=<path>/.php-cs-fixer.php -> it will apply changes to all php files
// php-cs-fixer fix application/Bootstrap.php --config=<path>/.php-cs-fixer.php -> it will apply only changes to a file or directory

// Install:
// wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer
Expand All @@ -19,38 +19,38 @@ $finder = PhpCsFixer\Finder::create()
->in(__DIR__)
;

return PhpCsFixer\Config::create()
->setCacheFile('/tmp/.php_cs.cache')
return (new PhpCsFixer\Config())
->setCacheFile('/tmp/.php-cs-fixer.php.cache')
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'heredoc_to_nowdoc' => true,
'no_extra_consecutive_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'no_short_echo_tag' => true,
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],
'echo_tag_syntax' => ['format' => 'long'],
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'function_declaration' => ['closure_function_spacing' => 'none'],
'ternary_to_null_coalescing' => true,
'method_chaining_indentation' => true,
'array_indentation' => true,
'blank_line_after_opening_tag' => false,
'self_accessor' => false,
'binary_operator_spaces' => ['align_double_arrow' => true],
'binary_operator_spaces' => ['operators' => ['=>' => 'align']],
'native_constant_invocation' => false,
'void_return' => true,
'concat_space' => ['spacing' => 'one'],
'native_function_invocation' => false,
'no_superfluous_phpdoc_tags' => false,
'yoda_style' => null,
'yoda_style' => [],
'phpdoc_summary' => false,
'increment_style' => null,
'increment_style' => [],
'method_chaining_indentation' => false,
'visibility_required' => ['elements' => ['property', 'method']],
])
->setFinder($finder)
;

0 comments on commit 1bf65df

Please sign in to comment.