diff --git a/.php_cs.dist b/.php_cs.dist index 694ec28..8d02bce 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,40 +1,13 @@ setRiskyAllowed(true) - ->setRules([ - "@PSR1" => true, - "@PSR2" => true, - "braces" => [ - "allow_single_line_closure" => true, - ], - "array_syntax" => ["syntax" => "short"], - "cast_spaces" => true, - "combine_consecutive_unsets" => true, - "function_to_constant" => true, - "native_function_invocation" => true, - "no_multiline_whitespace_before_semicolons" => true, - "no_unused_imports" => true, - "no_useless_else" => true, - "no_useless_return" => true, - "no_whitespace_before_comma_in_array" => true, - "no_whitespace_in_blank_line" => true, - "non_printable_character" => true, - "normalize_index_brace" => true, - "ordered_imports" => true, - "php_unit_construct" => true, - "php_unit_dedicate_assert" => true, - "php_unit_fqcn_annotation" => true, - "phpdoc_summary" => true, - "phpdoc_types" => true, - "psr4" => true, - "return_type_declaration" => ["space_before" => "none"], - "short_scalar_cast" => true, - "single_blank_line_before_namespace" => true, - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->in(__DIR__ . "/examples") - ->in(__DIR__ . "/lib") - ->in(__DIR__ . "/test") - ); +$config = new Amp\CodeStyle\Config(); +$config->getFinder() + ->in(__DIR__ . '/examples') + ->in(__DIR__ . '/lib') + ->in(__DIR__ . '/test'); + +$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__; + +$config->setCacheFile($cacheDir . '/.php_cs.cache'); + +return $config; diff --git a/.travis.yml b/.travis.yml index 5492994..6f2c01f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -54,4 +54,6 @@ after_script: cache: directories: - - $HOME/.composer/cache/files + - $HOME/.composer/cache + - $HOME/.php-cs-fixer + - $HOME/.local diff --git a/composer.json b/composer.json index e9dd204..c731a52 100644 --- a/composer.json +++ b/composer.json @@ -37,8 +37,8 @@ }, "require-dev": { "amphp/phpunit-util": "^1", + "amphp/php-cs-fixer-config": "dev-master", "react/promise": "^2", - "friendsofphp/php-cs-fixer": "^2.3", "phpunit/phpunit": "^6.0.9", "phpstan/phpstan": "^0.8.5" },