-
Notifications
You must be signed in to change notification settings - Fork 11
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
chore: add phpstan strict type checking #153
Conversation
Looks good to me. The errors saying
looked like they could be a failure to find all the classes in contrib, but that's the only instance of that kind of thing, and that class is relatively new, so I think it might be a problem with step_by_step rather than the CI setup. |
This is because we have included some plugins that are defined in a patch on the Preview Link module, but we haven't release the code pulling in the patch because of test failures: localgovdrupal/localgov#730 (comment) Just looking at potential fixes for this. |
f7a37e5
to
c4c352f
Compare
chore: update lando tooling to better reflect usage chore: only run phpcs and phpstan on latest php version chore: update step name feat: update phpstan to mirro upgrade_status results feat: update phpstan to ignore errors from phpunit dynamic call fix: remove booleansInConditions check
7077bf8
to
d1d0c6c
Compare
Think this is ready to go now. I've created a PHPStan baseline to ignore the remaining errors for now so we can fix them in future. The reason for this is we are getting more people contributing and this feels more important to get in now so it runs on the workflows and for future code contributions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Largely looks fine. Just a couple of comments.
In Microsites we have ignored some Drupal 12 deprecations until we can drop support versions of Drupal that don't support the changes. See https://github.com/localgovdrupal/localgov_microsites_project/blob/4.x/phpstan.neon. There's a draft PR adding these with #174. Do we want to include this here?
Is the plan to create issues for all the ignored rules in each repo so we can fix them and then remove the exceptions here?
Yep that makes sense @stephen-cox I've updated the PR to include ignoring Drupal 12 deprecations. Also correct on the second point, once merged I plan to create issue tickets for everything in the baseline and tag with "good first issue" or similar so over time we can chip away at that file and then remove it.
|
Hi @stephen-cox phpstan baseline updated, test failures unrelated |
It looks like the pull request from @MattOz-CDS here inludes some of the same lines for Drupal 12 deprecations: https://github.com/localgovdrupal/localgov_project/pull/171/files I note that in that pull request, it mentions renderPlain twice, and specifies the interface and class, where as here we just mention it once and don't specifiy the interface / class.
Is it just less specific to avoid mention of interface or class? |
@finnlewis yes when I tested recently the message had changed slightly so it wasn't ignoring, this makes it less specific but still allows for it to be ignored |
Additional context here: localgovdrupal/localgov#685
level
to1
to match Drupal core (https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/phpstan.neon.dist?ref_type=heads#L9)phpstan/phpstan-strict-rules
phpstan.neon
to include rulecheckFunctionArgumentTypes
as per https://www.drupal.org/project/drupal/issues/3404246phpstan/phpstan-strict-rules
exceptstrictCalls
Deprecated
check on workflow toPHPStan