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

Commit 9b6effa

Browse files
Make autoloader function anonymous.
1 parent c99c125 commit 9b6effa

File tree

3 files changed

+43
-61
lines changed

3 files changed

+43
-61
lines changed

Diff for: PHPUnit/Extensions/TicketListener/Jira/Autoload.php

+19-31
Original file line numberDiff line numberDiff line change
@@ -42,38 +42,26 @@
4242
* @since File available since Release 1.0.0
4343
*/
4444

45-
function phpunit_ticketlistener_jira_autoload($class = NULL)
46-
{
47-
static $classes = NULL;
48-
static $path = NULL;
45+
spl_autoload_register(
46+
function ($class)
47+
{
48+
static $classes = NULL;
49+
static $path = NULL;
4950

50-
if ($classes === NULL) {
51-
$classes = array(
52-
'phpunit_extensions_ticketlistener_jira_client' => '/Extensions/TicketListener/Jira/Client.php',
53-
'phpunit_extensions_ticketlistener_jira_statusconverter' => '/Extensions/TicketListener/Jira/StatusConverter.php',
54-
'phpunit_extesions_ticketlistener_jira' => '/Extensions/TicketListener/Jira.php'
55-
);
51+
if ($classes === NULL) {
52+
$classes = array(
53+
'phpunit_extensions_ticketlistener_jira_client' => '/Extensions/TicketListener/Jira/Client.php',
54+
'phpunit_extensions_ticketlistener_jira_statusconverter' => '/Extensions/TicketListener/Jira/StatusConverter.php',
55+
'phpunit_extesions_ticketlistener_jira' => '/Extensions/TicketListener/Jira.php'
56+
);
5657

57-
$path = dirname(dirname(dirname(dirname(__FILE__))));
58-
}
58+
$path = dirname(dirname(dirname(dirname(__FILE__))));
59+
}
5960

60-
if ($class === NULL) {
61-
$result = array(__FILE__);
61+
$cn = strtolower($class);
6262

63-
foreach ($classes as $file) {
64-
$result[] = $path . $file;
65-
}
66-
67-
return $result;
68-
}
69-
70-
$cn = strtolower($class);
71-
72-
if (isset($classes[$cn])) {
73-
$file = $path . $classes[$cn];
74-
75-
require $file;
76-
}
77-
}
78-
79-
spl_autoload_register('phpunit_ticketlistener_jira_autoload');
63+
if (isset($classes[$cn])) {
64+
require $path . $classes[$cn];
65+
}
66+
}
67+
);

Diff for: PHPUnit/Extensions/TicketListener/Jira/Autoload.php.in

+17-29
Original file line numberDiff line numberDiff line change
@@ -42,36 +42,24 @@
4242
* @since File available since Release 1.0.0
4343
*/
4444

45-
function phpunit_ticketlistener_jira_autoload($class = NULL)
46-
{
47-
static $classes = NULL;
48-
static $path = NULL;
45+
spl_autoload_register(
46+
function ($class)
47+
{
48+
static $classes = NULL;
49+
static $path = NULL;
4950

50-
if ($classes === NULL) {
51-
$classes = array(
52-
___CLASSLIST___
53-
);
51+
if ($classes === NULL) {
52+
$classes = array(
53+
___CLASSLIST___
54+
);
5455

55-
$path = dirname(dirname(dirname(dirname(__FILE__))));
56-
}
56+
$path = dirname(dirname(dirname(dirname(__FILE__))));
57+
}
5758

58-
if ($class === NULL) {
59-
$result = array(__FILE__);
59+
$cn = strtolower($class);
6060

61-
foreach ($classes as $file) {
62-
$result[] = $path . $file;
63-
}
64-
65-
return $result;
66-
}
67-
68-
$cn = strtolower($class);
69-
70-
if (isset($classes[$cn])) {
71-
$file = $path . $classes[$cn];
72-
73-
require $file;
74-
}
75-
}
76-
77-
spl_autoload_register('phpunit_ticketlistener_jira_autoload');
61+
if (isset($classes[$cn])) {
62+
require $path . $classes[$cn];
63+
}
64+
}
65+
);

Diff for: build.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
<project name="phpunit-ticketlistener-jira" default="phpab" basedir=".">
33
<target name="phpab" description="Generates the autoloader using PHPAB">
44
<exec executable="phpab">
5-
<arg line='-o PHPUnit/Extensions/TicketListener/Jira/Autoload.php -c -t PHPUnit/Extensions/TicketListener/Jira/Autoload.php.in --indent " " PHPUnit' />
5+
<arg value="--output" />
6+
<arg path="PHPUnit/Extensions/TicketListener/Jira/Autoload.php" />
7+
<arg value="--template" />
8+
<arg path="PHPUnit/Extensions/TicketListener/Jira/Autoload.php.in" />
9+
<arg value="--indent" />
10+
<arg value=" " />
11+
<arg path="PHPUnit" />
612
</exec>
713
</target>
814
</project>

0 commit comments

Comments
 (0)