Skip to content

Commit

Permalink
Merge 17f2de5 into 012d199
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton committed Jul 14, 2021
2 parents 012d199 + 17f2de5 commit 4f7b437
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 0 additions & 2 deletions src/Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ protected function process(): Data
*
* @return void
* @throws ControllerException
* @throws ReflectionException
*/
protected function findFile(): void
{
Expand All @@ -274,7 +273,6 @@ protected function findFile(): void
*
* @return string
* @throws ControllerException
* @throws ReflectionException
*/
protected function getFile(): string
{
Expand Down
27 changes: 14 additions & 13 deletions src/Response/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@

namespace Bluz\Response;

use Bluz\Http\Exception\NotAcceptableException;
use Bluz\Common\Options;
use Bluz\Controller\Controller;
use Bluz\Http\StatusCode;
use Bluz\Layout\Layout;
use Bluz\Proxy\Messages;
use DateTime;
use InvalidArgumentException;
use Laminas\Diactoros\Response\EmptyResponse;
use Laminas\Diactoros\Response\HtmlResponse;
use Laminas\Diactoros\Response\JsonResponse;
Expand Down Expand Up @@ -144,7 +145,7 @@ public function getType(): string
/**
* Set Response Type, one of JSON, HTML or CLI
*
* @param $type
* @param string $type
*/
public function setType(string $type): void
{
Expand Down Expand Up @@ -285,7 +286,7 @@ public function hasHeader(string $header): bool
* or an array of strings.
*
* @param string $header header name
* @param string|string[] $value header value(s)
* @param int|int[]|string|string[] $value header value(s)
*
* @return void
*/
Expand All @@ -301,11 +302,11 @@ public function setHeader(string $header, $value): void
* value will be appended to the existing list.
*
* @param string $header header name to add
* @param string $value value of the header
* @param string|int $value value of the header
*
* @return void
*/
public function addHeader(string $header, string $value): void
public function addHeader(string $header, $value): void
{
if ($this->hasHeader($header)) {
$this->headers[$header][] = $value;
Expand Down Expand Up @@ -424,14 +425,14 @@ public function clearBody(): void
*
* @param string $name
* @param string $value
* @param int|string|\DateTime $expire
* @param int|string|DateTime $expire
* @param string $path
* @param string $domain
* @param bool $secure
* @param bool $httpOnly
*
* @return void
* @throws \InvalidArgumentException
* @throws InvalidArgumentException
*/
public function setCookie(
string $name,
Expand All @@ -444,20 +445,20 @@ public function setCookie(
): void {
// from PHP source code
if (preg_match("/[=,; \t\r\n\013\014]/", $name)) {
throw new \InvalidArgumentException('The cookie name contains invalid characters.');
throw new InvalidArgumentException('The cookie name contains invalid characters.');
}

if (empty($name)) {
throw new \InvalidArgumentException('The cookie name cannot be empty.');
throw new InvalidArgumentException('The cookie name cannot be empty.');
}

// convert expiration time to a Unix timestamp
if ($expire instanceof \DateTime) {
if ($expire instanceof DateTime) {
$expire = $expire->format('U');
} elseif (!is_numeric($expire)) {
$expire = strtotime($expire);
if (false === $expire || -1 === $expire) {
throw new \InvalidArgumentException('The cookie expiration time is not valid.');
throw new InvalidArgumentException('The cookie expiration time is not valid.');
}
}

Expand All @@ -467,8 +468,8 @@ public function setCookie(
'expire' => $expire,
'path' => $path,
'domain' => $domain,
'secure' => (bool)$secure,
'httpOnly' => (bool)$httpOnly
'secure' => $secure,
'httpOnly' => $httpOnly
];
}

Expand Down

0 comments on commit 4f7b437

Please sign in to comment.