http icon indicating copy to clipboard operation
http copied to clipboard

Set up PHPStan on GitHub Actions

Open nhedger opened this issue 3 years ago • 1 comments

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, src and tests folders
  • [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.

nhedger avatar Sep 17 '22 14:09 nhedger

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.

nhedger avatar Sep 17 '22 15:09 nhedger

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:

clue avatar Jun 23 '23 10:06 clue