Skip to content

Commit 5f1aff2

Browse files
authored
Merge pull request #1069 from phpDocumentor/backport/1.x/pr-1063
[BUGFIX] Allow escaped version
2 parents fdb02c2 + 625e5a8 commit 5f1aff2

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

packages/guides/src/DependencyInjection/GuidesExtension.php

+23-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
use function is_int;
4343
use function is_string;
4444
use function pathinfo;
45+
use function trim;
4546
use function var_export;
4647

4748
final class GuidesExtension extends Extension implements CompilerPassInterface, ConfigurationInterface, PrependExtensionInterface
@@ -68,12 +69,33 @@ static function ($value) {
6869
return var_export($value, true);
6970
}
7071

72+
if (is_string($value)) {
73+
return trim($value, "'");
74+
}
75+
76+
return $value;
77+
},
78+
)
79+
->end()
80+
->end()
81+
->scalarNode('release')
82+
->beforeNormalization()
83+
->always(
84+
// We need to revert the phpize call in XmlUtils. Version is always a string!
85+
static function ($value) {
86+
if (!is_int($value) && !is_string($value)) {
87+
return var_export($value, true);
88+
}
89+
90+
if (is_string($value)) {
91+
return trim($value, "'");
92+
}
93+
7194
return $value;
7295
},
7396
)
7497
->end()
7598
->end()
76-
->scalarNode('release')->end()
7799
->scalarNode('copyright')->end()
78100
->end()
79101
->end()

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

+1-1
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

+1-1
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

+1-1
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)