From d2a1c1281e7defaf020cd54446c11f2c9fb8e031 Mon Sep 17 00:00:00 2001 From: mambax7 Date: Sun, 1 Oct 2023 23:21:11 -0400 Subject: [PATCH] PHP 8.0: @ Error Suppression operator does not silent fatal errors --- src/FilterInput.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/FilterInput.php b/src/FilterInput.php index 7770d78..d7ce9ea 100644 --- a/src/FilterInput.php +++ b/src/FilterInput.php @@ -214,14 +214,14 @@ public function cleanVar($source, $type = 'string') case 'INTEGER': // Only use the first integer value preg_match('/-?\d+/', (string) $source, $matches); - $result = @ (int) $matches[0]; + $result = isset($matches[0]) ? (int) $matches[0] : 0; break; case 'FLOAT': case 'DOUBLE': // Only use the first floating point value preg_match('/-?\d+(\.\d+)?/', (string) $source, $matches); - $result = @ (float) $matches[0]; + $result = isset($matches[0]) ? (float) $matches[0] : 0; break; case 'BOOL': @@ -259,7 +259,7 @@ public function cleanVar($source, $type = 'string') $source = trim((string) $source); $pattern = '/^([-_\.\/A-Z0-9=&%?~]+)(.*)$/i'; preg_match($pattern, $source, $matches); - $result = @ (string) $matches[1]; + $result = isset($matches[1]) ? (string) $matches[1] : ''; break; case 'USERNAME':