$line) { // Don't pay attention to things outside the docblocks. if (preg_match("/^[ ]*\*/", $line)) { // Prefix for notices. $print = "$filename line " . ($line_num + 1); // Verify that the line is 80 chars or less, excluding the \n. $length = strlen(str_replace("\n", '', $line)); if ($length > 80) { $over_80[$length][] = $print; } // If it's an @return line, check the line above. if (strpos($line, '@return') !== FALSE) { if (!preg_match("/^[ ]*\*$/", $file[$line_num - 1])) { $ret_line[] = $print; } } // If it's @see or @ingroup, check that it's at the end of the docblock. if ((strpos($line, '@see') !== FALSE) || (strpos($line, '@ingroup') !== FALSE)) { // Collect all lines until the docblock closing or the end of the file. $i = 1; $next_lines = array(); while (!preg_match("/^[ ]*\*\/$/", $file[$line_num + $i]) && (sizeof($file) > ($line_num + $i))) { $next_lines[] = $file[$line_num + $i]; $i++; } foreach ($next_lines as $next_line) { if ((strpos($next_line, '@see') === FALSE) && (strpos($next_line, '@ingroup') === FALSE) && (strpos($next_line, '@{') === FALSE)) { $see_ingroup[] = $print; break; } } } } } } print "Lines over 80 chars:\n"; ksort($over_80); print_r($over_80); print "@return lines missing blank line above:\n"; print_r($ret_line); print "@see or @ingroup not at end of docblock:\n"; print_r($see_ingroup);