Skip to content

Commit df77819

Browse files
OskarStarkxabbuh
authored andcommitted
[Filesystem][Finder][Form] Use CPP
1 parent 8533622 commit df77819

15 files changed

+86
-102
lines changed

Chunk/DataChunk.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@
2020
*/
2121
class DataChunk implements ChunkInterface
2222
{
23-
private int $offset = 0;
24-
private string $content = '';
25-
26-
public function __construct(int $offset = 0, string $content = '')
27-
{
28-
$this->offset = $offset;
29-
$this->content = $content;
23+
public function __construct(
24+
private int $offset = 0,
25+
private string $content = '',
26+
) {
3027
}
3128

3229
public function isTimeout(): bool

Chunk/ErrorChunk.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,13 @@
2323
class ErrorChunk implements ChunkInterface
2424
{
2525
private bool $didThrow = false;
26-
private int $offset;
2726
private string $errorMessage;
2827
private ?\Throwable $error = null;
2928

30-
public function __construct(int $offset, \Throwable|string $error)
31-
{
32-
$this->offset = $offset;
33-
29+
public function __construct(
30+
private int $offset,
31+
\Throwable|string $error,
32+
) {
3433
if (\is_string($error)) {
3534
$this->errorMessage = $error;
3635
} else {

Internal/AmpBody.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ class AmpBody implements RequestBody, InputStream
2727
{
2828
private ResourceInputStream|\Closure|string $body;
2929
private array $info;
30-
private \Closure $onProgress;
3130
private ?int $offset = 0;
3231
private int $length = -1;
3332
private ?int $uploaded = null;
3433

3534
/**
3635
* @param \Closure|resource|string $body
3736
*/
38-
public function __construct($body, &$info, \Closure $onProgress)
39-
{
37+
public function __construct(
38+
$body,
39+
&$info,
40+
private \Closure $onProgress,
41+
) {
4042
$this->info = &$info;
41-
$this->onProgress = $onProgress;
4243

4344
if (\is_resource($body)) {
4445
$this->offset = ftell($body);

Internal/AmpClientState.php

+6-9
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,15 @@ final class AmpClientState extends ClientState
4747

4848
private array $clients = [];
4949
private \Closure $clientConfigurator;
50-
private int $maxHostConnections;
51-
private int $maxPendingPushes;
52-
private ?LoggerInterface $logger;
5350

54-
public function __construct(?callable $clientConfigurator, int $maxHostConnections, int $maxPendingPushes, ?LoggerInterface &$logger)
55-
{
51+
public function __construct(
52+
?callable $clientConfigurator,
53+
private int $maxHostConnections,
54+
private int $maxPendingPushes,
55+
private ?LoggerInterface &$logger,
56+
) {
5657
$clientConfigurator ??= static fn (PooledHttpClient $client) => new InterceptedHttpClient($client, new RetryRequests(2));
5758
$this->clientConfigurator = $clientConfigurator(...);
58-
59-
$this->maxHostConnections = $maxHostConnections;
60-
$this->maxPendingPushes = $maxPendingPushes;
61-
$this->logger = &$logger;
6259
}
6360

6461
/**

Internal/AmpListener.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@
2626
class AmpListener implements EventListener
2727
{
2828
private array $info;
29-
private array $pinSha256;
30-
private \Closure $onProgress;
31-
/** @var resource|null */
32-
private $handle;
3329

34-
public function __construct(array &$info, array $pinSha256, \Closure $onProgress, &$handle)
35-
{
30+
/**
31+
* @param resource|null $handle
32+
*/
33+
public function __construct(
34+
array &$info,
35+
private array $pinSha256,
36+
private \Closure $onProgress,
37+
private &$handle,
38+
) {
3639
$info += [
3740
'connect_time' => 0.0,
3841
'pretransfer_time' => 0.0,
@@ -44,9 +47,6 @@ public function __construct(array &$info, array $pinSha256, \Closure $onProgress
4447
];
4548

4649
$this->info = &$info;
47-
$this->pinSha256 = $pinSha256;
48-
$this->onProgress = $onProgress;
49-
$this->handle = &$handle;
5050
}
5151

5252
public function startRequest(Request $request): Promise

Internal/AmpResolver.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@
2525
*/
2626
class AmpResolver implements Dns\Resolver
2727
{
28-
private array $dnsMap;
29-
30-
public function __construct(array &$dnsMap)
31-
{
32-
$this->dnsMap = &$dnsMap;
28+
public function __construct(
29+
private array &$dnsMap,
30+
) {
3331
}
3432

3533
public function resolve(string $name, int $typeRestriction = null): Promise

Internal/Canary.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
*/
1919
final class Canary
2020
{
21-
private \Closure $canceller;
22-
23-
public function __construct(\Closure $canceller)
24-
{
25-
$this->canceller = $canceller;
21+
public function __construct(
22+
private \Closure $canceller,
23+
) {
2624
}
2725

2826
public function cancel(): void

Internal/HttplugWaitLoop.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,15 @@
3030
*/
3131
final class HttplugWaitLoop
3232
{
33-
private HttpClientInterface $client;
34-
private ?\SplObjectStorage $promisePool;
35-
private ResponseFactoryInterface $responseFactory;
36-
private StreamFactoryInterface $streamFactory;
37-
3833
/**
3934
* @param \SplObjectStorage<ResponseInterface, array{Psr7RequestInterface, Promise}>|null $promisePool
4035
*/
41-
public function __construct(HttpClientInterface $client, ?\SplObjectStorage $promisePool, ResponseFactoryInterface $responseFactory, StreamFactoryInterface $streamFactory)
42-
{
43-
$this->client = $client;
44-
$this->promisePool = $promisePool;
45-
$this->responseFactory = $responseFactory;
46-
$this->streamFactory = $streamFactory;
36+
public function __construct(
37+
private HttpClientInterface $client,
38+
private ?\SplObjectStorage $promisePool,
39+
private ResponseFactoryInterface $responseFactory,
40+
private StreamFactoryInterface $streamFactory,
41+
) {
4742
}
4843

4944
public function wait(?ResponseInterface $pendingResponse, float $maxDuration = null, float $idleTimeout = null): int

Response/AmpResponse.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ final class AmpResponse implements ResponseInterface, StreamableInterface
4545

4646
private static string $nextId = 'a';
4747

48-
private AmpClientState $multi;
4948
private ?array $options;
5049
private \Closure $onProgress;
5150

@@ -54,9 +53,12 @@ final class AmpResponse implements ResponseInterface, StreamableInterface
5453
/**
5554
* @internal
5655
*/
57-
public function __construct(AmpClientState $multi, Request $request, array $options, ?LoggerInterface $logger)
58-
{
59-
$this->multi = $multi;
56+
public function __construct(
57+
private AmpClientState $multi,
58+
Request $request,
59+
array $options,
60+
?LoggerInterface $logger,
61+
) {
6062
$this->options = &$options;
6163
$this->logger = $logger;
6264
$this->timeout = $options['timeout'];

Response/CurlResponse.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ final class CurlResponse implements ResponseInterface, StreamableInterface
3232
}
3333
use TransportResponseTrait;
3434

35-
private CurlClientState $multi;
36-
3735
/**
3836
* @var resource
3937
*/
@@ -42,10 +40,16 @@ final class CurlResponse implements ResponseInterface, StreamableInterface
4240
/**
4341
* @internal
4442
*/
45-
public function __construct(CurlClientState $multi, \CurlHandle|string $ch, array $options = null, LoggerInterface $logger = null, string $method = 'GET', callable $resolveRedirect = null, int $curlVersion = null, string $originalUrl = null)
46-
{
47-
$this->multi = $multi;
48-
43+
public function __construct(
44+
private CurlClientState $multi,
45+
\CurlHandle|string $ch,
46+
array $options = null,
47+
LoggerInterface $logger = null,
48+
string $method = 'GET',
49+
callable $resolveRedirect = null,
50+
int $curlVersion = null,
51+
string $originalUrl = null,
52+
) {
4953
if ($ch instanceof \CurlHandle) {
5054
$this->handle = $ch;
5155
$this->debugBuffer = fopen('php://temp', 'w+');

Response/HttplugPromise.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@
2323
*/
2424
final class HttplugPromise implements HttplugPromiseInterface
2525
{
26-
private GuzzlePromiseInterface $promise;
27-
28-
public function __construct(GuzzlePromiseInterface $promise)
29-
{
30-
$this->promise = $promise;
26+
public function __construct(
27+
private GuzzlePromiseInterface $promise,
28+
) {
3129
}
3230

3331
public function then(callable $onFulfilled = null, callable $onRejected = null): self

Response/NativeResponse.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ final class NativeResponse implements ResponseInterface, StreamableInterface
2929
use CommonResponseTrait;
3030
use TransportResponseTrait;
3131

32-
/**
33-
* @var resource
34-
*/
35-
private $context;
36-
private string $url;
3732
private \Closure $resolver;
3833
private ?\Closure $onProgress;
3934
private ?int $remaining = null;
@@ -43,18 +38,23 @@ final class NativeResponse implements ResponseInterface, StreamableInterface
4338
*/
4439
private $buffer;
4540

46-
private NativeClientState $multi;
4741
private float $pauseExpiry = 0.0;
4842

4943
/**
5044
* @internal
45+
* @param $context resource
5146
*/
52-
public function __construct(NativeClientState $multi, $context, string $url, array $options, array &$info, callable $resolver, ?callable $onProgress, ?LoggerInterface $logger)
53-
{
54-
$this->multi = $multi;
47+
public function __construct(
48+
private NativeClientState $multi,
49+
private $context,
50+
private string $url,
51+
array $options,
52+
array &$info,
53+
callable $resolver,
54+
?callable $onProgress,
55+
?LoggerInterface $logger,
56+
) {
5557
$this->id = $id = (int) $context;
56-
$this->context = $context;
57-
$this->url = $url;
5858
$this->logger = $logger;
5959
$this->timeout = $options['timeout'];
6060
$this->info = &$info;

Response/ResponseStream.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@
2020
*/
2121
final class ResponseStream implements ResponseStreamInterface
2222
{
23-
private \Generator $generator;
24-
25-
public function __construct(\Generator $generator)
26-
{
27-
$this->generator = $generator;
23+
public function __construct(
24+
private \Generator $generator,
25+
) {
2826
}
2927

3028
public function key(): ResponseInterface

Response/TraceableResponse.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@
3131
*/
3232
class TraceableResponse implements ResponseInterface, StreamableInterface
3333
{
34-
private HttpClientInterface $client;
35-
private ResponseInterface $response;
36-
private mixed $content;
37-
private ?StopwatchEvent $event;
38-
39-
public function __construct(HttpClientInterface $client, ResponseInterface $response, &$content, StopwatchEvent $event = null)
40-
{
41-
$this->client = $client;
42-
$this->response = $response;
43-
$this->content = &$content;
44-
$this->event = $event;
34+
public function __construct(
35+
private HttpClientInterface $client,
36+
private ResponseInterface $response,
37+
private mixed &$content,
38+
private ?StopwatchEvent $event = null,
39+
) {
4540
}
4641

4742
public function __sleep(): array

Retry/GenericRetryStrategy.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ class GenericRetryStrategy implements RetryStrategyInterface
3636
510 => self::IDEMPOTENT_METHODS,
3737
];
3838

39-
private array $statusCodes;
4039
private int $delayMs;
4140
private float $multiplier;
4241
private int $maxDelayMs;
@@ -49,10 +48,13 @@ class GenericRetryStrategy implements RetryStrategyInterface
4948
* @param int $maxDelayMs Maximum delay to allow (0 means no maximum)
5049
* @param float $jitter Probability of randomness int delay (0 = none, 1 = 100% random)
5150
*/
52-
public function __construct(array $statusCodes = self::DEFAULT_RETRY_STATUS_CODES, int $delayMs = 1000, float $multiplier = 2.0, int $maxDelayMs = 0, float $jitter = 0.1)
53-
{
54-
$this->statusCodes = $statusCodes;
55-
51+
public function __construct(
52+
private array $statusCodes = self::DEFAULT_RETRY_STATUS_CODES,
53+
int $delayMs = 1000,
54+
float $multiplier = 2.0,
55+
int $maxDelayMs = 0,
56+
float $jitter = 0.1,
57+
) {
5658
if ($delayMs < 0) {
5759
throw new InvalidArgumentException(sprintf('Delay must be greater than or equal to zero: "%s" given.', $delayMs));
5860
}

0 commit comments

Comments
 (0)