Problem/Motivation

This is a child issue of #3376057: [META] Add declare(strict_types=1) to all tests. After adding enabling strict types to all tests there were around 3000 errors. Fixing them all in one issue will lead to an enormous merge request that's difficult to review, as per the issue scope guidelines.

Steps to reproduce

See #3399373: Add declare(strict_types=1) to all Unit tests

Run the test suite:

./vendor/bin/phpunit -c core/phpunit.xml.dist --bootstrap=core/tests/bootstrap.php --testsuite=unit

Proposed resolution

Remaining tasks

Review updated MR

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#34 3397890-nr-bot.txt90 bytesneeds-review-queue-bot

Issue fork drupal-3397890

Command icon 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

mstrelan created an issue. See original summary.

mstrelan’s picture

Issue summary: View changes
Status: Active » Needs work
mstrelan’s picture

Status: Needs work » Needs review
mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes

smustgrave’s picture

Status: Needs review » Needs work

So MR 5216 appears to have test failures.

mstrelan’s picture

Status: Needs work » Needs review

JS test was a random fail, Unit test was due to a line number mismatch since this MR is not including the declaration. Should be good now.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Yup not seeing any failures now.

dww’s picture

Issue summary: View changes

!5216 is only fixing the strict type bugs in the tests. That much looks good to my eyes. A few trivial nits, but only personal preference and not worth holding up anything over. However, that's point 1 of proposed resolution. Is the idea to commit that first, then re-visit !5196 as part of this same issue? Or should we split these into separate issues for better scope management?

Thanks!
-Derek

mstrelan’s picture

I don't mind either way. Separate commits would make for better git archaeology and therefore a separate issue probably makes sense. There are some erroneous line break removals after running rector which seems to occur when there is a file doc block in a test. Maybe we should remove those doc blocks in another issue too, since they are not needed, then run rector again.

mstrelan’s picture

Title: Add declare(strict_types=1) to all unit tests » Fix strict type errors in unit tests
Status: Reviewed & tested by the community » Needs review

I've reduced the scope of this issue to simply provide the fixes. I've opened #3399370: Remove @file annotation from test classes which would allow the rector to run cleanly and #3399373: Add declare(strict_types=1) to all Unit tests to run the rector.

mstrelan’s picture

Issue summary: View changes
dww’s picture

Status: Needs review » Reviewed & tested by the community

Great, thanks!

In that case, !5216 is hereby RTBC. The changes are well-scoped and correct, this issue summary and title are accurate, the tests are still passing.

Thanks,
-Derek

p.s. Crediting mstrelan for working on this, and Sam and myself for reviews.

mstrelan’s picture

Issue summary: View changes

Updated IS with simpler instructions to run rector and avoid manually reverting certain files.

mstrelan’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes
xjm’s picture

Status: Reviewed & tested by the community » Needs work

This all looks correct to me. Thanks for the scope fix.

Unfortunately, it no longer applies as a diff nor rebases cleanly. Presumably there's a merge conflict. Thanks!

xjm’s picture

Oh I actually would not credit @smustgrave here based on comments so far since the two comments are specifically raised as "will not be credited" types in the core issue credit policy. (Also his name is Stephen, not Sam.) 😀 I am trying to encourage some more detailed review comments generally so that the credits reflect all his work.

mstrelan’s picture

Status: Needs work » Needs review

Merge conflict resolved

xjm’s picture

Status: Needs review » Reviewed & tested by the community

I confirmed the diffstat is the same; restoring RTBC. In the future though it'd be good to document the specific merge request on-issue. 🙂

  • xjm committed 910b569f on 11.x
    Issue #3397890 by mstrelan, dww: Fix strict type errors in unit tests
    

  • xjm committed f66861dd on 10.2.x
    Issue #3397890 by mstrelan, dww: Fix strict type errors in unit tests
    
    (...
xjm’s picture

Version: 11.x-dev » 10.1.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 11.x and 10.2.x. I tried to cherry-pick it to 10.1.x, but it did not cherry-pick cleanly. Presumably the pre-merge version of the MR would be what we want; however, I was not able to figure out how to get GitLab to give me a plain diff version of the difference between version 3 and HEAD. (https://git.drupalcode.org/project/drupal/-/compare/11.x...d8d0a9eb27417... or https://git.drupalcode.org/project/drupal/-/merge_requests/5216/diffs?di... but as plain diff was the goal.)

So, we could make a patch or 10.1.x MR from the previous commit to backport this to 10.1.x so that the tests are similarly robust there.

Thanks!

acbramley’s picture

Guess I should've commented on the issue, I did the initial review when this first issue was posted but wasn't given credit.

xjm’s picture

Ah yes, thanks @acbramley. Fixing.

acbramley’s picture

Thank you @xjm! Need to remember in the future to comment on issues if I do an MR only review :)

mstrelan’s picture

Status: Patch (to be ported) » Needs review

Added an MR for 10.1.x

The conflict was caused by #2921133: Remove "Please" from the codebase.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

MR for 10.1 seems good.

needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The 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 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.

mstrelan’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: +no-needs-review-bot

  • xjm committed 263ce2a8 on 10.1.x
    Issue #3397890 by mstrelan, xjm, dww, acbramley: Fix strict type errors...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Committed the backport to 10.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mstrelan’s picture

Issue summary: View changes