Skip to content

Commit

Permalink
Dump autoload
Browse files Browse the repository at this point in the history
  • Loading branch information
esamattis committed Sep 28, 2021
1 parent 6589a26 commit d4d5df9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
44 changes: 40 additions & 4 deletions vendor/composer/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@
*
* @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/
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
private $vendorDir;

// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
Expand All @@ -57,10 +59,17 @@ 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)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}

return array();
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,13 +328,17 @@ public function register($prepend = false)
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));

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

/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
Expand All @@ -323,6 +347,8 @@ public function loadClass($class)

return true;
}

return null;
}

/**
Expand Down Expand Up @@ -367,6 +393,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
1 change: 1 addition & 0 deletions vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
$baseDir = dirname($vendorDir);

return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
'WPGraphQL\\Extensions\\Polylang\\Helpers' => $baseDir . '/src/Helpers.php',
'WPGraphQL\\Extensions\\Polylang\\LanguageRootQueries' => $baseDir . '/src/LanguageRootQueries.php',
'WPGraphQL\\Extensions\\Polylang\\Loader' => $baseDir . '/src/Loader.php',
Expand Down
4 changes: 2 additions & 2 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public static function getLoader()
}

spl_autoload_register(array('ComposerAutoloaderInit43da53adb50141669ba75c3d91fe6230', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit43da53adb50141669ba75c3d91fe6230', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInit43da53adb50141669ba75c3d91fe6230::getInitializer($loader));
} else {
Expand Down
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ComposerStaticInit43da53adb50141669ba75c3d91fe6230
);

public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
'WPGraphQL\\Extensions\\Polylang\\Helpers' => __DIR__ . '/../..' . '/src/Helpers.php',
'WPGraphQL\\Extensions\\Polylang\\LanguageRootQueries' => __DIR__ . '/../..' . '/src/LanguageRootQueries.php',
'WPGraphQL\\Extensions\\Polylang\\Loader' => __DIR__ . '/../..' . '/src/Loader.php',
Expand Down

0 comments on commit d4d5df9

Please sign in to comment.