Skip to content

Commit 9727c78

Browse files
committed
Fix php-cs-fixer: auto-format to PER-CS standard
1 parent 93d7362 commit 9727c78

6 files changed

Lines changed: 24 additions & 22 deletions

File tree

src/Client.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ public function __construct(array $options)
7777
$rawEndpoint = ($options['endpoint'] ?? '') ?: self::DEFAULT_ENDPOINT;
7878
$this->endpoint = SSRF::validateEndpoint($rawEndpoint);
7979

80-
$this->flushInterval = (float)($options['flush_interval'] ?? self::DEFAULT_FLUSH_INTERVAL);
81-
$this->batchSize = (int)($options['batch_size'] ?? self::DEFAULT_BATCH_SIZE);
82-
$this->maxBufferSize = (int)($options['max_buffer_size'] ?? self::DEFAULT_MAX_BUFFER_SIZE);
83-
$this->maxStorageBytes = (int)($options['max_storage_bytes'] ?? self::DEFAULT_MAX_STORAGE_BYTES);
84-
$this->maxEventBytes = (int)($options['max_event_bytes'] ?? self::DEFAULT_MAX_EVENT_BYTES);
85-
$this->debug = (bool)($options['debug'] ?? false);
86-
$this->collectQueryString = (bool)($options['collect_query_string'] ?? false);
80+
$this->flushInterval = (float) ($options['flush_interval'] ?? self::DEFAULT_FLUSH_INTERVAL);
81+
$this->batchSize = (int) ($options['batch_size'] ?? self::DEFAULT_BATCH_SIZE);
82+
$this->maxBufferSize = (int) ($options['max_buffer_size'] ?? self::DEFAULT_MAX_BUFFER_SIZE);
83+
$this->maxStorageBytes = (int) ($options['max_storage_bytes'] ?? self::DEFAULT_MAX_STORAGE_BYTES);
84+
$this->maxEventBytes = (int) ($options['max_event_bytes'] ?? self::DEFAULT_MAX_EVENT_BYTES);
85+
$this->debug = (bool) ($options['debug'] ?? false);
86+
$this->collectQueryString = (bool) ($options['collect_query_string'] ?? false);
8787
$this->onError = $options['on_error'] ?? null;
8888
$this->identifyConsumer = $options['identify_consumer'] ?? null;
8989

@@ -199,10 +199,10 @@ private function trackInner(array $event): void
199199
}
200200

201201
// Sanitize
202-
$event['method'] = strtoupper(substr((string)($event['method'] ?? ''), 0, self::MAX_METHOD_LENGTH));
203-
$event['path'] = substr((string)($event['path'] ?? ''), 0, self::MAX_PATH_LENGTH);
202+
$event['method'] = strtoupper(substr((string) ($event['method'] ?? ''), 0, self::MAX_METHOD_LENGTH));
203+
$event['path'] = substr((string) ($event['path'] ?? ''), 0, self::MAX_PATH_LENGTH);
204204
if (isset($event['consumer_id'])) {
205-
$event['consumer_id'] = substr((string)$event['consumer_id'], 0, self::MAX_CONSUMER_ID_LENGTH);
205+
$event['consumer_id'] = substr((string) $event['consumer_id'], 0, self::MAX_CONSUMER_ID_LENGTH);
206206
}
207207

208208
// Timestamp
@@ -357,7 +357,7 @@ private function persistToDisk(array $events): void
357357
$size = file_exists($path) ? filesize($path) : 0;
358358

359359
if ($size !== false && $size >= $this->maxStorageBytes) {
360-
$this->debugLog("[peekapi] storage file full, dropping " . count($events) . " events\n");
360+
$this->debugLog("[peekapi] storage file full, dropping " . count($events) . " events\n");
361361
return;
362362
}
363363

@@ -409,7 +409,7 @@ private function loadFromDisk(): void
409409
if ($events !== []) {
410410
$this->buffer = array_merge(
411411
$this->buffer,
412-
array_slice($events, 0, $this->maxBufferSize)
412+
array_slice($events, 0, $this->maxBufferSize),
413413
);
414414
$this->debugLog("[peekapi] loaded " . count($events) . " events from disk\n");
415415
}

