-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96bf4c4
commit 6376278
Showing
110 changed files
with
3,111 additions
and
6,775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"require": { | ||
"guzzlehttp/guzzle": "6.2.0" | ||
"guzzlehttp/guzzle": "6.3.0" | ||
}, | ||
|
||
"autoload": { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,9 +13,7 @@ | |
namespace Composer\Autoload; | ||
|
||
/** | ||
* ClassLoader implements a PSR-0 class loader | ||
* | ||
* See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md | ||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader. | ||
* | ||
* $loader = new \Composer\Autoload\ClassLoader(); | ||
* | ||
|
@@ -39,6 +37,8 @@ | |
* | ||
* @author Fabien Potencier <[email protected]> | ||
* @author Jordi Boggiano <[email protected]> | ||
* @see http://www.php-fig.org/psr/psr-0/ | ||
* @see http://www.php-fig.org/psr/psr-4/ | ||
*/ | ||
class ClassLoader | ||
{ | ||
|
@@ -53,8 +53,9 @@ class ClassLoader | |
|
||
private $useIncludePath = false; | ||
private $classMap = array(); | ||
|
||
private $classMapAuthoritative = false; | ||
private $missingClasses = array(); | ||
private $apcuPrefix; | ||
|
||
public function getPrefixes() | ||
{ | ||
|
@@ -147,7 +148,7 @@ public function add($prefix, $paths, $prepend = false) | |
* appending or prepending to the ones previously set for this namespace. | ||
* | ||
* @param string $prefix The prefix/namespace, with trailing '\\' | ||
* @param array|string $paths The PSR-0 base directories | ||
* @param array|string $paths The PSR-4 base directories | ||
* @param bool $prepend Whether to prepend the directories | ||
* | ||
* @throws \InvalidArgumentException | ||
|
@@ -271,6 +272,26 @@ public function isClassMapAuthoritative() | |
return $this->classMapAuthoritative; | ||
} | ||
|
||
/** | ||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled. | ||
* | ||
* @param string|null $apcuPrefix | ||
*/ | ||
public function setApcuPrefix($apcuPrefix) | ||
{ | ||
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; | ||
} | ||
|
||
/** | ||
* The APCu prefix in use, or null if APCu caching is not enabled. | ||
* | ||
* @return string|null | ||
*/ | ||
public function getApcuPrefix() | ||
{ | ||
return $this->apcuPrefix; | ||
} | ||
|
||
/** | ||
* Registers this instance as an autoloader. | ||
* | ||
|
@@ -313,29 +334,34 @@ public function loadClass($class) | |
*/ | ||
public function findFile($class) | ||
{ | ||
// work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 | ||
if ('\\' == $class[0]) { | ||
$class = substr($class, 1); | ||
} | ||
|
||
// class map lookup | ||
if (isset($this->classMap[$class])) { | ||
return $this->classMap[$class]; | ||
} | ||
if ($this->classMapAuthoritative) { | ||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { | ||
return false; | ||
} | ||
if (null !== $this->apcuPrefix) { | ||
$file = apcu_fetch($this->apcuPrefix.$class, $hit); | ||
if ($hit) { | ||
return $file; | ||
} | ||
} | ||
|
||
$file = $this->findFileWithExtension($class, '.php'); | ||
|
||
// Search for Hack files if we are running on HHVM | ||
if ($file === null && defined('HHVM_VERSION')) { | ||
if (false === $file && defined('HHVM_VERSION')) { | ||
$file = $this->findFileWithExtension($class, '.hh'); | ||
} | ||
|
||
if ($file === null) { | ||
if (null !== $this->apcuPrefix) { | ||
apcu_add($this->apcuPrefix.$class, $file); | ||
} | ||
|
||
if (false === $file) { | ||
// Remember that this class does not exist. | ||
return $this->classMap[$class] = false; | ||
$this->missingClasses[$class] = true; | ||
} | ||
|
||
return $file; | ||
|
@@ -348,10 +374,14 @@ private function findFileWithExtension($class, $ext) | |
|
||
$first = $class[0]; | ||
if (isset($this->prefixLengthsPsr4[$first])) { | ||
foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { | ||
if (0 === strpos($class, $prefix)) { | ||
foreach ($this->prefixDirsPsr4[$prefix] as $dir) { | ||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { | ||
$subPath = $class; | ||
while (false !== $lastPos = strrpos($subPath, '\\')) { | ||
$subPath = substr($subPath, 0, $lastPos); | ||
$search = $subPath.'\\'; | ||
if (isset($this->prefixDirsPsr4[$search])) { | ||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); | ||
foreach ($this->prefixDirsPsr4[$search] as $dir) { | ||
if (file_exists($file = $dir . $pathEnd)) { | ||
return $file; | ||
} | ||
} | ||
|
@@ -399,6 +429,8 @@ private function findFileWithExtension($class, $ext) | |
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { | ||
return $file; | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
|
||
|
Oops, something went wrong.