Skip to content

Commit 9c5cc73

Browse files
authored
Provide message variable in Exception (#76)
1 parent 1272c94 commit 9c5cc73

File tree

5 files changed

+43
-20
lines changed

5 files changed

+43
-20
lines changed

.github/workflows/phpstan.yml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ on:
55
pull_request:
66

77
concurrency:
8-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
9-
cancel-in-progress: true
8+
group: ${{ github.workflow }}-${{ github.ref_name }}
109

1110
permissions:
1211
contents: read
@@ -16,23 +15,35 @@ jobs:
1615
name: PHPStan
1716
runs-on: ubuntu-latest
1817

18+
strategy:
19+
matrix:
20+
php-versions: [8.1]
21+
1922
steps:
20-
- name: Checkout
23+
- name: Checkout code
2124
uses: actions/checkout@v4
2225

2326
- name: Setup PHP
2427
uses: shivammathur/setup-php@v2
2528
with:
26-
php-version: '8.2'
27-
extensions: pdo
29+
php-version: ${{ matrix.php-versions }}
30+
extensions: pdo, mbstring, pcre, curl, json
2831
ini-values: "memory_limit=-1"
29-
coverage: none
30-
tools: phpstan
32+
tools: composer:v2, phpstan
33+
34+
- name: Get composer cache directory
35+
id: composer-cache
36+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
37+
38+
- name: Cache composer dependencies
39+
uses: actions/cache@v3
40+
with:
41+
path: ${{ steps.composer-cache.outputs.dir }}
42+
key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('composer.json') }}
43+
restore-keys: ${{ runner.os }}-${{ matrix.php-versions }}-composer-
3144

3245
- name: Install dependencies
33-
run: |
34-
composer config --no-plugins allow-plugins.dealerdirect/phpcodesniffer-composer-installer false
35-
composer install --prefer-dist
46+
run: composer install --no-progress --prefer-dist --no-interaction
3647

37-
- name: phpstan
38-
run: phpstan analyse -l 5 src
48+
- name: Run PHPStan
49+
run: phpstan analyse -vvv -l 5 src

.github/workflows/tests.yml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
pull_request:
66

77
concurrency:
8-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
8+
group: ${{ github.workflow }}-${{ github.ref_name }}
99
cancel-in-progress: true
1010

1111
permissions:
@@ -19,7 +19,7 @@ jobs:
1919

2020
strategy:
2121
matrix:
22-
php-versions: ['8.1', '8.2', '8.3']
22+
php-versions: ['8.1', '8.2', '8.3', '8.4']
2323
fail-fast: false
2424

2525
services:
@@ -38,11 +38,22 @@ jobs:
3838
php-version: ${{ matrix.php-versions }}
3939
extensions: pdo
4040
ini-values: "memory_limit=-1"
41-
tools: composer
41+
tools: composer:v2
4242
coverage: xdebug
4343

44+
- name: Get composer cache directory
45+
id: composer-cache
46+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
47+
48+
- name: Cache composer dependencies
49+
uses: actions/cache@v3
50+
with:
51+
path: ${{ steps.composer-cache.outputs.dir }}
52+
key: ${{ runner.os }}-${{ matrix.php-versions }}-composer-${{ hashFiles('composer.json') }}
53+
restore-keys: ${{ runner.os }}-${{ matrix.php-versions }}-composer-
54+
4455
- name: Install dependencies
45-
run: composer install --prefer-dist
56+
run: composer install --no-progress --prefer-dist --no-interaction
4657

4758
- name: Run tests
4859
run: ./vendor/bin/phpunit --configuration ./phpunit.xml.dist --coverage-text

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
},
3434
"require-dev": {
3535
"doctrine/coding-standard": "^4.0 || ^9.0",
36-
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0"
36+
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0",
37+
"phpstan/phpstan": "*"
3738
},
3839
"autoload": {
3940
"psr-4": {

src/ClickHouseSchemaManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function listTableIndexes(string $table): array
7373
$matches
7474
);
7575

76-
if (is_array($matches) && array_key_exists(2, $matches)) {
76+
if (array_key_exists(2, $matches)) {
7777
$indexColumns = array_filter(
7878
array_map('trim', explode(',', $matches[2])),
7979
fn (string $column): bool => !str_contains($column, '(')

src/ClickHouseStatement.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ public function execute($params = null): Result
128128
: $this->client->write($statement)->rows()
129129
)
130130
);
131-
} catch (ClickHouseException $exception) {
132-
throw new Exception(previous: $exception, sqlState: $exception->getMessage());
131+
} catch (ClickHouseException $e) {
132+
throw new Exception($e->getMessage(), code: $e->getCode(), previous: $e, sqlState: $this->statement);
133133
}
134134
}
135135

0 commit comments

Comments
 (0)