diff --git a/.gitattributes b/.gitattributes index 0ace0bec..39bf373e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ /bin/ export-ignore +/dev-tools/ export-ignore /Resources/ export-ignore /tests/ export-ignore /.* export-ignore diff --git a/.gitignore b/.gitignore index 8b81de02..daf46916 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.sublime-project *.sublime-workspace .idea +/.php_cs.cache /nbproject/private/ /build/ /cache/ diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..d605c9aa --- /dev/null +++ b/.php_cs @@ -0,0 +1,16 @@ +setFinder( + PhpCsFixer\Finder::create() + ->files() + ->in(__DIR__ . '/bin') + ->in(__DIR__ . '/src') + ->in(__DIR__ . '/tests') + ->append([__FILE__]) + ->notName('DefaultRuleProvider.php') + ) + ->setRiskyAllowed(true) + ->setRules([ + '@PSR2' => true, + ]); diff --git a/.travis.yml b/.travis.yml index 08f3a8ec..7e3123ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,6 +18,7 @@ matrix: - php: 7.1 env: COMPOSER_FLAGS='--prefer-lowest' - php: 7.2 + env: ANALYSIS=1 - php: nightly allow_failures: - php: nightly @@ -32,8 +33,11 @@ before_install: install: - COMPOSER_MEMORY_LIMIT=-1 travis_retry composer update $COMPOSER_FLAGS --no-suggest + - if [ $ANALYSIS == 1 ]; then travis_retry composer update --working-dir=./dev-tools --no-suggest; fi -script: vendor/bin/phpunit --verbose --coverage-clover=coverage.clover +script: + - vendor/bin/phpunit --verbose --coverage-clover=coverage.clover + - if [ $ANALYSIS == 1 ]; then PHP_CS_FIXER_FUTURE_MODE=1 ./dev-tools/vendor/bin/php-cs-fixer fix --ansi --diff --dry-run --verbose || travis_terminate 1; fi after_script: - sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi;' diff --git a/bin/generate-default.php b/bin/generate-default.php index d232ce9a..b3ef3ffb 100644 --- a/bin/generate-default.php +++ b/bin/generate-default.php @@ -56,4 +56,3 @@ function insertRules($fileName, array $rules = []) } else { printf("Error writing rules into '%s'.\n", $fileName); } - diff --git a/dev-tools/composer.json b/dev-tools/composer.json new file mode 100644 index 00000000..6d9218d1 --- /dev/null +++ b/dev-tools/composer.json @@ -0,0 +1,5 @@ +{ + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16" + } +} diff --git a/src/Bridge/Nette/SlugifyExtension.php b/src/Bridge/Nette/SlugifyExtension.php index f1500349..12fdbe56 100644 --- a/src/Bridge/Nette/SlugifyExtension.php +++ b/src/Bridge/Nette/SlugifyExtension.php @@ -33,7 +33,7 @@ public function beforeCompile() $builder = $this->getContainerBuilder(); $self = $this; - $registerToLatte = function(ServiceDefinition $def) use ($self) { + $registerToLatte = function (ServiceDefinition $def) use ($self) { $def->addSetup('addFilter', ['slugify', [$self->prefix('@helper'), 'slugify']]); }; diff --git a/src/Bridge/Symfony/Configuration.php b/src/Bridge/Symfony/Configuration.php index c37b5b0d..49593625 100644 --- a/src/Bridge/Symfony/Configuration.php +++ b/src/Bridge/Symfony/Configuration.php @@ -28,7 +28,6 @@ public function getConfigTreeBuilder() $rootNode = $treeBuilder->getRootNode(); } else { $rootNode = $treeBuilder->root('cocur_slugify'); - } $rootNode diff --git a/src/Bridge/Twig/SlugifyExtension.php b/src/Bridge/Twig/SlugifyExtension.php index 559c69af..dc726a12 100644 --- a/src/Bridge/Twig/SlugifyExtension.php +++ b/src/Bridge/Twig/SlugifyExtension.php @@ -76,5 +76,4 @@ public function getName() { return "SlugifyExtension"; } - }