Skip to content

Commit

Permalink
Merge branch '4.1.x' into 4.1.0-rsm
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrellmann committed Sep 19, 2024
2 parents 7ff0c97 + 7a82524 commit d164e06
Show file tree
Hide file tree
Showing 43 changed files with 581 additions and 397 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -628,4 +628,4 @@ jobs:
directory: reports
fail_ci_if_error: true
env:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 0 additions & 1 deletion ci/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/appveyor/mssql.sql2017.sqlsrv.appveyor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/ibm_db2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/mysqli-tls.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/mysqli.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/oci8-21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/oci8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_mysql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_oci-21.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_oci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_sqlite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pdo_sqlsrv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/pgsql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/sqlite3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 0 additions & 1 deletion ci/github/phpunit/sqlsrv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
xsi:noNamespaceSchemaLocation="../../../vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
"doctrine/coding-standard": "12.0.0",
"fig/log-test": "^1",
"jetbrains/phpstorm-stubs": "2023.2",
"phpstan/phpstan": "1.11.7",
"phpstan/phpstan": "1.12.0",
"phpstan/phpstan-phpunit": "1.4.0",
"phpstan/phpstan-strict-rules": "^1.6",
"phpunit/phpunit": "10.5.28",
"phpunit/phpunit": "10.5.30",
"psalm/plugin-phpunit": "0.19.0",
"slevomat/coding-standard": "8.13.1",
"squizlabs/php_codesniffer": "3.10.2",
"symfony/cache": "^6.3.8|^7.0",
"symfony/console": "^5.4|^6.3|^7.0",
"vimeo/psalm": "5.24.0"
"vimeo/psalm": "5.25.0"
},
"suggest": {
"symfony/console": "For helpful console commands such as SQL execution and import of files."
Expand Down
2 changes: 1 addition & 1 deletion docs/en/reference/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ Connect to your Postgres server and run the ``SHOW server_version`` query::
(1 row)

In the example above, ``15.2 (Debian 15.2-1.pgdg110+1)`` is the correct value for
``server Version``.
``serverVersion``.

Other Platforms
^^^^^^^^^^^^^^^
Expand Down
3 changes: 3 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ parameters:
-
message: '~^Parameter #1 \$driverOptions of method Doctrine\\DBAL\\Tests\\Functional\\Driver\\Mysqli\\ConnectionTest\:\:getConnection\(\) expects array<string, mixed>, .* given\.$~'
path: tests/Functional/Driver/Mysqli/ConnectionTest.php
-
message: '~^Parameter #1 \$params of method Doctrine\\DBAL\\Driver\:\:connect\(\) expects array~'
path: tests/Driver/PDO/*/DriverTest.php

# DriverManagerTest::testDatabaseUrl() should be refactored as it's too dynamic.
-
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
failOnRisky="true"
failOnWarning="true"
>
Expand Down
1 change: 1 addition & 0 deletions psalm.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
<InvalidArgument>
<errorLevel type="suppress">
<!-- We're testing with invalid input here. -->
<file name="tests/Driver/PDO/*/DriverTest.php"/>
<file name="tests/Functional/Driver/Mysqli/ConnectionTest.php"/>
<file name="tests/Platforms/AbstractPlatformTestCase.php"/>
</errorLevel>
Expand Down
7 changes: 2 additions & 5 deletions src/Cache/ArrayResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ public function columnCount(): int

public function getColumnName(int $index): string
{
if ($this->data === [] || $index > count($this->data[0])) {
throw InvalidColumnIndex::new($index);
}

return array_keys($this->data[0])[$index];
return array_keys($this->data[0] ?? [])[$index]
?? throw InvalidColumnIndex::new($index);
}

public function free(): void
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/AbstractMySQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function getMariaDbMysqlVersionNumber(string $versionString): string
'/^(?:5\.5\.5-)?(mariadb-)?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)/i',
$versionString,
$versionParts,
) === 0
) !== 1
) {
throw InvalidPlatformVersion::new(
$versionString,
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/AbstractPostgreSQLDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getDatabasePlatform(ServerVersionProvider $versionProvider): Pos
{
$version = $versionProvider->getServerVersion();

if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts) === 0) {
if (preg_match('/^(?P<major>\d+)(?:\.(?P<minor>\d+)(?:\.(?P<patch>\d+))?)?/', $version, $versionParts) !== 1) {
throw InvalidPlatformVersion::new(
$version,
'<major_version>.<minor_version>.<patch_version>',
Expand Down
23 changes: 23 additions & 0 deletions src/Driver/PDO/Exception/InvalidConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Doctrine\DBAL\Driver\PDO\Exception;

use Doctrine\DBAL\Driver\AbstractException;

use function get_debug_type;
use function sprintf;

/** @psalm-immutable */
final class InvalidConfiguration extends AbstractException
{
public static function notAStringOrNull(string $key, mixed $value): self
{
return new self(sprintf(
'The %s configuration parameter is expected to be either a string or null, got %s.',
$key,
get_debug_type($value),
));
}
}
9 changes: 9 additions & 0 deletions src/Driver/PDO/MySQL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\PDO\Connection;
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDO\Exception\InvalidConfiguration;
use PDO;
use PDOException;
use SensitiveParameter;

use function is_string;

final class Driver extends AbstractMySQLDriver
{
/**
Expand All @@ -26,6 +29,12 @@ public function connect(
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

foreach (['user', 'password'] as $key) {
if (isset($params[$key]) && ! is_string($params[$key])) {
throw InvalidConfiguration::notAStringOrNull($key, $params[$key]);
}
}

$safeParams = $params;
unset($safeParams['password']);

Expand Down
9 changes: 9 additions & 0 deletions src/Driver/PDO/OCI/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Driver\PDO\Connection;
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDO\Exception\InvalidConfiguration;
use PDO;
use PDOException;
use SensitiveParameter;

use function is_string;

final class Driver extends AbstractOracleDriver
{
/**
Expand All @@ -26,6 +29,12 @@ public function connect(
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

foreach (['user', 'password'] as $key) {
if (isset($params[$key]) && ! is_string($params[$key])) {
throw InvalidConfiguration::notAStringOrNull($key, $params[$key]);
}
}

$safeParams = $params;
unset($safeParams['password']);

Expand Down
9 changes: 9 additions & 0 deletions src/Driver/PDO/PgSQL/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\PDO\Connection;
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDO\Exception\InvalidConfiguration;
use PDO;
use PDOException;
use SensitiveParameter;

use function is_string;

final class Driver extends AbstractPostgreSQLDriver
{
/**
Expand All @@ -26,6 +29,12 @@ public function connect(
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

foreach (['user', 'password'] as $key) {
if (isset($params[$key]) && ! is_string($params[$key])) {
throw InvalidConfiguration::notAStringOrNull($key, $params[$key]);
}
}

$safeParams = $params;
unset($safeParams['password']);

Expand Down
15 changes: 9 additions & 6 deletions src/Driver/PDO/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PDO;
use PDOException;
use PDOStatement;
use ValueError;

final class Result implements ResultInterface
{
Expand Down Expand Up @@ -78,15 +79,17 @@ public function getColumnName(int $index): string
{
try {
$meta = $this->statement->getColumnMeta($index);

if ($meta === false) {
throw InvalidColumnIndex::new($index);
}

return $meta['name'];
} catch (ValueError $exception) {
throw InvalidColumnIndex::new($index, $exception);
} catch (PDOException $exception) {
throw Exception::new($exception);
}

if ($meta === false) {
throw InvalidColumnIndex::new($index);
}

return $meta['name'];
}

public function free(): void
Expand Down
8 changes: 8 additions & 0 deletions src/Driver/PDO/SQLSrv/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
use Doctrine\DBAL\Driver\Exception;
use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection;
use Doctrine\DBAL\Driver\PDO\Exception as PDOException;
use Doctrine\DBAL\Driver\PDO\Exception\InvalidConfiguration;
use PDO;
use SensitiveParameter;

use function is_int;
use function is_string;
use function sprintf;

final class Driver extends AbstractSQLServerDriver
Expand Down Expand Up @@ -40,6 +42,12 @@ public function connect(
$driverOptions[PDO::ATTR_PERSISTENT] = true;
}

foreach (['user', 'password'] as $key) {
if (isset($params[$key]) && ! is_string($params[$key])) {
throw InvalidConfiguration::notAStringOrNull($key, $params[$key]);
}
}

$safeParams = $params;
unset($safeParams['password']);

Expand Down
Loading

0 comments on commit d164e06

Please sign in to comment.