diff options
| author | fox <fox@fakecake.org> | 2026-06-26 17:47:01 +0300 |
|---|---|---|
| committer | fox <fox@fakecake.org> | 2026-06-26 17:47:01 +0300 |
| commit | 04524943b6b6b1ed314df320630fa3eed1783b2c (patch) | |
| tree | 410d76eb9004c783545ee80129c69096b2040752 /classes/Request.php | |
| parent | a17d0f6277cd169f237ce8bb5cfc705c5582ed66 (diff) | |
| parent | 96299844c2e630a8ea27d86d53aadf98216b9ab8 (diff) | |
| download | the-epube-04524943b6b6b1ed314df320630fa3eed1783b2c.tar.gz the-epube-04524943b6b6b1ed314df320630fa3eed1783b2c.tar.xz | |
Merge branch 'dev' into 'master'
drop clean() See merge request git/the-epube!69
Diffstat (limited to 'classes/Request.php')
| -rw-r--r-- | classes/Request.php | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/classes/Request.php b/classes/Request.php index 3a8e696..cd7cbe8 100644 --- a/classes/Request.php +++ b/classes/Request.php @@ -3,7 +3,7 @@ * Typed parameter extraction wrapper around PHP superglobals. * * Provides clean, type-safe access to request parameters, replacing the - * repetitive clean($_REQUEST['key'] ?? default) pattern throughout handlers. + * repetitive $_REQUEST['key'] ?? default pattern throughout handlers. * * Usage: * $request = new Request(); @@ -131,11 +131,11 @@ class Request { if ($value === null) { return $default; } - return clean((string)$value); + return trim((string)$value); } /** - * Get a sanitized integer value. + * Get an integer value. * * @param string $key * @param int $default @@ -146,11 +146,11 @@ class Request { if ($value === null) { return $default; } - return (int) clean((string)$value); + return (int) $value; } /** - * Get a sanitized float value. + * Get a float value. * * @param string $key * @param float $default @@ -161,7 +161,7 @@ class Request { if ($value === null) { return $default; } - return (float) clean((string)$value); + return (float) $value; } /** @@ -186,7 +186,7 @@ class Request { * Get a sanitized array value. * * If the value is a comma-separated string, it will be split into an array. - * Each element is trimmed and HTML tags are stripped. + * Each element is trimmed. * * @param string $key * @param array<int|string, mixed> $default @@ -199,16 +199,16 @@ class Request { } if (is_array($value)) { - return clean($value); + return array_map(static fn($v) => is_string($v) ? trim((string)$v) : $v, $value); } // Handle comma-separated string values - $cleaned = clean((string)$value); - if ($cleaned === '') { + $trimmed = trim((string)$value); + if ($trimmed === '') { return []; } - return array_map('trim', explode(',', $cleaned)); + return array_map('trim', explode(',', $trimmed)); } /** @@ -349,7 +349,9 @@ class Request { * @return bool */ public static function _to_bool(mixed $value): bool { - $value = clean($value); + if (is_string($value)) { + $value = trim($value); + } if (is_bool($value)) { return $value; |
