Skip to content

Commit 031e30b

Browse files
committed
[BUGFIX] Make InstalledVersions work again
When including multiple autoload.php files during the same runtime, Composer InstalledVersions relies on the registered autoloaders to be able to resolve all available packages. If class alias loader is now calling ->unregister API, the static registry of available classes is removed, which does not reflect the state when class alias loader is registered. Therefore, we now call spl_autoload_unregister ourselves instead of using the API, because the classes will be loadable, just not directly but proxied through class alias loader
1 parent f80021a commit 031e30b

2 files changed

Lines changed: 1 addition & 10 deletions

File tree

src/ClassAliasLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public function getClassNameForAlias($aliasOrClassName)
9898
*/
9999
public function register($prepend = false)
100100
{
101-
$this->composerClassLoader->unregister();
101+
spl_autoload_unregister(array($this->composerClassLoader, 'loadClass'));
102102
spl_autoload_register(array($this, 'loadClassWithAlias'), true, $prepend);
103103
}
104104

tests/Unit/ClassAliasLoaderTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ public function tearMeDown()
4646
$this->subject->unregister();
4747
}
4848

49-
/**
50-
* @test
51-
*/
52-
public function registeringTheAliasLoaderUnregistersComposerClassLoader()
53-
{
54-
$this->composerClassLoaderMock->expects($this->once())->method('unregister');
55-
$this->subject->register();
56-
}
57-
5849
/**
5950
* @test
6051
*/

0 commit comments

Comments
 (0)