From e9132f48b4ed7f12886a352de0ea64988119fee7 Mon Sep 17 00:00:00 2001 From: Luca Di Fazio Date: Wed, 27 Jul 2022 15:14:31 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20PHPStan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 16 +++++++++++++ README.md | 4 ++++ composer.json | 6 ++++- composer.lock | 54 ++++++++++++++++++++++++++++++++++++++++++- phpstan.neon | 8 +++++++ 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 phpstan.neon diff --git a/.vscode/settings.json b/.vscode/settings.json index c244872..6e0edd8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,21 @@ { "[php]": { "editor.defaultFormatter": "karye.prettier-php" + }, + "intelephense.diagnostics.undefinedVariables": false, + "intelephense.diagnostics.undefinedTypes": false, + "intelephense.diagnostics.undefinedSymbols": false, + "intelephense.diagnostics.undefinedProperties": false, + "intelephense.diagnostics.undefinedFunctions": false, + "intelephense.diagnostics.undefinedConstants": false, + "intelephense.diagnostics.undefinedClassConstants": false, + "intelephense.diagnostics.typeErrors": false, + "intelephense.diagnostics.embeddedLanguages": false, + "intelephense.diagnostics.duplicateSymbols": false, + "intelephense.diagnostics.deprecated": false, + "intelephense.diagnostics.argumentCount": false, + "intelephense.diagnostics.undefinedMethods": false, + "files.associations": { + "phpstan.neon": "yaml" } } diff --git a/README.md b/README.md index 990699e..2cfc54c 100644 --- a/README.md +++ b/README.md @@ -16,3 +16,7 @@ npm i ``` NPM is required to format the code, since we use [a PHP Plugin for Prettier](https://github.com/prettier/plugin-php). + +### Static Analysis + +We use [PHPStan](https://github.com/phpstan/phpstan) for static analysis. diff --git a/composer.json b/composer.json index c71ed74..0ff6100 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "gmponos/guzzle_logger": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^9.5" + "phpunit/phpunit": "^9.5", + "phpstan/phpstan": "^1.8" }, "license": "MIT", "authors": [ @@ -24,5 +25,8 @@ "psr-4": { "Mediatoolkit\\Tests\\": "tests/" } + }, + "scripts": { + "phpstan": "phpstan analyse" } } diff --git a/composer.lock b/composer.lock index 07a2f43..8309ba4 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "230feb64b6564ebc527860998bbc8169", + "content-hash": "6e3c4de54c8b8c780c38fb3fa30c624a", "packages": [ { "name": "gmponos/guzzle_logger", @@ -1158,6 +1158,58 @@ }, "time": "2021-12-08T12:19:24+00:00" }, + { + "name": "phpstan/phpstan", + "version": "1.8.2", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/c53312ecc575caf07b0e90dee43883fdf90ca67c", + "reference": "c53312ecc575caf07b0e90dee43883fdf90ca67c", + "shasum": "" + }, + "require": { + "php": "^7.2|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": ["phpstan", "phpstan.phar"], + "type": "library", + "autoload": { + "files": ["bootstrap.php"] + }, + "notification-url": "https://packagist.org/downloads/", + "license": ["MIT"], + "description": "PHPStan - PHP Static Analysis Tool", + "support": { + "issues": "https://github.com/phpstan/phpstan/issues", + "source": "https://github.com/phpstan/phpstan/tree/1.8.2" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], + "time": "2022-07-20T09:57:31+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.15", diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..e348386 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,8 @@ +parameters: + paths: + - src + - tests + + level: 1 + + checkMissingIterableValueType: false