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.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | field-ui-test-trait-type-hints.patch | 2.27 KB | ishani patel |
Issue fork drupal-3582566
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
Comment #2
longwaveWhy 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?
Comment #4
sivaji_ganesh_jojodae commentedThis was noted while reviewing #3575234: Add return types to FieldUiTestTrait and hence I've created this.
Comment #5
ishani patel commentedI've created a patch for this.
Please check and review it.
Comment #7
ishani patel commented