Permalink
Browse files

Use Use Symfony YAML PEAR autoloader when available

  • Loading branch information...
1 parent cfb96eb commit f35bf1843c22fe14b2e2fda618612c56e6ebee8b @sebastianbergmann committed Mar 19, 2013
Showing with 40 additions and 34 deletions.
  1. +20 −17 PHPUnit/Autoload.php
  2. +20 −17 PHPUnit/Autoload.php.in
View
@@ -206,25 +206,28 @@ function ($class)
}
);
-// Symfony Yaml autoloader
-spl_autoload_register(
- function ($class) {
- if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
- $file = sprintf(
- 'Symfony/Component/Yaml%s.php',
-
- substr(
- str_replace('\\', '/', $class),
- strlen('Symfony\Component\Yaml')
- )
- );
-
- if (stream_resolve_include_path($file)) {
- require_once $file;
+if (stream_resolve_include_path('Symfony/Component/Yaml/autoloader.php')) {
+ require_once 'Symfony/Component/Yaml/autoloader.php';
+} else {
+ spl_autoload_register(
+ function ($class) {
+ if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
+ $file = sprintf(
+ 'Symfony/Component/Yaml%s.php',
+
+ substr(
+ str_replace('\\', '/', $class),
+ strlen('Symfony\Component\Yaml')
+ )
+ );
+
+ if (stream_resolve_include_path($file)) {
+ require_once $file;
+ }
}
}
- }
-);
+ );
+}
if (stream_resolve_include_path('PHP/Invoker/Autoload.php')) {
require_once 'PHP/Invoker/Autoload.php';
View
@@ -89,25 +89,28 @@ spl_autoload_register(
}
);
-// Symfony Yaml autoloader
-spl_autoload_register(
- function ($class) {
- if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
- $file = sprintf(
- 'Symfony/Component/Yaml%s.php',
-
- substr(
- str_replace('\\', '/', $class),
- strlen('Symfony\Component\Yaml')
- )
- );
-
- if (stream_resolve_include_path($file)) {
- require_once $file;
+if (stream_resolve_include_path('Symfony/Component/Yaml/autoloader.php')) {
+ require_once 'Symfony/Component/Yaml/autoloader.php';
+} else {
+ spl_autoload_register(
+ function ($class) {
+ if (0 === strpos(ltrim($class, '/'), 'Symfony\Component\Yaml')) {
+ $file = sprintf(
+ 'Symfony/Component/Yaml%s.php',
+
+ substr(
+ str_replace('\\', '/', $class),
+ strlen('Symfony\Component\Yaml')
+ )
+ );
+
+ if (stream_resolve_include_path($file)) {
+ require_once $file;
+ }
}
}
- }
-);
+ );
+}
if (stream_resolve_include_path('PHP/Invoker/Autoload.php')) {
require_once 'PHP/Invoker/Autoload.php';

1 comment on commit f35bf18

Contributor

whatthejeff commented on f35bf18 Mar 19, 2013

@sebastianbergmann, did you look at symfony/symfony#7385 / #846 (comment)? Might be better not to use the Symfony autoloader for now.

Please sign in to comment.