Skip to content

Commit d10d1a2

Browse files
committed
some methods use real default values instead of nulls (BC break)
1 parent aef9e6f commit d10d1a2

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

src/Http/IResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ function setCookie(
206206
?int $expire,
207207
?string $path = null,
208208
?string $domain = null,
209-
?bool $secure = null,
210-
?bool $httpOnly = null,
209+
bool $secure = false,
210+
bool $httpOnly = true,
211211
): static;
212212

213213
/**
@@ -217,6 +217,6 @@ function deleteCookie(
217217
string $name,
218218
?string $path = null,
219219
?string $domain = null,
220-
?bool $secure = null,
220+
bool $secure = false,
221221
);
222222
}

src/Http/Request.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,23 @@ class Request implements IRequest
5050

5151
public function __construct(
5252
UrlScript $url,
53-
?array $post = null,
54-
?array $files = null,
55-
?array $cookies = null,
56-
?array $headers = null,
57-
?string $method = null,
53+
array $post = [],
54+
array $files = [],
55+
array $cookies = [],
56+
array $headers = [],
57+
string $method = 'GET',
5858
?string $remoteAddress = null,
5959
?string $remoteHost = null,
6060
?callable $rawBodyCallback = null,
6161
?string $user = null,
6262
?string $password = null,
6363
) {
6464
$this->url = $url;
65-
$this->post = (array) $post;
66-
$this->files = (array) $files;
67-
$this->cookies = (array) $cookies;
68-
$this->headers = array_change_key_case((array) $headers, CASE_LOWER);
69-
$this->method = $method ?: 'GET';
65+
$this->post = $post;
66+
$this->files = $files;
67+
$this->cookies = $cookies;
68+
$this->headers = array_change_key_case($headers, CASE_LOWER);
69+
$this->method = $method;
7070
$this->remoteAddress = $remoteAddress;
7171
$this->remoteHost = $remoteHost;
7272
$this->rawBodyCallback = $rawBodyCallback;

src/Http/RequestFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ private function getHeaders(): array
250250
}
251251

252252

253-
private function getMethod(): ?string
253+
private function getMethod(): string
254254
{
255-
$method = $_SERVER['REQUEST_METHOD'] ?? null;
255+
$method = $_SERVER['REQUEST_METHOD'] ?? 'GET';
256256
if (
257257
$method === 'POST'
258258
&& preg_match('#^[A-Z]+$#D', $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ?? '')

src/Http/Response.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,17 +250,17 @@ public function setCookie(
250250
?string $path = null,
251251
?string $domain = null,
252252
?bool $secure = null,
253-
?bool $httpOnly = null,
254-
?string $sameSite = null,
253+
bool $httpOnly = true,
254+
string $sameSite = self::SAME_SITE_LAX,
255255
): static {
256256
self::checkHeaders();
257257
setcookie($name, $value, [
258258
'expires' => $time ? (int) DateTime::from($time)->format('U') : 0,
259259
'path' => $path ?? ($domain ? '/' : $this->cookiePath),
260260
'domain' => $domain ?? ($path ? '' : $this->cookieDomain),
261261
'secure' => $secure ?? $this->cookieSecure,
262-
'httponly' => $httpOnly ?? true,
263-
'samesite' => $sameSite ?? self::SAME_SITE_LAX,
262+
'httponly' => $httpOnly,
263+
'samesite' => $sameSite,
264264
]);
265265
return $this;
266266
}

0 commit comments

Comments
 (0)