diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index ffed63c2f..24414083c 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -580,7 +580,8 @@ INCLUDE_PATH; } $file .= <<= $staticPhpVersion && !defined('HHVM_VERSION')) { + \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION'); + if (\$useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader)); @@ -646,7 +647,7 @@ REGISTER_LOADER; if ($useIncludeFiles) { $file .= <<= $staticPhpVersion) { + if (\$useStaticLoader) { \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files; } else { \$includeFiles = require __DIR__ . '/autoload_files.php'; diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php index f9e816205..674f73038 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_files_by_dependency.php @@ -23,7 +23,8 @@ class ComposerAutoloaderInitFilesAutoloadOrder self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoloadOrder', 'loadClassLoader')); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::getInitializer($loader)); @@ -46,7 +47,7 @@ class ComposerAutoloaderInitFilesAutoloadOrder $loader->register(true); - if (PHP_VERSION_ID >= 50600) { + if ($useStaticLoader) { $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoloadOrder::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index c3f7482a3..ecbcc41f9 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -23,7 +23,8 @@ class ComposerAutoloaderInitFilesAutoload self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); @@ -46,7 +47,7 @@ class ComposerAutoloaderInitFilesAutoload $loader->register(true); - if (PHP_VERSION_ID >= 50600) { + if ($useStaticLoader) { $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php index b223cbb54..e63c75cb5 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_include_paths.php @@ -27,7 +27,8 @@ class ComposerAutoloaderInitFilesAutoload array_push($includePaths, get_include_path()); set_include_path(join(PATH_SEPARATOR, $includePaths)); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); @@ -50,7 +51,7 @@ class ComposerAutoloaderInitFilesAutoload $loader->register(true); - if (PHP_VERSION_ID >= 50600) { + if ($useStaticLoader) { $includeFiles = Composer\Autoload\ComposerStaticInitFilesAutoload::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php'; diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php index 6543b9222..007fd89d9 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions_with_removed_include_paths_and_autolad_files.php @@ -23,7 +23,8 @@ class ComposerAutoloaderInitFilesAutoload self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitFilesAutoload', 'loadClassLoader')); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitFilesAutoload::getInitializer($loader)); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php index a575fa28d..cce1198cb 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php @@ -23,7 +23,8 @@ class ComposerAutoloaderInitIncludePath self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitIncludePath', 'loadClassLoader')); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitIncludePath::getInitializer($loader)); diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php index 61c4ba6ad..b3d4b22a8 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php @@ -23,7 +23,8 @@ class ComposerAutoloaderInitTargetDir self::$loader = $loader = new \Composer\Autoload\ClassLoader(); spl_autoload_unregister(array('ComposerAutoloaderInitTargetDir', 'loadClassLoader')); - if (PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION')) { + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION'); + if ($useStaticLoader) { require_once __DIR__ . '/autoload_static.php'; call_user_func(\Composer\Autoload\ComposerStaticInitTargetDir::getInitializer($loader)); @@ -48,7 +49,7 @@ class ComposerAutoloaderInitTargetDir $loader->register(true); - if (PHP_VERSION_ID >= 50600) { + if ($useStaticLoader) { $includeFiles = Composer\Autoload\ComposerStaticInitTargetDir::$files; } else { $includeFiles = require __DIR__ . '/autoload_files.php';