芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/bit-alphas-ltd.com/user/project/vendor/vonage/nexmo-bridge/src/Autoloader.php
*/ protected static $namespaces = ['Nexmo\\' => 'Vonage\\']; /** * @var array
*/ protected static $namespacesReversed = ['Vonage\\' => 'Nexmo\\']; public static function load() : void { $loaded = new ArrayObject([]); spl_autoload_register(self::createPrependAutoloader( static::$namespacesReversed, self::getClassLoader(), $loaded ), true, true); spl_autoload_register(self::createAppendAutoloader( static::$namespaces, $loaded )); } /** * @throws RuntimeException */ private static function getClassLoader() : ClassLoader { if (file_exists(getenv('COMPOSER_VENDOR_DIR') . '/autoload.php')) { return include getenv('COMPOSER_VENDOR_DIR') . '/autoload.php'; } if (file_exists(__DIR__ . '/../../../autoload.php')) { return include __DIR__ . '/../../../autoload.php'; } if (file_exists(__DIR__ . '/../vendor/autoload.php')) { return include __DIR__ . '/../vendor/autoload.php'; } throw new RuntimeException('Cannot detect composer autoload. Please run composer install'); } /** * @param array
$namespaces Namespaces to flip between * @return Closure(string): void */ private static function createPrependAutoloader( array $namespaces, ClassLoader $classLoader, ArrayObject $loaded ) : Closure { /** * @param string $class Class name to autoload * @return void */ return static function (string $class) use ($namespaces, $classLoader, $loaded) : void { if (isset($loaded[$class])) { return; } $segments = explode('\\', $class); $i = 0; $check = ''; while (isset($segments[$i + 1], $namespaces[$check . $segments[$i] . '\\'])) { $check .= $segments[$i] . '\\'; ++$i; } if ($check === '') { return; } if ($classLoader->loadClass($class)) { $legacy = $namespaces[$check] . strtr(substr($class, strlen($check)), [ 'Vonage' => 'Nexmo', ]); class_alias($class, $legacy); } }; } /** * @param array
$namespaces Namespaces to flip between * @return Closure(string): void */ private static function createAppendAutoloader(array $namespaces, ArrayObject $loaded) : Closure { /** * @param string $class Class name to autoload * @return void */ return static function (string $class) use ($namespaces, $loaded) : void { $segments = explode('\\', $class); $i = 0; $check = ''; // We are checking segments of the namespace to match quicker while (isset($segments[$i + 1], $namespaces[$check . $segments[$i] . '\\'])) { $check .= $segments[$i] . '\\'; ++$i; } if ($check === '') { return; } $alias = $namespaces[$check] . strtr(substr($class, strlen($check)), [ 'Nexmo' => 'Vonage', ]); $loaded[$alias] = true; if (class_exists($alias) || interface_exists($alias) || trait_exists($alias)) { class_alias($alias, $class); } }; } }