As per the core issue #3376057: [META] Add declare(strict_types=1) to all tests

Now that all tests are running green (thank you @ivnish!) I think it would be useful to strengthen them by declaring strict_types in all tests/test modules. This is the new core standard, and I have found it useful because it tends to find problems in the test cases, and even problems in the code being tested. Since strict_types will be turned on only for testing and not the module code (yet), this should not have any impact on any sites.

I'm going to make a MR with this, then add commits to clean up any problems this reveals in the tests.

Issue fork flag-3486525

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

tr created an issue. See original summary.

tr’s picture

With the (temporary) modification of phpstan.neon, I can see there is an unused test method (doFlagUiFieldPlugin()) that uses an undefined core method (drupalPostAjaxForm()). I opened up #3486527: drupalPostAjaxForm() does not exist anymore for that issue.

tr’s picture

Opened up a new issue for this:
Installing the table sequences with the method KernelTestBase::installSchema() is deprecated in drupal:10.2.0 and is removed from drupal:12.0.0.
See #3486530: [10.2] Drupal\Core\Database\Connection::nextId(), the {sequences} table and schema are deprecated

ivnish made their first commit to this issue’s fork.

tr’s picture

Status: Active » Needs review

All phpstan issue related to turning on strict_types in the tests have now been resolved, with the exception of #3486527: drupalPostAjaxForm() does not exist anymore, which requires changes that IMO are outside the scope of this issue.

  • ivnish committed 45b295b3 on 8.x-4.x authored by tr
    Issue #3486525 by tr: Add declare(strict_types=1) to all test modules
    
ivnish’s picture

Good job, TR!

ivnish’s picture

Assigned: tr » Unassigned
Status: Needs review » Fixed
ivnish’s picture

Status: Fixed » Closed (fixed)

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