This one might be a big ambiguous, so perhaps its not a bug after all, but I thought I'd bring it up, because it has been causing some problems with code I've run though codesniffer.

On the drupal coding standards page (http://drupal.org/coding-standards and http://drupal.org/node/608152) it doesn't seem well defined what should be used for variable names in the local scope of a class method. Ex:

class foo {
  function bar($fooBar) {
    print $fooBar;
  }
}

Throws a warning, while:

class foo {
  function bar($foo_bar) {
    print $foo_bar;
  }
}

Doesn't throw a warning. Looking for further clarification I took a look at what the coder module did, and it stays out of the issue, not throwing warnings either way. It appears that Drupal core code tends toward lower underscores, however it also contains examples of camel case. For example on at the top of common/entity.inc in D7:

interface DrupalEntityControllerInterface {
  public function __construct($entityType);
}

This ticket is more a question then anything, what is the coding style preferred? Perhaps if its left up to the developer then some sort of easily disable check is desirable.

Comments

klausi’s picture

I personally think that we should stick with underscores for local variables in a function. It helps us to distinguish class variables/properties (camel case) from local variables (underscores).

klausi’s picture

Status: Active » Closed (won't fix)

Drupal Code Sniffer has been merged into Coder 7.x-2.x. Please move this issue to the Coder queue and reopen it if the problem still exists.