示例#1
0
 /**
  * Scans a set of files using a set of rules.
  *
  * @param  array $files
  * @return array
  */
 public function scan(array $files)
 {
     $result = array();
     foreach ($files as $file) {
         $bytecode = @bytekit_disassemble_file($file);
         if (!$bytecode) {
             printf("WARNING: Could not disassemble \"%s\". Check for syntax errors.\n", $file);
             continue;
         }
         foreach ($bytecode['functions'] as $function => $oparray) {
             foreach ($this->rules as $rule) {
                 $rule->process($oparray, $file, $function, $result);
             }
         }
     }
     return $result;
 }
 /**
  * Constructor.
  *
  * @param  string $file
  * @return array
  */
 public function __construct($filename)
 {
     $this->bytecode = @bytekit_disassemble_file($filename);
     $this->filename = realpath($filename);
 }
示例#3
0
 /**
  * Counts the Executable Lines of Code (ELOC) using Bytekit.
  *
  * @param  string  $filename
  * @param  integer $loc
  * @return integer
  * @since  Method available since Release 1.1.0
  */
 protected function countEloc($filename, $loc)
 {
     $bytecode = @bytekit_disassemble_file($filename);
     if (!is_array($bytecode)) {
         return 0;
     }
     $lines = array();
     foreach ($bytecode['functions'] as $function) {
         foreach ($function['raw']['opcodes'] as $opline) {
             if ($opline['lineno'] <= $loc && !isset($this->opcodeBlacklist[$opline['opcode']]) && !isset($lines[$opline['lineno']])) {
                 $lines[$opline['lineno']] = TRUE;
             }
         }
     }
     return count($lines);
 }