Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Http/IResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ interface IResponse
* Sets HTTP response code.
* @return static
*/
function setCode(int $code);
function setCode(int $code, ?string $reason = null);

/**
* Returns HTTP response code.
Expand All @@ -99,7 +99,7 @@ function getCode(): int;
* Sends a HTTP header and replaces a previous one.
* @return static
*/
function setHeader(string $name, string $value);
function setHeader(string $name, ?string $value);

/**
* Adds HTTP header.
Expand All @@ -111,7 +111,7 @@ function addHeader(string $name, string $value);
* Sends a Content-type HTTP header.
* @return static
*/
function setContentType(string $type, string $charset = null);
function setContentType(string $type, ?string $charset = null);

/**
* Redirects to a new URL.
Expand Down Expand Up @@ -144,10 +144,10 @@ function getHeaders(): array;
* @param string|int|\DateTimeInterface $expire time, value 0 means "until the browser is closed"
* @return static
*/
function setCookie(string $name, string $value, $expire, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null);
function setCookie(string $name, string $value, $expire, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null);

/**
* Deletes a cookie.
*/
function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null);
function deleteCookie(string $name, ?string $path = null, ?string $domain = null, ?bool $secure = null);
}
8 changes: 4 additions & 4 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct()
* @throws Nette\InvalidArgumentException if code is invalid
* @throws Nette\InvalidStateException if HTTP headers have been sent
*/
public function setCode(int $code, string $reason = null)
public function setCode(int $code, ?string $reason = null)
{
if ($code < 100 || $code > 599) {
throw new Nette\InvalidArgumentException("Bad HTTP response '$code'.");
Expand Down Expand Up @@ -129,7 +129,7 @@ public function addHeader(string $name, string $value)
* @return static
* @throws Nette\InvalidStateException if HTTP headers have been sent
*/
public function setContentType(string $type, string $charset = null)
public function setContentType(string $type, ?string $charset = null)
{
$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
return $this;
Expand Down Expand Up @@ -235,7 +235,7 @@ public function __destruct()
* @return static
* @throws Nette\InvalidStateException if HTTP headers have been sent
*/
public function setCookie(string $name, string $value, $time, string $path = null, string $domain = null, bool $secure = null, bool $httpOnly = null, string $sameSite = null)
public function setCookie(string $name, string $value, $time, ?string $path = null, ?string $domain = null, ?bool $secure = null, ?bool $httpOnly = null, ?string $sameSite = null)
{
self::checkHeaders();
$options = [
Expand Down Expand Up @@ -267,7 +267,7 @@ public function setCookie(string $name, string $value, $time, string $path = nul
* Deletes a cookie.
* @throws Nette\InvalidStateException if HTTP headers have been sent
*/
public function deleteCookie(string $name, string $path = null, string $domain = null, bool $secure = null): void
public function deleteCookie(string $name, ?string $path = null, ?string $domain = null, ?bool $secure = null): void
{
$this->setCookie($name, '', 0, $path, $domain, $secure);
}
Expand Down