Pārlūkot izejas kodu

Always include the ClassLoader since autoload_real is included only once, refs #963

Jordi Boggiano 13 gadi atpakaļ
vecāks
revīzija
4f0ad98905

+ 1 - 3
src/Composer/Autoload/AutoloadGenerator.php

@@ -311,9 +311,7 @@ AUTOLOAD;
 
 // autoload_real$suffix.php generated by Composer
 
-if (!class_exists('Composer\\\\Autoload\\\\ClassLoader', false)) {
-    require __DIR__ . '/ClassLoader.php';
-}
+require __DIR__ . '/ClassLoader.php';
 
 class ComposerAutoloaderInit$suffix
 {

+ 6 - 0
tests/Composer/Test/Autoload/AutoloadGeneratorTest.php

@@ -278,6 +278,9 @@ class AutoloadGeneratorTest extends TestCase
         $this->assertFileEquals(__DIR__.'/Fixtures/autoload_functions.php', $this->vendorDir.'/autoload.php');
         $this->assertFileEquals(__DIR__.'/Fixtures/autoload_real_functions.php', $this->vendorDir.'/composer/autoload_realFilesAutoload.php');
 
+        // suppress the class loader to avoid fatals if the class is redefined
+        file_put_contents($this->vendorDir.'/composer/ClassLoader.php', '');
+
         include $this->vendorDir . '/autoload.php';
         $this->assertTrue(function_exists('testFilesAutoloadGeneration1'));
         $this->assertTrue(function_exists('testFilesAutoloadGeneration2'));
@@ -360,6 +363,9 @@ class AutoloadGeneratorTest extends TestCase
 
         $oldIncludePath = get_include_path();
 
+        // suppress the class loader to avoid fatals if the class is redefined
+        file_put_contents($this->vendorDir.'/composer/ClassLoader.php', '');
+
         require($this->vendorDir."/autoload.php");
 
         $this->assertEquals(

+ 1 - 3
tests/Composer/Test/Autoload/Fixtures/autoload_real_functions.php

@@ -2,9 +2,7 @@
 
 // autoload_realFilesAutoload.php generated by Composer
 
-if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
-    require __DIR__ . '/ClassLoader.php';
-}
+require __DIR__ . '/ClassLoader.php';
 
 class ComposerAutoloaderInitFilesAutoload
 {

+ 1 - 3
tests/Composer/Test/Autoload/Fixtures/autoload_real_target_dir.php

@@ -2,9 +2,7 @@
 
 // autoload_realTargetDir.php generated by Composer
 
-if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
-    require __DIR__ . '/ClassLoader.php';
-}
+require __DIR__ . '/ClassLoader.php';
 
 class ComposerAutoloaderInitTargetDir
 {