Replies: 2 comments 1 reply
-
IMHO this would work very well combined with https://github.com/orgs/reactphp/discussions/472 👍 . |
Beta Was this translation helpful? Give feedback.
-
@nhedger Excellent initiative, would love to have @phpstan support in @reactphp! I have to admit I also like this would bring us full circle, considering @phpstan also uses @reactphp 🎉 Let's start small: Adding this to GitHub actions only and then only running this on one of the latest PHP versions would probably be a good starting point. I think that unlike PHPUnit, there's little value in also running this against the full test matrix and this would only complicate things. Adding this to This topic seems to be in good hands here, so I'll leave this up to you to decide. Looking forward to your PR! |
Beta Was this translation helpful? Give feedback.
-
General idea
Enable PHPStan static code analysis on the various ReactPHP repositories.
Description
I believe the ReactPHP project as a whole and its contributors would benefit from enabling PHPStan. Apart from helping us to catch bugs early, it would also encourage contributors to more strictly type their code with the help of PHPDoc or native type annotations.
Here are some pros:
Challenges
Since most libraries of the ReactPHP project support a wide range of PHP versions, it might be challenging to set up PHPStan in a way that supports all those versions.
>=8.1
>=5.3
>=5.3
>=5.3
>=5.3
>=5.3
>=7.4
>=5.3
>=7.1
>=5.3
>=5.3
>=5.3
>=5.3.8
Implementation
Given the previous table, it's pretty clear that we would not be able to add
phpstan/phpstan
as a development dependency because the required PHP version would clash.GitHub Actions
PHPStan could be installed with
shivammathur/setup-php@v2
and run only the latest PHP version supported by a given library. Code written for older PHP versions could still be analyzed by specifying thephpVersion
configuration parameter of PHPStan.This would add static code analysis to:
Running locally
I think it's fairly safe to assume that most contributors are running a PHP version superior to
7.1
, so we could pull PHPStan's PHAR into each repository (and exclude it from dist) and run it from there.What are your thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions