Skip to content

Commit

Permalink
Don't try to autoload any of Composer's classes
Browse files Browse the repository at this point in the history
If the composer autoloader has prepend-autoloader: false set, the PHPCS
autoloader will take priority over the composer autoloader, and composer
will have trouble autoloading its own autoloader.

Avoid all of that by simply not trying to load any classes that are
under the "Composer" namespace.

Fixes #1497
  • Loading branch information
legoktm committed Jul 6, 2017
1 parent 776e20a commit 2039c8a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ public static function load($class)
// so this autoloader runs before the composer one as we need to include
// all files so we can figure out what the class/interface/trait name is.
if (self::$composerAutoloader === null) {
// Make sure we don't try to load any of Composer's classes
// while the autoloader is being setup.
if (strpos($class, 'Composer\\') === 0) {
return;
}

if (strpos(__DIR__, 'phar://') !== 0
&& file_exists(__DIR__.'/../../autoload.php') === true
) {
Expand All @@ -82,7 +88,7 @@ public static function load($class)
} else {
self::$composerAutoloader = false;
}
}
}//end if

$ds = DIRECTORY_SEPARATOR;
$path = false;
Expand Down

0 comments on commit 2039c8a

Please sign in to comment.