From 274175bf42ca048cc89dee3cfc6c28230a283c8d Mon Sep 17 00:00:00 2001 From: Jaapio Date: Wed, 4 Sep 2024 20:06:12 +0200 Subject: [PATCH] [BUGFIX] Allow escaped version symfony is trying to normalize the xml input using some logic. However in our case we want to fetch the raw value for version. But this is not possible. therefor an escape system is added by adding `'`. --- .../DependencyInjection/GuidesExtension.php | 24 ++++++++++++++++++- .../config-project/expected/index.html | 2 +- .../config-project/input/guides.xml | 2 +- .../version-from-guides-xml/input/guides.xml | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/packages/guides/src/DependencyInjection/GuidesExtension.php b/packages/guides/src/DependencyInjection/GuidesExtension.php index 89904c0d4..6db4af678 100644 --- a/packages/guides/src/DependencyInjection/GuidesExtension.php +++ b/packages/guides/src/DependencyInjection/GuidesExtension.php @@ -42,6 +42,7 @@ use function is_int; use function is_string; use function pathinfo; +use function trim; use function var_export; final class GuidesExtension extends Extension implements CompilerPassInterface, ConfigurationInterface, PrependExtensionInterface @@ -68,12 +69,33 @@ static function ($value) { return var_export($value, true); } + if (is_string($value)) { + return trim($value, "'"); + } + + return $value; + }, + ) + ->end() + ->end() + ->scalarNode('release') + ->beforeNormalization() + ->always( + // We need to revert the phpize call in XmlUtils. Version is always a string! + static function ($value) { + if (!is_int($value) && !is_string($value)) { + return var_export($value, true); + } + + if (is_string($value)) { + return trim($value, "'"); + } + return $value; }, ) ->end() ->end() - ->scalarNode('release')->end() ->scalarNode('copyright')->end() ->end() ->end() diff --git a/tests/Integration/tests/configuration/config-project/expected/index.html b/tests/Integration/tests/configuration/config-project/expected/index.html index a1b6deb4b..a6616fe41 100644 --- a/tests/Integration/tests/configuration/config-project/expected/index.html +++ b/tests/Integration/tests/configuration/config-project/expected/index.html @@ -10,7 +10,7 @@

Document Title

Title
version:
-
12.4
+
12.4.0
release:
12.4.9-dev
diff --git a/tests/Integration/tests/configuration/config-project/input/guides.xml b/tests/Integration/tests/configuration/config-project/input/guides.xml index 08662d48c..f6cab3fc2 100644 --- a/tests/Integration/tests/configuration/config-project/input/guides.xml +++ b/tests/Integration/tests/configuration/config-project/input/guides.xml @@ -5,7 +5,7 @@ > diff --git a/tests/Integration/tests/meta/version-from-guides-xml/input/guides.xml b/tests/Integration/tests/meta/version-from-guides-xml/input/guides.xml index 608bf0953..66a4a6264 100644 --- a/tests/Integration/tests/meta/version-from-guides-xml/input/guides.xml +++ b/tests/Integration/tests/meta/version-from-guides-xml/input/guides.xml @@ -6,7 +6,7 @@ >