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

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

mstrelan created an issue. See original summary.

mstrelan’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

This seems straight forward, LGTM!

bbrala’s picture

Yes, ran though, had a small brainfart in regards to scope, but then reread the IS and all is fine. :)

Indeed RTBC

  • xjm committed 2ecc2eb9 on 11.x
    Issue #3552181 by mstrelan, bbrala: Stop passing null as the label to...

  • xjm committed 33e2940a on 11.2.x
    Issue #3552181 by mstrelan, bbrala: Stop passing null as the label to...
xjm’s picture

Status: Reviewed & tested by the community » Fixed

Now 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!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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