| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * $Id$ 4 * 5 * Copyright(c) 2004-2005, SpikeSource Inc. All Rights Reserved. 6 * Licensed under the Open Source License version 2.1 7 * (See http://www.spikesource.com/license.html) 8 */ 9 ?> 10 <?php 11 12 /** 13 * Reader that parses Xdebug Trace data. 14 * 15 * @author Nimish Pachapurkar <npac@spikesource.com> 16 * @version $Revision: $ 17 * @package tests_runner 18 */ 19 class XdebugTraceReader { 20 /*{{{ Members */ 21 22 protected $traceFilePath; 23 protected $handle; 24 protected $coverage = array(); 25 26 /*}}}*/ 27 /*{{{ Constructor */ 28 29 /** 30 * Constructor 31 * 32 * @param $traceFilePath Path of the Xdebug trace file 33 * @access public 34 */ 35 public function __construct($traceFilePath) { 36 $this->traceFilePath = $traceFilePath; 37 } 38 39 /*}}}*/ 40 /*{{{ protected function openTraceFile() */ 41 42 /** 43 * Opens the trace file 44 * 45 * @return Boolean True on success, false on failure. 46 * @access protected 47 */ 48 protected function openTraceFile() { 49 $this->handle = fopen($this->traceFilePath, "r"); 50 return !empty($this->handle); 51 } 52 53 /*}}}*/ 54 /*{{{ public function parseTraceFile() */ 55 56 /** 57 * Parses the trace file 58 * 59 * @return Boolean True on success, false on failure. 60 * @access public 61 */ 62 public function parseTraceFile() { 63 if(!$this->openTraceFile()) { 64 error_log("[XdebugTraceReader::parseTraceFile()] Unable to read trace file."); 65 return false; 66 } 67 while(!feof($this->handle)) { 68 $line = fgets($this->handle); 69 // echo "Line: " . $line . "\n"; 70 $this->processTraceLine($line); 71 } 72 fclose($this->handle); 73 return true; 74 } 75 76 /*}}}*/ 77 /*{{{ protected function processTraceLine() */ 78 79 /** 80 * Process a give trace line 81 * 82 * @param $line Line from a trace file 83 * @return Boolean True on success, false on failure 84 * @access protected 85 */ 86 protected function processTraceLine($line) { 87 $dataparts = explode("\t", $line); 88 // print_r($dataparts); 89 $cnt = count($dataparts); 90 if($cnt < 2) { 91 return false; 92 } 93 if(!file_exists($dataparts[$cnt-2])) { 94 // echo "No file: " . $dataparts[$cnt-2] . "\n"; 95 return false; 96 } 97 // Trim the entries 98 $dataparts[$cnt-2] = trim($dataparts[$cnt-2]); 99 $dataparts[$cnt-1] = trim($dataparts[$cnt-1]); 100 101 if(!isset($this->coverage[$dataparts[$cnt-2]][$dataparts[$cnt-1]])) { 102 $this->coverage[$dataparts[$cnt-2]][$dataparts[$cnt-1]] = 1; 103 } 104 else { 105 $this->coverage[$dataparts[$cnt-2]][$dataparts[$cnt-1]] ++; 106 } 107 return true; 108 } 109 110 /*}}}*/ 111 /*{{{ public function getCoverageData() */ 112 113 /** 114 * Returns the coverage array 115 * 116 * @return Array Array of coverage data from parsing. 117 * @access public 118 */ 119 public function getCoverageData() { 120 return $this->coverage; 121 } 122 123 /*}}}*/ 124 } 125 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Dec 2 03:54:09 2008 | Cross-referenced by PHPXref 0.7 |