update autoloader
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
e489a1a7c8
commit
7f0e4a5357
|
@ -43,7 +43,7 @@ namespace Composer\Autoload;
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
// PSR-4
|
// PSR-4
|
||||||
private $prefixLengthsPsr4 = array();
|
private $firstCharsPsr4 = array();
|
||||||
private $prefixDirsPsr4 = array();
|
private $prefixDirsPsr4 = array();
|
||||||
private $fallbackDirsPsr4 = array();
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
@ -170,11 +170,10 @@ class ClassLoader
|
||||||
}
|
}
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
// Register directories for a new namespace.
|
// Register directories for a new namespace.
|
||||||
$length = strlen($prefix);
|
if ('\\' !== substr($prefix, -1)) {
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
$this->firstCharsPsr4[$prefix[0]] = true;
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
} elseif ($prepend) {
|
} elseif ($prepend) {
|
||||||
// Prepend directories for an already registered namespace.
|
// Prepend directories for an already registered namespace.
|
||||||
|
@ -221,11 +220,10 @@ class ClassLoader
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
} else {
|
} else {
|
||||||
$length = strlen($prefix);
|
if ('\\' !== substr($prefix, -1)) {
|
||||||
if ('\\' !== $prefix[$length - 1]) {
|
|
||||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||||
}
|
}
|
||||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
$this->firstCharsPsr4[$prefix[0]] = true;
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,15 +371,15 @@ class ClassLoader
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
if (isset($this->firstCharsPsr4[$first])) {
|
||||||
$subPath = $class;
|
$subPath = $class;
|
||||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||||
$subPath = substr($subPath, 0, $lastPos);
|
$subPath = substr($subPath, 0, $lastPos);
|
||||||
$search = $subPath.'\\';
|
$search = $subPath.'\\';
|
||||||
if (isset($this->prefixDirsPsr4[$search])) {
|
if (isset($this->prefixDirsPsr4[$search])) {
|
||||||
|
$pathEnd = substr($logicalPathPsr4, $lastPos + 1);
|
||||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||||
$length = $this->prefixLengthsPsr4[$first][$search];
|
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $pathEnd)) {
|
||||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
|
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,8 @@ namespace Composer\Autoload;
|
||||||
|
|
||||||
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
||||||
{
|
{
|
||||||
public static $prefixLengthsPsr4 = array (
|
public static $firstCharsPsr4 = array (
|
||||||
'O' =>
|
'O' => true,
|
||||||
array (
|
|
||||||
'OC\\Settings\\' => 12,
|
|
||||||
'OC\\Core\\' => 8,
|
|
||||||
'OC\\' => 3,
|
|
||||||
'OCP\\' => 4,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $prefixDirsPsr4 = array (
|
public static $prefixDirsPsr4 = array (
|
||||||
|
@ -914,7 +908,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
|
||||||
public static function getInitializer(ClassLoader $loader)
|
public static function getInitializer(ClassLoader $loader)
|
||||||
{
|
{
|
||||||
return \Closure::bind(function () use ($loader) {
|
return \Closure::bind(function () use ($loader) {
|
||||||
$loader->prefixLengthsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixLengthsPsr4;
|
$loader->firstCharsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$firstCharsPsr4;
|
||||||
$loader->prefixDirsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixDirsPsr4;
|
$loader->prefixDirsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixDirsPsr4;
|
||||||
$loader->classMap = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$classMap;
|
$loader->classMap = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$classMap;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue