Skip to content

Commit a017731

Browse files
authored
Merge pull request #1 from litebase/pint-workflow
Pint workflow
2 parents 5f8d403 + 84f00f4 commit a017731

17 files changed

Lines changed: 99 additions & 49 deletions

.github/workflows/pint.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: pint
2+
3+
on:
4+
push:
5+
branches: [main]
6+
workflow_dispatch:
7+
8+
jobs:
9+
lint:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v5
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: "8.4"
22+
tools: composer:v2
23+
coverage: xdebug
24+
25+
- name: Install Dependencies
26+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
27+
28+
- name: Run Pint
29+
run: composer run pint
30+
31+
- name: Check for changes
32+
id: verify-changed-files
33+
run: |
34+
if [ -n "$(git status --porcelain)" ]; then
35+
echo "changed=true" >> $GITHUB_OUTPUT
36+
echo "Changes detected after Pint"
37+
git status --porcelain
38+
else
39+
echo "changed=false" >> $GITHUB_OUTPUT
40+
echo "No changes detected after Pint"
41+
fi
42+
43+
- name: Commit and Push changes
44+
if: steps.verify-changed-files.outputs.changed == 'true'
45+
run: |
46+
git config --local user.email "action@github.com"
47+
git config --local user.name "GitHub Action"
48+
git add -u
49+
git commit -m "Apply PHP Pint fixes"
50+
git push

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
"scripts": {
4949
"generate_openapi": "openapi-generator-cli generate -c openapi_config.yaml",
50-
"format": "vendor/bin/pint --no-interaction",
50+
"pint": "vendor/bin/pint --no-interaction",
5151
"test": "vendor/bin/pest",
5252
"test-coverage": "vendor/bin/pest --coverage-html coverage"
5353
}

pint.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"exclude": ["src/Generated"]
3+
}

