Skip to content

Commit a7ab73b

Browse files
OskarStarknicolas-grekas
authored andcommitted
[Asset][BrowserKit][Cache][Console][CssSelector] Use CPP
1 parent c53a6e9 commit a7ab73b

File tree

3 files changed

+32
-44
lines changed

3 files changed

+32
-44
lines changed

Cookie.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,10 @@ class Cookie
3535
'D M d H:i:s Y T',
3636
];
3737

38-
protected string $name;
3938
protected string $value;
4039
protected ?string $expires = null;
4140
protected string $path;
42-
protected string $domain;
43-
protected bool $secure;
44-
protected bool $httponly;
4541
protected string $rawValue;
46-
private ?string $samesite;
4742

4843
/**
4944
* Sets a cookie.
@@ -58,21 +53,25 @@ class Cookie
5853
* @param bool $encodedValue Whether the value is encoded or not
5954
* @param string|null $samesite The cookie samesite attribute
6055
*/
61-
public function __construct(string $name, ?string $value, string $expires = null, string $path = null, string $domain = '', bool $secure = false, bool $httponly = true, bool $encodedValue = false, string $samesite = null)
62-
{
56+
public function __construct(
57+
private string $name,
58+
?string $value,
59+
string $expires = null,
60+
string $path = null,
61+
private string $domain = '',
62+
private bool $secure = false,
63+
private bool $httponly = true,
64+
bool $encodedValue = false,
65+
private ?string $samesite = null,
66+
) {
6367
if ($encodedValue) {
6468
$this->rawValue = $value ?? '';
6569
$this->value = urldecode($this->rawValue);
6670
} else {
6771
$this->value = $value ?? '';
6872
$this->rawValue = rawurlencode($this->value);
6973
}
70-
$this->name = $name;
7174
$this->path = empty($path) ? '/' : $path;
72-
$this->domain = $domain;
73-
$this->secure = $secure;
74-
$this->httponly = $httponly;
75-
$this->samesite = $samesite;
7675

7776
if (null !== $expires) {
7877
$timestampAsDateTime = \DateTimeImmutable::createFromFormat('U', $expires);

Request.php

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,29 @@
1616
*/
1717
class Request
1818
{
19-
protected string $uri;
20-
protected string $method;
21-
protected array $parameters;
22-
protected array $files;
23-
protected array $cookies;
24-
protected array $server;
25-
protected ?string $content;
26-
2719
/**
28-
* @param string $uri The request URI
29-
* @param string $method The HTTP method request
30-
* @param array $parameters The request parameters
31-
* @param array $files An array of uploaded files
32-
* @param array $cookies An array of cookies
33-
* @param array $server An array of server parameters
34-
* @param string $content The raw body data
20+
* @param string $uri The request URI
21+
* @param string $method The HTTP method request
22+
* @param array $parameters The request parameters
23+
* @param array $files An array of uploaded files
24+
* @param array $cookies An array of cookies
25+
* @param array $server An array of server parameters
26+
* @param string|null $content The raw body data
3527
*/
36-
public function __construct(string $uri, string $method, array $parameters = [], array $files = [], array $cookies = [], array $server = [], string $content = null)
37-
{
38-
$this->uri = $uri;
39-
$this->method = $method;
40-
28+
public function __construct(
29+
protected string $uri,
30+
protected string $method,
31+
protected array $parameters = [],
32+
protected array $files = [],
33+
protected array $cookies = [],
34+
protected array $server = [],
35+
protected ?string $content = null,
36+
) {
4137
array_walk_recursive($parameters, static function (&$value) {
4238
$value = (string) $value;
4339
});
4440

4541
$this->parameters = $parameters;
46-
$this->files = $files;
47-
$this->cookies = $cookies;
48-
$this->server = $server;
49-
$this->content = $content;
5042
}
5143

5244
/**

Response.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
*/
1919
final class Response
2020
{
21-
private string $content;
22-
private int $status;
23-
private array $headers;
2421
private array $jsonData;
2522

2623
/**
@@ -31,11 +28,11 @@ final class Response
3128
* @param int $status The response status code (302 "Found" by default)
3229
* @param array $headers An array of headers
3330
*/
34-
public function __construct(string $content = '', int $status = 200, array $headers = [])
35-
{
36-
$this->content = $content;
37-
$this->status = $status;
38-
$this->headers = $headers;
31+
public function __construct(
32+
private string $content = '',
33+
private int $status = 200,
34+
private array $headers = [],
35+
) {
3936
}
4037

4138
/**

0 commit comments

Comments
 (0)