Skip to content

Commit

Permalink
Merge pull request #302 from bowphp/feat/http-uploaded
Browse files Browse the repository at this point in the history
fix: session and e helpers
  • Loading branch information
papac authored Dec 18, 2024
2 parents 9391ffa + 61c3044 commit 9cce14e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Support/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,18 +794,19 @@ function raw_email(string $to, string $subject, string $message, array $headers
/**
* Session help
*
* @param string $value
* @param mixed $default
* @param array|string $value
* @param mixed $default
* @return mixed
*/
function session(string $value = null, mixed $default = null): mixed
function session(array|string $value = null, mixed $default = null): mixed
{
if ($value == null) {
return Session::getInstance();
}

if (!is_array($value)) {
return Session::getInstance()->get($value, $default);
$key = $value;
return Session::getInstance()->get($key, $default);
}

foreach ($value as $key => $item) {
Expand Down Expand Up @@ -927,12 +928,12 @@ function route(string $name, bool|array $data = [], bool $absolute = false)
/**
* Escape the HTML tags in the chain.
*
* @param string $value
* @param ?string $value
* @return string
*/
function e(string $value): string
function e(?string $value = null): string
{
return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
return htmlspecialchars($value ?? '', ENT_QUOTES, 'UTF-8');
}
}

Expand Down

0 comments on commit 9cce14e

Please sign in to comment.