Skip to content

Commit 3c965c0

Browse files
committed
Merge branch '4.2.x' into 4.3.x
* 4.2.x: Ignore new PHPStan errors Bump dev tools (#7002) fix(PgSQL): Allow to pass IPv6 address in URI notation for postgres (#6344) Run tests on MySQL 9.3 instead of 9.1 (#7001) CI MariaDB: add 11.8 (#6991)
2 parents 1f3b6e4 + a4f15b4 commit 3c965c0

File tree

6 files changed

+65
-3
lines changed

6 files changed

+65
-3
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ jobs:
143143
- "10.6" # LTS (Jul 2026) We have code specific to 10.6.0-10.10.0
144144
- "10.11" # LTS (Feb 2028) We have code specific to ^10.10
145145
- "11.4" # LTS (May 2029)
146+
- "11.8" # LTS (Jun 2028)
146147
extension:
147148
- "mysqli"
148149
- "pdo_mysql"
@@ -172,7 +173,7 @@ jobs:
172173
mysql-version:
173174
- "5.7"
174175
- "8.0" # We have code specific to ^8.0
175-
- "9.1"
176+
- "9.3"
176177
extension:
177178
- "mysqli"
178179
- "pdo_mysql"

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@
4040
"doctrine/coding-standard": "13.0.0",
4141
"fig/log-test": "^1",
4242
"jetbrains/phpstorm-stubs": "2023.2",
43-
"phpstan/phpstan": "2.1.1",
43+
"phpstan/phpstan": "2.1.17",
4444
"phpstan/phpstan-phpunit": "2.0.6",
4545
"phpstan/phpstan-strict-rules": "^2",
4646
"phpunit/phpunit": "11.5.15",
4747
"slevomat/coding-standard": "8.16.2",
48-
"squizlabs/php_codesniffer": "3.12.0",
48+
"squizlabs/php_codesniffer": "3.13.1",
4949
"symfony/cache": "^6.3.8|^7.0",
5050
"symfony/console": "^5.4|^6.3|^7.0"
5151
},

src/Driver/PgSQL/Connection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function __construct(private readonly PgSqlConnection $connection)
3131

3232
public function __destruct()
3333
{
34+
// @phpstan-ignore isset.initializedProperty
3435
if (! isset($this->connection)) {
3536
return;
3637
}

src/Driver/PgSQL/Driver.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use function func_get_args;
1818
use function implode;
1919
use function pg_connect;
20+
use function preg_match;
2021
use function restore_error_handler;
2122
use function set_error_handler;
2223
use function sprintf;
@@ -66,9 +67,18 @@ private function constructConnectionString(
6667
#[SensitiveParameter]
6768
array $params,
6869
): string {
70+
// pg_connect used by Doctrine DBAL does not support [...] notation,
71+
// but requires the host address in plain form like `aa:bb:99...`
72+
$matches = [];
73+
if (isset($params['host']) && preg_match('/^\[(.+)\]$/', $params['host'], $matches) === 1) {
74+
$params['hostaddr'] = $matches[1];
75+
unset($params['host']);
76+
}
77+
6978
$components = array_filter(
7079
[
7180
'host' => $params['host'] ?? null,
81+
'hostaddr' => $params['hostaddr'] ?? null,
7282
'port' => $params['port'] ?? null,
7383
'dbname' => $params['dbname'] ?? 'postgres',
7484
'user' => $params['user'] ?? null,

src/Driver/PgSQL/Statement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function __construct(
3939

4040
public function __destruct()
4141
{
42+
// @phpstan-ignore isset.initializedProperty
4243
if (! isset($this->connection)) {
4344
return;
4445
}

tests/Driver/PgSQL/DriverTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\DBAL\Tests\Driver\PgSQL;
6+
7+
use Doctrine\DBAL\Driver as DriverInterface;
8+
use Doctrine\DBAL\Driver\PgSQL\Driver;
9+
use Doctrine\DBAL\Tests\Driver\AbstractPostgreSQLDriverTestCase;
10+
use Doctrine\DBAL\Tests\TestUtil;
11+
12+
use function in_array;
13+
14+
class DriverTest extends AbstractPostgreSQLDriverTestCase
15+
{
16+
protected function setUp(): void
17+
{
18+
parent::setUp();
19+
20+
if (isset($GLOBALS['db_driver']) && $GLOBALS['db_driver'] === 'pgsql') {
21+
return;
22+
}
23+
24+
self::markTestSkipped('Test enabled only when using pgsql specific phpunit.xml');
25+
}
26+
27+
/**
28+
* Ensure we can handle URI notation for IPv6 addresses
29+
*/
30+
public function testConnectionIPv6(): void
31+
{
32+
if (! in_array($GLOBALS['db_host'], ['localhost', '127.0.0.1', '[::1]'], true)) {
33+
// We cannot assume that every contributor runs the same setup as our CI
34+
self::markTestSkipped('This test only works if there is a Postgres server listening on localhost.');
35+
}
36+
37+
self::expectNotToPerformAssertions();
38+
39+
$params = TestUtil::getConnectionParams();
40+
$params['host'] = '[::1]';
41+
42+
$this->driver->connect($params);
43+
}
44+
45+
protected function createDriver(): DriverInterface
46+
{
47+
return new Driver();
48+
}
49+
}

0 commit comments

Comments
 (0)