| @@ -8,10 +8,11 @@ | ||
| 8 | 8 | * |
| 9 | 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | 10 | * file that was distributed with this source code. |
| 11 | 11 | */ |
| 12 | -namespace WindPressPackages\Composer\Autoload; | |
| 13 | 12 | |
| 13 | +namespace Composer\Autoload; | |
| 14 | + | |
| 14 | 15 | /** |
| 15 | 16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. |
| 16 | 17 | * |
| 17 | 18 | * $loader = new \Composer\Autoload\ClassLoader(); |
| @@ -42,10 +43,12 @@ | ||
| 42 | 43 | class ClassLoader |
| 43 | 44 | { |
| 44 | 45 | /** @var \Closure(string):void */ |
| 45 | 46 | private static $includeFile; |
| 47 | + | |
| 46 | 48 | /** @var string|null */ |
| 47 | 49 | private $vendorDir; |
| 50 | + | |
| 48 | 51 | // PSR-4 |
| 49 | 52 | /** |
| 50 | 53 | * @var array<string, array<string, int>> |
| 51 | 54 | */ |
| @@ -57,8 +60,9 @@ | ||
| 57 | 60 | /** |
| 58 | 61 | * @var list<string> |
| 59 | 62 | */ |
| 60 | 63 | private $fallbackDirsPsr4 = array(); |
| 64 | + | |
| 61 | 65 | // PSR-0 |
| 62 | 66 | /** |
| 63 | 67 | * List of PSR-0 prefixes |
| 64 | 68 | * |
| @@ -70,26 +74,33 @@ | ||
| 70 | 74 | /** |
| 71 | 75 | * @var list<string> |
| 72 | 76 | */ |
| 73 | 77 | private $fallbackDirsPsr0 = array(); |
| 78 | + | |
| 74 | 79 | /** @var bool */ |
| 75 | - private $useIncludePath = \false; | |
| 80 | + private $useIncludePath = false; | |
| 81 | + | |
| 76 | 82 | /** |
| 77 | 83 | * @var array<string, string> |
| 78 | 84 | */ |
| 79 | 85 | private $classMap = array(); |
| 86 | + | |
| 80 | 87 | /** @var bool */ |
| 81 | - private $classMapAuthoritative = \false; | |
| 88 | + private $classMapAuthoritative = false; | |
| 89 | + | |
| 82 | 90 | /** |
| 83 | 91 | * @var array<string, bool> |
| 84 | 92 | */ |
| 85 | 93 | private $missingClasses = array(); |
| 94 | + | |
| 86 | 95 | /** @var string|null */ |
| 87 | 96 | private $apcuPrefix; |
| 97 | + | |
| 88 | 98 | /** |
| 89 | 99 | * @var array<string, self> |
| 90 | 100 | */ |
| 91 | 101 | private static $registeredLoaders = array(); |
| 102 | + | |
| 92 | 103 | /** |
| 93 | 104 | * @param string|null $vendorDir |
| 94 | 105 | */ |
| 95 | 106 | public function __construct($vendorDir = null) |
| @@ -96,8 +107,9 @@ | ||
| 96 | 107 | { |
| 97 | 108 | $this->vendorDir = $vendorDir; |
| 98 | 109 | self::initializeIncludeClosure(); |
| 99 | 110 | } |
| 111 | + | |
| 100 | 112 | /** |
| 101 | 113 | * @return array<string, list<string>> |
| 102 | 114 | */ |
| 103 | 115 | public function getPrefixes() |
| @@ -102,12 +114,14 @@ | ||
| 102 | 114 | */ |
| 103 | 115 | public function getPrefixes() |
| 104 | 116 | { |
| 105 | 117 | if (!empty($this->prefixesPsr0)) { |
| 106 | - return \call_user_func_array('WindPressPackages\\array_merge', \array_values($this->prefixesPsr0)); | |
| 118 | + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); | |
| 107 | 119 | } |
| 120 | + | |
| 108 | 121 | return array(); |
| 109 | 122 | } |
| 123 | + | |
| 110 | 124 | /** |
| 111 | 125 | * @return array<string, list<string>> |
| 112 | 126 | */ |
| 113 | 127 | public function getPrefixesPsr4() |
| @@ -113,8 +127,9 @@ | ||
| 113 | 127 | public function getPrefixesPsr4() |
| 114 | 128 | { |
| 115 | 129 | return $this->prefixDirsPsr4; |
| 116 | 130 | } |
| 131 | + | |
| 117 | 132 | /** |
| 118 | 133 | * @return list<string> |
| 119 | 134 | */ |
| 120 | 135 | public function getFallbackDirs() |
| @@ -120,8 +135,9 @@ | ||
| 120 | 135 | public function getFallbackDirs() |
| 121 | 136 | { |
| 122 | 137 | return $this->fallbackDirsPsr0; |
| 123 | 138 | } |
| 139 | + | |
| 124 | 140 | /** |
| 125 | 141 | * @return list<string> |
| 126 | 142 | */ |
| 127 | 143 | public function getFallbackDirsPsr4() |
| @@ -127,8 +143,9 @@ | ||
| 127 | 143 | public function getFallbackDirsPsr4() |
| 128 | 144 | { |
| 129 | 145 | return $this->fallbackDirsPsr4; |
| 130 | 146 | } |
| 147 | + | |
| 131 | 148 | /** |
| 132 | 149 | * @return array<string, string> Array of classname => path |
| 133 | 150 | */ |
| 134 | 151 | public function getClassMap() |
| @@ -134,8 +151,9 @@ | ||
| 134 | 151 | public function getClassMap() |
| 135 | 152 | { |
| 136 | 153 | return $this->classMap; |
| 137 | 154 | } |
| 155 | + | |
| 138 | 156 | /** |
| 139 | 157 | * @param array<string, string> $classMap Class to filename map |
| 140 | 158 | * |
| 141 | 159 | * @return void |
| @@ -142,13 +160,14 @@ | ||
| 142 | 160 | */ |
| 143 | 161 | public function addClassMap(array $classMap) |
| 144 | 162 | { |
| 145 | 163 | if ($this->classMap) { |
| 146 | - $this->classMap = \array_merge($this->classMap, $classMap); | |
| 164 | + $this->classMap = array_merge($this->classMap, $classMap); | |
| 147 | 165 | } else { |
| 148 | 166 | $this->classMap = $classMap; |
| 149 | 167 | } |
| 150 | 168 | } |
| 169 | + | |
| 151 | 170 | /** |
| 152 | 171 | * Registers a set of PSR-0 directories for a given prefix, either |
| 153 | 172 | * appending or prepending to the ones previously set for this prefix. |
| 154 | 173 | * |
| @@ -157,30 +176,46 @@ | ||
| 157 | 176 | * @param bool $prepend Whether to prepend the directories |
| 158 | 177 | * |
| 159 | 178 | * @return void |
| 160 | 179 | */ |
| 161 | - public function add($prefix, $paths, $prepend = \false) | |
| 180 | + public function add($prefix, $paths, $prepend = false) | |
| 162 | 181 | { |
| 163 | 182 | $paths = (array) $paths; |
| 164 | 183 | if (!$prefix) { |
| 165 | 184 | if ($prepend) { |
| 166 | - $this->fallbackDirsPsr0 = \array_merge($paths, $this->fallbackDirsPsr0); | |
| 185 | + $this->fallbackDirsPsr0 = array_merge( | |
| 186 | + $paths, | |
| 187 | + $this->fallbackDirsPsr0 | |
| 188 | + ); | |
| 167 | 189 | } else { |
| 168 | - $this->fallbackDirsPsr0 = \array_merge($this->fallbackDirsPsr0, $paths); | |
| 190 | + $this->fallbackDirsPsr0 = array_merge( | |
| 191 | + $this->fallbackDirsPsr0, | |
| 192 | + $paths | |
| 193 | + ); | |
| 169 | 194 | } |
| 195 | + | |
| 170 | 196 | return; |
| 171 | 197 | } |
| 198 | + | |
| 172 | 199 | $first = $prefix[0]; |
| 173 | 200 | if (!isset($this->prefixesPsr0[$first][$prefix])) { |
| 174 | 201 | $this->prefixesPsr0[$first][$prefix] = $paths; |
| 202 | + | |
| 175 | 203 | return; |
| 176 | 204 | } |
| 177 | 205 | if ($prepend) { |
| 178 | - $this->prefixesPsr0[$first][$prefix] = \array_merge($paths, $this->prefixesPsr0[$first][$prefix]); | |
| 206 | + $this->prefixesPsr0[$first][$prefix] = array_merge( | |
| 207 | + $paths, | |
| 208 | + $this->prefixesPsr0[$first][$prefix] | |
| 209 | + ); | |
| 179 | 210 | } else { |
| 180 | - $this->prefixesPsr0[$first][$prefix] = \array_merge($this->prefixesPsr0[$first][$prefix], $paths); | |
| 211 | + $this->prefixesPsr0[$first][$prefix] = array_merge( | |
| 212 | + $this->prefixesPsr0[$first][$prefix], | |
| 213 | + $paths | |
| 214 | + ); | |
| 181 | 215 | } |
| 182 | 216 | } |
| 217 | + | |
| 183 | 218 | /** |
| 184 | 219 | * Registers a set of PSR-4 directories for a given namespace, either |
| 185 | 220 | * appending or prepending to the ones previously set for this namespace. |
| 186 | 221 | * |
| @@ -191,21 +226,27 @@ | ||
| 191 | 226 | * @throws \InvalidArgumentException |
| 192 | 227 | * |
| 193 | 228 | * @return void |
| 194 | 229 | */ |
| 195 | - public function addPsr4($prefix, $paths, $prepend = \false) | |
| 230 | + public function addPsr4($prefix, $paths, $prepend = false) | |
| 196 | 231 | { |
| 197 | 232 | $paths = (array) $paths; |
| 198 | 233 | if (!$prefix) { |
| 199 | 234 | // Register directories for the root namespace. |
| 200 | 235 | if ($prepend) { |
| 201 | - $this->fallbackDirsPsr4 = \array_merge($paths, $this->fallbackDirsPsr4); | |
| 236 | + $this->fallbackDirsPsr4 = array_merge( | |
| 237 | + $paths, | |
| 238 | + $this->fallbackDirsPsr4 | |
| 239 | + ); | |
| 202 | 240 | } else { |
| 203 | - $this->fallbackDirsPsr4 = \array_merge($this->fallbackDirsPsr4, $paths); | |
| 241 | + $this->fallbackDirsPsr4 = array_merge( | |
| 242 | + $this->fallbackDirsPsr4, | |
| 243 | + $paths | |
| 244 | + ); | |
| 204 | 245 | } |
| 205 | 246 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
| 206 | 247 | // Register directories for a new namespace. |
| 207 | - $length = \strlen($prefix); | |
| 248 | + $length = strlen($prefix); | |
| 208 | 249 | if ('\\' !== $prefix[$length - 1]) { |
| 209 | 250 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 210 | 251 | } |
| 211 | 252 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
| @@ -211,14 +252,21 @@ | ||
| 211 | 252 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
| 212 | 253 | $this->prefixDirsPsr4[$prefix] = $paths; |
| 213 | 254 | } elseif ($prepend) { |
| 214 | 255 | // Prepend directories for an already registered namespace. |
| 215 | - $this->prefixDirsPsr4[$prefix] = \array_merge($paths, $this->prefixDirsPsr4[$prefix]); | |
| 256 | + $this->prefixDirsPsr4[$prefix] = array_merge( | |
| 257 | + $paths, | |
| 258 | + $this->prefixDirsPsr4[$prefix] | |
| 259 | + ); | |
| 216 | 260 | } else { |
| 217 | 261 | // Append directories for an already registered namespace. |
| 218 | - $this->prefixDirsPsr4[$prefix] = \array_merge($this->prefixDirsPsr4[$prefix], $paths); | |
| 262 | + $this->prefixDirsPsr4[$prefix] = array_merge( | |
| 263 | + $this->prefixDirsPsr4[$prefix], | |
| 264 | + $paths | |
| 265 | + ); | |
| 219 | 266 | } |
| 220 | 267 | } |
| 268 | + | |
| 221 | 269 | /** |
| 222 | 270 | * Registers a set of PSR-0 directories for a given prefix, |
| 223 | 271 | * replacing any others previously set for this prefix. |
| 224 | 272 | * |
| @@ -234,8 +282,9 @@ | ||
| 234 | 282 | } else { |
| 235 | 283 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
| 236 | 284 | } |
| 237 | 285 | } |
| 286 | + | |
| 238 | 287 | /** |
| 239 | 288 | * Registers a set of PSR-4 directories for a given namespace, |
| 240 | 289 | * replacing any others previously set for this namespace. |
| 241 | 290 | * |
| @@ -250,9 +299,9 @@ | ||
| 250 | 299 | { |
| 251 | 300 | if (!$prefix) { |
| 252 | 301 | $this->fallbackDirsPsr4 = (array) $paths; |
| 253 | 302 | } else { |
| 254 | - $length = \strlen($prefix); | |
| 303 | + $length = strlen($prefix); | |
| 255 | 304 | if ('\\' !== $prefix[$length - 1]) { |
| 256 | 305 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
| 257 | 306 | } |
| 258 | 307 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
| @@ -258,8 +307,9 @@ | ||
| 258 | 307 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
| 259 | 308 | $this->prefixDirsPsr4[$prefix] = (array) $paths; |
| 260 | 309 | } |
| 261 | 310 | } |
| 311 | + | |
| 262 | 312 | /** |
| 263 | 313 | * Turns on searching the include path for class files. |
| 264 | 314 | * |
| 265 | 315 | * @param bool $useIncludePath |
| @@ -269,8 +319,9 @@ | ||
| 269 | 319 | public function setUseIncludePath($useIncludePath) |
| 270 | 320 | { |
| 271 | 321 | $this->useIncludePath = $useIncludePath; |
| 272 | 322 | } |
| 323 | + | |
| 273 | 324 | /** |
| 274 | 325 | * Can be used to check if the autoloader uses the include path to check |
| 275 | 326 | * for classes. |
| 276 | 327 | * |
| @@ -279,8 +330,9 @@ | ||
| 279 | 330 | public function getUseIncludePath() |
| 280 | 331 | { |
| 281 | 332 | return $this->useIncludePath; |
| 282 | 333 | } |
| 334 | + | |
| 283 | 335 | /** |
| 284 | 336 | * Turns off searching the prefix and fallback directories for classes |
| 285 | 337 | * that have not been registered with the class map. |
| 286 | 338 | * |
| @@ -291,8 +343,9 @@ | ||
| 291 | 343 | public function setClassMapAuthoritative($classMapAuthoritative) |
| 292 | 344 | { |
| 293 | 345 | $this->classMapAuthoritative = $classMapAuthoritative; |
| 294 | 346 | } |
| 347 | + | |
| 295 | 348 | /** |
| 296 | 349 | * Should class lookup fail if not found in the current class map? |
| 297 | 350 | * |
| 298 | 351 | * @return bool |
| @@ -300,8 +353,9 @@ | ||
| 300 | 353 | public function isClassMapAuthoritative() |
| 301 | 354 | { |
| 302 | 355 | return $this->classMapAuthoritative; |
| 303 | 356 | } |
| 357 | + | |
| 304 | 358 | /** |
| 305 | 359 | * APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
| 306 | 360 | * |
| 307 | 361 | * @param string|null $apcuPrefix |
| @@ -309,10 +363,11 @@ | ||
| 309 | 363 | * @return void |
| 310 | 364 | */ |
| 311 | 365 | public function setApcuPrefix($apcuPrefix) |
| 312 | 366 | { |
| 313 | - $this->apcuPrefix = \function_exists('apcu_fetch') && \filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; | |
| 367 | + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; | |
| 314 | 368 | } |
| 369 | + | |
| 315 | 370 | /** |
| 316 | 371 | * The APCu prefix in use, or null if APCu caching is not enabled. |
| 317 | 372 | * |
| 318 | 373 | * @return string|null |
| @@ -320,8 +375,9 @@ | ||
| 320 | 375 | public function getApcuPrefix() |
| 321 | 376 | { |
| 322 | 377 | return $this->apcuPrefix; |
| 323 | 378 | } |
| 379 | + | |
| 324 | 380 | /** |
| 325 | 381 | * Registers this instance as an autoloader. |
| 326 | 382 | * |
| 327 | 383 | * @param bool $prepend Whether to prepend the autoloader or not |
| @@ -327,14 +383,16 @@ | ||
| 327 | 383 | * @param bool $prepend Whether to prepend the autoloader or not |
| 328 | 384 | * |
| 329 | 385 | * @return void |
| 330 | 386 | */ |
| 331 | - public function register($prepend = \false) | |
| 387 | + public function register($prepend = false) | |
| 332 | 388 | { |
| 333 | - \spl_autoload_register(array($this, 'loadClass'), \true, $prepend); | |
| 389 | + spl_autoload_register(array($this, 'loadClass'), true, $prepend); | |
| 390 | + | |
| 334 | 391 | if (null === $this->vendorDir) { |
| 335 | 392 | return; |
| 336 | 393 | } |
| 394 | + | |
| 337 | 395 | if ($prepend) { |
| 338 | 396 | self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; |
| 339 | 397 | } else { |
| 340 | 398 | unset(self::$registeredLoaders[$this->vendorDir]); |
| @@ -340,8 +398,9 @@ | ||
| 340 | 398 | unset(self::$registeredLoaders[$this->vendorDir]); |
| 341 | 399 | self::$registeredLoaders[$this->vendorDir] = $this; |
| 342 | 400 | } |
| 343 | 401 | } |
| 402 | + | |
| 344 | 403 | /** |
| 345 | 404 | * Unregisters this instance as an autoloader. |
| 346 | 405 | * |
| 347 | 406 | * @return void |
| @@ -347,13 +406,15 @@ | ||
| 347 | 406 | * @return void |
| 348 | 407 | */ |
| 349 | 408 | public function unregister() |
| 350 | 409 | { |
| 351 | - \spl_autoload_unregister(array($this, 'loadClass')); | |
| 410 | + spl_autoload_unregister(array($this, 'loadClass')); | |
| 411 | + | |
| 352 | 412 | if (null !== $this->vendorDir) { |
| 353 | 413 | unset(self::$registeredLoaders[$this->vendorDir]); |
| 354 | 414 | } |
| 355 | 415 | } |
| 416 | + | |
| 356 | 417 | /** |
| 357 | 418 | * Loads the given class or interface. |
| 358 | 419 | * |
| 359 | 420 | * @param string $class The name of the class |
| @@ -363,12 +424,15 @@ | ||
| 363 | 424 | { |
| 364 | 425 | if ($file = $this->findFile($class)) { |
| 365 | 426 | $includeFile = self::$includeFile; |
| 366 | 427 | $includeFile($file); |
| 367 | - return \true; | |
| 428 | + | |
| 429 | + return true; | |
| 368 | 430 | } |
| 431 | + | |
| 369 | 432 | return null; |
| 370 | 433 | } |
| 434 | + | |
| 371 | 435 | /** |
| 372 | 436 | * Finds the path to the file where the class is defined. |
| 373 | 437 | * |
| 374 | 438 | * @param string $class The name of the class |
| @@ -381,30 +445,36 @@ | ||
| 381 | 445 | if (isset($this->classMap[$class])) { |
| 382 | 446 | return $this->classMap[$class]; |
| 383 | 447 | } |
| 384 | 448 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
| 385 | - return \false; | |
| 449 | + return false; | |
| 386 | 450 | } |
| 387 | 451 | if (null !== $this->apcuPrefix) { |
| 388 | - $file = \apcu_fetch($this->apcuPrefix . $class, $hit); | |
| 452 | + $file = apcu_fetch($this->apcuPrefix.$class, $hit); | |
| 389 | 453 | if ($hit) { |
| 390 | 454 | return $file; |
| 391 | 455 | } |
| 392 | 456 | } |
| 457 | + | |
| 393 | 458 | $file = $this->findFileWithExtension($class, '.php'); |
| 459 | + | |
| 394 | 460 | // Search for Hack files if we are running on HHVM |
| 395 | - if (\false === $file && \defined('WindPressPackages\\HHVM_VERSION')) { | |
| 461 | + if (false === $file && defined('HHVM_VERSION')) { | |
| 396 | 462 | $file = $this->findFileWithExtension($class, '.hh'); |
| 397 | 463 | } |
| 464 | + | |
| 398 | 465 | if (null !== $this->apcuPrefix) { |
| 399 | - \apcu_add($this->apcuPrefix . $class, $file); | |
| 466 | + apcu_add($this->apcuPrefix.$class, $file); | |
| 400 | 467 | } |
| 401 | - if (\false === $file) { | |
| 468 | + | |
| 469 | + if (false === $file) { | |
| 402 | 470 | // Remember that this class does not exist. |
| 403 | - $this->missingClasses[$class] = \true; | |
| 471 | + $this->missingClasses[$class] = true; | |
| 404 | 472 | } |
| 473 | + | |
| 405 | 474 | return $file; |
| 406 | 475 | } |
| 476 | + | |
| 407 | 477 | /** |
| 408 | 478 | * Returns the currently registered loaders keyed by their corresponding vendor directories. |
| 409 | 479 | * |
| 410 | 480 | * @return array<string, self> |
| @@ -412,8 +482,9 @@ | ||
| 412 | 482 | public static function getRegisteredLoaders() |
| 413 | 483 | { |
| 414 | 484 | return self::$registeredLoaders; |
| 415 | 485 | } |
| 486 | + | |
| 416 | 487 | /** |
| 417 | 488 | * @param string $class |
| 418 | 489 | * @param string $ext |
| 419 | 490 | * @return string|false |
| @@ -420,19 +491,20 @@ | ||
| 420 | 491 | */ |
| 421 | 492 | private function findFileWithExtension($class, $ext) |
| 422 | 493 | { |
| 423 | 494 | // PSR-4 lookup |
| 424 | - $logicalPathPsr4 = \strtr($class, '\\', \DIRECTORY_SEPARATOR) . $ext; | |
| 495 | + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; | |
| 496 | + | |
| 425 | 497 | $first = $class[0]; |
| 426 | 498 | if (isset($this->prefixLengthsPsr4[$first])) { |
| 427 | 499 | $subPath = $class; |
| 428 | - while (\false !== ($lastPos = \strrpos($subPath, '\\'))) { | |
| 429 | - $subPath = \substr($subPath, 0, $lastPos); | |
| 500 | + while (false !== $lastPos = strrpos($subPath, '\\')) { | |
| 501 | + $subPath = substr($subPath, 0, $lastPos); | |
| 430 | 502 | $search = $subPath . '\\'; |
| 431 | 503 | if (isset($this->prefixDirsPsr4[$search])) { |
| 432 | - $pathEnd = \DIRECTORY_SEPARATOR . \substr($logicalPathPsr4, $lastPos + 1); | |
| 504 | + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | |
| 433 | 505 | foreach ($this->prefixDirsPsr4[$search] as $dir) { |
| 434 | - if (\file_exists($file = $dir . $pathEnd)) { | |
| 506 | + if (file_exists($file = $dir . $pathEnd)) { | |
| 435 | 507 | return $file; |
| 436 | 508 | } |
| 437 | 509 | } |
| 438 | 510 | } |
| @@ -437,27 +509,31 @@ | ||
| 437 | 509 | } |
| 438 | 510 | } |
| 439 | 511 | } |
| 440 | 512 | } |
| 513 | + | |
| 441 | 514 | // PSR-4 fallback dirs |
| 442 | 515 | foreach ($this->fallbackDirsPsr4 as $dir) { |
| 443 | - if (\file_exists($file = $dir . \DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |
| 516 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { | |
| 444 | 517 | return $file; |
| 445 | 518 | } |
| 446 | 519 | } |
| 520 | + | |
| 447 | 521 | // PSR-0 lookup |
| 448 | - if (\false !== ($pos = \strrpos($class, '\\'))) { | |
| 522 | + if (false !== $pos = strrpos($class, '\\')) { | |
| 449 | 523 | // namespaced class name |
| 450 | - $logicalPathPsr0 = \substr($logicalPathPsr4, 0, $pos + 1) . \strtr(\substr($logicalPathPsr4, $pos + 1), '_', \DIRECTORY_SEPARATOR); | |
| 524 | + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) | |
| 525 | + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); | |
| 451 | 526 | } else { |
| 452 | 527 | // PEAR-like class name |
| 453 | - $logicalPathPsr0 = \strtr($class, '_', \DIRECTORY_SEPARATOR) . $ext; | |
| 528 | + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; | |
| 454 | 529 | } |
| 530 | + | |
| 455 | 531 | if (isset($this->prefixesPsr0[$first])) { |
| 456 | 532 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
| 457 | - if (0 === \strpos($class, $prefix)) { | |
| 533 | + if (0 === strpos($class, $prefix)) { | |
| 458 | 534 | foreach ($dirs as $dir) { |
| 459 | - if (\file_exists($file = $dir . \DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 535 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 460 | 536 | return $file; |
| 461 | 537 | } |
| 462 | 538 | } |
| 463 | 539 | } |
| @@ -462,20 +538,24 @@ | ||
| 462 | 538 | } |
| 463 | 539 | } |
| 464 | 540 | } |
| 465 | 541 | } |
| 542 | + | |
| 466 | 543 | // PSR-0 fallback dirs |
| 467 | 544 | foreach ($this->fallbackDirsPsr0 as $dir) { |
| 468 | - if (\file_exists($file = $dir . \DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 545 | + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { | |
| 469 | 546 | return $file; |
| 470 | 547 | } |
| 471 | 548 | } |
| 549 | + | |
| 472 | 550 | // PSR-0 include paths. |
| 473 | - if ($this->useIncludePath && ($file = \stream_resolve_include_path($logicalPathPsr0))) { | |
| 551 | + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | |
| 474 | 552 | return $file; |
| 475 | 553 | } |
| 476 | - return \false; | |
| 554 | + | |
| 555 | + return false; | |
| 477 | 556 | } |
| 557 | + | |
| 478 | 558 | /** |
| 479 | 559 | * @return void |
| 480 | 560 | */ |
| 481 | 561 | private static function initializeIncludeClosure() |
| @@ -482,8 +562,9 @@ | ||
| 482 | 562 | { |
| 483 | 563 | if (self::$includeFile !== null) { |
| 484 | 564 | return; |
| 485 | 565 | } |
| 566 | + | |
| 486 | 567 | /** |
| 487 | 568 | * Scope isolated include. |
| 488 | 569 | * |
| 489 | 570 | * Prevents access to $this/self from included files. |
| @@ -490,9 +571,9 @@ | ||
| 490 | 571 | * |
| 491 | 572 | * @param string $file |
| 492 | 573 | * @return void |
| 493 | 574 | */ |
| 494 | - self::$includeFile = \Closure::bind(static function ($file) { | |
| 575 | + self::$includeFile = \Closure::bind(static function($file) { | |
| 495 | 576 | include $file; |
| 496 | 577 | }, null, null); |
| 497 | 578 | } |
| 498 | 579 | } |