How to fix “Hook implementations should not duplicate @param documentation.”?

I am using PhpStorm to experiment with cleaning up my code in a custom module. For the following function, I'm getting this warning:

Hook implementations should not duplicate @param documentation.

/**
* Implements hook_field_widget_form_alter().
*
* @param array $element * @param array$form_state
* @param array $context */ function mymodule_field_widget_form_alter(&$element, $form_state,$context) {
if ($context['widget'] instanceof \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget) {$element['#after_build'][] = '_mymodule_remove_textarea_help';
}
}


What should I do to fix this? I thought I needed to delete the @param comments, but when I do that, PhpStorm complains that I don't have any param comments.

• Turn off "Preferences -> Editor -> Inspections -> PHP -> PHPDoc -> Missing PHPDoc comment" maybe? The general answer is to get PHPStorm's document inspections to match up to Drupal's documentation standards – Clive Feb 3 '16 at 9:25
• The problem ist that you check for drupal coding standards and php coding standards. You should deactivate the sniffer for the general php coding standards and use the custom drupal coding standards – sgoelz Feb 3 '16 at 10:32
• @Clive has the right answer here. That error has nothing to do with coding standard, and everything to do with PHPStorm's built in inspections :) – Chapabu Jun 28 '16 at 14:22
• The accepted awnswer solve the problem in the IDE but if you check the coding standard the problem is still there. See my solution. – Adrian Cid Almaguer Jul 14 '17 at 17:04

The problem is that if you're implementing a hook and you don't need to write more than this:

/**
* Implements hook_field_widget_form_alter().
*/


Because you will have all the information in the hook_field_widget_form_alter() definition, so just write always in the hooks implementations only this:

/**
* Implements hook_hook_name().
*/


/**
* Implements hook_field_widget_form_alter().
*/
function mymodule_field_widget_form_alter(&$element,$form_state, $context) { if ($context['widget'] instanceof \Drupal\text\Plugin\Field\FieldWidget\TextareaWidget) {
\$element['#after_build'][] = '_mymodule_remove_textarea_help';
}
}


You need to turn off the built in PHPStorm inspection that checks for "Missing PHPDoc Comments", then you can safely delete your @param blocks.

• Would the downvoter care to explain what's wrong so I can amend the answer? Or is just a "tit for tat" downvote? – Chapabu Jun 28 '16 at 16:03
• This solve the problem in the IDE but if you check the coding standard the problem is still there. See my solution. – Adrian Cid Almaguer Jul 14 '17 at 17:04

As others have said, you need to set the PHPStorm config to treat your project as a Drupal project.

Second to that, get up and running with Coder.

Once you have those packages installed, you can wire them up in PHPStorm and set your standards system accordingly or just run the reports from command line. This will make your environment more in-line with the Drupal coding standards instead of the general ones that ship with PHPStorm out of the box config.

• The downvotes were mine. I didn't "carpet bomb" anything, I merely downvoted the answers as they were incorrect. – Chapabu Jun 28 '16 at 14:30
• What a impolite act. – Jimmy Ko Jul 20 '16 at 9:34