Problem/Motivation
PHPStan reports calls like FieldConfig::loadByName(...)->setTranslatable(TRUE) as a call to an undefined method. There are 49 of these in the baseline, for setTranslatable(), setSetting(), setRequired(), setDefaultValue(), setSettings() and addPropertyConstraints().
This is because FieldConfig::loadByName() and MediaSourceInterface::createSourceField() are documented to return \Drupal\field\FieldConfigInterface, and there are two interfaces called FieldConfigInterface:
\Drupal\Core\Field\FieldConfigInterfaceextendsFieldDefinitionInterfaceandConfigEntityInterfaceand declares the setters.\Drupal\field\FieldConfigInterfaceextends the same interfaces directly, so it has none of those setters.
The concrete class, \Drupal\field\Entity\FieldConfig, already implements the core interface via \Drupal\Core\Field\FieldConfigBase, so the interface hierarchy just doesn't match the class hierarchy.
Steps to reproduce
grep 'Drupal\\\\field\\\\FieldConfigInterface::' core/.phpstan-baseline.php
Proposed resolution
Make the field interface extend the Core\Field interface.
Remaining tasks
Determine why we have two interfaces with the same name and if we still need them both.
Comments
Comment #2
shank115 commentedThis looks like it might be a duplicate of #2818877 which proposes the same change(making
\Drupal\field\FieldConfigInterfaceextend\Drupal\Core\Field\FieldConfigInterface)Comment #3
mstrelan commentedYep sorry about that