Index: coder.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/coder.module,v
retrieving revision 1.88.2.59.2.5
diff -u -p -r1.88.2.59.2.5 coder.module
--- coder.module	1 Oct 2008 14:08:38 -0000	1.88.2.59.2.5
+++ coder.module	23 Oct 2008 10:45:27 -0000
@@ -1540,31 +1540,49 @@ 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_array) {
       foreach ($line_array as $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)) {
-            $paren += ($match[0] == '{') ? 1 : -1;
+            $function_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 ($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)) {
+            $class_current = $match[1];
+          }
+          if (preg_match('/([{}])/', $line, $match)) {
+            $class_paren += ($match[0] == '{') ? 1 : -1;
+          }
+          if ($class_paren < 0 || ($class_regex && $class_current == '')
+            || ($class_regex && !preg_match($class_regex, $class_current))
+            || ($class_not_regex && preg_match($class_not_regex, $class_current))
+             ) {
+          }
+        }
 
         if (preg_match($regex, $line, $matches)) {
           // Don't match some regex's.
Index: includes/coder_style.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/coder/includes/coder_style.inc,v
retrieving revision 1.16.2.18.2.4
diff -u -p -r1.16.2.18.2.4 coder_style.inc
--- includes/coder_style.inc	23 Oct 2008 09:22:18 -0000	1.16.2.18.2.4
+++ includes/coder_style.inc	23 Oct 2008 10:45:28 -0000
@@ -92,7 +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 _',
-      '#filename-not' => array('test'),
+      '#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.7.2.1
diff -u -p -r1.7.2.1 coder_style.test
--- tests/coder_style.test	19 Oct 2008 19:00:59 -0000	1.7.2.1
+++ tests/coder_style.test	23 Oct 2008 10:45:28 -0000
@@ -22,20 +22,26 @@ class CoderStyleTest extends CoderTestCa
   }
 
   function testStyleTabs() {
-    $this->assertCoderPass('// Tab in	comment');
-    $this->assertCoderPass('$var = "tab in	double quote"');
-    $this->assertCoderPass('$var = \'tab in	single quote\'');
-    $this->assertCoderFail('	$var = "tab in line";');
+    $this->assertCoderPass('// Tab in comment');
+    $this->assertCoderPass('$var = "tab in double quote"');
+    $this->assertCoderPass('$var = \'tab in single quote\'');
+    $this->assertCoderFail(' $var = "tab in line";');
   }
 
   function testStyleCamelCase() {
     $this->assertCoderPass('  $var = new stdClass();');
     $this->assertCoderPass('  $var = $obj->camelCase();');
+    $this->assertCoderFail('  $var = $camelCaseVar;');
+    $this->assertCoderFail('  $var =$camelCaseVar;');
     $this->assertCoderFail('  $camelCase = "1";');
     $this->assertCoderFail('  function camelCase() {');
     $this->assertCoderPass('  ?>This is embedded php and should Not trigger a camelCase error.<?php');
     $this->assertCoderPass("  ?>This second embedded php and should Not trigger\na camelCase error.<?php");
     $this->assertCoderPass('  $var = 0xFF;');
+    $this->assertCoderPass("  class xyx {\n  camelCase();\n}");
+    $this->assertCoderPass('  new camelCase();');
+    $this->assertCoderPass('  $camel_case = "camelCase";');
+    $this->assertCoderPass('  $camel_Case = "";');
   }
 
   function testStyleBr() {
