Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make autoloader function anonymous.

  • Loading branch information...
commit 4bd5862865cfc0c0bf695506d4fa170623000774 1 parent 5175e9b
@sebastianbergmann authored
Showing with 35 additions and 54 deletions.
  1. +17 −26 PHP/Timer/Autoload.php
  2. +17 −26 PHP/Timer/Autoload.php.in
  3. +1 −2  build.xml
View
43 PHP/Timer/Autoload.php
@@ -43,33 +43,24 @@
* @since File available since Release 1.1.0
*/
-function php_timer_autoload($class = NULL) {
- static $classes = NULL;
- static $path = NULL;
+spl_autoload_register(
+ function ($class)
+ {
+ static $classes = NULL;
+ static $path = NULL;
- if ($classes === NULL) {
- $classes = array(
- 'php_timer' => '/Timer.php'
- );
+ if ($classes === NULL) {
+ $classes = array(
+ 'php_timer' => '/Timer.php'
+ );
- $path = dirname(dirname(__FILE__));
- }
+ $path = dirname(dirname(__FILE__));
+ }
- if ($class === NULL) {
- $result = array(__FILE__);
+ $cn = strtolower($class);
- foreach ($classes as $file) {
- $result[] = $path . $file;
- }
-
- return $result;
- }
-
- $cn = strtolower($class);
-
- if (isset($classes[$cn])) {
- require $path . $classes[$cn];
- }
-}
-
-spl_autoload_register('php_timer_autoload');
+ if (isset($classes[$cn])) {
+ require $path . $classes[$cn];
+ }
+ }
+);
View
43 PHP/Timer/Autoload.php.in
@@ -43,33 +43,24 @@
* @since File available since Release 1.1.0
*/
-function php_timer_autoload($class = NULL) {
- static $classes = NULL;
- static $path = NULL;
+spl_autoload_register(
+ function ($class)
+ {
+ static $classes = NULL;
+ static $path = NULL;
- if ($classes === NULL) {
- $classes = array(
- ___CLASSLIST___
- );
+ if ($classes === NULL) {
+ $classes = array(
+ ___CLASSLIST___
+ );
- $path = dirname(dirname(__FILE__));
- }
+ $path = dirname(dirname(__FILE__));
+ }
- if ($class === NULL) {
- $result = array(__FILE__);
+ $cn = strtolower($class);
- foreach ($classes as $file) {
- $result[] = $path . $file;
- }
-
- return $result;
- }
-
- $cn = strtolower($class);
-
- if (isset($classes[$cn])) {
- require $path . $classes[$cn];
- }
-}
-
-spl_autoload_register('php_timer_autoload');
+ if (isset($classes[$cn])) {
+ require $path . $classes[$cn];
+ }
+ }
+);
View
3  build.xml
@@ -44,11 +44,10 @@
<exec executable="phpab">
<arg value="--output" />
<arg path="PHP/Timer/Autoload.php" />
- <arg value="--compat" />
<arg value="--template" />
<arg path="PHP/Timer/Autoload.php.in" />
<arg value="--indent" />
- <arg value=" " />
+ <arg value=" " />
<arg path="PHP" />
</exec>
</target>
Please sign in to comment.
Something went wrong with that request. Please try again.