Skip to content

Commit 1b43184

Browse files
authored
Merge pull request #7747 from nextcloud/composer_up_12
Update of composer
2 parents 607f699 + 0a880e6 commit 1b43184

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

lib/composer/composer/ClassLoader.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
class ClassLoader
4444
{
4545
// PSR-4
46-
private $firstCharsPsr4 = array();
46+
private $prefixLengthsPsr4 = array();
4747
private $prefixDirsPsr4 = array();
4848
private $fallbackDirsPsr4 = array();
4949

@@ -170,10 +170,11 @@ public function addPsr4($prefix, $paths, $prepend = false)
170170
}
171171
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172172
// Register directories for a new namespace.
173-
if ('\\' !== substr($prefix, -1)) {
173+
$length = strlen($prefix);
174+
if ('\\' !== $prefix[$length - 1]) {
174175
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
175176
}
176-
$this->firstCharsPsr4[$prefix[0]] = true;
177+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
177178
$this->prefixDirsPsr4[$prefix] = (array) $paths;
178179
} elseif ($prepend) {
179180
// Prepend directories for an already registered namespace.
@@ -220,10 +221,11 @@ public function setPsr4($prefix, $paths)
220221
if (!$prefix) {
221222
$this->fallbackDirsPsr4 = (array) $paths;
222223
} else {
223-
if ('\\' !== substr($prefix, -1)) {
224+
$length = strlen($prefix);
225+
if ('\\' !== $prefix[$length - 1]) {
224226
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
225227
}
226-
$this->firstCharsPsr4[$prefix[0]] = true;
228+
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
227229
$this->prefixDirsPsr4[$prefix] = (array) $paths;
228230
}
229231
}
@@ -371,15 +373,15 @@ private function findFileWithExtension($class, $ext)
371373
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
372374

373375
$first = $class[0];
374-
if (isset($this->firstCharsPsr4[$first])) {
376+
if (isset($this->prefixLengthsPsr4[$first])) {
375377
$subPath = $class;
376378
while (false !== $lastPos = strrpos($subPath, '\\')) {
377379
$subPath = substr($subPath, 0, $lastPos);
378380
$search = $subPath.'\\';
379381
if (isset($this->prefixDirsPsr4[$search])) {
380-
$pathEnd = substr($logicalPathPsr4, $lastPos + 1);
382+
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
381383
foreach ($this->prefixDirsPsr4[$search] as $dir) {
382-
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $pathEnd)) {
384+
if (file_exists($file = $dir . $pathEnd)) {
383385
return $file;
384386
}
385387
}

lib/composer/composer/autoload_static.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66

77
class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
88
{
9-
public static $firstCharsPsr4 = array (
10-
'O' => true,
9+
public static $prefixLengthsPsr4 = array (
10+
'O' =>
11+
array (
12+
'OC\\Settings\\' => 12,
13+
'OC\\Core\\' => 8,
14+
'OC\\' => 3,
15+
'OCP\\' => 4,
16+
),
1117
);
1218

1319
public static $prefixDirsPsr4 = array (
@@ -908,7 +914,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
908914
public static function getInitializer(ClassLoader $loader)
909915
{
910916
return \Closure::bind(function () use ($loader) {
911-
$loader->firstCharsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$firstCharsPsr4;
917+
$loader->prefixLengthsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixLengthsPsr4;
912918
$loader->prefixDirsPsr4 = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$prefixDirsPsr4;
913919
$loader->classMap = ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c::$classMap;
914920

0 commit comments

Comments
 (0)