diff --git a/.gitattributes b/.gitattributes index 401ae60..b9e932a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,19 +1,21 @@ -/.build export-ignore -/.github export-ignore -/.idea export-ignore -/.phan export-ignore -/.phpdoc export-ignore -/docs export-ignore -/examples export-ignore -/tests export-ignore -/.editorconfig export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.readthedocs.yml export-ignore -/composer.lock export-ignore -/phpcs.xml.dist export-ignore -/phpdoc.xml.dist export-ignore -/phpmd.xml.dist export-ignore -/phpunit.xml.dist export-ignore +/.build export-ignore +/.github export-ignore +/.idea export-ignore +/.phan export-ignore +/.phpdoc export-ignore +/docs export-ignore +/examples export-ignore +/tests export-ignore +/.editorconfig export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.readthedocs.yml export-ignore +/composer.lock export-ignore +/phpcs.xml.dist export-ignore +/phpdoc.xml.dist export-ignore +/phpmd.xml.dist export-ignore +/phpunit.xml.dist export-ignore +/phpstan.dist.neon export-ignore +/phpstan-baseline.neon export-ignore *.php diff=php diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26e44bc..a697171 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,10 +38,6 @@ jobs: - "8.2" - "8.3" - env: - PHAN_ALLOW_XDEBUG: 0 - PHAN_DISABLE_XDEBUG_WARN: 1 - steps: - name: "Checkout" uses: actions/checkout@v4 @@ -50,7 +46,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} - extensions: ast, ${{ env.PHP_EXTENSIONS }} + extensions: ${{ env.PHP_EXTENSIONS }} ini-values: ${{ env.PHP_INI_VALUES }} coverage: none @@ -60,8 +56,8 @@ jobs: - name: "Install dependencies with composer" uses: ramsey/composer-install@v3 - - name: "Run phan" - run: php vendor/bin/phan --target-php-version=${{ matrix.php-version }} + - name: "Run PHPStan" + run: php vendor/bin/phpstan tests: diff --git a/.gitignore b/.gitignore index 84109c7..7420578 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ phpcs.xml phpdoc.xml phpmd.xml phpunit.xml +phpstan.neon diff --git a/.phan/config.php b/.phan/config.php deleted file mode 100644 index b62fe11..0000000 --- a/.phan/config.php +++ /dev/null @@ -1,61 +0,0 @@ - null, - 'minimum_target_php_version' => '8.1', - - // A list of directories that should be parsed for class and - // method information. After excluding the directories - // defined in exclude_analysis_directory_list, the remaining - // files will be statically analyzed for errors. - // - // Thus, both first-party and third-party code being used by - // your application should be included in this list. - 'directory_list' => [ - '.phan/stubs', - 'examples', - 'src', - 'tests', - 'vendor', - ], - - // A regex used to match every file name that you want to - // exclude from parsing. Actual value will exclude every - // "test", "tests", "Test" and "Tests" folders found in - // "vendor/" directory. - 'exclude_file_regex' => '@^vendor/.*/(tests?|Tests?)/@', - - // A directory list that defines files that will be excluded - // from static analysis, but whose class and method - // information should be included. - // - // Generally, you'll want to include the directories for - // third-party code (such as "vendor/") in this list. - // - // n.b.: If you'd like to parse but not analyze 3rd - // party code, directories containing that code - // should be added to both the `directory_list` - // and `exclude_analysis_directory_list` arrays. - 'exclude_analysis_directory_list' => [ - 'vendor/', - '.phan/stubs', - ], - 'suppress_issue_types' => [ - 'PhanAccessMethodInternal', - ], -]; diff --git a/README.md b/README.md index d966b8a..5a0721c 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ A template/boilerplate for PHP libraries. - [GitHub Actions](https://github.com/chillerlan/php-library-template/actions) runner - [Composer](https://getcomposer.org) dependency management - [PHPUnit](https://phpunit.de) unit tests -- [PHAN](https://github.com/phan/phan) static analysis +- [PHPStan](https://github.com/phpstan/phpstan) static analysis - [PHPCS](https://github.com/PHPCSStandards/PHP_CodeSniffer) coding standard analyzer - [PHPMD](https://phpmd.org) mess detector - [Codecov](https://codecov.io) code coverage analysis diff --git a/composer.json b/composer.json index 04ce64f..0d90509 100644 --- a/composer.json +++ b/composer.json @@ -34,27 +34,28 @@ "php": "^8.1" }, "require-dev": { - "phan/phan": "^5.4", "phpunit/phpunit": "^10.5", "phpmd/phpmd": "^2.15", - "squizlabs/php_codesniffer": "^3.9" + "phpstan/phpstan": "^1.11", + "phpstan/phpstan-deprecation-rules": "^1.2", + "squizlabs/php_codesniffer": "^3.10" }, "suggest": { }, "autoload": { "psr-4": { - "chillerlan\\LibraryTemplate\\": "src/" + "chillerlan\\LibraryTemplate\\": "src" } }, "autoload-dev": { "psr-4": { - "chillerlan\\LibraryTemplateTest\\": "tests/" + "chillerlan\\LibraryTemplateTest\\": "tests" } }, "scripts": { - "phan": "@php vendor/bin/phan", "phpcs": "@php vendor/bin/phpcs", - "phpunit": "@php vendor/bin/phpunit" + "phpunit": "@php vendor/bin/phpunit", + "phpstan": "@php vendor/bin/phpstan" }, "config": { "lock": false, diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..aab4991 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,2 @@ +parameters: + ignoreErrors: [] diff --git a/phpstan.dist.neon b/phpstan.dist.neon new file mode 100644 index 0000000..a545e56 --- /dev/null +++ b/phpstan.dist.neon @@ -0,0 +1,17 @@ +# https://phpstan.org/config-reference + +parameters: + level: 9 + tmpDir: .build/phpstan-cache + paths: + - examples + - src + - tests + + treatPhpDocTypesAsCertain: false + +includes: + - phpstan-baseline.neon + - vendor/phpstan/phpstan/conf/bleedingEdge.neon + - vendor/phpstan/phpstan-deprecation-rules/rules.neon +# - vendor/chillerlan/php-settings-container/rules-magic-access.neon