mirror of
https://github.com/composer/composer
synced 2025-05-09 16:42:57 +00:00
ComposerAutoloaderInitXXX::getLoader behaves like a ClassLoader singleton
Calling ComposerAutoloaderInit::getLoader twice when a package requires a .php file containing functions, lead to the functions to be declared twice, and cause an error. In my case, using behat + symfony2extension + assetic, the error that occured: PHP Fatal error: Cannot redeclare assetic_init() (previously declared in vendor/kriswallsmith/assetic/src/functions.php:20) in /vendor/kriswallsmith/assetic/src/functions.php on line 26 Fatal error: Cannot redeclare assetic_init() (previously declared in /vendor/kriswallsmith/assetic/src/functions.php:20) in /vendor/kriswallsmith/assetic/src/functions.php on line 26
This commit is contained in:
parent
02917bd892
commit
fd58c24a9f
4 changed files with 28 additions and 4 deletions
|
@ -372,9 +372,15 @@ require __DIR__ . '/ClassLoader.php';
|
|||
|
||||
class ComposerAutoloaderInit$suffix
|
||||
{
|
||||
private static \$loader;
|
||||
|
||||
public static function getLoader()
|
||||
{
|
||||
\$loader = new \\Composer\\Autoload\\ClassLoader();
|
||||
if (null !== static::\$loader) {
|
||||
return static::\$loader;
|
||||
}
|
||||
|
||||
static::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader();
|
||||
\$vendorDir = $vendorPathCode;
|
||||
\$baseDir = $appBaseDirCode;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue