Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add coding-standard rules with PHP-CS-Fixer #5989

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ composer.phar
composer.lock
vendor

# PHP-CS-Fixer related
.php_cs.cache

# javascript dependencies
plugins/enigma/openpgp.min.js
plugins/managesieve/codemirror/
Expand Down
37 changes: 37 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'long'],
'binary_operator_spaces' => false,
'concat_space' => ['spacing' => 'one'],
'heredoc_to_nowdoc' => true,
'method_argument_space' => true,
'modernize_types_casting' => false,
'no_extra_consecutive_blank_lines' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block'],
'no_php4_constructor' => true,
'no_short_echo_tag' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'php_unit_fqcn_annotation' => false,
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'phpdoc_trim' => false,
'semicolon_after_instruction' => true,
'simplified_null_return' => true,
'single_quote' => false,
'yoda_style' => false,
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/installer')
->in(__DIR__ . '/plugins')
->in(__DIR__ . '/program')
->in(__DIR__ . '/tests')
)
;
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ matrix:
- php: 5.5
- php: 5.6
- php: 7.0
env: CS_CHECK=1
- php: 7.1
env: CODE_COVERAGE=1
- php: 7.2
Expand All @@ -20,10 +21,12 @@ cache:
install:
- if [ "$CODE_COVERAGE" != 1 ]; then phpenv config-rm xdebug.ini || true; fi
- cp composer.json-dist composer.json
- if [ "$CS_CHECK" != 1 ]; then composer remove --no-update --no-scripts --dev friendsofphp/php-cs-fixer; fi
- composer install --prefer-dist

script:
- if [ "$CODE_COVERAGE" = 1 ]; then CODE_COVERAGE_ARGS="--coverage-text"; fi; vendor/bin/phpunit -c tests/phpunit.xml $CODE_COVERAGE_ARGS
- if [ "$CS_CHECK" = 1 ]; then vendor/bin/php-cs-fixer fix --diff --dry-run --verbose; fi

notifications:
email: false
1 change: 1 addition & 0 deletions composer.json-dist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"endroid/qrcode": "~1.6.5"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.2",
"phpunit/phpunit": "^4.8.36 || ^5.7.21"
},
"suggest": {
Expand Down