Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up PHPStan on GitHub Actions #472

Closed
wants to merge 3 commits into from
Closed

Set up PHPStan on GitHub Actions #472

wants to merge 3 commits into from

Conversation

nhedger
Copy link
Contributor

@nhedger nhedger commented Sep 17, 2022

This PR sets up PHPStan to run on GitHub Actions, as discussed in discussions#469.

Overview

  • Sets up PHPStan to run on GitHub Actions on PHP 8.1 only
  • Configures PHPStan to run the analysis on the examples, src and tests folders
  • 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.

Comment on lines +10 to +11
excludePaths:
- src/Server.php
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to exclude this file because otherwise I could not generate the baseline.

This is due to the Server class attempting to extend the final HttpServer class

@nhedger
Copy link
Contributor Author

nhedger commented Sep 17, 2022

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 nhedger closed this by deleting the head repository Apr 21, 2023
@clue
Copy link
Member

clue commented Jun 23, 2023

For the reference: It looks like this wasn't closed intentionally (as discussed in reactphp/async#64). We've recently started applying PHPStan on max level into our projects with reactphp/async#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! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants