Set up PHPStan on GitHub Actions
This PR sets up PHPStan to run on GitHub Actions, as discussed in discussions#469.
Overview
- [x] Sets up PHPStan to run on GitHub Actions on PHP 8.1 only
- [x] Configures PHPStan to run the analysis on the
examples,srcandtestsfolders - [x] Generates the baseline so that static analysis passes immediately
Baseline
Because this PR aims to set up PHPStan and not address the errors it reports, I've generated a baseline to make the pipeline succeed. We'll then be able to incrementally fix the problems in future PRs.
The generated baseline produces different results on different operating systems.
The pipeline succeeds when running on macOS but fails when running on Ubuntu (in the GitHub Actions runner at least).
------ -----------------------------------------------------------
Line examples/92-client-benchmark-upload.php
------ -----------------------------------------------------------
109 Call to an undefined method ChunkRepeater::getPosition().
116 Call to an undefined method ChunkRepeater::getPosition().
116 Call to an undefined method ChunkRepeater::getPosition().
------ -----------------------------------------------------------
------ -----------------------------------------------------------------------
Line examples/99-server-benchmark-download.php
------ -----------------------------------------------------------------------
Ignored error pattern #^Call to an undefined method
ChunkRepeater\:\:getSize\(\)\.$# in path
/home/runner/work/http/http/examples/99-server-benchmark-download.php
was not matched in reported errors.
------ -----------------------------------------------------------------------
It seems to complain about a method not being defined although the method is defined. I cannot find a reason for this currently.
Possible solution
As a temporary solution, I could probably ignore the problematic files, which are examples anyway.
For the reference: It looks like this wasn't closed intentionally (as discussed in https://github.com/reactphp/async/pull/64). We've recently started applying PHPStan on max level into our projects with https://github.com/reactphp/async/pull/76 and we'll go ahead with this and apply PHPStan on max level to all our projects in the future.
Thank you very much for your contribution and sparking this discussion! :+1: