This repository has been archived by the owner on May 26, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add PHP CS Fixer as a dev dependencies. - Add PHP CS Fixer cache file to gitignore/gitattributes - Add custom code style config - Update TravisCI config to check code style
- Loading branch information
Showing
5 changed files
with
110 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# Ignore all test and documentation for archive | ||
# Ignore all test, documentation and dot files for archive | ||
/tests export-ignore | ||
/.editorconfig export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/.php_cs.dist export-ignore | ||
/.scrutinizer.yml export-ignore | ||
/.travis.yml export-ignore | ||
/composer.lock export-ignore | ||
/CONTRIBUTING.md export-ignore | ||
/logo.png export-ignore | ||
/phpunit.xml export-ignore |
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,6 +1,8 @@ | ||
/.idea | ||
*.iml | ||
|
||
/tests/resources/generated | ||
/tests/coverage | ||
/vendor | ||
/.idea | ||
*.iml | ||
composer.lock | ||
/composer.lock | ||
/.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,58 @@ | ||
<?php | ||
|
||
$config = PhpCsFixer\Config::create() | ||
->setRiskyAllowed(true) | ||
->setRules([ | ||
'@Symfony' => true, | ||
'align_multiline_comment' => false, | ||
'array_syntax' => ['syntax' => 'short'], | ||
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => null], | ||
'blank_line_before_statement' => ['statements' => ['return']], | ||
'combine_consecutive_unsets' => true, | ||
'concat_space' => ['spacing' => 'one'], | ||
'declare_equal_normalize' => ['space' => 'single'], | ||
'heredoc_to_nowdoc' => true, | ||
'is_null' => ['use_yoda_style' => false], | ||
'method_argument_space' => ['ensure_fully_multiline' => true], | ||
'modernize_types_casting' => true, | ||
'no_break_comment' => ['comment_text' => 'do nothing'], | ||
'no_empty_phpdoc' => false, | ||
'no_null_property_initialization' => true, | ||
'no_short_echo_tag' => true, | ||
'no_superfluous_elseif' => true, | ||
'no_unneeded_control_parentheses' => ['statements' => ['break', 'clone', 'continue', 'echo_print', 'switch_case', 'yield']], | ||
'no_unneeded_curly_braces' => true, | ||
'no_unneeded_final_method' => true, | ||
'no_useless_else' => false, | ||
'no_useless_return' => true, | ||
'ordered_imports' => true, | ||
'phpdoc_add_missing_param_annotation' => true, | ||
'phpdoc_align' => false, | ||
'phpdoc_annotation_without_dot' => false, | ||
'phpdoc_no_empty_return' => false, | ||
'phpdoc_order' => true, | ||
'phpdoc_summary' => false, | ||
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'], | ||
'phpdoc_separation' => false, | ||
'pre_increment' => false, | ||
'protected_to_private' => true, | ||
'psr4' => true, | ||
'return_type_declaration' => ['space_before' => 'one'], | ||
'semicolon_after_instruction' => true, | ||
'simplified_null_return' => false, | ||
'single_line_comment_style' => ['comment_types' => ['hash']], | ||
'strict_comparison' => true, | ||
'void_return' => true, | ||
]); | ||
|
||
$config->setFinder( | ||
PhpCsFixer\Finder::create() | ||
->exclude('vendor') | ||
->in(__DIR__) | ||
->name('*.php') | ||
); | ||
|
||
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; | ||
$config->setCacheFile($cacheDir . '/.php_cs.cache'); | ||
|
||
return $config; |
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,27 +1,60 @@ | ||
language: php | ||
|
||
dist: trusty | ||
sudo: false | ||
|
||
language: php | ||
|
||
php: | ||
- 5.6 | ||
- 7.0 | ||
- 7.1 | ||
- hhvm-3.6 | ||
matrix: | ||
include: | ||
- php: 5.6 | ||
env: WITH_PHPUNIT=true | ||
- php: 5.6 | ||
env: WITH_CS=true | ||
- php: 7.0 | ||
env: WITH_PHPUNIT=true | ||
- php: 7.1 | ||
env: WITH_PHPUNIT=true WITH_COVERAGE=true | ||
- php: hhvm-3.6 | ||
env: WITH_PHPUNIT=true | ||
|
||
cache: | ||
directories: | ||
- $HOME/.composer/cache | ||
- $HOME/.php-cs-fixer | ||
|
||
before_install: | ||
- | | ||
if [[ "$WITH_COVERAGE" != "true" ]]; then | ||
phpenv config-rm xdebug.ini | ||
fi | ||
if [[ "$WITH_CS" != "true" ]]; then | ||
composer remove friendsofphp/php-cs-fixer --dev --no-update | ||
fi | ||
- composer validate | ||
|
||
install: | ||
- composer install --no-interaction --prefer-source | ||
|
||
script: | ||
before_script: | ||
- mkdir -p "$HOME/.php-cs-fixer" | ||
- mkdir -p build/logs | ||
- php vendor/bin/phpunit --coverage-clover=build/logs/coverage.clover | ||
|
||
script: | ||
- | | ||
if [[ "$WITH_CS" == "true" ]]; then | ||
vendor/bin/php-cs-fixer fix --config=.php_cs.dist --verbose --diff --dry-run | ||
fi | ||
- | | ||
if [[ "$WITH_PHPUNIT" == "true" ]]; then | ||
if [[ "$WITH_COVERAGE" == "true" ]]; then | ||
vendor/bin/phpunit --coverage-clover=build/logs/coverage.clover | ||
else | ||
vendor/bin/phpunit --no-coverage | ||
fi | ||
fi | ||
after_script: | ||
- | | ||
if [[ "$TRAVIS_PHP_VERSION" = '7.1' ]]; then | ||
if [[ "$WITH_COVERAGE" == "true" ]]; then | ||
wget https://scrutinizer-ci.com/ocular.phar | ||
php ocular.phar code-coverage:upload --format=php-clover build/logs/coverage.clover | ||
fi |
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