Merge branch '1.6'
commit
be040f8e31
|
@ -783,11 +783,6 @@ HEADER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// BC handling when converting to a new ClassLoader
|
|
||||||
if (isset($maps['prefixLengthsPsr4'])) {
|
|
||||||
$maps['firstCharsPsr4'] = array_map('is_array', $maps['prefixLengthsPsr4']);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($maps as $prop => $value) {
|
foreach ($maps as $prop => $value) {
|
||||||
if (count($value) > 32767) {
|
if (count($value) > 32767) {
|
||||||
// Static arrays are limited to 32767 values on PHP 5.6
|
// Static arrays are limited to 32767 values on PHP 5.6
|
||||||
|
|
|
@ -43,8 +43,7 @@ namespace Composer\Autoload;
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
{
|
{
|
||||||
// PSR-4
|
// PSR-4
|
||||||
private $firstCharsPsr4 = array();
|
private $prefixLengthsPsr4 = array();
|
||||||
private $prefixLengthsPsr4 = array(); // For BC with legacy static maps
|
|
||||||
private $prefixDirsPsr4 = array();
|
private $prefixDirsPsr4 = array();
|
||||||
private $fallbackDirsPsr4 = array();
|
private $fallbackDirsPsr4 = array();
|
||||||
|
|
||||||
|
@ -171,10 +170,11 @@ class ClassLoader
|
||||||
}
|
}
|
||||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||||
// Register directories for a new namespace.
|
// Register directories for a new namespace.
|
||||||
if ('\\' !== substr($prefix, -1)) {
|
$length = strlen($prefix);
|
||||||
|
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->firstCharsPsr4[$prefix[0]] = true;
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
$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,10 +221,11 @@ class ClassLoader
|
||||||
if (!$prefix) {
|
if (!$prefix) {
|
||||||
$this->fallbackDirsPsr4 = (array) $paths;
|
$this->fallbackDirsPsr4 = (array) $paths;
|
||||||
} else {
|
} else {
|
||||||
if ('\\' !== substr($prefix, -1)) {
|
$length = strlen($prefix);
|
||||||
|
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->firstCharsPsr4[$prefix[0]] = true;
|
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,7 +373,7 @@ class ClassLoader
|
||||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||||
|
|
||||||
$first = $class[0];
|
$first = $class[0];
|
||||||
if (isset($this->firstCharsPsr4[$first]) || isset($this->prefixLengthsPsr4[$first])) {
|
if (isset($this->prefixLengthsPsr4[$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);
|
||||||
|
|
Loading…
Reference in New Issue