1
0
Fork 0

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
pull/1106/head
Adrien Brault 2012-09-14 11:21:34 +02:00
parent 02917bd892
commit fd58c24a9f
4 changed files with 28 additions and 4 deletions

View File

@ -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;

View File

@ -6,9 +6,15 @@ require __DIR__ . '/ClassLoader.php';
class ComposerAutoloaderInitFilesAutoloadOrder
{
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 = dirname(__DIR__);
$baseDir = dirname($vendorDir);

View File

@ -6,9 +6,15 @@ require __DIR__ . '/ClassLoader.php';
class ComposerAutoloaderInitFilesAutoload
{
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 = dirname(__DIR__);
$baseDir = dirname($vendorDir);

View File

@ -6,9 +6,15 @@ require __DIR__ . '/ClassLoader.php';
class ComposerAutoloaderInitTargetDir
{
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 = dirname(__DIR__);
$baseDir = dirname($vendorDir);