Problem/Motivation

The FieldUiTestTrait contains several methods where parameter type hints are missing, despite the codebase increasingly adopting strict typing.

For example:

public function fieldUIAddNewField($bundle_path, $field_name, $label = NULL, $field_type = 'test_field', array $storage_edit = [], array $field_edit = [], bool $save_settings = TRUE): void

Some parameters such as $bundle_path, $field_name, and $label can be explicitly typed (e.g., ?string, string) based on their usage.

Steps to reproduce

1. Inspect core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php

2. Review method signatures such as:

* fieldUIAddNewField()
* fieldUIAddExistingField()
* fieldUIDeleteField()
* getFieldFromGroup()

3. Observe that several parameters lack type hints even though their expected types are clear from usage.

Proposed resolution

Add appropriate parameter type hints where applicable, for example:

public function fieldUIAddNewField(
  ?string $bundle_path,
  string $field_name,
  ?string $label = NULL,
  string $field_type = 'test_field',
  array $storage_edit = [],
  array $field_edit = [],
  bool $save_settings = TRUE
): void

Remaining tasks

None.

User interface changes

None.

Introduced terminology

None.

API changes

None.

Issue fork drupal-3582566

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

longwave’s picture

Why this particular trait? Does this help catch any bugs found elsewhere in the issue queue? Should we try to cover more test traits in one go?

ishani patel made their first commit to this issue’s fork.

sivaji_ganesh_jojodae’s picture

This was noted while reviewing #3575234: Add return types to FieldUiTestTrait and hence I've created this.

ishani patel’s picture

StatusFileSize
new2.27 KB

I've created a patch for this.
Please check and review it.

ishani patel’s picture

Status: Active » Needs review
sivaji_ganesh_jojodae’s picture

Status: Needs review » Needs work

Because of error reported by phpstan and phpcs.