diff --git a/.gitattributes b/.gitattributes index 2ae0178..a69a0df 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,6 +9,7 @@ /.gitignore export-ignore /.github export-ignore /phpcs.xml.dist export-ignore +/phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore /phpunit-bootstrap.php export-ignore /PHPCSDebug/Tests export-ignore diff --git a/.github/workflows/cs.yml b/.github/workflows/cs.yml index d402f45..8738bd4 100644 --- a/.github/workflows/cs.yml +++ b/.github/workflows/cs.yml @@ -97,3 +97,30 @@ jobs: - name: Show PHPCS results in PR if: ${{ always() && steps.phpcs.outcome == 'failure' }} run: cs2pr ./phpcs-report.xml + + phpstan: + name: "PHPStan" + runs-on: "ubuntu-latest" + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 'latest' + coverage: none + tools: phpstan + + # Install dependencies and handle caching in one go. + # Dependencies need to be installed to make sure the PHPCS and PHPUnit classes are recognized. + # @link https://github.com/marketplace/actions/install-composer-dependencies + - name: Install Composer dependencies + uses: "ramsey/composer-install@v3" + with: + # Bust the cache at least once a month - output format: YYYY-MM. + custom-cache-suffix: $(date -u "+%Y-%m") + + - name: Run PHPStan + run: phpstan analyse diff --git a/.gitignore b/.gitignore index 8561573..1b0eeda 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock phpcs.xml phpunit.xml .phpunit.result.cache +phpstan.neon diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..43cff6f --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,11 @@ +parameters: + #phpVersion: 50400 # Needs to be 70100 or higher... sigh... + level: 6 + paths: + - bin + - PHPCSDebug + - Scripts + - Tests + bootstrapFiles: + - phpunit-bootstrap.php + treatPhpDocTypesAsCertain: false