Index: coder.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/coder.module,v
retrieving revision 1.88.2.50
diff -u -u -p -r1.88.2.50 coder.module
--- coder.module	20 Sep 2008 11:35:41 -0000	1.88.2.50
+++ coder.module	20 Sep 2008 13:09:14 -0000
@@ -1435,26 +1435,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 13:09:14 -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.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/tests/coder_style.inc,v
retrieving revision 1.6.2.8
diff -u -u -p -r1.6.2.8 coder_style.inc
--- tests/coder_style.inc	14 Jul 2008 13:29:59 -0000	1.6.2.8
+++ tests/coder_style.inc	20 Sep 2008 13:09:14 -0000
@@ -27,12 +27,6 @@ function coder_test_stdclass() {
   $var = new stdclassToo(); // Should be camelcase rule.
 }
 
-function coderCamelCase() {
-  $camelCaseVar = 'whatever'; // Camel case functions and vars not allowed.
-  $var = $obj->camelCase; // But camel case objects elements are.
-  new camcelCase(); // Is ok.
-}
-
 function coder_test_two_errors_on_same_line() {
   if('test=' . $test == 'test='){ // There are 3 errors on this line.
   }
Index: tests/coder_style.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/tests/coder_style.test,v
retrieving revision 1.1
diff -u -u -p -r1.1 coder_style.test
--- tests/coder_style.test	24 Aug 2008 11:30:47 -0000	1.1
+++ tests/coder_style.test	20 Sep 2008 13:09:14 -0000
@@ -22,6 +22,18 @@ class CoderStyleTest extends DrupalTestC
       '$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,
     );
 
     $reviews = coder_reviews();
