diff --git a/.gitignore b/.gitignore index 9dd271e..809a913 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /vendor/ /.php-cs-fixer.php /composer.lock +/phpstan.neon diff --git a/composer.json b/composer.json index 42257b6..1a8e58e 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,19 @@ "require": { "php": "^8.2" }, + "require-dev": { + "phpstan/extension-installer": "^1.4", + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-deprecation-rules": "^1.2", + "phpstan/phpstan-phpunit": "^1.4", + "phpstan/phpstan-strict-rules": "^1.6" + }, "minimum-stability": "dev", "prefer-stable": true, "config": { + "allow-plugins": { + "phpstan/extension-installer": true + }, "optimize-autoloader": true, "preferred-install": "dist", "sort-packages": true @@ -31,10 +41,14 @@ "@composer update --ansi --working-dir=tools" ], "cs:check": "tools/vendor/bin/php-cs-fixer check --ansi --verbose --diff", - "cs:fix": "tools/vendor/bin/php-cs-fixer fix --ansi --verbose --diff" + "cs:fix": "tools/vendor/bin/php-cs-fixer fix --ansi --verbose --diff", + "phpstan:baseline": "phpstan analyse --ansi --generate-baseline=phpstan-baseline.php", + "phpstan:check": "phpstan analyse --ansi --verbose" }, "scripts-descriptions": { "cs:check": "Checks for coding style violations", - "cs:fix": "Fixes any coding style violations" + "cs:fix": "Fixes any coding style violations", + "phpstan:baseline": "Runs PHPStans and dumps resulting errors to baseline", + "phpstan:check": "Runs PHPStan with identifiers support" } } diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000..4809c8a --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,28 @@ +includes: + - vendor/phpstan/phpstan/conf/bleedingEdge.neon + +parameters: + phpVersion: 80200 + level: 8 + tmpDir: build/phpstan + paths: + - src + - tests + - tools + excludePaths: + analyseAndScan: + - tools/vendor/** + bootstrapFiles: + - vendor/autoload.php + exceptions: + check: + missingCheckedExceptionInThrows: true + tooWideThrowType: true + checkTooWideReturnTypesInProtectedAndPublicMethods: true + checkUninitializedProperties: true + checkBenevolentUnionTypes: true + reportPossiblyNonexistentGeneralArrayOffset: true + reportPossiblyNonexistentConstantArrayOffset: true + reportAlwaysTrueInLastCondition: true + reportAnyTypeWideningInVarTag: true + checkMissingCallableSignature: true