Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drupal check errors on baseFieldDefinitions #252

Closed
Chris-Devriese opened this issue Dec 17, 2021 · 1 comment
Closed

Drupal check errors on baseFieldDefinitions #252

Chris-Devriese opened this issue Dec 17, 2021 · 1 comment

Comments

@Chris-Devriese
Copy link

The errors can be reproduced by installing the drupal examples module and drupal check the content_entity_example submodule provided.

drupal-check is installed globally via Composer

Environment:

  • OS: Ubuntu 21.10
  • PHP Version: 8.0.13
  • Drupal core: 9.3.0

drupal-check -a moduleName gives error on:
Access to an undefined property Drupal\Core\Entity\EntityInterface::$title

But the property does exist, it is created dynamically via:
public static baseFieldDefinitions(EntityTypeInterface $entity_type)

Q: Is drupal-check unable to check this?

drupal-check -a moduleName gives error on:
Method Drupal\ModuleName\Entity\Sample::getOwner() should return
Drupal\user\UserInterface but returns
Drupal\Core\Entity\EntityInterface.

getOwner returns: return $this->get('user_id')->entity;

Q: Isn't this a user interface?

@mglaman
Copy link
Owner

mglaman commented Jan 7, 2022

Method Drupal\ModuleName\Entity\Sample::getOwner() should return
Drupal\user\UserInterface but returns
Drupal\Core\Entity\EntityInterface.

Does the code know it's an interface? You need to type hint the result

@mglaman mglaman closed this as completed Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants