@@ -159,12 +159,12 @@ public function setPlatformRequirementFilter(PlatformRequirementFilterInterface
159159 /**
160160 * @param string $targetDir
161161 * @param bool $scanPsrPackages
162- * @param string $suffix
162+ * @param string|null $suffix
163163 * @return int
164164 * @throws \Seld\JsonLint\ParsingException
165165 * @throws \RuntimeException
166166 */
167- public function dump (Config $ config , InstalledRepositoryInterface $ localRepo , RootPackageInterface $ rootPackage , InstallationManager $ installationManager , $ targetDir , $ scanPsrPackages = false , $ suffix = '' )
167+ public function dump (Config $ config , InstalledRepositoryInterface $ localRepo , RootPackageInterface $ rootPackage , InstallationManager $ installationManager , $ targetDir , $ scanPsrPackages = false , $ suffix = null )
168168 {
169169 if ($ this ->classMapAuthoritative ) {
170170 // Force scanPsrPackages when classmap is authoritative
@@ -374,16 +374,23 @@ public static function autoload(\$class)
374374 }
375375 $ classmapFile .= "); \n" ;
376376
377- if (!$ suffix ) {
378- if (!$ config ->get ('autoloader-suffix ' ) && Filesystem::isReadable ($ vendorPath .'/autoload.php ' )) {
377+ if ('' === $ suffix ) {
378+ $ suffix = null ;
379+ }
380+ if (null === $ suffix ) {
381+ $ suffix = $ config ->get ('autoloader-suffix ' );
382+
383+ // carry over existing autoload.php's suffix if possible and none is configured
384+ if (null === $ suffix && Filesystem::isReadable ($ vendorPath .'/autoload.php ' )) {
379385 $ content = file_get_contents ($ vendorPath .'/autoload.php ' );
380386 if (Preg::isMatch ('{ComposerAutoloaderInit([^:\s]+)::} ' , $ content , $ match )) {
381387 $ suffix = $ match [1 ];
382388 }
383389 }
384390
385- if (!$ suffix ) {
386- $ suffix = $ config ->get ('autoloader-suffix ' ) ?: md5 (uniqid ('' , true ));
391+ // generate one if we still haven't got a suffix
392+ if (null === $ suffix ) {
393+ $ suffix = md5 (uniqid ('' , true ));
387394 }
388395 }
389396
0 commit comments