svn: /pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer/ Sqlite.php

[email protected] (Brett Bieber) Sun, 05 Sep 2010 13:32:31 +0000
Newsgroups php.pear.cvs,php.pear.core
Message-ID <[email protected]>
saltybeagle                              Sun, 05 Sep 2010 13:32:31 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=303054

Log:
When adding files with no coverage, fatal errors may occur due to dependencies on external classes which are not defined. In this instance, fake the class definition.

Changed paths:
    U   pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer/Sqlite.php

Modified: pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer/Sqlite.php
===================================================================
--- pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer/Sqlite.php	2010-09-05 12:29:47 UTC (rev 303053)
+++ pear2/Pyrus_Developer/trunk/src/Pyrus/Developer/CoverageAnalyzer/Sqlite.php	2010-09-05 13:32:31 UTC (rev 303054)
@@ -2,19 +2,20 @@
 namespace PEAR2\Pyrus\Developer\CoverageAnalyzer;
 class Sqlite
 {
-    protected $db;
-    protected $totallines = 0;
-    protected $coveredlines = 0;
-    protected $deadlines = 0;
-    protected $pathCovered = array();
-    protected $pathTotal = array();
-    protected $pathDead = array();
     public $codepath;
     public $testpath;

+    protected $db;
+    protected $totallines   = 0;
+    protected $coveredlines = 0;
+    protected $deadlines    = 0;
+    protected $pathCovered  = array();
+    protected $pathTotal    = array();
+    protected $pathDead     = array();
+
     private $statement;
-    private $lines = array();
-    private $files = array();
+    private $lines   = array();
+    private $files   = array();
     private $deleted = array();

     const COVERAGE_COVERED      = 1;
@@ -712,7 +713,12 @@
                 include $file;
                 return true;
             }
-            return false;
+            $fake_class = '<?php class '.$class.' {}';
+            $fake_class_file = tempnam(sys_get_temp_dir(), 'pyrus_tmp');
+            file_put_contents($fake_class_file, $fake_class);
+            include $fake_class_file;
+            unlink($fake_class_file);
+            return true;
         });

         foreach ($this->files as $file) {