Problem/Motivation
#3555468: Recent commits to *.3.x branches break BC fixed some compatibility issues for 10.x under the 3.3.x branch. However, there are some outstanding PHPStan warnings that weren't blockers, but should be fixed.
Steps to reproduce
See pipeline for phpstan (previous major).
Proposed resolution
Some of the issues can be fixed with a before_script, to remove the attributes before phpstan (previous major) runs:
phpstan (previous major):
before_script:
- if [[ "$DRUPAL_CORE" =~ ^10 ]]; then
- sed -i '/#\[Legacy.*\]/d' $DRUPAL_PROJECT_FOLDER/*.module $DRUPAL_PROJECT_FOLDER/*.inc $DRUPAL_PROJECT_FOLDER/modules/*/*.module $DRUPAL_PROJECT_FOLDER/tests/modules/*/*.module
- sed -i '/^.*#\[\(Hook\)\(.*\)\].*$/d' $DRUPAL_PROJECT_FOLDER/src/Hook/*.php $DRUPAL_PROJECT_FOLDER/modules/*/src/Hook/*.php $DRUPAL_PROJECT_FOLDER/tests/modules/*/src/Hook/*.php
- fi
There are some other problems that will need further investigation. These stem from changes to the (expected) warnings generated by phpstan v1 vs. v2, changed in #3533155: Fix CI after core updating to newer version of phpunit.. We need to conditionally define the expected warnings based on which phpstan version we're using.
Remaining tasks
Add before script as described above.- Investigate other warnings.
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork group-3555505
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
dwwI pushed a commit to the issue fork from @lostcarpark in the parent issue's MR branch. All the LegacyHook stuff should hopefully now be resolved here. However, there are still other phpstan errors when testing against 10.5.x core, so calling this NW for now.
Comment #5
dwwHrm, looking at
phpstan.neon, it's clear that we're trying to silence deprecation warnings about all thisGroupMembershipandGroupMembershipLoaderstuff:So I kinda think we're "barking up the wrong tree" here. The phpstan job is also failing (only in 10.5.x) due to:
This was most recently touched in #3533155: Fix CI after core updating to newer version of phpunit.:
So instead of changing the test code at all, I think we need to consider something like https://git.drupalcode.org/project/project_browser/-/blob/2.0.x/phpstan-... and have a separate phpstan.neon include file for D10 vs. D11 so we're accurately ignoring the right warnings depending on the phpstan version we're running. More or less.
Comment #6
dwwPushed some commits for that. Let's see what the bot thinks now...
Comment #7
dwwHuzzah, that's working. 🎉 The MR is now not touching any code, only the
phpstanconfig and.gitlab-ci.yml. So I think this is safe and entirely non-disruptive. However, I'll definitely wait for someone else to RTBC before I commit this.Comment #8
lostcarpark commentedI have reviewed the changes in this MR.
The changes are only to PHPStan ignore rules, to cause specific errors to be ignored, specifically to skip known safe deprecation warnings, and for Drupal 10, to ignore warnings about hook attributes.
I haven't done any manual testing, but as there is no change to the module code, there should be no change to module behaviour, so manual testing should not be necessary to validate it.
I am happy that this change will correctly suppress hook messages for Drupal 10 only, and will suppress deprecation warnings appropriately for each version.
Moving to RTBC.
Comment #9
amateescu commentedReviewed the MR and it looks great to me! Posted a couple of comments, one for wrong indentation in the
-v1file and the other for a cosmetic change.Leaving at RTBC because those points can be accepted (or not) before merging.
Comment #13
kristiaanvandeneyndeThanks all!