src/Middleware/Laravel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function handle(mixed $request, Closure $next): mixed
7676
'path' => $path,
7777
'status_code' => 500,
7878
'response_time_ms' => round($elapsedMs, 2),
79-
'request_size' => (int)$request->header('Content-Length', '0'),
79+
'request_size' => (int) $request->header('Content-Length', '0'),
8080
'response_size' => 0,
8181
'consumer_id' => $this->identifyConsumer($request),
8282
]);
@@ -96,7 +96,7 @@ public function handle(mixed $request, Closure $next): mixed
9696

9797
$responseSize = 0;
9898
if (method_exists($response, 'headers') && $response->headers->has('Content-Length')) {
99-
$responseSize = (int)$response->headers->get('Content-Length');
99+
$responseSize = (int) $response->headers->get('Content-Length');
100100
} elseif (method_exists($response, 'getContent')) {
101101
$responseSize = strlen($response->getContent());
102102
}
@@ -115,7 +115,7 @@ public function handle(mixed $request, Closure $next): mixed
115115
'path' => $path,
116116
'status_code' => $statusCode,
117117
'response_time_ms' => round($elapsedMs, 2),
118-
'request_size' => (int)$request->header('Content-Length', '0'),
118+
'request_size' => (int) $request->header('Content-Length', '0'),
119119
'response_size' => $responseSize,
120120
'consumer_id' => $this->identifyConsumer($request),
121121
]);

src/Middleware/PSR15.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function process(
6868
$responseSize = 0;
6969
$contentLength = $response->getHeaderLine('Content-Length');
7070
if ($contentLength !== '') {
71-
$responseSize = (int)$contentLength;
71+
$responseSize = (int) $contentLength;
7272
} else {
7373
$responseSize = $response->getBody()->getSize() ?? 0;
7474
}
@@ -115,7 +115,7 @@ private function requestSize(ServerRequestInterface $request): int
115115
{
116116
$contentLength = $request->getHeaderLine('Content-Length');
117117
if ($contentLength !== '') {
118-
return (int)$contentLength;
118+
return (int) $contentLength;
119119
}
120120
return $request->getBody()->getSize() ?? 0;
121121
}

src/SSRF.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private static function ipInCidr(string $ip, string $cidr): bool
8686
return false;
8787
}
8888

89-
$bits = (int)$bits;
89+
$bits = (int) $bits;
9090
$len = strlen($ipBin);
9191
$mask = str_repeat("\xff", intdiv($bits, 8));
9292
$remainder = $bits % 8;
@@ -124,7 +124,7 @@ public static function validateEndpoint(string $endpoint): string
124124

125125
if ($scheme !== 'https' && !$isLocalhost) {
126126
throw new InvalidArgumentException(
127-
"HTTPS required for non-localhost endpoint: {$endpoint}"
127+
"HTTPS required for non-localhost endpoint: {$endpoint}",
128128
);
129129
}
130130

@@ -134,7 +134,7 @@ public static function validateEndpoint(string $endpoint): string
134134

135135
if (!$isLocalhost && self::isPrivateIp($hostname)) {
136136
throw new InvalidArgumentException(
137-
"Endpoint resolves to private/reserved IP: {$hostname}"
137+
"Endpoint resolves to private/reserved IP: {$hostname}",
138138
);
139139
}
140140

tests/ClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function testPersistAndRecover(): void
264264
// Verify file exists
265265
$this->assertTrue(
266266
file_exists($storagePath) || file_exists($storagePath . '.recovering'),
267-
'Persistence file should exist'
267+
'Persistence file should exist',
268268
);
269269

270270
// New client should load from disk

tests/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ public function allEvents(): array
109109

110110
$events = [];
111111
foreach (explode("\n", trim($content)) as $line) {
112-
if ($line === '') continue;
112+
if ($line === '') {
113+
continue;
114+
}
113115
$parsed = json_decode($line, true);
114116
if (is_array($parsed)) {
115117
if (array_is_list($parsed)) {

0 commit comments

Comments
 (0)