Skip to content

Commit 2ca348a

Browse files
milodg
authored andcommitted
Helpers: htmlspecialchars() strict type fix (#229)
1 parent 9270dac commit 2ca348a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Forms/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public static function createInputList(array $items, array $inputAttrs = null, a
152152
$res .= ($res === '' && $wrapperEnd === '' ? '' : $wrapper)
153153
. $labelTag . $label->attributes() . '>'
154154
. $inputTag . $input->attributes() . (Html::$xhtml ? ' />' : '>')
155-
. ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars($caption, ENT_NOQUOTES, 'UTF-8'))
155+
. ($caption instanceof Nette\Utils\IHtmlString ? $caption : htmlspecialchars((string) $caption, ENT_NOQUOTES, 'UTF-8'))
156156
. '</label>'
157157
. $wrapperEnd;
158158
}

tests/Forms/Helpers.createInputList.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ test(function () {
2525
Helpers::createInputList(['a'])
2626
);
2727

28+
Assert::same(
29+
'<label><input value="0">1</label>',
30+
Helpers::createInputList([1])
31+
);
32+
2833
Assert::same(
2934
'<label><input value="a">First</label><label><input value="b">Second</label>',
3035
Helpers::createInputList(

0 commit comments

Comments
 (0)