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.
This commit is contained in:
stephan.kasdorf
2025-07-07 15:14:38 +02:00
parent be9d217732
commit 523fb822ef

View File

@@ -168,18 +168,23 @@ class Controller extends View
/** /**
* @param string $param * @param string $param
* @param bool $params * @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!="") if($param!="")
{ {
return $_REQUEST[$param]; if(array_key_exists($param, $_REQUEST))
{
return $_REQUEST[$param];
}
return null;
} }
elseif($params) elseif($params)
{ {
return $_REQUEST; return $_REQUEST;
} }
return null;
} }
/** /**