Index: coder.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/coder.module,v
retrieving revision 1.88.2.52
diff -u -u -p -r1.88.2.52 coder.module
--- coder.module	20 Sep 2008 15:32:08 -0000	1.88.2.52
+++ coder.module	20 Sep 2008 15:40:28 -0000
@@ -1438,26 +1438,45 @@ function do_coder_review($coder_args, $r
  */
 function do_coder_review_regex(&$coder_args, $review, $rule, $lines, &$results) {
   if (isset($rule['#value'])) {
-    $regexflags = isset($rule['#case-sensitive']) ? '' : 'i';
-    $regex = '/'. $rule['#value'] .'/'. $regexflags;
     $function_regex = isset($rule['#function']) ? '/'. $rule['#function'] .'/' : '';
     $function_not_regex = isset($rule['#function-not']) ? '/'. $rule['#function-not'] .'/' : '';
-    $current_function = '';
-    $paren = 0;
+    $function_current = '';
+    $function_paren = 0;
+    $class_regex = isset($rule['#class']) ? '/'. $rule['#class'] .'/' : '';
+    $class_not_regex = isset($rule['#class-not']) ? '/'. $rule['#class-not'] .'/' : '';
+    $class_current = '';
+    $class_paren = 0;
+    $regexflags = isset($rule['#case-sensitive']) ? '' : 'i';
+    $regex = '/'. $rule['#value'] .'/'. $regexflags;
     $not_regex = isset($rule['#not']) ? '/'. $rule['#not'] .'/'. $regexflags : '';
     $never_regex = isset($rule['#never']) ? '/'. $rule['#never'] .'/'. $regexflags : '';
     foreach ($lines as $lineno => $line) {
       // Some rules apply only within certain functions.
       if ($function_regex || $function_not_regex) {
-        if (preg_match('/function (\w+)\(/', $line, $match)) {
-          $current_function = $match[1];
+        if (preg_match('/function (\w+)\s*\(/', $line, $match)) {
+          $function_current = $match[1];
+        }
+        if (preg_match('/([{}])/', $line, $match)) {
+          $function_paren += ($match[0] == '{') ? 1 : -1;
+        }
+        if ($function_paren < 0 || $function_current == ''
+            || ($function_regex && !preg_match($function_regex, $function_current))
+            || ($function_not_regex && preg_match($function_not_regex, $function_current))
+           ) {
+          continue;
+        }
+      }
+      // Some rules apply only within certain classes.
+      if ($class_regex || $class_not_regex) {
+        if (preg_match('/class (\w+)/', $line, $match)) {
+          $current_class = $match[1];
         }
         if (preg_match('/([{}])/', $line, $match)) {
-          $paren += ($match[0] == '{') ? 1 : -1;
+          $class_paren += ($match[0] == '{') ? 1 : -1;
         }
-        if ($paren < 0 || $current_function == ''
-            || ($function_regex && !preg_match($function_regex, $current_function))
-            || ($function_not_regex && preg_match($function_not_regex, $current_function))
+        if ($class_paren < 0 || $class_current == ''
+            || ($class_regex && !preg_match($class_regex, $class_current))
+            || ($class_not_regex && preg_match($class_not_regex, $class_current))
            ) {
           continue;
         }
Index: includes/coder_style.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/includes/coder_style.inc,v
retrieving revision 1.16.2.18
diff -u -u -p -r1.16.2.18 coder_style.inc
--- includes/coder_style.inc	28 Aug 2008 14:31:19 -0000	1.16.2.18
+++ includes/coder_style.inc	20 Sep 2008 15:40:28 -0000
@@ -92,6 +92,7 @@ function coder_style_reviews() {
       '#type' => 'regex',
       '#value' => '(?-i)(function\s+|\$)(([a-z]+[A-Z]+([a-z]*[A-Z]*)*)|([A-Z]+[a-z]+([A-Z]*[a-z]*)*))',
       '#warning' => 'do not use mixed case (camelCase), use lower case and _',
+      '#class-not' => '.*',
     ),
     array(
       '#type' => 'regex',
Index: tests/coder_style.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/tests/coder_style.test,v
retrieving revision 1.2
diff -u -u -p -r1.2 coder_style.test
--- tests/coder_style.test	20 Sep 2008 15:04:49 -0000	1.2
+++ tests/coder_style.test	20 Sep 2008 15:40:28 -0000
@@ -21,6 +21,18 @@ class CoderStyleTest extends CoderTestCa
       '$var = "tab in	double quote"' => CODER_OK,
       '$var = \'tab in	single quote\'' => CODER_OK,
       '	$var = "tab in line";' => CODER_NOT_OK,
+      // CamelCase checks.
+      "class xyx {\n  camelCase();\n}" => CODER_OK,
+      "function xyx() {\n  camelCase();\n}" => CODER_NOT_OK,
+      'function camelCaseFunction() {' => CODER_NOT_OK,
+      '  $camelCaseVar = "whatever";' => CODER_NOT_OK,
+      '  $var = $camelCaseVar;' => CODER_NOT_OK,
+      '  $var =$camelCaseVar;' => CODER_NOT_OK,
+      '  $var = $obj->camelCase;' => CODER_OK,
+      '  camelCase();' => CODER_NOT_OK,
+      '  new camelCase();' => CODER_OK,
+      '  $camel_case = "camelCase";' => CODER_OK,
+      '  $camel_Case = "";' => CODER_OK,
     );
     $this->runCoderTests($snippets);
   }
Index: tests/coder_test_case.tinc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/tests/Attic/coder_test_case.tinc,v
retrieving revision 1.1.2.1
diff -u -u -p -r1.1.2.1 coder_test_case.tinc
--- tests/coder_test_case.tinc	20 Sep 2008 15:07:43 -0000	1.1.2.1
+++ tests/coder_test_case.tinc	20 Sep 2008 15:40:28 -0000
@@ -24,7 +24,7 @@ class CoderTestCase extends DrupalTestCa
           foreach ($results as $error) {
             $warnings[] = _coder_warning($error['rule']);
           }
-          $this->assertTrue(FALSE, 'Expect NO warning: '. $code .': '. implode('; ', $warning));
+          $this->assertTrue(FALSE, 'Expect NO warning: '. $code .': '. implode('; ', $warnings));
         }
       }
       else {
