Skip to content

Commit cf1f695

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

File tree

70 files changed

+340
-441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+340
-441
lines changed

src/Symfony/Component/Asset/Context/RequestStackContext.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@
2020
*/
2121
class RequestStackContext implements ContextInterface
2222
{
23-
private RequestStack $requestStack;
24-
private string $basePath;
25-
private bool $secure;
26-
27-
public function __construct(RequestStack $requestStack, string $basePath = '', bool $secure = false)
28-
{
29-
$this->requestStack = $requestStack;
30-
$this->basePath = $basePath;
31-
$this->secure = $secure;
23+
public function __construct(
24+
private RequestStack $requestStack,
25+
private string $basePath = '',
26+
private bool $secure = false,
27+
) {
3228
}
3329

3430
public function getBasePath(): string

src/Symfony/Component/Asset/Package.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
*/
2424
class Package implements PackageInterface
2525
{
26-
private VersionStrategyInterface $versionStrategy;
2726
private ContextInterface $context;
2827

29-
public function __construct(VersionStrategyInterface $versionStrategy, ContextInterface $context = null)
30-
{
31-
$this->versionStrategy = $versionStrategy;
28+
public function __construct(
29+
private VersionStrategyInterface $versionStrategy,
30+
ContextInterface $context = null,
31+
) {
3232
$this->context = $context ?? new NullContext();
3333
}
3434

src/Symfony/Component/Asset/Packages.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@
2222
*/
2323
class Packages
2424
{
25-
private ?PackageInterface $defaultPackage;
2625
private array $packages = [];
2726

2827
/**
2928
* @param PackageInterface[] $packages Additional packages indexed by name
3029
*/
31-
public function __construct(PackageInterface $defaultPackage = null, iterable $packages = [])
32-
{
33-
$this->defaultPackage = $defaultPackage;
34-
30+
public function __construct(
31+
private ?PackageInterface $defaultPackage = null,
32+
iterable $packages = [],
33+
) {
3534
foreach ($packages as $name => $package) {
3635
$this->addPackage($name, $package);
3736
}

src/Symfony/Component/Asset/VersionStrategy/JsonManifestVersionStrategy.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,17 @@
3131
*/
3232
class JsonManifestVersionStrategy implements VersionStrategyInterface
3333
{
34-
private string $manifestPath;
3534
private array $manifestData;
36-
private ?HttpClientInterface $httpClient;
37-
private bool $strictMode;
3835

3936
/**
4037
* @param string $manifestPath Absolute path to the manifest file
4138
* @param bool $strictMode Throws an exception for unknown paths
4239
*/
43-
public function __construct(string $manifestPath, HttpClientInterface $httpClient = null, bool $strictMode = false)
44-
{
45-
$this->manifestPath = $manifestPath;
46-
$this->httpClient = $httpClient;
47-
$this->strictMode = $strictMode;
48-
40+
public function __construct(
41+
private string $manifestPath,
42+
private ?HttpClientInterface $httpClient = null,
43+
private bool $strictMode = false,
44+
) {
4945
if (null === $this->httpClient && ($scheme = parse_url($this->manifestPath, \PHP_URL_SCHEME)) && str_starts_with($scheme, 'http')) {
5046
throw new LogicException(sprintf('The "%s" class needs an HTTP client to use a remote manifest. Try running "composer require symfony/http-client".', self::class));
5147
}

src/Symfony/Component/Asset/VersionStrategy/StaticVersionStrategy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
*/
1919
class StaticVersionStrategy implements VersionStrategyInterface
2020
{
21-
private string $version;
2221
private string $format;
2322

2423
/**
2524
* @param string $version Version number
2625
* @param string $format Url format
2726
*/
28-
public function __construct(string $version, string $format = null)
29-
{
30-
$this->version = $version;
27+
public function __construct(
28+
private string $version,
29+
string $format = null,
30+
) {
3131
$this->format = $format ?: '%s?%s';
3232
}
3333

src/Symfony/Component/BrowserKit/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);

src/Symfony/Component/BrowserKit/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
/**

src/Symfony/Component/BrowserKit/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
/**

src/Symfony/Component/Cache/Adapter/ApcuAdapter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@
2020
*/
2121
class ApcuAdapter extends AbstractAdapter
2222
{
23-
private ?MarshallerInterface $marshaller;
24-
2523
/**
2624
* @throws CacheException if APCu is not enabled
2725
*/
28-
public function __construct(string $namespace = '', int $defaultLifetime = 0, string $version = null, MarshallerInterface $marshaller = null)
29-
{
26+
public function __construct(
27+
string $namespace = '',
28+
int $defaultLifetime = 0,
29+
string $version = null,
30+
private ?MarshallerInterface $marshaller = null,
31+
) {
3032
if (!static::isSupported()) {
3133
throw new CacheException('APCu is not enabled.');
3234
}
@@ -43,8 +45,6 @@ public function __construct(string $namespace = '', int $defaultLifetime = 0, st
4345
apcu_add($version.'@'.$namespace, null);
4446
}
4547
}
46-
47-
$this->marshaller = $marshaller;
4848
}
4949

5050
public static function isSupported(): bool

src/Symfony/Component/Cache/Adapter/ArrayAdapter.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ class ArrayAdapter implements AdapterInterface, CacheInterface, LoggerAwareInter
3030
{
3131
use LoggerAwareTrait;
3232

33-
private bool $storeSerialized;
3433
private array $values = [];
3534
private array $tags = [];
3635
private array $expiries = [];
37-
private int $defaultLifetime;
38-
private float $maxLifetime;
39-
private int $maxItems;
4036

4137
private static \Closure $createCacheItem;
4238

4339
/**
4440
* @param bool $storeSerialized Disabling serialization can lead to cache corruptions when storing mutable values but increases performance otherwise
4541
*/
46-
public function __construct(int $defaultLifetime = 0, bool $storeSerialized = true, float $maxLifetime = 0, int $maxItems = 0)
47-
{
42+
public function __construct(
43+
private int $defaultLifetime = 0,
44+
private bool $storeSerialized = true,
45+
private float $maxLifetime = 0,
46+
private int $maxItems = 0,
47+
) {
4848
if (0 > $maxLifetime) {
4949
throw new InvalidArgumentException(sprintf('Argument $maxLifetime must be positive, %F passed.', $maxLifetime));
5050
}
@@ -53,10 +53,6 @@ public function __construct(int $defaultLifetime = 0, bool $storeSerialized = tr
5353
throw new InvalidArgumentException(sprintf('Argument $maxItems must be a positive integer, %d passed.', $maxItems));
5454
}
5555

56-
$this->defaultLifetime = $defaultLifetime;
57-
$this->storeSerialized = $storeSerialized;
58-
$this->maxLifetime = $maxLifetime;
59-
$this->maxItems = $maxItems;
6056
self::$createCacheItem ??= \Closure::bind(
6157
static function ($key, $value, $isHit, $tags) {
6258
$item = new CacheItem();

0 commit comments

Comments
 (0)