From 49431b72cd6b41b3bf6cd1cc83181fa227f30de4 Mon Sep 17 00:00:00 2001 From: Sebastian Schreiber Date: Tue, 11 May 2021 15:09:17 +0200 Subject: [PATCH] [TASK] Do not prefix class ComposerJson Resolves: rectorphp/rector#6405 --- build/target-repository/bootstrap.php | 8 ++++++++ scoper.php | 9 +++++++++ utils/compiler/src/PhpScoper/StaticEasyPrefixer.php | 2 ++ 3 files changed, 19 insertions(+) diff --git a/build/target-repository/bootstrap.php b/build/target-repository/bootstrap.php index daf0ed94c96..0e2ca34994c 100644 --- a/build/target-repository/bootstrap.php +++ b/build/target-repository/bootstrap.php @@ -28,4 +28,12 @@ require $filePath; } } + + // aliased by php-scoper, that's why its missing + if ($class === 'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson') { + $filePath = __DIR__ . '/vendor/symplify/composer-json-manipulator/src/ValueObject/ComposerJson.php'; + if (file_exists($filePath)) { + require $filePath; + } + } }); diff --git a/scoper.php b/scoper.php index a333387d62d..9aec00865dc 100644 --- a/scoper.php +++ b/scoper.php @@ -74,6 +74,15 @@ function (string $filePath, string $prefix, string $content): string { ); }, + // unprefixed ComposerJson + function (string $filePath, string $prefix, string $content): string { + return Strings::replace( + $content, ' + #' . $prefix . '\\\\Symplify\\\\ComposerJsonManipulator\\\\ValueObject\\\\ComposerJson#', + 'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson' + ); + }, + // get version for prefixed version function (string $filePath, string $prefix, string $content): string { if (! Strings::endsWith($filePath, 'src/Configuration/Configuration.php')) { diff --git a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php index c60eef9acc3..60b549fe77d 100644 --- a/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php +++ b/utils/compiler/src/PhpScoper/StaticEasyPrefixer.php @@ -16,6 +16,8 @@ final class StaticEasyPrefixer 'Doctrine\Inflector\Inflector', // for SmartFileInfo 'Symplify\SmartFileSystem\SmartFileInfo', + // for ComposerJson because it is part of the public API. I.e. ComposerRectorInterface + 'Symplify\ComposerJsonManipulator\ValueObject\ComposerJson' ]; /**