From d6c46f2091a0310d37d10940633db585d4ab3e07 Mon Sep 17 00:00:00 2001 From: Stan Lemon Date: Sun, 22 Dec 2013 22:01:42 -0500 Subject: [PATCH 1/2] Allow the autoloader suffix to be configured from a project's composer.json --- res/composer-schema.json | 4 ++++ src/Composer/Autoload/AutoloadGenerator.php | 2 +- src/Composer/Config.php | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/res/composer-schema.json b/res/composer-schema.json index 7b52d7733..e3599485f 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -176,6 +176,10 @@ "type": ["string", "boolean"], "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"." }, + "autoloader-suffix": { + "type": ["string", "boolean"], + "description": "Optional string to be used as a suffix to the autoloader generator. When null a random one will be generated." + }, "prepend-autoloader": { "type": "boolean", "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true." diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 1252371d6..7b019e012 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -169,7 +169,7 @@ EOF; $classmapFile .= ");\n"; if (!$suffix) { - $suffix = md5(uniqid('', true)); + $suffix = $config->get('autoloader-suffix') ? $config->get('autoloader-suffix') : md5(uniqid('', true)); } file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile); diff --git a/src/Composer/Config.php b/src/Composer/Config.php index c893091c6..68a3410f3 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -35,6 +35,7 @@ class Config 'cache-files-ttl' => null, // fallback to cache-ttl 'cache-files-maxsize' => '300MiB', 'discard-changes' => false, + 'autoload-suffix' => false, 'prepend-autoloader' => true, 'github-domains' => array('github.com'), ); From 5fd3223aecf56852f06e36cd5d23cce4d9bfc970 Mon Sep 17 00:00:00 2001 From: Stan Lemon Date: Mon, 23 Dec 2013 11:27:33 -0500 Subject: [PATCH 2/2] Updates per @stof --- res/composer-schema.json | 2 +- src/Composer/Autoload/AutoloadGenerator.php | 2 +- src/Composer/Config.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/res/composer-schema.json b/res/composer-schema.json index e3599485f..180656c1d 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -177,7 +177,7 @@ "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"." }, "autoloader-suffix": { - "type": ["string", "boolean"], + "type": "string", "description": "Optional string to be used as a suffix to the autoloader generator. When null a random one will be generated." }, "prepend-autoloader": { diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 7b019e012..b26fb5831 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -169,7 +169,7 @@ EOF; $classmapFile .= ");\n"; if (!$suffix) { - $suffix = $config->get('autoloader-suffix') ? $config->get('autoloader-suffix') : md5(uniqid('', true)); + $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true)); } file_put_contents($targetDir.'/autoload_namespaces.php', $namespacesFile); diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 68a3410f3..311c7de85 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -35,7 +35,7 @@ class Config 'cache-files-ttl' => null, // fallback to cache-ttl 'cache-files-maxsize' => '300MiB', 'discard-changes' => false, - 'autoload-suffix' => false, + 'autoload-suffix' => null, 'prepend-autoloader' => true, 'github-domains' => array('github.com'), );