Skip to content

Commit 95a4e82

Browse files
committed
[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 `'`.
1 parent 075539c commit 95a4e82

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

packages/guides/src/DependencyInjection/GuidesExtension.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function getConfigTreeBuilder(): TreeBuilder
5959
->arrayNode('project')
6060
->children()
6161
->scalarNode('title')->end()
62-
->scalarNode('version')
62+
->node('version', 'scalar')
6363
->beforeNormalization()
6464
->always(
6565
// We need to revert the phpize call in XmlUtils. Version is always a string!
@@ -68,12 +68,33 @@ static function ($value) {
6868
return var_export($value, true);
6969
}
7070

71+
if (is_string($value)) {
72+
return trim($value, "'");
73+
}
74+
75+
return $value;
76+
},
77+
)
78+
->end()
79+
->end()
80+
->node('release', 'scalar')
81+
->beforeNormalization()
82+
->always(
83+
// We need to revert the phpize call in XmlUtils. Version is always a string!
84+
static function ($value) {
85+
if (!is_int($value) && !is_string($value)) {
86+
return var_export($value, true);
87+
}
88+
89+
if (is_string($value)) {
90+
return trim($value, "'");
91+
}
92+
7193
return $value;
7294
},
7395
)
7496
->end()
7597
->end()
76-
->scalarNode('release')->end()
7798
->scalarNode('copyright')->end()
7899
->end()
79100
->end()

tests/Integration/tests/configuration/config-project/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h1>Document Title</h1>
1010
<dd>Title</dd>
1111
<dt>version:</dt>
1212

13-
<dd>12.4</dd>
13+
<dd>12.4.0</dd>
1414
<dt>release:</dt>
1515

1616
<dd>12.4.9-dev</dd>

tests/Integration/tests/configuration/config-project/input/guides.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
>
66
<project
77
title="Title"
8-
version="12.4"
8+
version="12.4.0"
99
release="12.4.9-dev"
1010
copyright="since 1998 phpDocumentor Team and Contributors"
1111
/>

tests/Integration/tests/meta/version-from-guides-xml/input/guides.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
>
77
<project
88
title="Render guides"
9-
version="3.0"
9+
version="'3.0'"
1010
release="3.0.0"
1111
/>
1212
</guides>

0 commit comments

Comments
 (0)