Skip to content

Commit f35bf18

Browse files
Use Use Symfony YAML PEAR autoloader when available
1 parent cfb96eb commit f35bf18

File tree

2 files changed

+40
-34
lines changed

2 files changed

+40
-34
lines changed

PHPUnit/Autoload.php

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -206,25 +206,28 @@ function ($class)
206206
}
207207
);
208208

209-
// Symfony Yaml autoloader
210-
spl_autoload_register(
211-
function ($class) {
212-
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
213-
$file = sprintf(
214-
'Symfony/Component/Yaml%s.php',
215-
216-
substr(
217-
str_replace('\\', '/', $class),
218-
strlen('Symfony\Component\Yaml')
219-
)
220-
);
221-
222-
if (stream_resolve_include_path($file)) {
223-
require_once $file;
209+
if (stream_resolve_include_path('Symfony/Component/Yaml/autoloader.php')) {
210+
require_once 'Symfony/Component/Yaml/autoloader.php';
211+
} else {
212+
spl_autoload_register(
213+
function ($class) {
214+
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
215+
$file = sprintf(
216+
'Symfony/Component/Yaml%s.php',
217+
218+
substr(
219+
str_replace('\\', '/', $class),
220+
strlen('Symfony\Component\Yaml')
221+
)
222+
);
223+
224+
if (stream_resolve_include_path($file)) {
225+
require_once $file;
226+
}
224227
}
225228
}
226-
}
227-
);
229+
);
230+
}
228231

229232
if (stream_resolve_include_path('PHP/Invoker/Autoload.php')) {
230233
require_once 'PHP/Invoker/Autoload.php';

PHPUnit/Autoload.php.in

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -89,25 +89,28 @@ spl_autoload_register(
8989
}
9090
);
9191

92-
// Symfony Yaml autoloader
93-
spl_autoload_register(
94-
function ($class) {
95-
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
96-
$file = sprintf(
97-
'Symfony/Component/Yaml%s.php',
98-
99-
substr(
100-
str_replace('\\', '/', $class),
101-
strlen('Symfony\Component\Yaml')
102-
)
103-
);
104-
105-
if (stream_resolve_include_path($file)) {
106-
require_once $file;
92+
if (stream_resolve_include_path('Symfony/Component/Yaml/autoloader.php')) {
93+
require_once 'Symfony/Component/Yaml/autoloader.php';
94+
} else {
95+
spl_autoload_register(
96+
function ($class) {
97+
if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
98+
$file = sprintf(
99+
'Symfony/Component/Yaml%s.php',
100+
101+
substr(
102+
str_replace('\\', '/', $class),
103+
strlen('Symfony\Component\Yaml')
104+
)
105+
);
106+
107+
if (stream_resolve_include_path($file)) {
108+
require_once $file;
109+
}
107110
}
108111
}
109-
}
110-
);
112+
);
113+
}
111114

112115
if (stream_resolve_include_path('PHP/Invoker/Autoload.php')) {
113116
require_once 'PHP/Invoker/Autoload.php';

0 commit comments

Comments
 (0)