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

[CI] Add php-cs-fixer check to Travis builds #1049

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
63 changes: 39 additions & 24 deletions .php_cs.dist
@@ -1,32 +1,47 @@
<?php

/*
* This file is part of the `liip/LiipImagineBundle` project.
*
* (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

use SLLH\StyleCIBridge\ConfigBridge;

require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php';

$header = <<<EOF
$fileHeaderComment = <<<COMMENT
This file is part of the `liip/LiipImagineBundle` project.

(c) https://github.com/liip/LiipImagineBundle/graphs/contributors

For the full copyright and license information, please view the LICENSE.md
file that was distributed with this source code.
EOF;

$config = ConfigBridge::create();
$config
->setRules(array_merge($config->getRules(), [
'header_comment' => ['header' => $header],
]))
->setUsingCache(false);

return $config;
COMMENT;

$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude(array('build', 'vendor'))
->files()
->name('*.php')
;

return PhpCsFixer\Config::create()
->setFinder($finder)
->setRiskyAllowed(true)
->setRules([
'@Symfony' => true,
'@Symfony:risky' => true,
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'header_comment' => ['header' => $fileHeaderComment, 'separate' => 'both'],
'heredoc_to_nowdoc' => true,
'linebreak_after_opening_tag' => true,
'mb_str_functions' => true,
'no_php4_constructor' => true,
'no_unreachable_default_argument_value' => true,
'no_useless_else' => true,
'no_useless_return' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'phpdoc_summary' => false,
'psr4' => true,
'semicolon_after_instruction' => true,
'strict_comparison' => true,
'strict_param' => true,
])
->setFinder($finder)
->setUsingCache(true)
;
10 changes: 9 additions & 1 deletion .travis.yml
Expand Up @@ -10,11 +10,17 @@ env:
global:
- SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- ENABLE_CODE_COVERAGE="false"
- RUN_UNIT_TESTS="true"
- CHECK_PHP_SYNTAX="false"

matrix:
fast_finish: true
include:
- php: 7.1
- php: 7.1
env:
- RUN_UNIT_TESTS="false"
- CHECK_PHP_SYNTAX="true"
- php: 7.1
env:
- SYMFONY_VERSION=4.0.*
Expand Down Expand Up @@ -60,7 +66,9 @@ install:
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then travis_retry composer require --dev satooshi/php-coveralls; fi

script:
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; else vendor/bin/simple-phpunit -v; fi;
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then vendor/bin/simple-phpunit --coverage-text --coverage-clover build/logs/clover.xml; fi;
- if [[ "$RUN_UNIT_TESTS" == "true" && "$ENABLE_CODE_COVERAGE" == "false" ]]; then vendor/bin/simple-phpunit -v; fi;
- if [[ "$CHECK_PHP_SYNTAX" == "true" ]]; then vendor/bin/php-cs-fixer --dry-run --diff -v fix; fi;

after_success:
- if [[ "$ENABLE_CODE_COVERAGE" == "true" && "$TRAVIS_EVENT_TYPE" == "cron" ]]; then php vendor/bin/coveralls -v --config .coveralls.yml; fi;