diff --git a/.gitignore b/.gitignore index bc959c53..8751a3b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /composer.lock +/phpstan.neon /phpunit.xml /vendor diff --git a/.travis.yml b/.travis.yml index 63cca25f..10c5cf6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ matrix: - php: 7.0 env: DEPS='lowest' - php: 7.3 - env: DEPS='unmodified' + env: DEPS='unmodified' WITH_STATIC_ANALYSIS='yes' - php: 7.3 env: SYMFONY_VERSION='3.4.*' PARAM_DB_DRIVER='pdo_sqlite' SYMFONY_DEPRECATIONS_HELPER='9' - php: 7.3 @@ -46,7 +46,9 @@ before_script: script: # validate composer.json - - composer validate --strict --no-check-lock + - if [ -n "${WITH_STATIC_ANALYSIS:-}" ]; then composer validate --strict --no-check-lock; fi; + # run PHPStan + - if [ -n "${WITH_STATIC_ANALYSIS:-}" ]; then vendor/bin/phpstan analyse; fi; # run PHPUnit - phpdbg -qrr vendor/phpunit/phpunit/phpunit -v --coverage-clover build/logs/clover.xml # upload code coverage data diff --git a/.travis_install_dependencies.sh b/.travis_install_dependencies.sh index b50d7e49..518309ff 100644 --- a/.travis_install_dependencies.sh +++ b/.travis_install_dependencies.sh @@ -22,4 +22,8 @@ case "${DEPS:-}" in fi esac +if [ -n "${WITH_STATIC_ANALYSIS:-}" ]; then + composer require --no-update --dev phpstan/phpstan-shim +fi + composer update ${COMPOSER_UPDATE_ARGS:-} diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 00000000..d1df9963 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,24 @@ +parameters: + level: 5 + paths: + - %currentWorkingDirectory% + excludes_analyse: + - %currentWorkingDirectory%/Tests/* + - %currentWorkingDirectory%/vendor/* + ignoreErrors: + - + message: '#^Result of || is always true\.$#' + path: %currentWorkingDirectory%/Form/Step.php + # TODO remove as soon as Symfony >= 4.1 is required + - + message: '#^Call to function property_exists\(\) with .+ and .size. will always evaluate to false\.$#' + path: %currentWorkingDirectory%/Storage/SerializableFile.php + # TODO remove as soon as Symfony >= 4.1 is required + - '#^Parameter \#5 \$test of class Symfony\\Component\\HttpFoundation\\File\\UploadedFile constructor expects bool, null given\.$#' + # TODO remove as soon as Symfony >= 4.3 is required + - + message: '#^Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\.$#' + path: %currentWorkingDirectory%/Form/FormFlow.php + - + message: '#^Parameter \#1 \$event of method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) expects object, string given\.$#' + path: %currentWorkingDirectory%/Form/FormFlow.php