src/Connection.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Connection
4545
/**
4646
* Create a new connection instance.
4747
*
48-
* @param array<string, int|string> $requestHeaders
48+
* @param array<string, int|string> $requestHeaders
4949
*/
5050
public function __construct(public string $url, public array $requestHeaders = [])
5151
{
@@ -183,7 +183,7 @@ protected function createThreads(): void
183183

184184
if ($byte === "\r") {
185185
// Expecting "\n" after "\r"
186-
$nextByte = $this->socket ? fread($this->socket, 1) : false;
186+
$nextByte = $this->socket ? fread($this->socket, 1) : false;
187187

188188
if ($nextByte === "\n") {
189189
break;
@@ -214,7 +214,7 @@ protected function createThreads(): void
214214

215215
while ($bytesRead < $chunkSize) {
216216
$remainingBytes = $chunkSize - $bytesRead;
217-
$readLength = max(1, (int)$remainingBytes);
217+
$readLength = max(1, (int) $remainingBytes);
218218

219219
$data = $this->socket && $remainingBytes > 0 ?
220220
fread($this->socket, $readLength) :
@@ -357,7 +357,7 @@ public function open(): void
357357
stream_set_timeout($this->socket, 5);
358358

359359
$error = fwrite($this->socket, "POST {$this->path} HTTP/1.1\r\n");
360-
$error = fwrite($this->socket, implode("\r\n", $this->headers) . "\r\n");
360+
$error = fwrite($this->socket, implode("\r\n", $this->headers)."\r\n");
361361
$error = fwrite($this->socket, "\r\n");
362362

363363
if ($error === false) {
@@ -367,7 +367,7 @@ public function open(): void
367367
$this->open = true;
368368

369369
$this->messages = [
370-
pack('C', QueryStreamMessageType::OPEN_CONNECTION->value . pack('V', 0)),
370+
pack('C', QueryStreamMessageType::OPEN_CONNECTION->value.pack('V', 0)),
371371
...$this->messages,
372372
];
373373

@@ -381,7 +381,7 @@ public function send(Query $query): QueryResult
381381
{
382382
$queryRequest = $this->queryRequestEncoder->encode($query);
383383

384-
$frame = pack('C', QueryStreamMessageType::FRAME->value) . pack('V', strlen($queryRequest)) . $queryRequest;
384+
$frame = pack('C', QueryStreamMessageType::FRAME->value).pack('V', strlen($queryRequest)).$queryRequest;
385385

386386
$this->messages[] = $frame;
387387

@@ -410,7 +410,7 @@ public function send(Query $query): QueryResult
410410

411411
continue;
412412
} catch (Exception $reconnectException) {
413-
throw new Exception('[Litebase Client Error]: Failed to reconnect after connection loss: ' . $reconnectException->getMessage());
413+
throw new Exception('[Litebase Client Error]: Failed to reconnect after connection loss: '.$reconnectException->getMessage());
414414
}
415415
}
416416
}
@@ -565,7 +565,7 @@ protected function writeMessage(string $message): void
565565
$chunkSize = dechex(strlen($message));
566566

567567
$n = $this->socket ?
568-
fwrite($this->socket, $chunkSize . "\r\n" . $message . "\r\n") :
568+
fwrite($this->socket, $chunkSize."\r\n".$message."\r\n") :
569569
false;
570570

571571
if ($n === false) {

src/Exceptions/QueryException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class QueryException extends Exception
2424
/**
2525
* Create a new QueryException instance.
2626
*
27-
* @param array<int|string, mixed> $parameters
27+
* @param array<int|string, mixed> $parameters
2828
*/
2929
public function __construct(string $message, string $statement, array $parameters, ?Throwable $previous = null)
3030
{

src/HasRequestHeaders.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
trait HasRequestHeaders
66
{
77
/**
8-
* @param array<string, string> $headers
8+
* @param array<string, string> $headers
99
* @return array<string, string>
1010
*/
1111
protected function requestHeaders(string $host, ?string $port, int $contentLength, array $headers = []): array

src/HttpStreamingTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ public function send(Query $query): ?QueryResult
4242
: sprintf('http://%s:%d/%s', $this->config->getHost(), $this->config->getPort(), $path);
4343

4444
if (! empty($this->config->getUsername()) || ! (empty($this->config->getPassword()))) {
45-
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ':' . $this->config->getPassword());
45+
$headers['Authorization'] = 'Basic '.base64_encode($this->config->getUsername().':'.$this->config->getPassword());
4646
}
4747

4848
if (! empty($this->config->getAccessToken())) {
49-
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
49+
$headers['Authorization'] = 'Bearer '.$this->config->getAccessToken();
5050
}
5151

5252
if (! empty($this->config->getAccessKeyId())) {

src/HttpTransport.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ public function send(Query $query): ?QueryResult
5050

5151
/** @var array<int, array<int, bool|float|int|string|null>> $rows */
5252
$rows = array_values(array_map(
53-
fn($row) => is_array($row) ? array_values($row) : (array) $row,
53+
fn ($row) => is_array($row) ? array_values($row) : (array) $row,
5454
$firstResult->getRows() ?? []
5555
));
5656

5757
return new QueryResult(
5858
changes: $firstResult->getChanges() ?? 0,
59-
columns: array_values(array_map(fn($col) => [
59+
columns: array_values(array_map(fn ($col) => [
6060
'type' => ColumnType::from($col->getType() ?? 1),
6161
'name' => $col->getName() ?? '',
6262
], $firstResult->getColumns() ?? [])),

src/LitebaseClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Exception;
66
use GuzzleHttp\Client;
7-
use Litebase\Generated\Model\Any;
87
use Litebase\Generated\Model\StatementParameter;
98
use Throwable;
109

@@ -217,7 +216,7 @@ public function withTransport(string $transportType): LitebaseClient
217216
$this->transport = new HttpStreamingTransport($this->configuration);
218217
break;
219218
default:
220-
throw new Exception('Invalid transport type: ' . $transportType);
219+
throw new Exception('Invalid transport type: '.$transportType);
221220
}
222221

223222
return $this;

src/LitebasePDO.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LitebasePDO extends Sqlite
1616
/**
1717
* Create a new instance of the PDO connection.
1818
*
19-
* @param array<string, string|null> $config
19+
* @param array<string, string|null> $config
2020
*/
2121
public function __construct(array $config)
2222
{
@@ -149,7 +149,7 @@ public function lastInsertId($name = null): string|false
149149
/**
150150
* Create a new prepared statement.
151151
*
152-
* @param array<string, mixed>|null $options Driver options.
152+
* @param array<string, mixed>|null $options Driver options.
153153
*/
154154
public function prepare(string $statement, $options = null): PDOStatement
155155
{

0 commit comments

Comments
 (0)