From 91a9d73772500cca95dfd946a9955eb45ba97f02 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Tue, 15 Feb 2022 21:56:45 +0000 Subject: [PATCH] Run PHPStan as Github Action (#2) * Depend on PHPUnit for development In order to run the unit tests, PHPUnit is a hard dev dependency, so I've included it in this commit, and now I can run the unit tests as part of this PR. * Depend on PHPStan for development This is for #89 - to ensure correct type hints are provided to developers who use IDEs. * Fix object model of AcceptHeader interface Fixes #89 - IDEs and PHPStan are happy with this implementation * Correct return type * Correct nonexistent Priority class to AcceptHeader * Improve typehint - allow looser type to be returned * Improve typehint - more accurate types as parameters * Improve typehint - more accurate generics as parameters * Expose script property - was only ever written * Properly typehint associative array * Typehint nullable string * Match typehints of parent method * Add PHPStan to CI * Configure PHPUnit versions for different PHP runtimes * Use real phpunit --- .github/workflows/ci.yaml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d3fee8c..867b906 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -31,4 +31,30 @@ jobs: uses: "ramsey/composer-install@v1" - name: "Run PHPUnit" - run: "vendor/bin/simple-phpunit --coverage-text" + run: "vendor/bin/phpunit --coverage-text" + + phpstan: + runs-on: "ubuntu-20.04" + + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.0" + - "8.1" + + steps: + - uses: actions/checkout@v2 + + - name: "Install PHP ${{ matrix.php-version }}" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php-version }}" + coverage: "pcov" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v1" + + - name: "Run PHPStan" + run: "vendor/bin/phpstan analyse src --level 5"