Skip to content

Commit

Permalink
Move Guzzle to the proxy-stream branch of WoltLab/guzzle
Browse files Browse the repository at this point in the history
Resolves #4038
  • Loading branch information
TimWolla committed Mar 4, 2021
1 parent 28f0a3f commit 8f09f3c
Show file tree
Hide file tree
Showing 9 changed files with 229 additions and 100 deletions.
11 changes: 9 additions & 2 deletions wcfsetup/install/files/lib/system/api/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
"true/punycode": "~2.0",
"pear/net_idna2": "^0.2.0",
"scssphp/scssphp": "^1.4",
"guzzlehttp/guzzle": "^7.2",
"guzzlehttp/guzzle": "dev-proxy-stream",
"paragonie/constant_time_encoding": "^2.3"
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/WoltLab/guzzle",
"no-api": true
}
]
}
52 changes: 18 additions & 34 deletions wcfsetup/install/files/lib/system/api/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions wcfsetup/install/files/lib/system/api/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
*/
class ClassLoader
{
private $vendorDir;

// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
Expand All @@ -57,6 +59,13 @@ class ClassLoader
private $missingClasses = array();
private $apcuPrefix;

private static $registeredLoaders = array();

public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
}

public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
Expand Down Expand Up @@ -300,6 +309,17 @@ public function getApcuPrefix()
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);

if (null === $this->vendorDir) {
return;
}

if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}

/**
Expand All @@ -308,6 +328,10 @@ public function register($prepend = false)
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));

if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}

/**
Expand Down Expand Up @@ -367,6 +391,16 @@ public function findFile($class)
return $file;
}

/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
*
* @return self[]
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}

private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
Expand Down

0 comments on commit 8f09f3c

Please sign in to comment.