Skip to content

Commit

Permalink
upd request
Browse files Browse the repository at this point in the history
  • Loading branch information
phphleb committed Feb 13, 2024
1 parent fa3ccee commit 6bc1516
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 23 deletions.
13 changes: 7 additions & 6 deletions Reference/RequestInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,15 @@ public function input(): array;
public function rawData(): array;

/**
* Returns the converted request body, for example if it is in JSON format.
* Returns the request body converted to an array, for example if it is in JSON format.
* (!) The data is returned in its original form,
* so you need to check it for vulnerabilities yourself.
*
* Возвращает преобразованное тело запроса, например, если оно в формате JSON.
*
* @param bool $cleared - clean data.
* - производить очистку данных.
* Возвращает преобразованное в массив тело запроса, например, если оно в формате JSON.
* (!) Данные возвращаются в исходном виде, поэтому нужно
* самостоятельно проверить их на уязвимости.
*/
public function getParsedBody(bool $cleared = true): null|array;
public function getParsedBody(): array;

/**
* Returns an object containing the URL data from the request.
Expand Down
12 changes: 3 additions & 9 deletions Reference/RequestReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,7 @@ public function data(): array
#[\Override]
public function input(): array
{
if (\array_key_exists('input', self::$cachedParams)) {
return self::$cachedParams['input'];
}

$data = \hl_clear_tags((array)self::getParsedBody());

return self::$cachedParams['input'] = $data;
return DynamicParams::getRequest()->getParsedBody(cleared: true) ?? [];
}

/** @inheritDoc */
Expand All @@ -116,9 +110,9 @@ public function rawData(): array

/** @inheritDoc */
#[\Override]
public function getParsedBody(bool $cleared = true): null|array
public function getParsedBody(): array
{
return DynamicParams::getRequest()->getParsedBody($cleared);
return DynamicParams::getRequest()->getParsedBody(cleared: false) ?? [];
}

/** @inheritDoc */
Expand Down
17 changes: 9 additions & 8 deletions Static/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,21 @@ public static function rawData(): array
}

/**
* Returns the converted request body, for example if it is in JSON format.
*
* Возвращает преобразованное тело запроса, например, если оно в формате JSON.
* Returns the request body converted to an array, for example if it is in JSON format.
* (!) The data is returned in its original form,
* so you need to check it for vulnerabilities yourself.
*
* @param bool $cleared - clean data.
* - производить очистку данных.
* Возвращает преобразованное в массив тело запроса, например, если оно в формате JSON.
* (!) Данные возвращаются в исходном виде, поэтому нужно
* самостоятельно проверить их на уязвимости.
*/
public static function getParsedBody(bool $cleared = true): null|array
public static function getParsedBody(): array
{
if (self::$replace) {
return self::$replace->getParsedBody($cleared);
return self::$replace->getParsedBody();
}

return BaseContainer::instance()->get(RequestInterface::class)->getParsedBody($cleared);
return BaseContainer::instance()->get(RequestInterface::class)->getParsedBody();
}

/**
Expand Down

0 comments on commit 6bc1516

Please sign in to comment.