You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Entities: Allow FieldItemList access through magic __get/__set methods
PHPStan said "Access to an undefined property". A custom entity may
define fields in ::baseFieldDefinitions(). Other ways to define a
field are though hook implementations like hook_entity_base_field_info(),
or through config entites created from the Drupal admin UI. Thus,
it seems very hard to track all cases in PHPStan.
While ContentEntityBase::__get() will return a FieldItemListInterface,
ContentEntityBase::__set may be used to set fields directly, thus I
decided to tell PHPStan that the type is mixed. For example, the following
code can be valid:
````php
$entity = SomeCustomEntity();
$entity->some_int_field = 34;
$entity->save();
````
0 commit comments