Add php-cs-fixer

This commit is contained in:
Anatoly Pashin 2020-05-29 00:13:02 +10:00 committed by andrey-sokolov
parent 4c85d8c07f
commit fea7300e27
5 changed files with 35 additions and 1 deletions

2
.gitignore vendored
View File

@ -14,3 +14,5 @@ rest-client.private.env.json
#Composer
vendor
composer.lock
.php_cs.cache

21
.php_cs Normal file
View File

@ -0,0 +1,21 @@
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__)
->append(['.php_cs'])
->notName('PhpStormStubsMap.php')
;
$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;
return PhpCsFixer\Config::create()
->setRules([
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_whitespace_in_blank_line' => true,
'single_blank_line_at_eof' => true,
// 'unix_line_endings' => true,
])
->setFinder($finder)
->setCacheFile($cacheDir . '/.php_cs.cache')
;

View File

@ -11,6 +11,10 @@ addons:
packages:
- docker-ce
cache:
directories:
- $HOME/.php-cs-fixer
install:
- composer install --ignore-platform-reqs
@ -18,3 +22,4 @@ script:
- docker-compose -f docker-compose.yml build >/dev/null
- docker-compose -f docker-compose.yml run php /opt/project/phpstorm-stubs/vendor/bin/phpunit /opt/project/phpstorm-stubs/tests/
- ./tests/check-stub-map
- composer cs

View File

@ -9,6 +9,7 @@ Please check our [issue tracker] for issues corresponding to the problem you fix
* Please avoid any unnecessary changes eg. spacing, line endings, HTML formatting. Remember, these files are NOT for human consumption. We want to preserve meaningful history.
* Please try to match existing style for any particular file - formatting, spacing, naming conventions.
* Please add corresponding @since tags
* Please run `composer cs` to check the code style and `composer cs-fix` to fix it
## Tests
* Please make sure that tests pass for your Pull Request.

View File

@ -17,7 +17,8 @@
"php": "^7.4",
"nikic/php-parser": "^4",
"phpdocumentor/reflection-docblock": "^4.3",
"phpunit/phpunit": "^7"
"phpunit/phpunit": "^7",
"friendsofphp/php-cs-fixer": "^2.16"
},
"autoload": {
"files": ["PhpStormStubsMap.php"]
@ -26,5 +27,9 @@
"psr-4": {
"StubTests\\": "tests/"
}
},
"scripts": {
"cs": "php-cs-fixer fix -vvv --diff --dry-run",
"cs-fix": "php-cs-fixer fix -v --diff"
}
}