Problem/Motivation

Drupal_Sniffs_Commenting_FunctionCommentSniff supports the syntax for hook doxygen that specifies a phptemplate template file, but not Twig, which causes false positives in core.

Proposed resolution

Make it support both.

Remaining tasks

Review. Commit.

User interface changes

n/a

API changes

n/a

Comments

traviscarden’s picture

Assigned: traviscarden » Unassigned
Status: Active » Needs review
StatusFileSize
new3.25 KB

This adds support for "Implements hook_foo() for some-template.html.twig." and preserves support for "Implements hook_foo() for some-template.tpl.php.".

klausi’s picture

Status: Needs review » Needs work

Patch does not apply.

  1. +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php
    @@ -217,9 +217,9 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
    -                $phpcsFile->addWarning('Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().", or "* Implements hook_foo_BAR_ID_bar() for xyz_bar.tpl.php.".', $commentStart + 1);
    +                $phpcsFile->addWarning('Format should be "* Implements hook_foo().", "* Implements hook_foo_BAR_ID_bar() for xyz_bar().", or "* Implements hook_foo_BAR_ID_bar() for xyz-bar.tpl.php.".', $commentStart + 1);
    

    I think that should also mention the twig possibility now, right?

  2. +++ b/coder_sniffer/Drupal/Sniffs/Commenting/FunctionCommentSniff.php
    @@ -363,7 +363,7 @@ class Drupal_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_S
    -                    // $this->currentFile->addError($error, $errorPos, 'MissingReturnType');
    +                    $this->currentFile->addError($error, $errorPos, 'MissingReturnType');
    

    Unrelated change?

traviscarden’s picture

Status: Needs work » Needs review
StatusFileSize
new2.06 KB

Oops. I created that patch from the wrong branch. Here's a clean one with the change request in #2.1.

  • Commit 2dded95 on 7.x-2.x authored by TravisCarden, committed by klausi:
    Issue #2203627 by TravisCarden: Fixed "Implements hook_foo() for some-...

  • Commit 8bc2c3c on 8.x-2.x authored by TravisCarden, committed by klausi:
    Issue #2203627 by TravisCarden: Fixed "Implements hook_foo() for some-...
klausi’s picture

Status: Needs review » Fixed

Committed to both branches, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.