Files
FreshRSS/lib/Minz/Helper.php
Alexandre Alapetite 5b28a35003 Pass PHPStan level 9 (#6544)
* More PHPStan

* More, passing

* 4 more files

* Update to PHPStan 1.11.4
Needed for fixed bug: Consider numeric-string types after string concat
https://github.com/phpstan/phpstan/releases/tag/1.11.4

* Pass PHPStan level 9
Start tracking booleansInConditions

* Fix mark as read

* Fix doctype

* ctype_digit
2024-06-09 20:32:12 +02:00

37 lines
806 B
PHP

<?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
*
* @param mixed $var
* @return mixed
*/
public static function htmlspecialchars_utf8($var) {
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;
}
}
}