Skip to content

Commit ad68e68

Browse files
authored
Remove unnecessary functionality from escapeOrCleanHtml (#4320)
1 parent e5a31f1 commit ad68e68

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

Diff for: module/VuFind/src/VuFind/View/Helper/Root/EscapeOrCleanHtml.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,20 @@ public function __construct(protected Escaper $escaper, protected CleanHtml $cle
6666
/**
6767
* Invoke this helper: escape a value
6868
*
69-
* @param ?string $value Value to escape
70-
* @param ?string $dataContext Data context (for fields that allow sanitized HTML)
71-
* @param ?bool $allowHtml Whether to allow sanitized HTML if passed a PropertyString
72-
* @param string $renderingContext Rendering context for cleaning HTML
69+
* @param string|PropertyStringInterface $value Value to escape
70+
* @param ?string $dataContext Data context (for fields that allow sanitized HTML)
71+
* @param ?bool $allowHtml Whether to allow sanitized HTML if passed a
72+
* PropertyString
73+
* @param string $renderingContext Rendering context for cleaning HTML
7374
*
74-
* @return mixed Given a string, returns an escaped string, otherwise returns self
75+
* @return mixed Returns an escaped or HTML-safe string
7576
*/
7677
public function __invoke(
77-
$value = null,
78+
string|PropertyStringInterface $value,
7879
?string $dataContext = null,
7980
?bool $allowHtml = null,
8081
string $renderingContext = 'default'
8182
) {
82-
if (null === $value) {
83-
return $this;
84-
}
8583
if ($value instanceof PropertyStringInterface) {
8684
if (
8785
($allowHtml ?? ($dataContext && ($this->htmlContexts[$dataContext] ?? false)))

Diff for: module/VuFind/tests/unit-tests/src/VuFindTest/View/Helper/Root/EscapeOrCleanHtmlTest.php

-13
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,4 @@ public function testEscapeOrCleanHtml(
110110
$result = $escapeOrCleanHtml($input, $dataContext, $allowHtml, $renderingContext);
111111
$this->assertEquals($expected, $result);
112112
}
113-
114-
/**
115-
* Test invoking without parameters
116-
*
117-
* @return void
118-
*/
119-
public function testInvokeWithoutParameters(): void
120-
{
121-
$escaper = new Escaper(false);
122-
$cleanHtml = $this->createCleanHtmlHelper();
123-
$escapeOrCleanHtml = new EscapeOrCleanHtml($escaper, $cleanHtml, []);
124-
$this->assertEquals($escapeOrCleanHtml, $escapeOrCleanHtml());
125-
}
126113
}

0 commit comments

Comments
 (0)