Problem/Motivation
The $field_label param for \Drupal\Tests\field\Traits\EntityReferenceFieldCreationTrait::createEntityReferenceField expects a string, but many times jsonapi (and once in views) we pass null. With strict types this is not allowed.
This also results in invalid schema:
field.field.*.*.* type is field_config_base
The label property type for field_config_base is required_label
The required_label has the NotBlank constraint.
Steps to reproduce
Add checkFunctionArgumentTypes: true to phpstan parameters
Run phpstan and grep for this function:
./vendor/bin/phpstan analyse -c core/phpstan.neon.dist --error-format=raw | grep createEntityReferenceField
Proposed resolution
Pass a string based on the field name instead
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3552181
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:
- 3552181-stop-passing-null
changes, plain diff MR !13486
Comments
Comment #3
mstrelan commentedComment #4
smustgrave commentedThis seems straight forward, LGTM!
Comment #5
bbralaYes, ran though, had a small brainfart in regards to scope, but then reread the IS and all is fine. :)
Indeed RTBC
Comment #8
xjmNow
testDanglingReferencesInAnEntityReferenceFieldFromIssue2968972()is a method name, y'all.Yay actually following documented typing for strict type enablement potential. Committed to 11.x and cherry-picked to 11.2.x as a patch-safe cleanup to individual tests. Thanks everyone!