示例#1
0
function lintc($code, $prefix = null)
{
    global $cleanup;
    static $counter = 0;
    $prefix = $prefix ?: 'unk';
    $counter++;
    $cleanup[] = $file = './tmp/' . $prefix . '-' . sprintf('%03d', $counter) . '-' . md5($code) . '.php';
    file_put_contents($file, '<?php return ' . $code . ';');
    return lint($file);
}
示例#2
0
// folder on server containing this script
$script_filename = $_SERVER['SCRIPT_FILENAME'];
$workdir = dirname($script_filename) . '/';
// start action parsing
if ($action === 'download') {
    print_redirect_header("lint_php.zip");
    $counter3 = log_action($workdir, "download");
    print_html_header();
    echo "lint_php was downloaded {$counter3} times.";
    print_html_footer();
} elseif (empty($text)) {
    $counter1 = log_action($workdir, "welcome");
    show_welcome_page($counter1, $debug_level);
} else {
    // main calculation
    $result = lint($text, $debug_level);
    print_html_header();
    echo "<h3>Cyclomatic complexity:</h3>\n";
    $text = $result[0]['res_lint'];
    foreach ($text as $line) {
        $line_html = htmlentities($line);
        echo "{$line_html}<br>\n";
    }
    echo "<br><hr>\n";
    echo "<h3>Analisys details:</h3>\n";
    $struc = $result[0]['lines_out'];
    show_lines2($struc['lines'], $struc['numlines'], $struc['list_indent_out'], 0, 10000, $struc['indent_mccount']);
    print_html_footer();
    $counter2 = log_action($workdir, "results");
    echo "<br><hr>\n";
    echo "Page viewed {$counter2} times.\n";
示例#3
0
     }
 }
 ++$fileCount;
 if ($concurrent) {
     $chn->in(['target_dir' => $target_dir, 'file' => $file]);
 } else {
     if (0 == $fileCount % 20) {
         fwrite(STDERR, ' ' . $fileCount . PHP_EOL);
     }
     $content = $cache->is_changed($target_dir, $file);
     if (false === $content) {
         ++$fileCount;
         ++$cacheHitCount;
         continue;
     }
     if ($lintBefore && !lint($file)) {
         fwrite(STDERR, 'Error lint:' . $file . PHP_EOL);
         continue;
     }
     $fmtCode = $fmt->formatCode($content);
     fwrite(STDERR, '.');
     if (null !== $cache) {
         $cache->upsert($target_dir, $file, $fmtCode);
     }
     if ($dryRun) {
         if ($fmtCode !== $content) {
             $filesChanged = true;
         }
     } else {
         file_put_contents($file . '-tmp', $fmtCode);
         $oldchmod = fileperms($file);