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