Adds an warning to the warning stack.
$file = PHP_CodeSniffer_File("example.php"); $lines = count($file->getTokens()) - $file->findNext(T_OPEN_TAG, 0)["line"] + 1; $file->recordMetric($filename, "Lines of Code", $lines);
$file = PHP_CodeSniffer_File("example.php"); $numFunctions = $file->numTokenOccurrences(T_FUNCTION, 0, -1); $file->recordMetric($filename, "Number of Functions", $numFunctions);This code example uses the recordMetric function to count the number of functions in a PHP file and record it as a metric. Package library: PHP_CodeSniffer.