From 0d63d74cbba125410402659c54da294aff86301f Mon Sep 17 00:00:00 2001 From: Jeremiah VALERIE Date: Thu, 23 Aug 2018 08:34:49 +0200 Subject: [PATCH] Add phpstan PHP Static Analysis Tool --- .gitignore | 1 + .travis.yml | 8 +++++++- composer.json | 12 +++++++++--- phpstan.neon | 0 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 phpstan.neon diff --git a/.gitignore b/.gitignore index 4e3728b..321655a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.phar composer.lock vendor/ bin/ +phpstan.phar diff --git a/.travis.yml b/.travis.yml index d8ec128..c9bb7fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,13 @@ php: - 7.2 - nightly -matrix: +jobs: + include: + - stage: Code Quality + php: 7.2 + env: STATIC_ANALYSIS + install: travis_retry composer install --prefer-dist + script: composer static-analysis allow_failures: - php: nightly diff --git a/composer.json b/composer.json index d48b76a..54d19a6 100644 --- a/composer.json +++ b/composer.json @@ -18,9 +18,6 @@ }, "config": { "bin-dir": "bin", - "platform": { - "php": "5.6.0" - }, "preferred-install": "dist", "sort-packages": true }, @@ -36,6 +33,15 @@ "GraphQL\\Examples\\Blog\\": "examples/01-blog/Blog/" } }, + "scripts": { + "static-analysis": [ + "rm phpstan.phar || true", + "@composer req --ansi --no-interaction --dev phpstan/phpstan-shim", + "cp -f vendor/phpstan/phpstan-shim/phpstan.phar .", + "@composer rem --ansi --dev phpstan/phpstan-shim", + "@php phpstan.phar analyse --ansi -l 1 -c phpstan.neon src" + ] + }, "suggest": { "react/promise": "To leverage async resolving on React PHP platform", "psr/http-message": "To use standard GraphQL server" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e69de29