Skip to content

Commit 8d13a4c

Browse files
committed
Fix styling
1 parent 7fa4b0e commit 8d13a4c

29 files changed

+685
-662
lines changed

config/pgsql/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
],
1515

1616
'pool_size' => (int) ($_ENV['DB_POOL_SIZE'] ?? 20),
17-
];
17+
];

src/Api/AsyncMySQLi.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ final class AsyncMySQLi
1515
{
1616
private static ?AsyncMySQLiPool $pool = null;
1717
private static bool $isInitialized = false;
18-
private const POOL_INTERVAL = 10;
19-
private const POOL_MAX_INTERVAL = 100;
18+
private const POOL_INTERVAL = 10;
19+
private const POOL_MAX_INTERVAL = 100;
2020

2121
public static function init(array $dbConfig, int $poolSize = 10): void
2222
{
@@ -158,7 +158,7 @@ private static function startCancellableRacingTransaction(callable $transactionC
158158
$mysqli->autocommit(true);
159159
self::getPool()->release($mysqli);
160160
} catch (Throwable $e) {
161-
error_log("Failed to cancel transaction {$index}: " . $e->getMessage());
161+
error_log("Failed to cancel transaction {$index}: ".$e->getMessage());
162162
self::getPool()->release($mysqli);
163163
}
164164
}
@@ -197,7 +197,7 @@ private static function finalizeRacingTransactions(array $mysqliConnections, int
197197
echo "Transaction $winnerIndex: Winner committed!\n";
198198
self::getPool()->release($mysqli);
199199
} catch (Throwable $e) {
200-
error_log("Failed to commit winner transaction {$winnerIndex}: " . $e->getMessage());
200+
error_log("Failed to commit winner transaction {$winnerIndex}: ".$e->getMessage());
201201
$mysqli->rollback();
202202
$mysqli->autocommit(true);
203203
self::getPool()->release($mysqli);
@@ -220,7 +220,7 @@ private static function rollbackAllTransactions(array $mysqliConnections): Promi
220220
$mysqli->autocommit(true);
221221
self::getPool()->release($mysqli);
222222
} catch (Throwable $e) {
223-
error_log("Failed to rollback transaction {$index}: " . $e->getMessage());
223+
error_log("Failed to rollback transaction {$index}: ".$e->getMessage());
224224
self::getPool()->release($mysqli);
225225
}
226226
})();
@@ -282,8 +282,8 @@ private static function executeAsyncQuery(string $sql, array $params, ?string $t
282282
try {
283283
if (count($params) > 0) {
284284
$stmt = $mysqli->prepare($sql);
285-
if (!$stmt) {
286-
throw new \RuntimeException('Prepare failed: ' . $mysqli->error);
285+
if (! $stmt) {
286+
throw new \RuntimeException('Prepare failed: '.$mysqli->error);
287287
}
288288

289289
if ($types === null) {
@@ -296,12 +296,12 @@ private static function executeAsyncQuery(string $sql, array $params, ?string $t
296296

297297
$processedParams = self::preprocessParameters($params);
298298

299-
if (!$stmt->bind_param($types, ...$processedParams)) {
300-
throw new \RuntimeException('Bind param failed: ' . $stmt->error);
299+
if (! $stmt->bind_param($types, ...$processedParams)) {
300+
throw new \RuntimeException('Bind param failed: '.$stmt->error);
301301
}
302302

303-
if (!$stmt->execute()) {
304-
throw new \RuntimeException('Execute failed: ' . $stmt->error);
303+
if (! $stmt->execute()) {
304+
throw new \RuntimeException('Execute failed: '.$stmt->error);
305305
}
306306

307307
if (
@@ -316,8 +316,8 @@ private static function executeAsyncQuery(string $sql, array $params, ?string $t
316316

317317
return self::processResult($result, $resultType, $stmt, $mysqli);
318318
} else {
319-
if (!$mysqli->query($sql, MYSQLI_ASYNC)) {
320-
throw new \RuntimeException('Query failed: ' . $mysqli->error);
319+
if (! $mysqli->query($sql, MYSQLI_ASYNC)) {
320+
throw new \RuntimeException('Query failed: '.$mysqli->error);
321321
}
322322

323323
$result = await(self::waitForAsyncCompletion($mysqli));
@@ -373,7 +373,7 @@ private static function processResult($result, string $resultType, ?mysqli_stmt
373373
if ($result === false) {
374374
$error = $stmt?->error ?? $mysqli?->error ?? 'Unknown error';
375375

376-
throw new \RuntimeException('Query execution failed: ' . $error);
376+
throw new \RuntimeException('Query execution failed: '.$error);
377377
}
378378

379379
return match ($resultType) {

src/Config/ConfigLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function findProjectRoot(): ?string
7575
{
7676
$dir = __DIR__;
7777
for ($i = 0; $i < 10; $i++) {
78-
if (is_dir($dir . '/vendor')) {
78+
if (is_dir($dir.'/vendor')) {
7979
return $dir;
8080
}
8181

@@ -95,7 +95,7 @@ private function loadDotEnv(): void
9595
throw new Exception('Root path not found, cannot load .env file');
9696
}
9797

98-
$envFile = $this->rootPath . '/.env';
98+
$envFile = $this->rootPath.'/.env';
9999

100100
if (file_exists($envFile)) {
101101
file_get_contents($envFile);
@@ -120,9 +120,9 @@ private function loadConfigFiles(): void
120120
throw new Exception('Root path not found, cannot load config files');
121121
}
122122

123-
$configDir = $this->rootPath . '/config/fiber-async';
123+
$configDir = $this->rootPath.'/config/fiber-async';
124124
if (is_dir($configDir)) {
125-
$files = glob($configDir . '/*.php');
125+
$files = glob($configDir.'/*.php');
126126
if ($files !== false) {
127127
foreach ($files as $file) {
128128
$key = basename($file, '.php');

src/Config/MysqliConfigLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function findProjectRoot(): ?string
7575
{
7676
$dir = __DIR__;
7777
for ($i = 0; $i < 10; $i++) {
78-
if (is_dir($dir . '/vendor')) {
78+
if (is_dir($dir.'/vendor')) {
7979
return $dir;
8080
}
8181

@@ -95,7 +95,7 @@ private function loadDotEnv(): void
9595
throw new Exception('Root path not found, cannot load .env file');
9696
}
9797

98-
$envFile = $this->rootPath . '/.env';
98+
$envFile = $this->rootPath.'/.env';
9999

100100
if (file_exists($envFile)) {
101101
file_get_contents($envFile);
@@ -120,9 +120,9 @@ private function loadConfigFiles(): void
120120
throw new Exception('Root path not found, cannot load config files');
121121
}
122122

123-
$configDir = $this->rootPath . '/config/mysqli';
123+
$configDir = $this->rootPath.'/config/mysqli';
124124
if (is_dir($configDir)) {
125-
$files = glob($configDir . '/*.php');
125+
$files = glob($configDir.'/*.php');
126126
if ($files !== false) {
127127
foreach ($files as $file) {
128128
$key = basename($file, '.php');

src/Config/PostgresConfigLoader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private function findProjectRoot(): ?string
7575
{
7676
$dir = __DIR__;
7777
for ($i = 0; $i < 10; $i++) {
78-
if (is_dir($dir . '/vendor')) {
78+
if (is_dir($dir.'/vendor')) {
7979
return $dir;
8080
}
8181

@@ -95,7 +95,7 @@ private function loadDotEnv(): void
9595
throw new Exception('Root path not found, cannot load .env file');
9696
}
9797

98-
$envFile = $this->rootPath . '/.env';
98+
$envFile = $this->rootPath.'/.env';
9999

100100
if (file_exists($envFile)) {
101101
file_get_contents($envFile);
@@ -120,9 +120,9 @@ private function loadConfigFiles(): void
120120
throw new Exception('Root path not found, cannot load config files');
121121
}
122122

123-
$configDir = $this->rootPath . '/config/pgsql';
123+
$configDir = $this->rootPath.'/config/pgsql';
124124
if (is_dir($configDir)) {
125-
$files = glob($configDir . '/*.php');
125+
$files = glob($configDir.'/*.php');
126126
if ($files !== false) {
127127
foreach ($files as $file) {
128128
$key = basename($file, '.php');

src/Http/Handlers/HttpHandler.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public function createStreamFromFile(string $path, string $mode = 'rb'): Stream
220220
*/
221221
public static function generateCacheKey(string $url): string
222222
{
223-
return 'http_' . sha1($url);
223+
return 'http_'.sha1($url);
224224
}
225225

226226
/**
@@ -276,12 +276,12 @@ public function sendRequest(string $url, array $curlOptions, ?CacheConfig $cache
276276

277277
if (isset($cachedItem['headers']['etag'])) {
278278
$etag = is_array($cachedItem['headers']['etag']) ? $cachedItem['headers']['etag'][0] : $cachedItem['headers']['etag'];
279-
$httpHeaders[] = 'If-None-Match: ' . $etag;
279+
$httpHeaders[] = 'If-None-Match: '.$etag;
280280
}
281281

282282
if (isset($cachedItem['headers']['last-modified'])) {
283283
$lastModified = is_array($cachedItem['headers']['last-modified']) ? $cachedItem['headers']['last-modified'][0] : $cachedItem['headers']['last-modified'];
284-
$httpHeaders[] = 'If-Modified-Since: ' . $lastModified;
284+
$httpHeaders[] = 'If-Modified-Since: '.$lastModified;
285285
}
286286

287287
$curlOptions[CURLOPT_HTTPHEADER] = $httpHeaders;
@@ -424,8 +424,6 @@ public function getCookieJar(): ?CookieJarInterface
424424
return $this->defaultCookieJar;
425425
}
426426

427-
428-
429427
/**
430428
* Process response cookies and update the cookie jar.
431429
*/

src/Http/Request.php

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function getRequestTarget(): string
124124
$target = '/';
125125
}
126126
if ($this->uri->getQuery() !== '') {
127-
$target .= '?' . $this->uri->getQuery();
127+
$target .= '?'.$this->uri->getQuery();
128128
}
129129

130130
return $target;
@@ -459,10 +459,10 @@ public function multipart(array $data): self
459459
* Create an SSE connection with automatic reconnection.
460460
* Inherits all configured request options (headers, auth, timeouts, etc.)
461461
*
462-
* @param string $url The SSE endpoint URL
463-
* @param callable(SSEEvent): void|null $onEvent Optional callback for each SSE event
464-
* @param callable(string): void|null $onError Optional callback for connection errors
465-
* @param SSEReconnectConfig|null $reconnectConfig Optional reconnection configuration
462+
* @param string $url The SSE endpoint URL
463+
* @param callable(SSEEvent): void|null $onEvent Optional callback for each SSE event
464+
* @param callable(string): void|null $onError Optional callback for connection errors
465+
* @param SSEReconnectConfig|null $reconnectConfig Optional reconnection configuration
466466
* @return CancellablePromiseInterface<SSEResponse>
467467
*/
468468
public function sse(
@@ -485,16 +485,15 @@ public function sse(
485485
/**
486486
* Configure SSE reconnection behavior.
487487
*
488-
* @param bool $enabled Whether reconnection is enabled
489-
* @param int $maxAttempts Maximum reconnection attempts
490-
* @param float $initialDelay Initial delay before first reconnection
491-
* @param float $maxDelay Maximum delay between attempts
492-
* @param float $backoffMultiplier Exponential backoff multiplier
493-
* @param bool $jitter Add random jitter to delays
494-
* @param array $retryableErrors List of retryable error messages
495-
* @param callable|null $onReconnect Callback called before each reconnection attempt
496-
* @param callable|null $shouldReconnect Custom logic to determine if reconnection should occur
497-
* @return self
488+
* @param bool $enabled Whether reconnection is enabled
489+
* @param int $maxAttempts Maximum reconnection attempts
490+
* @param float $initialDelay Initial delay before first reconnection
491+
* @param float $maxDelay Maximum delay between attempts
492+
* @param float $backoffMultiplier Exponential backoff multiplier
493+
* @param bool $jitter Add random jitter to delays
494+
* @param array $retryableErrors List of retryable error messages
495+
* @param callable|null $onReconnect Callback called before each reconnection attempt
496+
* @param callable|null $shouldReconnect Custom logic to determine if reconnection should occur
498497
*/
499498
public function sseReconnect(
500499
bool $enabled = true,
@@ -534,8 +533,7 @@ public function sseReconnect(
534533
/**
535534
* Configure SSE reconnection using a custom configuration object.
536535
*
537-
* @param SSEReconnectConfig $config The reconnection configuration
538-
* @return self
536+
* @param SSEReconnectConfig $config The reconnection configuration
539537
*/
540538
public function sseReconnectWith(SSEReconnectConfig $config): self
541539
{
@@ -546,8 +544,6 @@ public function sseReconnectWith(SSEReconnectConfig $config): self
546544

547545
/**
548546
* Disable SSE reconnection.
549-
*
550-
* @return self
551547
*/
552548
public function noSseReconnect(): self
553549
{
@@ -620,7 +616,7 @@ public function streamPost(string $url, $body = null, ?callable $onChunk = null)
620616
public function get(string $url, array $query = []): PromiseInterface
621617
{
622618
if (count($query) > 0) {
623-
$url .= (strpos($url, '?') !== false ? '&' : '?') . http_build_query($query);
619+
$url .= (strpos($url, '?') !== false ? '&' : '?').http_build_query($query);
624620
}
625621

626622
return $this->send('GET', $url);
@@ -831,10 +827,10 @@ function ($asyncResponse) use ($interceptors, $resolve, $reject) {
831827
public function cookie(string $name, string $value): self
832828
{
833829
$existingCookies = $this->getHeaderLine('Cookie');
834-
$newCookie = $name . '=' . urlencode($value);
830+
$newCookie = $name.'='.urlencode($value);
835831

836832
if ($existingCookies !== '') {
837-
return $this->header('Cookie', $existingCookies . '; ' . $newCookie);
833+
return $this->header('Cookie', $existingCookies.'; '.$newCookie);
838834
} else {
839835
return $this->header('Cookie', $newCookie);
840836
}
@@ -1156,7 +1152,7 @@ private function buildCurlOptions(string $method, string $url): array
11561152
if ($cookieHeader !== '') {
11571153
$existingCookies = $this->getHeaderLine('Cookie');
11581154
if ($existingCookies !== '') {
1159-
$this->header('Cookie', $existingCookies . '; ' . $cookieHeader);
1155+
$this->header('Cookie', $existingCookies.'; '.$cookieHeader);
11601156
} else {
11611157
$this->header('Cookie', $cookieHeader);
11621158
}
@@ -1197,13 +1193,13 @@ private function addProxyOptions(array &$options): void
11971193
return;
11981194
}
11991195

1200-
$options[CURLOPT_PROXY] = $this->proxyConfig->host . ':' . $this->proxyConfig->port;
1196+
$options[CURLOPT_PROXY] = $this->proxyConfig->host.':'.$this->proxyConfig->port;
12011197
$options[CURLOPT_PROXYTYPE] = $this->proxyConfig->getCurlProxyType();
12021198

12031199
if ($this->proxyConfig->username !== null) {
12041200
$proxyAuth = $this->proxyConfig->username;
12051201
if ($this->proxyConfig->password !== null) {
1206-
$proxyAuth .= ':' . $this->proxyConfig->password;
1202+
$proxyAuth .= ':'.$this->proxyConfig->password;
12071203
}
12081204
$options[CURLOPT_PROXYUSERPWD] = $proxyAuth;
12091205
}
@@ -1225,7 +1221,7 @@ private function addHeaderOptions(array &$options): void
12251221
if (count($this->headers) > 0) {
12261222
$headerStrings = [];
12271223
foreach ($this->headers as $name => $value) {
1228-
$headerStrings[] = "{$name}: " . implode(', ', $value);
1224+
$headerStrings[] = "{$name}: ".implode(', ', $value);
12291225
}
12301226
$options[CURLOPT_HTTPHEADER] = $headerStrings;
12311227
}
@@ -1272,7 +1268,7 @@ private function updateHostFromUri(): void
12721268
}
12731269

12741270
if (($port = $this->uri->getPort()) !== null) {
1275-
$host .= ':' . $port;
1271+
$host .= ':'.$port;
12761272
}
12771273

12781274
if (isset($this->headerNames['host'])) {

0 commit comments

Comments
 (0)