Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the psr/event-dispatcher package #616

Merged
merged 1 commit into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
bin
*/**/phpstan.neon
.php_cs.dist
# ignore editor config
**/*.editorconfig
# ignore demo files
**/.travis.yml
# ignore .github files
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@
"microsoft/azure-storage-blob": "^1.5",
"nextcloud/lognormalizer": "^1.0",
"nikic/php-parser": "^4.2",
"opis/closure": "^3.6",
"patchwork/jsqueeze": "^2.0",
"pear/archive_tar": "^1.4.9",
"pear/pear-core-minimal": "^v1.10",
"phpseclib/phpseclib": "2.0.30",
"php-ds/php-ds": "^1.3",
"php-http/guzzle7-adapter": "^0.1.1",
"php-opencloud/openstack": "^3.1",
"phpseclib/phpseclib": "2.0.30",
"pimple/pimple": "3.3.1",
"psr/container": "^1.0",
"psr/event-dispatcher": "^1.0",
"punic/punic": "^1.6",
"sabre/dav": "^4.1.3",
"scssphp/scssphp": "^1.4.0",
Expand All @@ -45,14 +48,12 @@
"symfony/console": "4.4.19",
"symfony/event-dispatcher": "4.4.19",
"symfony/event-dispatcher-contracts": "1.1.9",
"symfony/polyfill-intl-normalizer": "^1.20",
"symfony/polyfill-intl-grapheme": "^1.20",
"symfony/polyfill-intl-normalizer": "^1.20",
"symfony/process": "4.4.19",
"symfony/routing": "4.4.19",
"symfony/translation": "4.4.19",
"web-auth/webauthn-lib": "^3.1",
"php-ds/php-ds": "^1.3",
"opis/closure": "^3.6"
"web-auth/webauthn-lib": "^3.1"
},
"scripts": {
"vendor": "composer install --no-dev && git clean -xdf && composer dump-autoload"
Expand Down
52 changes: 51 additions & 1 deletion composer.lock

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

32 changes: 32 additions & 0 deletions 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,15 @@ public function getApcuPrefix()
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);

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

/**
Expand All @@ -308,6 +326,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 +389,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
Loading