Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Feb 4, 2011
1 parent 91bfe31 commit 31f8c75
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 32 deletions.
71 changes: 71 additions & 0 deletions PHPDCD/Autoload.php
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* phpdcd
*
* Copyright (c) 2009-2011, Sebastian Bergmann <sb@sebastian-bergmann.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package phpdcd
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @since File available since Release 1.0.0
*/

require_once 'File/Iterator/Autoload.php';
require_once 'PHP/Token/Stream/Autoload.php';
require_once 'PHP/Timer/Autoload.php';
require_once 'ezc/Base/base.php';

function phpdcd_autoload($class) {
static $classes = NULL;
static $path = NULL;

if ($classes === NULL) {
$classes = array(
'phpdcd_detector' => '/Detector.php',
'phpdcd_textui_command' => '/TextUI/Command.php',
'phpdcd_textui_resultprinter' => '/TextUI/ResultPrinter.php'
);

$path = dirname(__FILE__);
}

$cn = strtolower($class);

if (isset($classes[$cn])) {
require $path . $classes[$cn];
}
}

spl_autoload_register('phpdcd_autoload');
spl_autoload_register(array('ezcBase', 'autoload'));
69 changes: 69 additions & 0 deletions PHPDCD/Autoload.php.in
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* phpdcd
*
* Copyright (c) 2009-2011, Sebastian Bergmann <sb@sebastian-bergmann.de>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* * Neither the name of Sebastian Bergmann nor the names of his
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* @package phpdcd
* @author Sebastian Bergmann <sb@sebastian-bergmann.de>
* @copyright 2009-2011 Sebastian Bergmann <sb@sebastian-bergmann.de>
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
* @since File available since Release 1.0.0
*/

require_once 'File/Iterator/Autoload.php';
require_once 'PHP/Token/Stream/Autoload.php';
require_once 'PHP/Timer/Autoload.php';
require_once 'ezc/Base/base.php';

function phpdcd_autoload($class) {
static $classes = NULL;
static $path = NULL;

if ($classes === NULL) {
$classes = array(
___CLASSLIST___
);

$path = dirname(__FILE__);
}

$cn = strtolower($class);

if (isset($classes[$cn])) {
require $path . $classes[$cn];
}
}

spl_autoload_register('phpdcd_autoload');
spl_autoload_register(array('ezcBase', 'autoload'));
3 changes: 0 additions & 3 deletions PHPDCD/Detector.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
* @since File available since Release 1.0.0 * @since File available since Release 1.0.0
*/ */


require_once 'PHP/Token/Stream.php';

/** /**
* PHPDCD code analyser. * PHPDCD code analyser.
* *
Expand Down Expand Up @@ -336,4 +334,3 @@ public function detectDeadCode(array $files, $recursive = FALSE)
return $result; return $result;
} }
} }
?>
12 changes: 0 additions & 12 deletions PHPDCD/TextUI/Command.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,17 +41,6 @@
* @since File available since Release 1.0.0 * @since File available since Release 1.0.0
*/ */


require_once 'File/Iterator/Factory.php';
require_once 'PHPDCD/Detector.php';
require_once 'PHPDCD/TextUI/ResultPrinter.php';

require_once 'ezc/Base/base.php';

function __autoload($className)
{
ezcBase::autoload($className);
}

/** /**
* TextUI frontend for PHPDCD. * TextUI frontend for PHPDCD.
* *
Expand Down Expand Up @@ -293,4 +282,3 @@ protected static function printVersionString()
print "phpdcd @package_version@ by Sebastian Bergmann.\n"; print "phpdcd @package_version@ by Sebastian Bergmann.\n";
} }
} }
?>
3 changes: 0 additions & 3 deletions PHPDCD/TextUI/ResultPrinter.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@
* @since File available since Release 1.0.0 * @since File available since Release 1.0.0
*/ */


require_once 'PHP/Timer.php';

