Skip to content

Commit a0eb098

Browse files
chore: run the project on PHP 8.5 (#467)
1 parent 70a6675 commit a0eb098

File tree

10 files changed

+40
-43
lines changed

10 files changed

+40
-43
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
- name: Set up PHP
4747
uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2
4848
with:
49-
php-version: '8.4'
49+
php-version: '8.5'
5050
extensions: ctype, json, mbstring
5151
tools: composer
5252

.github/workflows/integration-tests.yml

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ jobs:
4141
name: "PostgreSQL ${{ matrix.postgres }} + PostGIS ${{ matrix.postgis }} + PHP ${{ matrix.php }}"
4242

4343
strategy:
44-
fail-fast: false
44+
fail-fast: ${{ github.event_name == 'pull_request' }}
4545
matrix:
46-
php: ['8.1', '8.2', '8.3', '8.4']
46+
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
4747
postgis: ['3.4', '3.5', '3.6']
4848
postgres: ['16', '17', '18']
4949
exclude:
@@ -57,7 +57,7 @@ jobs:
5757
postgis: '3.5'
5858
include:
5959
# Code coverage on the latest stable combination
60-
- php: '8.4'
60+
- php: '8.5'
6161
postgres: '18'
6262
postgis: '3.6'
6363
calculate-code-coverage: true
@@ -92,15 +92,20 @@ jobs:
9292
- name: Validate composer.json and composer.lock
9393
run: composer validate --strict
9494

95+
- name: Get composer cache directory
96+
id: composer-cache-dir
97+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
98+
9599
- name: Cache Composer packages
96-
id: composer-cache
97100
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
98101
with:
99-
path: vendor
100-
key: ${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}-${{ hashFiles('**/composer.lock') }}
102+
path: |
103+
${{ steps.composer-cache-dir.outputs.dir }}
104+
vendor
105+
key: ${{ runner.os }}-php-${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
101106
restore-keys: |
102-
${{ runner.os }}-php-${{ matrix.php }}-pg-${{ matrix.postgres }}-
103-
${{ runner.os }}-php-${{ matrix.php }}-
107+
${{ runner.os }}-php-${{ matrix.php }}-composer-
108+
${{ runner.os }}-composer-
104109
105110
- name: Install dependencies
106111
run: composer install --prefer-dist --no-interaction --no-progress
@@ -112,22 +117,7 @@ jobs:
112117
113118
- name: Verify PostgreSQL connection and setup
114119
run: |
115-
echo "Checking PostgreSQL version:"
116-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SELECT version();"
117-
118-
echo "\nChecking PostgreSQL configuration:"
119-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SHOW server_version;"
120-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SHOW max_connections;"
121-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SHOW shared_buffers;"
122-
123-
echo "\nCreating test schema:"
124-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "CREATE SCHEMA IF NOT EXISTS test;"
125-
126-
echo "\nListing available PostgreSQL extensions:"
127-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SELECT * FROM pg_available_extensions;"
128-
129-
echo "\nVerifying PostGIS installation:"
130-
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "SELECT PostGIS_Version();"
120+
PGPASSWORD=postgres psql -h localhost -U postgres -d postgres_doctrine_test -c "CREATE SCHEMA IF NOT EXISTS test; SELECT PostGIS_Version();"
131121
132122
- name: Run integration test suite
133123
run: |

.github/workflows/unit-tests.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,16 @@ jobs:
4141
name: "PHP ${{ matrix.php }} + Doctrine ORM ${{ matrix.doctrine-orm }} + Doctrine Lexer ${{ matrix.doctrine-lexer }}"
4242

4343
strategy:
44-
fail-fast: false
44+
fail-fast: ${{ github.event_name == 'pull_request' }}
4545
matrix:
46-
php: ['8.1', '8.2', '8.3', '8.4']
46+
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
4747
doctrine-lexer: ['2.1', '3.0', 'latest']
4848
doctrine-orm: ['2.14', '2.18', '3.0', 'latest']
4949
include:
5050
- php: '8.1'
5151
doctrine-orm: '2.14'
5252
doctrine-lexer: '1.2'
53-
- php: '8.4' # Run coverage report only based on the latest dependencies
53+
- php: '8.5' # Run coverage report only based on the latest dependencies
5454
doctrine-lexer: 'latest'
5555
doctrine-orm: 'latest'
5656
calculate-code-coverage: true
@@ -71,11 +71,16 @@ jobs:
7171
extensions: ctype, json, mbstring
7272
tools: composer
7373

74+
- name: Get composer cache directory
75+
id: composer-cache-dir
76+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
77+
7478
- name: Cache Composer packages
75-
id: composer-cache
7679
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
7780
with:
78-
path: vendor
81+
path: |
82+
${{ steps.composer-cache-dir.outputs.dir }}
83+
vendor
7984
key: ${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}-${{ hashFiles('**/composer.lock') }}
8085
restore-keys: |
8186
${{ runner.os }}-php-${{ matrix.php }}-orm-${{ matrix.doctrine-orm }}-lexer-${{ matrix.doctrine-lexer }}-

ci/php-cs-fixer/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
->setRules(
1919
[
2020
'@PSR2' => true,
21-
'@PHP71Migration' => true,
21+
'@PHP7x1Migration' => true,
2222
'@DoctrineAnnotation' => true,
2323
'@PhpCsFixer' => true,
2424
'align_multiline_comment' => false,

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
},
3838

3939
"require": {
40-
"php": "^8.1",
40+
"php": "^8.1 <8.6",
4141
"ext-ctype": "*",
4242
"ext-json": "*",
4343
"ext-mbstring": "*",
@@ -57,7 +57,7 @@
5757
"symfony/cache": "^6.4||^7.0"
5858
},
5959
"suggest": {
60-
"php": "^8.3",
60+
"php": "^8.4",
6161
"doctrine/orm": "~2.14||~3.0"
6262
},
6363

docs/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ Using local-only plaintext secrets here is acceptable.
128128
For example, this file:
129129
130130
- Install [Harlequin](https://harlequin.sh/) database TUI.
131-
- Set PHP version to 8.4.
132-
- Change PostgreSQL related environment variables.
131+
- Set PHP version to 8.5.
132+
- Change PostgreSQL-related environment variables.
133133
134134
```nix
135135
# devenv.local.nix
@@ -139,7 +139,7 @@ For example, this file:
139139
packages = with pkgs; [ harlequin ];
140140
141141
# https://devenv.sh/languages/
142-
languages.php.version = "8.4";
142+
languages.php.version = "8.5";
143143
144144
# https://devenv.sh/basics/
145145
env = {

src/MartinGeorgiev/Doctrine/DBAL/Types/BaseIntegerArray.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ private function throwIfInvalidArrayItemForDatabase(mixed $item): void
4444
throw InvalidIntegerArrayItemForDatabaseException::doesNotMatchRegex($item);
4545
}
4646

47-
$doesNotFitIntoPHPInteger = $stringValue !== (string) (int) $stringValue;
48-
if ($doesNotFitIntoPHPInteger) {
47+
if (!$this->fitsInPHPInteger($stringValue)) {
4948
throw InvalidIntegerArrayItemForDatabaseException::isOutOfRange($item);
5049
}
5150

@@ -75,8 +74,7 @@ public function transformArrayItemForPHP(mixed $item): ?int
7574
throw InvalidIntegerArrayItemForPHPException::forValueThatIsNotAValidPHPInteger($item, static::TYPE_NAME);
7675
}
7776

78-
$doesNotFitIntoPHPInteger = $stringValue !== (string) (int) $stringValue;
79-
if ($doesNotFitIntoPHPInteger) {
77+
if (!$this->fitsInPHPInteger($stringValue)) {
8078
throw InvalidIntegerArrayItemForPHPException::forValueOutOfRangeInPHP($item, static::TYPE_NAME);
8179
}
8280

@@ -88,4 +86,9 @@ public function transformArrayItemForPHP(mixed $item): ?int
8886

8987
return $integerValue;
9088
}
89+
90+
private function fitsInPHPInteger(string $value): bool
91+
{
92+
return \filter_var($value, \FILTER_VALIDATE_INT) !== false;
93+
}
9194
}

src/MartinGeorgiev/Doctrine/DBAL/Types/SpatialDataArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private function parseUnquotedWktArray(string $content): array
200200
$wktItems[] = $currentWktItem;
201201
}
202202

203-
return \array_map('trim', $wktItems);
203+
return \array_map(trim(...), $wktItems);
204204
}
205205

206206
public function isValidArrayItemForDatabase(mixed $item): bool

src/MartinGeorgiev/Utils/PHPArrayToPostgresValueTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public static function transformToPostgresTextArray(array $phpArray): string
3030
return self::POSTGRESQL_EMPTY_ARRAY;
3131
}
3232

33-
if (\array_filter($phpArray, 'is_array')) {
33+
if (\array_filter($phpArray, is_array(...))) {
3434
throw InvalidArrayFormatException::multiDimensionalArrayNotSupported();
3535
}
3636

tests/Unit/MartinGeorgiev/Utils/PHPArrayToPostgresValueTransformerTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,5 @@ public function can_transform_array_with_gd_resource(): void
260260
$resource = \imagecreatetruecolor(1, 1);
261261
$result = PHPArrayToPostgresValueTransformer::transformToPostgresTextArray([$resource]);
262262
$this->assertStringContainsString('GdImage', $result);
263-
\imagedestroy($resource);
264263
}
265264
}

0 commit comments

Comments
 (0)