diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 284150135..a7dd76706 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -605,7 +605,14 @@ METHOD_FOOTER; function composerRequire$suffix(\$file) { - require \$file; + static \$requiredFiles = array(); + \$fileSignature = md5_file(\$file); + + if (empty(\$requiredFiles[\$fileSignature])) { + require \$file; + + \$requiredFiles[\$fileSignature] = true; + } } FOOTER; 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 083070539..43ce6855a 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 @@ -51,5 +51,12 @@ class ComposerAutoloaderInitFilesAutoloadOrder function composerRequireFilesAutoloadOrder($file) { - require $file; + static $requiredFiles = array(); + $fileSignature = md5_file($file); + + if (empty($requiredFiles[$fileSignature])) { + require $file; + + $requiredFiles[$fileSignature] = true; + } } diff --git a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php index 1c0154964..d13f7e65e 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php @@ -51,5 +51,12 @@ class ComposerAutoloaderInitFilesAutoload function composerRequireFilesAutoload($file) { - require $file; + static $requiredFiles = array(); + $fileSignature = md5_file($file); + + if (empty($requiredFiles[$fileSignature])) { + require $file; + + $requiredFiles[$fileSignature] = true; + } } 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 65ba6819e..78e3bc8da 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_include_path.php @@ -67,5 +67,12 @@ class ComposerAutoloaderInitIncludePath function composerRequireIncludePath($file) { - require $file; + static $requiredFiles = array(); + $fileSignature = md5_file($file); + + if (empty($requiredFiles[$fileSignature])) { + require $file; + + $requiredFiles[$fileSignature] = true; + } } 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 dc786f767..eb38a1035 100644 --- a/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php +++ b/tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php @@ -71,5 +71,12 @@ class ComposerAutoloaderInitTargetDir function composerRequireTargetDir($file) { - require $file; + static $requiredFiles = array(); + $fileSignature = md5_file($file); + + if (empty($requiredFiles[$fileSignature])) { + require $file; + + $requiredFiles[$fileSignature] = true; + } }