From 523fb822efc7b2119c39bdc652a385d686220e3c Mon Sep 17 00:00:00 2001 From: "stephan.kasdorf" Date: Mon, 7 Jul 2025 15:14:38 +0200 Subject: [PATCH] Add null return type and handling in getRequest method The `getRequest` method in `controller.php` now includes a nullable return type and additional checks for array key existence in the `$_REQUEST` array. This update ensures robust error handling and prevents undefined index notices. --- core/c/controller.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/c/controller.php b/core/c/controller.php index bd64746..6a501ac 100755 --- a/core/c/controller.php +++ b/core/c/controller.php @@ -168,18 +168,23 @@ class Controller extends View /** * @param string $param * @param bool $params - * @return string|array + * @return string|array|null */ - public function getRequest( string $param, bool $params = false ) + public function getRequest( string $param, bool $params = false ):string|array|null { if($param!="") { - return $_REQUEST[$param]; + if(array_key_exists($param, $_REQUEST)) + { + return $_REQUEST[$param]; + } + return null; } elseif($params) { return $_REQUEST; } + return null; } /**