/** /**
* A ResultPrinter for the TextUI. * A ResultPrinter for the TextUI.
* *
Expand Down Expand Up @@ -75,4 +73,3 @@ public function printResult(array $result, $commonPath)
print "\n" . PHP_Timer::resourceUsage() . "\n"; print "\n" . PHP_Timer::resourceUsage() . "\n";
} }
} }
?>
2 changes: 0 additions & 2 deletions Tests/DetectorTest.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
); );
} }


require_once 'PHPDCD/Detector.php';

/** /**
* Tests for the PHPDCD_Detector class. * Tests for the PHPDCD_Detector class.
* *
Expand Down
7 changes: 7 additions & 0 deletions build.xml
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,7 @@
<project name="phpdcd" default="phpab" basedir=".">
<target name="phpab">
<exec executable="phpab">
<arg line='-o PHPDCD/Autoload.php -c -t PHPDCD/Autoload.php.in --indent " " PHPDCD' />
</exec>
</target>
</project>
23 changes: 13 additions & 10 deletions package.xml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
<email>sb@sebastian-bergmann.de</email> <email>sb@sebastian-bergmann.de</email>
<active>yes</active> <active>yes</active>
</lead> </lead>
<date>2010-01-07</date> <date>201Y-MM-DD</date>
<version> <version>
<release>0.9.2</release> <release>1.0.0</release>
<api>0.9.2</api> <api>1.0.0</api>
</version> </version>
<stability> <stability>
<release>beta</release> <release>stable</release>
<api>beta</api> <api>stable</api>
</stability> </stability>
<license>BSD License</license> <license>BSD License</license>
<notes>http://github.com/sebastianbergmann/phpdcd/tree</notes> <notes>http://github.com/sebastianbergmann/phpdcd/tree</notes>
Expand All @@ -39,6 +39,9 @@
<tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@package_version@" to="version" type="package-info" />
</file> </file>
</dir> </dir>
<file baseinstalldir="/" name="Autoload.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" />
</file>
<file baseinstalldir="/" name="Detector.php" role="php"> <file baseinstalldir="/" name="Detector.php" role="php">
<tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@package_version@" to="version" type="package-info" />
</file> </file>
Expand All @@ -58,25 +61,25 @@
<dependencies> <dependencies>
<required> <required>
<php> <php>
<min>5.2.0</min> <min>5.2.7</min>
</php> </php>
<pearinstaller> <pearinstaller>
<min>1.8.1</min> <min>1.9.1</min>
</pearinstaller> </pearinstaller>
<package> <package>
<name>File_Iterator</name> <name>File_Iterator</name>
<channel>pear.phpunit.de</channel> <channel>pear.phpunit.de</channel>
<min>1.1.0</min> <min>1.3.0</min>
</package> </package>
<package> <package>
<name>PHP_Timer</name> <name>PHP_Timer</name>
<channel>pear.phpunit.de</channel> <channel>pear.phpunit.de</channel>
<min>1.0.0</min> <min>1.1.0</min>
</package> </package>
<package> <package>
<name>PHP_TokenStream</name> <name>PHP_TokenStream</name>
<channel>pear.phpunit.de</channel> <channel>pear.phpunit.de</channel>
<min>0.9.1</min> <min>1.1.0</min>
</package> </package>
<package> <package>
<name>ConsoleTools</name> <name>ConsoleTools</name>
Expand Down
2 changes: 1 addition & 1 deletion phpdcd.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path()); set_include_path(dirname(__FILE__) . PATH_SEPARATOR . get_include_path());
} }


require 'PHPDCD/TextUI/Command.php'; require 'PHPDCD/Autoload.php';


PHPDCD_TextUI_Command::main(); PHPDCD_TextUI_Command::main();
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@


<phpunit backupGlobals="false" <phpunit backupGlobals="false"
backupStaticAttributes="false" backupStaticAttributes="false"
syntaxCheck="false"> syntaxCheck="false"
bootstrap="PHPDCD/Autoload.php">
<testsuites> <testsuites>
<testsuite name="PHPDCD"> <testsuite name="PHPDCD">
<directory suffix="Test.php">Tests</directory> <directory suffix="Test.php">Tests</directory>
Expand Down

0 comments on commit 31f8c75

Please sign in to comment.