Problem/Motivation
Part of #3404246: [META] Fix strict type errors detected by phpstan.
By correcting 22 incorrect documented types we resolve 90 detected issues.
Steps to reproduce
Add checkFunctionArgumentTypes: true to the parameters section of phpstan.neon.dist
Run phpstan:
$ ./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw
Compare 11.x to this branch
Proposed resolution
Fix doc types to resolve the attached errors
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | 3552759-fixes.txt | 25.65 KB | mstrelan |
Issue fork drupal-3552759
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:
- 3552759-phpdoc-fixes
changes, plain diff MR !13512
Comments
Comment #3
mstrelan commentedComment #4
smustgrave commentedLeft some comments. But shouldn't the descriptions be updated too to match what's being changed?
Comment #5
mstrelan commentedFrom my perspective that just opens up more for reviewers and committers to have to parse and agree on. You could also argue that if we're updating the doc types we should also be adding native typing too, but that's not in scope, so why are descriptions? Nevertheless I've taken a stab at this.
Comment #6
smustgrave commentedFair point. I’m going to mark as this does seem to be a net gain plus.
Thanks for making those changes!
Comment #7
quietone commentedHow was this group of changes selected? They seem to be a variety of types.
Comment #8
mstrelan commentedThey are selected at random from looking at a list of around 400 errors and picking ones that occurred several times or looked easy to fix. I have another batch ready to go but this feels like a good size. I don't think there is a way to group them that is particularly meaningful.
Comment #9
quietone commented@mstrelan, thanks. I scanned this earlier and didn't see any problems. It is now late and I will review again tomorrow, so assigning to myself.
Comment #10
quietone commentedJust some removals to keep this in scope, more details in the MR.
Comment #11
mstrelan commentedReverted the two changes that include description updates. Not opening follow ups for these yet as they'll eventually be picked up in the existing meta.
Comment #12
dcam commentedI did manual checks on all the changes. Overall they look OK to me. I left comments for the couple of things that I noticed.
Comment #13
mstrelan commentedRebased and found a few that had been fixed in sibling issues. Reverted change to DataDefinitionInterface, we can discuss it in another issue. This PR now has 22 fixes, resolving 90 issues. Ready for another review.
Comment #14
smustgrave commentedSorry appears to need a rebase.
Comment #15
mstrelan commentedRebased
Comment #16
dcam commentedI ran PHPStan before and after the changes. I verified that the changes reduce the violation count by 90. My recent feedback was addressed. Tests are passing. This looks good to me.
Comment #17
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #18
mstrelan commentedRebased and responded to feedback
Comment #19
smustgrave commentedLeaning on previous reviews, but feedback appears to be addressed.
Comment #20
borisson_I have reviewed this as well, this looks great, and all questions are answered indeed. rtbc++
Comment #21
mstrelan commentedRebased on
main, there was one conflict inMigrationConfigurationTrait::getMigrationsthat was updated in #3557514: Fix "expects int, string given" issues detected by phpstan and I acceptedtheirs, meaning the param is typed asnumericinstead ofstring. Leaving the status as it is.Comment #23
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #24
dcam commentedPost-bot-rebellion rebase
Comment #25
mstrelan commentedRebased. There was a conflict with AnnotatedClassDiscovery because #3567159: Fix "expects array<string>" issues detected by phpstan also touched this class, so I think at least that file needs review.
Comment #26
borisson_That change looks good to me.
Comment #30
longwaveEverything here looks good to me. There is one case where File could have been FileInterface but it's only in a test and not worth the effort.
Backported to 11.3.x as a docs-only fix. Doesn't apply to 10.6.x, not sure it's worth the effort there either.
Committed and pushed 126e77458b2 to main and 32caacf906b to 11.x and 990c5fe085c to 11.3.x. Thanks!