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

Conflict with phpcs for hook implementations #301

Open
andrewbelcher opened this issue Aug 16, 2023 · 1 comment
Open

Conflict with phpcs for hook implementations #301

andrewbelcher opened this issue Aug 16, 2023 · 1 comment

Comments

@andrewbelcher
Copy link

How is drupal-check installed?
drupal-check is installed as a dependency to my project

Environment:

  • OS: DDEV
  • PHP Version: 8.2
  • Drupal core: 10.x.x

Describe the bug
phpcs coding standards and drupal-check conflict with hook implementations. An example:

/**
 * Implements hook_entity_type_build().
 */
function mymodule_enttiy_type-build(array &$entity_types): void {
  // Do stuff....
}

This will pass phpcs coding standards, but will fail drupal-check with Function mymodule_entity_type_build() has parameter $entity_types with no value type specified in iterable type array.

The fix for phpstan is to use an @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types, but this then causes phpcs to fail with Hook implementations should not duplicate @param documentation.

It's worth noting that hook_entity_type_build already has the correct typehint.

Suggested fix
Is there a way we can extend the phpdoc interpretation to follow Implements hook_HOOK_NAME(). in a similar way that {@inheritdoc} is followed for classes?

@andrewbelcher
Copy link
Author

Actually, just found mglaman/phpstan-drupal#404 which I think is where this would actually be fixed...

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

1 participant