Skip to content

Commit 99e2076

Browse files
Initial work on autoloader.
1 parent 2fe7eb8 commit 99e2076

File tree

17 files changed

+154
-23
lines changed

17 files changed

+154
-23
lines changed

PHP/CodeCoverage.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage/Driver/Xdebug.php';
47-
require_once 'PHP/CodeCoverage/Filter.php';
48-
require_once 'PHP/CodeCoverage/Util.php';
49-
5046
/**
5147
* Provides collection functionality for PHP code coverage information.
5248
*

PHP/CodeCoverage/Autoload.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
<?php
2+
/**
3+
* PHP_CodeCoverage
4+
*
5+
* Copyright (c) 2009-2010, Sebastian Bergmann <[email protected]>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @category PHP
38+
* @package CodeCoverage
39+
* @author Sebastian Bergmann <[email protected]>
40+
* @copyright 2009-2010 Sebastian Bergmann <[email protected]>
41+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
42+
* @link http://github.com/sebastianbergmann/php-code-coverage
43+
* @since File available since Release 1.1.0
44+
*/
45+
46+
function php_codecoverage_autoload($class) {
47+
static $classes = NULL;
48+
static $path = NULL;;
49+
50+
if ($classes === NULL) {
51+
$classes = array(
52+
'php_codecoverage' => '/CodeCoverage.php',
53+
'php_codecoverage_driver_xdebug' => '/CodeCoverage/Driver/Xdebug.php',
54+
'php_codecoverage_util' => '/CodeCoverage/Util.php',
55+
'php_codecoverage_driver' => '/CodeCoverage/Driver.php',
56+
'php_codecoverage_filter' => '/CodeCoverage/Filter.php',
57+
'php_codecoverage_textui_command' => '/CodeCoverage/TextUI/Command.php',
58+
'php_codecoverage_report_php' => '/CodeCoverage/Report/PHP.php',
59+
'php_codecoverage_report_html' => '/CodeCoverage/Report/HTML.php',
60+
'php_codecoverage_report_clover' => '/CodeCoverage/Report/Clover.php',
61+
'php_codecoverage_report_html_node' => '/CodeCoverage/Report/HTML/Node.php',
62+
'php_codecoverage_report_html_node_iterator' => '/CodeCoverage/Report/HTML/Node/Iterator.php',
63+
'php_codecoverage_report_html_node_file' => '/CodeCoverage/Report/HTML/Node/File.php',
64+
'php_codecoverage_report_html_node_directory' => '/CodeCoverage/Report/HTML/Node/Directory.php'
65+
);
66+
67+
$path = dirname(dirname(__FILE__));
68+
}
69+
70+
$cn = strtolower($class);
71+
72+
if (isset($classes[$cn])) {
73+
require $path . $classes[$cn];
74+
}
75+
}
76+
77+
spl_autoload_register('php_codecoverage_autoload');

PHP/CodeCoverage/Autoload.php.in

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* PHP_CodeCoverage
4+
*
5+
* Copyright (c) 2009-2010, Sebastian Bergmann <[email protected]>.
6+
* All rights reserved.
7+
*
8+
* Redistribution and use in source and binary forms, with or without
9+
* modification, are permitted provided that the following conditions
10+
* are met:
11+
*
12+
* * Redistributions of source code must retain the above copyright
13+
* notice, this list of conditions and the following disclaimer.
14+
*
15+
* * Redistributions in binary form must reproduce the above copyright
16+
* notice, this list of conditions and the following disclaimer in
17+
* the documentation and/or other materials provided with the
18+
* distribution.
19+
*
20+
* * Neither the name of Sebastian Bergmann nor the names of his
21+
* contributors may be used to endorse or promote products derived
22+
* from this software without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27+
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28+
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30+
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34+
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35+
* POSSIBILITY OF SUCH DAMAGE.
36+
*
37+
* @category PHP
38+
* @package CodeCoverage
39+
* @author Sebastian Bergmann <[email protected]>
40+
* @copyright 2009-2010 Sebastian Bergmann <[email protected]>
41+
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
42+
* @link http://github.com/sebastianbergmann/php-code-coverage
43+
* @since File available since Release 1.1.0
44+
*/
45+
46+
function php_codecoverage_autoload($class) {
47+
static $classes = NULL;
48+
static $path = NULL;;
49+
50+
if ($classes === NULL) {
51+
$classes = array(
52+
___CLASSLIST___
53+
);
54+
55+
$path = dirname(dirname(__FILE__));
56+
}
57+
58+
$cn = strtolower($class);
59+
60+
if (isset($classes[$cn])) {
61+
require $path . $classes[$cn];
62+
}
63+
}
64+
65+
spl_autoload_register('php_codecoverage_autoload');

PHP/CodeCoverage/Driver/Xdebug.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage/Driver.php';
47-
4846
if (version_compare(phpversion('xdebug'), '2.2.0-dev', '>=') &&
4947
!ini_get('xdebug.coverage_enable')) {
5048
die("You need to set xdebug.coverage_enable=On in your php.ini.\n");

PHP/CodeCoverage/Report/Clover.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage.php';
4746
require_once 'PHP/Token/Stream/CachingFactory.php';
4847

4948
/**

PHP/CodeCoverage/Report/HTML.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage.php';
47-
require_once 'PHP/CodeCoverage/Report/HTML/Node.php';
4846
require_once 'Text/Template.php';
4947

5048
/**

PHP/CodeCoverage/Report/HTML/Node/Directory.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage/Report/HTML/Node/Iterator.php';
47-
4846
/**
4947
* Represents a directory in the code coverage information tree.
5048
*

PHP/CodeCoverage/Report/PHP.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* @since File available since Release 1.1.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage.php';
47-
4846
/**
4947
* Uses serialize() to write a PHP_CodeCoverage object to a file.
5048
*

PHP/CodeCoverage/TextUI/Command.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* @since File available since Release 1.0.0
4444
*/
4545

46-
require_once 'PHP/CodeCoverage.php';
47-
4846
require_once 'ezc/Base/base.php';
4947
spl_autoload_register(array('ezcBase', 'autoload'));
5048

Tests/PHP/CodeCoverage/FilterTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
* @since File available since Release 1.0.0
4545
*/
4646

47-
require_once 'PHP/CodeCoverage/Filter.php';
48-
4947
if (!defined('TEST_FILES_PATH')) {
5048
define(
5149
'TEST_FILES_PATH',

0 commit comments

Comments
 (0)