diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 619d3b32f..cbf3b0aba 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -858,9 +858,9 @@ CLASSMAPAUTHORITATIVE; } if ($this->apcu) { - $apcuPrefix = is_string($this->apcu) ? $this->apcu : substr(base64_encode(md5(uniqid('', true), true)), 0, -3); + $apcuPrefix = var_export(is_string($this->apcu) ? $this->apcu : substr(base64_encode(md5(uniqid('', true), true)), 0, -3), true); $file .= <<setApcuPrefix('$apcuPrefix'); + \$loader->setApcuPrefix($apcuPrefix); APCU; } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index fbc2ba86b..0cdc58dda 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -853,7 +853,7 @@ EOF; file_put_contents($this->vendorDir.'/c/c/foo/ClassMapBaz.php', 'generator->setClassMapAuthoritative(true); - $this->generator->setApcu('customPrefix'); + $this->generator->setApcu('custom\'Prefix'); $this->generator->dump($this->config, $this->repository, $package, $this->im, 'composer', false, '_7'); $this->assertFileExists($this->vendorDir.'/composer/autoload_classmap.php', "ClassMap file needs to be generated."); @@ -869,7 +869,7 @@ EOF; $this->assertAutoloadFiles('classmap8', $this->vendorDir.'/composer', 'classmap'); $this->assertStringContainsString('$loader->setClassMapAuthoritative(true);', file_get_contents($this->vendorDir.'/composer/autoload_real.php')); - $this->assertStringContainsString('$loader->setApcuPrefix(\'customPrefix\');', file_get_contents($this->vendorDir.'/composer/autoload_real.php')); + $this->assertStringContainsString('$loader->setApcuPrefix(\'custom\\\'Prefix\');', file_get_contents($this->vendorDir.'/composer/autoload_real.php')); } public function testFilesAutoloadGeneration()