diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2021-01-28 20:38:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 20:38:22 +0100 |
commit | e29f903dc4cf2b95df3e4c505e24b30bee999dd0 (patch) | |
tree | daaa236083c64219caa0d46357b2944896407cf5 /apps/files/composer | |
parent | 57b78f57a1d4d0bc26ee051896076cf2f14d7a7f (diff) | |
parent | 299f37c5d99982032c2c607467cb344759212d68 (diff) | |
download | nextcloud-server-e29f903dc4cf2b95df3e4c505e24b30bee999dd0.tar.gz nextcloud-server-e29f903dc4cf2b95df3e4c505e24b30bee999dd0.zip |
Merge pull request #25360 from nextcloud/fix/update-autoloaders
Update all composer autoloader files
Diffstat (limited to 'apps/files/composer')
-rw-r--r-- | apps/files/composer/composer/ClassLoader.php | 32 | ||||
-rw-r--r-- | apps/files/composer/composer/autoload_real.php | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/apps/files/composer/composer/ClassLoader.php b/apps/files/composer/composer/ClassLoader.php index 1a58957d25d..4d989a212c9 100644 --- a/apps/files/composer/composer/ClassLoader.php +++ b/apps/files/composer/composer/ClassLoader.php @@ -42,6 +42,8 @@ namespace Composer\Autoload; */ class ClassLoader { + private $vendorDir; + // PSR-4 private $prefixLengthsPsr4 = array(); private $prefixDirsPsr4 = array(); @@ -57,6 +59,13 @@ class ClassLoader private $missingClasses = array(); private $apcuPrefix; + private static $registeredLoaders = array(); + + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + } + public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -300,6 +309,15 @@ class ClassLoader public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + //no-op + } elseif ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } } /** @@ -308,6 +326,10 @@ class ClassLoader public function unregister() { spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } } /** @@ -367,6 +389,16 @@ class ClassLoader return $file; } + /** + * Returns the currently registered loaders indexed by their corresponding vendor directories. + * + * @return self[] + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + private function findFileWithExtension($class, $ext) { // PSR-4 lookup diff --git a/apps/files/composer/composer/autoload_real.php b/apps/files/composer/composer/autoload_real.php index e95b5b4e539..462094eaafc 100644 --- a/apps/files/composer/composer/autoload_real.php +++ b/apps/files/composer/composer/autoload_real.php @@ -23,7 +23,7 @@ class ComposerAutoloaderInitFiles } spl_autoload_register(array('ComposerAutoloaderInitFiles', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInitFiles', 'loadClassLoader')); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |