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:
@@ -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!="")
|
||||
{
|
||||
if(array_key_exists($param, $_REQUEST))
|
||||
{
|
||||
return $_REQUEST[$param];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
elseif($params)
|
||||
{
|
||||
return $_REQUEST;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user