Step 0: Reading
Read xjm's comment on the fixing type hints before working on the patch or reviewing this issue.
Problem/Motivation
This is a part of the attempt to fix #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard
This issue is created to work on the sub-sniff Drupal.Commenting.FunctionComment.MissingReturnType
There is work in older, by module issues, that can be added to this. #1800046: [META] Add missing type hinting to core docblocks, fix Drupal.Commenting.FunctionComment.Missing*
Steps to reproduce
N/A
Proposed resolution
Remove the exclusion of Drupal.Commenting.FunctionComment.MissingReturnType from phpcs.xml
Remaining tasks
Make a patch for 9.5.x
Note: This patch has 90 files changed, 210 insertions, 217 deletions.
Review - read Step 0 above
Commit
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Release notes snippet
The Drupal.Commenting.FunctionComment.MissingReturnType coding standard has been enabled in core.
| Comment | File | Size | Author |
|---|---|---|---|
| #67 | 2941148-67-9.5.x.patch | 88.67 KB | quietone |
| #67 | interdiff-58-67-9.5.x.txt | 3.28 KB | quietone |
| #66 | 2941148-66-10.patch | 86.3 KB | quietone |
| #66 | interdiff-63-66-10.txt | 2.57 KB | quietone |
| #63 | 2941148-63-10.0.x.patch | 88.87 KB | quietone |
Issue fork drupal-2941148
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 #2
cilefen commentedComment #3
vitaliyb98 commentedComment #4
vitaliyb98 commentedAdded hint type to first 23 class
Comment #5
vitaliyb98 commentedComment #6
martin107 commentedWhile I think this is a good idea.
It is on the path to becoming unreviewable.
Could we make this a meta issue and then spin off issue for say the component namespace, the Drupal\Core\Entity namespace etc?
Comment #7
sweetchuckI change the status to "needs review" because of the #4
Comment #8
ankitjain28may commentedThis should be type array as its an array of strings.
Comment #9
ankitjain28may commentedAdd interdiff for the above patch #4
Comment #10
borisson_There is a phpcs rule we can enable for this. We should also not do anything else other than
@returnfixes in this issue.The phpcs rule is
Drupal.Commenting.FunctionComment.MissingReturnType. We should do that intead, see also #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard for more information.Comment #13
sweetchuckgit grep --line-number --perl-regexp '@return$' > i2941148-phpdoc-return.txtComment #18
quietone commentedMoving this to a child of #2571965: [meta] Fix PHP coding standards in core, stage 1. I have updated the IS and the patch. Not running tests yet.
Comment #19
quietone commentedThe patch in #18 includes changes from;
Comment #22
quietone commentedAdded some more changes.
There are still coding standard fixes to make here.
Comment #23
beatrizrodriguesi'll fix some of the coding standard problems
Comment #24
beatrizrodriguesSo, I did the reroll of the patch because I was having some problems at applying it. I actually found only a few phpcs problems about return missing type. I left some files behind, I mean, I didn't add return because this files were changed in this issue that I worked:
3246665 - Incorrect docblock return type in Upsert::execute() and Update::execute()
So, I don't know it is a good thing fixing this files here. (The 3246665 issue is not closed as fixed but, I don't know, if it is a case of fixing here too...)
I'm sending the new patch and a interdiff too.
Comment #25
beatrizrodriguesComment #26
daffie commentedThe testbot is returning with:
Comment #27
sweetchuckComment #29
quietone commentedClosed #2109603: Fix throws in Drupal\Core\Database which included a fix that is duplicated here, adding credit.
Comment #31
sweetchuckI could not reproduce the failing test with LayoutBuilderDisableInteractionsTest.
PHP 7.4.25 and 8.0.12
MySQL (Percona) 8.0.26-16
ChromeDriver 95.0.4638.54 (Chromium)
I ran the test several times (~15-20) and it was always green, then I got this error message:
Since then I could not reproduce this error message (~15-20 rerun).
Just for the record the, the error message for the patch #27 on Drupal CI is something else:
Maybe this one is an unstable test.
I just rerun the test on Drupal CI. Let see what happens.
Comment #32
sweetchuckComment #33
quietone commented@Sweetchuck, thanks for looking into the failing test. There is a Meta issue which lists the tests that have random failures, #2829040: [meta] Known intermittent, random, and environment-specific test failures. Since this issue isn't changing code, I think it is perfectly OK to comment that the failure is in a test listed on that page and setting the issue back to NR. Running the tests is a real cost to the Drupal Association and it is OK to avoid that cost when we can.
Comment #35
lucienchalom commentedI reviewed the last patch #27 and found out it needed a reroll.
I also added return statements in 2 files that were missing.
Thank you
Comment #38
WagnerMelo commentedHello, i reviewed this issue, checking all files that received change, and everything's look like that make sense, so i'll move this issue to RTBC
Comment #39
daffie commentedThe change to the file core/phpcs.xml.dist is missing.
Comment #40
quietone commentedUpdated patch for 10.0.x and updated phpcs.xml per #39.
Comment #41
daffie commentedTestbot is still not happy.
Comment #42
ravi.shankar commentedFixed Drupal CS errors of patch #40.
Comment #43
daffie commentedStill testbot errors: https://www.drupal.org/pift-ci-job/2386398
Comment #44
bruno.bicudoI rerolled #42 as it wasn't applying and tried to address the erros.
Comment #45
bruno.bicudoComment #46
bruno.bicudoOk, for some reason patch didn't apply because of a change on Merge.php (despite that it applied good on local). Trying again.
Comment #47
bruno.bicudoOk so, trying to address the last errors.
Comment #48
bruno.bicudoLast patch i'll send for this issue. I'm unable to reproduce the errors locally and working against DO logs mess a lot with the issue feed.
Sorry for cluttering the feed with patches. Hope it's all solved by now.
Needs review :)
Comment #49
bbralaHi,
You should also attach an interdiff if you are working with patch files. Check out this documentation page.
Also if want to check the codestyle of your core patch, check out this page on the dev tools included and hwo to run them.
Comment #50
quietone commented@ravi.shankar, thanks for the reroll. Since this issue for coding standards only there should be no changes to the code. The phpstan errors need to be fixed in the documentation.
I rerolled this from the patch in #40 where the phpstan first appeared.
Comment #51
quietone commentedComment #52
daffie commentedThe patch looks good!
I think we can remove "|null" as null is part of mixed.
See previous.
See previous.
I am not happy with this one, only I do not know how to make it better.
Should this not be: "@return array".
The return value can also be "-1".
Comment #53
sophiavs commentedHello, i will be doing those changes specified on #52
Comment #54
sophiavs commentedI changed those returns
Comment #55
bruno.bicudoI reviewed #54 and looks like it covers everything pointed in #52.
So far so good, so I'm moving to RTBC.
Comment #56
quietone commentedYes, this almost done!
@sophiavs, Welcome to Drupal! Thanks for making the changes to the patch. To help reviewers always add an interdiff, or a diff, whichever is appropriate. There are instructions for creating an interdiff. Thanks.
This needs a patch for 9.5.x.
Comment #57
ravi.shankar commentedAdded reroll of patch #54 on Drupal 9.5.x.
Comment #58
quietone commented@ravi.shankar, thanks but remember to run the commit code checks locally .
Add back the changes for 9.5.x for deprecated code.
Comment #59
quietone commentedTo help with review, I am adding the missing interdiff.
Comment #60
quietone commentedComment #61
quietone commentedThis isn't being found by tag. Re-entering tag
Comment #62
daffie commentedIt all look good to me.
All my points have been addressed.
The suppression of the rule has been removed.
The testbot is green.
For me it is RTBC.
Thanks everybody for working on this.
Comment #63
quietone commented@daffie, thanks!
Now, make a patch for 10. This applies to 10.0 and 10.1
Comment #64
longwaveI checked all three patches by running
rg @return$to find empty return tags, then applying the patches and rerunning the command. After applying there are no empty return tags left.I also read through the patches and all the changes look good and make sense. There is one exception:
Technically @param is out of scope here, but this is still the correct fix so we can let this one slide.
Therefore this is RTBC.
Comment #65
catchIs this actually necessary for the documentation change? Would think the implicit NULL from
return;would still be fine?Comment #66
quietone commentedMaking the changes for #65 for Drupal 10. The patch applied locally to 10.0 and 10.1.
Comment #67
quietone commentedAnd repeat for the 9.5.x patch.
Comment #68
sweetchuckI understand why the
return NULL;parts was changed back toreturn;,but this way it is not clear what is the intention of the code author.
return void (this one does not matches the PHPDoc)
or
return null
I think in a follow up issue those
return;statements should be changed toreturn NULL;, and everywhere else in the code base.Comment #69
longwave#66/#67 look good, back to RTBC.
Adding followup tag for #68.
Comment #70
alexpottCommitted and pushed b8ac0d9850 to 10.1.x and ecd67af7a4 to 10.0.x. Thanks!
Committed 452bf18 and pushed to 9.5.x. Thanks!
It'd be great if someone could create the follow-up for #68 but I don't think it not existing should prevent this going in.
Comment #74
longwaveComment #75
quietone commentedFollow up was made, #3312049: [Followup] Fix Drupal.Commenting.FunctionComment.MissingReturnType returns for NULL. I am removing the tag.