Skip to content

Commit 72ef762

Browse files
Merge branch 'master' into report-refactoring
2 parents 5549cba + db5c61d commit 72ef762

File tree

3 files changed

+42
-80
lines changed

3 files changed

+42
-80
lines changed

PHP/CodeCoverage.php

Lines changed: 20 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,6 @@ class PHP_CodeCoverage
101101
*/
102102
protected $tests = array();
103103

104-
/**
105-
* @var boolean
106-
*/
107-
protected $isCodeCoverageTestSuite = FALSE;
108-
109-
/**
110-
* @var boolean
111-
*/
112-
protected $isFileIteratorTestSuite = FALSE;
113-
114-
/**
115-
* @var boolean
116-
*/
117-
protected $isTimerTestSuite = FALSE;
118-
119-
/**
120-
* @var boolean
121-
*/
122-
protected $isTokenStreamTestSuite = FALSE;
123-
124104
/**
125105
* Constructor.
126106
*
@@ -141,23 +121,34 @@ public function __construct(PHP_CodeCoverage_Driver $driver = NULL, PHP_CodeCove
141121
$this->driver = $driver;
142122
$this->filter = $filter;
143123

144-
if (defined('PHP_CODECOVERAGE_TESTSUITE')) {
145-
$this->isCodeCoverageTestSuite = TRUE;
124+
// @codeCoverageIgnoreStart
125+
if (!defined('PHP_CODECOVERAGE_TESTSUITE')) {
126+
$this->filter->addFilesToBlacklist(php_codecoverage_autoload());
146127
}
147128

148-
// @codeCoverageIgnoreStart
149-
if (defined('FILE_ITERATOR_TESTSUITE')) {
150-
$this->isFileIteratorTestSuite = TRUE;
129+
if (!defined('PHPUNIT_TESTSUITE')) {
130+
$this->filter->addFilesToBlacklist(phpunit_autoload());
131+
$this->filter->addFilesToBlacklist(phpunit_dbunit_autoload());
132+
$this->filter->addFilesToBlacklist(phpunit_mockobject_autoload());
133+
$this->filter->addFilesToBlacklist(phpunit_selenium_autoload());
134+
$this->filter->addFilesToBlacklist(phpunit_story_autoload());
135+
}
136+
137+
if (!defined('FILE_ITERATOR_TESTSUITE')) {
138+
$this->filter->addFilesToBlacklist(file_iterator_autoload());
151139
}
152140

153-
if (defined('PHP_TIMER_TESTSUITE')) {
154-
$this->isTimerTestSuite = TRUE;
141+
if (!defined('PHP_TIMER_TESTSUITE') &&
142+
function_exists('php_timer_autoload')) {
143+
$this->filter->addFilesToBlacklist(php_timer_autoload());
155144
}
156145

157-
if (defined('PHP_TOKENSTREAM_TESTSUITE')) {
158-
$this->isTokenStreamTestSuite = TRUE;
146+
if (!defined('PHP_TOKENSTREAM_TESTSUITE')) {
147+
$this->filter->addFilesToBlacklist(php_tokenstream_autoload());
159148
}
160149
// @codeCoverageIgnoreEnd
150+
151+
$this->filter->addFilesToBlacklist(text_template_autoload());
161152
}
162153

163154
/**
@@ -280,7 +271,6 @@ public function append(array $data, $id = NULL)
280271
throw new InvalidArgumentException;
281272
}
282273

283-
$this->applySelfFilter($data);
284274
$this->applyListsFilter($data);
285275
$this->initializeFilesThatAreSeenTheFirstTime($data);
286276
$this->applyCoversAnnotationFilter($data, $id);
@@ -443,54 +433,6 @@ protected function applyListsFilter(&$data)
443433
}
444434
}
445435

446-
/**
447-
* Filters sourcecode files from PHP_CodeCoverage, PHP_TokenStream,
448-
* Text_Template, and File_Iterator.
449-
*
450-
* @param array $data
451-
* @codeCoverageIgnore
452-
*/
453-
protected function applySelfFilter(&$data)
454-
{
455-
foreach (array_keys($data) as $filename) {
456-
if (!$this->filter->isFile($filename)) {
457-
unset($data[$filename]);
458-
continue;
459-
}
460-
461-
if (!$this->isCodeCoverageTestSuite &&
462-
strpos($filename, dirname(__FILE__)) === 0) {
463-
unset($data[$filename]);
464-
continue;
465-
}
466-
467-
if (!$this->isFileIteratorTestSuite &&
468-
(substr($filename, -17) == 'File/Iterator.php' ||
469-
substr($filename, -25) == 'File/Iterator/Factory.php')) {
470-
unset($data[$filename]);
471-
continue;
472-
}
473-
474-
if (!$this->isTimerTestSuite &&
475-
(substr($filename, -13) == 'PHP/Timer.php')) {
476-
unset($data[$filename]);
477-
continue;
478-
}
479-
480-
if (!$this->isTokenStreamTestSuite &&
481-
(substr($filename, -13) == 'PHP/Token.php' ||
482-
substr($filename, -20) == 'PHP/Token/Stream.php' ||
483-
substr($filename, -35) == 'PHP/Token/Stream/CachingFactory.php')) {
484-
unset($data[$filename]);
485-
continue;
486-
}
487-
488-
if (substr($filename, -17) == 'Text/Template.php') {
489-
unset($data[$filename]);
490-
}
491-
}
492-
}
493-
494436
/**
495437
* @since Method available since Release 1.1.0
496438
*/

PHP/CodeCoverage/Autoload.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
require_once 'PHP/Token/Stream/Autoload.php';
4848
require_once 'Text/Template/Autoload.php';
4949

50-
function php_codecoverage_autoload($class) {
50+
function php_codecoverage_autoload($class = NULL) {
5151
static $classes = NULL;
5252
static $path = NULL;
5353

@@ -77,6 +77,16 @@ function php_codecoverage_autoload($class) {
7777
$path = dirname(dirname(__FILE__));
7878
}
7979

80+
if ($class === NULL) {
81+
$result = array();
82+
83+
foreach ($classes as $file) {
84+
$result[] = $path . $file;
85+
}
86+
87+
return $result;
88+
}
89+
8090
$cn = strtolower($class);
8191

8292
if (isset($classes[$cn])) {

PHP/CodeCoverage/Autoload.php.in

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ require_once 'File/Iterator/Autoload.php';
4747
require_once 'PHP/Token/Stream/Autoload.php';
4848
require_once 'Text/Template/Autoload.php';
4949

50-
function php_codecoverage_autoload($class) {
50+
function php_codecoverage_autoload($class = NULL) {
5151
static $classes = NULL;
5252
static $path = NULL;
5353

@@ -59,6 +59,16 @@ function php_codecoverage_autoload($class) {
5959
$path = dirname(dirname(__FILE__));
6060
}
6161

62+
if ($class === NULL) {
63+
$result = array();
64+
65+
foreach ($classes as $file) {
66+
$result[] = $path . $file;
67+
}
68+
69+
return $result;
70+
}
71+
6272
$cn = strtolower($class);
6373

6474
if (isset($classes[$cn])) {

0 commit comments

Comments
 (0)