From 618b22ab217b773d18abfce8bfe4dd6960738371 Mon Sep 17 00:00:00 2001 From: n-peugnet Date: Mon, 20 Apr 2020 20:05:14 +0200 Subject: tests: add phpstan static analysis tool (level5) --- Makefile | 8 +++++++- composer.json | 1 + composer.lock | 44 +++++++++++++++++++++++++++++++++++++++++++- phpstan.neon | 7 +++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 phpstan.neon diff --git a/Makefile b/Makefile index 816f019..43ce4c1 100644 --- a/Makefile +++ b/Makefile @@ -94,6 +94,7 @@ dist/w_cms_%.zip: all "package*" \ phpcs.xml \ phpunit.xml \ + phpstan.neon \ webpack.config.js # Generate the js bundles (and sourcemaps). @@ -158,13 +159,18 @@ buildclean: # Run all checks. .PHONY: check -check: vendor lint test +check: vendor lint analyse test # Lint php code with phpcs. .PHONY: lint lint: $(phpcs_dir) phpcs --report-full --report-checkstyle=$(phpcs_dir)/checkstyle.xml +# Analyse php code with phpstan. +.PHONY: analyse +analyse: + phpstan analyse + # Test php code with phpunit. .PHONY: test test: $(phpunit_dir) diff --git a/composer.json b/composer.json index 4f72d20..8640d17 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ "michelf/php-markdown": "^1.8" }, "require-dev": { + "phpstan/phpstan": "^0.12.19", "phpunit/phpunit": "^8.5", "sentry/sdk": "^2.0", "squizlabs/php_codesniffer": "^3.5" diff --git a/composer.lock b/composer.lock index b1b02ce..d7b1737 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "7a0cc5da0ce5a7eec0d4fdc30087dd9b", + "content-hash": "b26e62f8b85c611f3db528f8690e4dfe", "packages": [ { "name": "altorouter/altorouter", @@ -1437,6 +1437,48 @@ ], "time": "2020-03-05T15:02:03+00:00" }, + { + "name": "phpstan/phpstan", + "version": "0.12.19", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d", + "reference": "054f6d76b12ba9a6c13a5a8d5fcdf51219615f4d", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.12-dev" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "time": "2020-04-19T20:35:10+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "7.0.10", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..8c4765c --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,7 @@ +parameters: + level: 5 + paths: + - app/class + - app/fn + - index.php + - tests -- cgit v1.2.3