I've corrected all the other problems reported by `phpcs --standard=Drupal --extensions=php,module,inc,install,test,profile,theme template.php` and the last two look like a bug to me. This code:


function k2tech_preprocess_page(&$variables) {
  if (isset($variables['node'])) {
    $variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
  }
}

function zen_id_safe($string) {
  if (is_numeric($string{0})) {
    // If the first character is numeric, add 'n' in front.
    $string = 'n' . $string;
  }
  return strtolower(preg_replace('/[^a-zA-Z0-9_-]+/', '-', $string));
}

Results in this report:

FILE: template.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 102 | ERROR | You must use "/**" style comments for a function comment
 108 | ERROR | Missing function doc comment
--------------------------------------------------------------------------------

It seems to me that both functions should have the "Missing function doc comment" error.

CommentFileSizeAuthor
#2 1665116-demonstrate-bug.txt483 bytesthsutton

Comments

klausi’s picture

Status: Active » Postponed (maintainer needs more info)

The snippet from above works correctly for me and throws the "Missing function doc comment" twice. Is there any other comment before the first function? Did you try with the latest release of drupalcs?

thsutton’s picture

Version: 7.x-1.0-alpha2 » 7.x-1.0-beta1
StatusFileSize
new483 bytes

It's interpretting a // comment inside the previous function as a "wrong style" of doc comments. I've attached a file which demonstrates the problem with the current release and (though I may be testing incorrectly) the current dev release.

FILE: .../1665116-demonstrate-bug.txt
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
 21 | ERROR | You must use "/**" style comments for a function comment
--------------------------------------------------------------------------------
thsutton’s picture

Status: Postponed (maintainer needs more info) » Active
klausi’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Fixed

Status: Fixed » Closed (fixed)

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