Skip to content

Commit

Permalink
Only count executable lines that actually exist.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Oct 20, 2009
1 parent f4394b6 commit 94a061b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions PHPLOC/Analyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public function countFile($file, $countTests)
$this->count['files']++;

if (function_exists('bytekit_disassemble_file')) {
$this->count['eloc'] += $this->countEloc($file);
$this->count['eloc'] += $this->countEloc($file, $loc);
}
}

Expand All @@ -450,11 +450,12 @@ public function getCount()
/**
* Counts the Executable Lines of Code (ELOC) using Bytekit.
*
* @param string $filename
* @param string $filename
* @param integer $loc
* @return integer
* @since Method available since Release 1.1.0
*/
protected function countEloc($filename)
protected function countEloc($filename, $loc)
{
$bytecode = @bytekit_disassemble_file($filename);

Expand All @@ -466,7 +467,8 @@ protected function countEloc($filename)

foreach ($bytecode['functions'] as $function) {
foreach ($function['raw']['opcodes'] as $opline) {
if (!isset($this->opcodeBlacklist[$opline['opcode']]) &&
if ($opline['lineno'] <= $loc &&
!isset($this->opcodeBlacklist[$opline['opcode']]) &&
!isset($lines[$opline['lineno']])) {
$lines[$opline['lineno']] = TRUE;
}
Expand Down

0 comments on commit 94a061b

Please sign in to comment.