Problem/Motivation
See #3455549: Add return typehints to protected test helper methods
Steps to reproduce
Add this to phpcs.xml.dist
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<include-pattern>*/tests/*</include-pattern>
</rule>
Run composer phpcbf
Grep the git diff output for changes that add : int to protected or private methods
Proposed resolution
Commit the changes identified in the steps to reproduce
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3458426
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:
- 3458426-protected-int-return
changes, plain diff MR !9323
Comments
Comment #3
abarrioI made a part of the development.
Comment #4
mstrelan commented@abarrio thanks for working on this. The scope should be limited to tests only, so in paths like core/tests/* and core/*/*/tests. We also don't want to add union types in this issue, to keep the scope down, so should be limited to int returns only.
Comment #6
mstrelan commentedComment #8
smustgrave commentedNot sure why cspell is showing up but pipeline failed.
Comment #9
mstrelan commentedcspell was due to catch and I debugging some pipeline cache issues, let's move that to #3470641: gitlab artifact caching doesn't work due to differences with project ID and build directories. Have reverted and rebased.
Comment #10
smustgrave commentedNice, in that case change seems fine.
Comment #11
quietone commentedI applied the diff and tested.
My results show two methods that have not been changed
Comment #12
mstrelan commentedThanks @quietone, I should have indicated why these were skipped. Both of these claim to return an int but actually return a string.
The two methods are:
\Drupal\Tests\comment\Functional\CommentTestBase::getUnapprovedComment\Drupal\KernelTests\Core\Entity\EntityDecoupledTranslationRevisionsTestI've added a note to fix these in the parent issue. Not opening individual issues for now so we can figure out appropriate scope for these little fixes.
Setting back to RTBC as there is nothing to change here.
Comment #14
quietone commented@mstrelan, thanks for the explanation.
I reviewed the MR and I think it is ready for commit. There is JavaScript here, which I no little of. So I confirmed that transfersize returns an int. So, this is good to go.
Comment #15
quietone commentedCommitted d433d96 and pushed to 11.x. Thanks!
Comment #16
quietone commentedI tried to find the commits made by @abarrio but wasn't able to. So, I DMed mstrelan who confirmed the contribution was valid, it just needed to be de-scoped. Therefor, adding credit.
Comment #18
quietone commentedThis is causing test failures on HEAD, from \Drupal\migrate_drupal\Tests\StubTestTrait::createEntityStub. Although, I don't understand why tests passed in the lastest pipeline here though.
Comment #19
mstrelan commentedI investigated the fail mentioned in #18 and it was due to #3400434: Enforce strict types in tests. This uncovered that sometimes
::createEntityStubreturns an int and sometimes a string. I've added this one to the list of return types to be fixed in the parent issue. I've removed the return type from this method in the MR, setting back to NR.Comment #20
smustgrave commentedAppears to have test failures.
Comment #21
quietone commentedYes, but those are in tests that are not changed in the MR.
Comment #22
smustgrave commentedRebase seems good and all green!
Comment #23
quietone commentedThanks!
Assigning to myself to commit within 24 hours.
Comment #25
quietone commentedThanks! Let's try this again.
Committed 2319f33 and pushed to 11.x. Thanks!