Add phpstan to the project, start small at level 1 with baseline #79
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Here's my proposal to add https://phpstan.org/user-guide/getting-started into this project 👋🏼
I've been using if for years in various projects to great success. It can be daunting at first for existing projects, but the sooner it's added, the better.
This PR includes:
(it already was a transient one, this now makes it explicit)
(which uses above composer script entries)
#[\ReturnTypeWillChange]annotation for PHP 8.1 compatibilityThis one was already exposed by phpstan 😅 and since annotations are comments and thus backwards compatible, this is the only "source level" change here:
Notes
I opted to run phpstan with PHP 8.1. This is important as the version you use to run phpstan is relevant and makes a difference in things being reported. I understand PHP 8.1 just left the door, but didn't see a reason to go lower.
Personally, I do use OSX / homebrew and 8.1 is already available here, so for me local testing is possible already.
This PR is "as unobtrusive as possible" to get the foot in the door for phpstan. That's why I chose a) the lowest level and b) added it fully to the baseline without any fixes yet.
I believe any fixes further on need to go into 2.x for the compatibility to transition from the forked package
Links