blob: 91c1bdc00760627ee793a6de9a7ed143db180cf9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
declare(strict_types=1);
/**
* MINZ - Copyright 2011 Marien Fressinaud
* Sous licence AGPL3 <http://www.gnu.org/licenses/>
*/
/**
* The Minz_Helper class contains some misc. help functions
*/
final class Minz_Helper {
/**
* Wrapper for htmlspecialchars.
* Force UTF-8 value and can be used on array too.
*
* @phpstan-template T of mixed
* @phpstan-param T $var
* @phpstan-return T
*/
public static function htmlspecialchars_utf8(mixed $var): mixed {
if (is_array($var)) {
// @phpstan-ignore argument.type, return.type
return array_map([self::class, 'htmlspecialchars_utf8'], $var);
} elseif (is_string($var)) {
// @phpstan-ignore return.type
return htmlspecialchars($var, ENT_COMPAT, 'UTF-8');
} else {
return $var;
}
}
}
|