Problem/Motivation

Among our efforts to add strict typing to core, tests are good early targets, because the majority of test code is internal API.

Proposed resolution

Add return typehints to the test codebase, first where non-disruptive, then where possibly disruptive (base classes, traits, etc.).

Remaining tasks

  1. #3421418: [May 2024] Add void return typehints to all test methods
  2. #3455549: Add return typehints to protected test helper methods
  3. #3421417: Add appropriate return typehints to all @dataProvider methods
  4. Decide how to handle test fixtures, both within and outside of test class files. (Probably merits its own child meta.)
  5. Children being added as various followups to the above.
  6. Enable SlevomatCodingStandard.TypeHints.ReturnTypeHint phpcs code sniff on */tests/*

API changes

Return typehints on methods in test code.

Release notes snippet

Maybe?

Comments

xjm created an issue. See original summary.

xjm’s picture

Issue summary: View changes
xjm’s picture

Issue summary: View changes
mstrelan’s picture

Issue summary: View changes

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.