Skip to content

Commit a8c323c

Browse files
committed
move type cast from Escaper to RouteParamsResolver and add type hints
1 parent 94e140f commit a8c323c

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

lib/internal/Magento/Framework/Escaper.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ public function escapeUrl($string)
289289
* @return string
290290
* @since 101.0.0
291291
*/
292-
public function encodeUrlParam($string)
292+
public function encodeUrlParam(string $string): string
293293
{
294-
return $this->getEscaper()->escapeUrl((string)$string);
294+
return $this->getEscaper()->escapeUrl($string);
295295
}
296296

297297
/**
@@ -328,9 +328,9 @@ function ($matches) {
328328
* @return string
329329
* @since 101.0.0
330330
*/
331-
public function escapeCss($string)
331+
public function escapeCss(string $string): string
332332
{
333-
return $this->getEscaper()->escapeCss((string)$string);
333+
return $this->getEscaper()->escapeCss($string);
334334
}
335335

336336
/**

lib/internal/Magento/Framework/Test/Unit/EscaperTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,6 @@ public function testEscapeCss($data, string $expected): void
384384
public function escapeCssDataProvider(): array
385385
{
386386
return [
387-
[
388-
'data' => 1,
389-
'expected' => '1',
390-
],
391387
[
392388
'data' => '*%string{foo}%::',
393389
'expected' => '\2A \25 string\7B foo\7D \25 \3A \3A ',
@@ -422,14 +418,6 @@ public function encodeUrlParamDataProvider(): array
422418
[
423419
'data' => "example string",
424420
'expected' => "example%20string",
425-
],
426-
[
427-
'data' => 1,
428-
'expected' => "1",
429-
],
430-
[
431-
'data' => null,
432-
'expected' => "",
433421
]
434422
];
435423
}

lib/internal/Magento/Framework/Url/RouteParamsResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function setRouteParams(array $data, $unsetOldParams = true)
112112
} else {
113113
$this->setRouteParam(
114114
$this->getEscaper()->encodeUrlParam($key),
115-
$this->getEscaper()->encodeUrlParam($value)
115+
$this->getEscaper()->encodeUrlParam((string)$value)
116116
);
117117
}
118118
}

0 commit comments

Comments
 (0)