From 22ba3c8a782a929ec14e6ba2cd4a9b4be86b7693 Mon Sep 17 00:00:00 2001 From: Olivier Bellone Date: Thu, 22 Aug 2019 15:19:03 -0700 Subject: [PATCH] Start using PHP CS Fixer --- .gitignore | 3 +++ .travis.yml | 4 +++- .vscode/extensions.json | 3 ++- .vscode/settings.json | 2 ++ README.md | 9 ++++++++- composer.json | 3 ++- 6 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 17b94183b..634e215fb 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,6 @@ clover.xml # Ignore IDE's configuration files .idea + +# Ignore PHP CS Fixer cache +.php_cs.cache diff --git a/.travis.yml b/.travis.yml index 3db6ce734..7f463b576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -56,6 +56,8 @@ before_install: STRIPE_MOCK_PID=$! - export PATH="${PATH}:${PWD}/stripe-mock/stripe-mock_${STRIPE_MOCK_VERSION}" -script: ./build.php ${AUTOLOAD} +script: + - ./build.php ${AUTOLOAD} + - ./vendor/bin/php-cs-fixer fix -v --dry-run --using-cache=no . after_script: ./vendor/bin/coveralls -v diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 15c5fcedd..db1056ca7 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "felixfbecker.php-intellisense", "ikappas.phpcs", "emallin.phpunit", - "EditorConfig.editorconfig" + "EditorConfig.editorconfig", + "sophisticode.php-formatter" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index d8132efae..d1ae331e1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,8 @@ // Formatting "editor.formatOnSave": true, + "phpformatter.composer": true, + "phpformatter.arguments": [""], // Linting "phpcs.enable": true, diff --git a/README.md b/README.md index 725857c36..9fb10ebc9 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,12 @@ Update bundled CA certificates from the [Mozilla cURL release][curl]: ./update_certs.php ``` +The library uses [PHP CS Fixer][php-cs-fixer] for code formatting. Code must be formatted before PRs are submitted, otherwise CI will fail. Run the formatter with: + +```bash +./vendor/bin/php-cs-fixer fix -v . +``` + ## Attention plugin developers Are you writing a plugin that integrates Stripe and embeds our library? Then please use the `setAppInfo` function to identify your plugin. For example: @@ -256,6 +262,7 @@ See the "SSL / TLS compatibility issues" paragraph above for full context. If yo [composer]: https://getcomposer.org/ [connect]: https://stripe.com/connect [curl]: http://curl.haxx.se/docs/caextract.html -[psr3]: http://www.php-fig.org/psr/psr-3/ [idempotency-keys]: https://stripe.com/docs/api/php#idempotent_requests +[php-cs-fixer]: https://github.com/FriendsOfPHP/PHP-CS-Fixer +[psr3]: http://www.php-fig.org/psr/psr-3/ [stripe-mock]: https://github.com/stripe/stripe-mock diff --git a/composer.json b/composer.json index 75e5e1191..ca7bafa61 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,8 @@ "phpunit/phpunit": "^5.7", "php-coveralls/php-coveralls": "^2.1", "squizlabs/php_codesniffer": "^3.3", - "symfony/process": "~3.4" + "symfony/process": "~3.4", + "friendsofphp/php-cs-fixer": "^2.15" }, "autoload": { "psr-4": { "Stripe\\" : "lib/" }