diff -ur coder.module coder.module
--- coder.module	2009-03-17 22:33:56.000000000 +0100
+++ coder.module	2009-03-17 22:49:22.000000000 +0100
@@ -1449,24 +1449,43 @@
   if (isset($rule['#value'])) {
     $regexflags = isset($rule['#case-sensitive']) ? '' : 'i';
     $regex = '/'. $rule['#value'] .'/'. $regexflags;
+    $class_regex = isset($rule['#class']) ? '/'. $rule['#class'] .'/' : '';
+    $class_not_regex = isset($rule['#class-not']) ? '/'. $rule['#class-not'] .'/' : '';
+    $class_current = '';
+    $class_paren = 0;
     $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;
     $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)) {
-          $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))
            ) {
           continue;
         }
diff -ur includes/coder_style.inc includes/coder_style.inc
--- includes/coder_style.inc	2008-08-28 16:31:19.000000000 +0200
+++ includes/coder_style.inc	2009-03-17 22:42:39.000000000 +0100
@@ -92,6 +92,7 @@
       '#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',
