diff --git a/composer.json b/composer.json index 4fa76294ba7..898cf464328 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "doctrine/event-manager": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "8.2.0", + "doctrine/coding-standard": "9.0.0", "jetbrains/phpstorm-stubs": "2020.2", "phpstan/phpstan": "0.12.81", "phpunit/phpunit": "^7.5.20|^8.5|9.5.0", diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 67ffe820341..23c2af2ccc2 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -178,11 +178,10 @@ class Connection implements DriverConnection * @param Driver $driver The driver to use. * @param Configuration|null $config The configuration, optional. * @param EventManager|null $eventManager The event manager, optional. + * @psalm-param Params $params + * @phpstan-param array $params * * @throws Exception - * - * @phpstan-param array $params - * @psalm-param Params $params */ public function __construct( array $params, @@ -229,9 +228,8 @@ public function __construct( * @internal * * @return array - * - * @phpstan-return array * @psalm-return Params + * @phpstan-return array */ public function getParams() { @@ -2200,9 +2198,9 @@ public function ping() * @param array|array $params * @param array|array $types * - * @throws Exception - * * @psalm-return never-return + * + * @throws Exception */ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void { @@ -2219,9 +2217,9 @@ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $par /** * @internal * - * @throws Exception - * * @psalm-return never-return + * + * @throws Exception */ public function handleDriverException(Throwable $e): void { @@ -2236,9 +2234,9 @@ public function handleDriverException(Throwable $e): void /** * @internal * - * @throws Exception - * * @psalm-return never-return + * + * @throws Exception */ private function throw(Exception $e): void { diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index ccbcff31892..be1d0b61b7a 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -5,13 +5,14 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\DriverManager; use Doctrine\Deprecations\Deprecation; use InvalidArgumentException; /** * @deprecated Use PrimaryReadReplicaConnection instead * - * @psalm-import-type Params from \Doctrine\DBAL\DriverManager + * @psalm-import-type Params from DriverManager */ class MasterSlaveConnection extends PrimaryReadReplicaConnection { @@ -21,11 +22,10 @@ class MasterSlaveConnection extends PrimaryReadReplicaConnection * @internal The connection can be only instantiated by the driver manager. * * @param array $params + * @psalm-param Params $params + * @phpstan-param array $params * * @throws InvalidArgumentException - * - * @phpstan-param array $params - * @psalm-param Params $params */ public function __construct( array $params, diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index e2ee5d12f31..2a1fa39dd3c 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; use InvalidArgumentException; @@ -56,7 +57,7 @@ * * Instantiation through the DriverManager looks like: * - * @psalm-import-type Params from \Doctrine\DBAL\DriverManager + * @psalm-import-type Params from DriverManager * @example * * $conn = DriverManager::getConnection(array( @@ -95,11 +96,10 @@ class PrimaryReadReplicaConnection extends Connection * @internal The connection can be only instantiated by the driver manager. * * @param array $params + * @psalm-param Params $params + * @phpstan-param array $params * * @throws InvalidArgumentException - * - * @phpstan-param array $params - * @psalm-param Params $params */ public function __construct( array $params, diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 2a4b6539250..d084e220340 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -156,10 +156,6 @@ private function __construct() * @param array $params * @param Configuration|null $config The configuration to use. * @param EventManager|null $eventManager The event manager to use. - * - * @throws Exception - * - * @phpstan-param array $params * @psalm-param array{ * charset?: string, * dbname?: string, @@ -184,7 +180,12 @@ private function __construct() * user?: string, * wrapperClass?: class-string, * } $params + * @phpstan-param array $params + * * @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection) + * + * @throws Exception + * * @template T of Connection */ public static function getConnection( @@ -281,11 +282,10 @@ public static function getAvailableDrivers(): array /** * @param array $params + * @psalm-param Params $params + * @phpstan-param array $params * * @throws Exception - * - * @phpstan-param array $params - * @psalm-param Params $params */ private static function createDriver(array $params): Driver { @@ -328,16 +328,15 @@ private static function normalizeDatabaseUrlPath(string $urlPath): string * updated list of parameters. * * @param mixed[] $params The list of parameters. + * @psalm-param Params $params + * @phpstan-param array $params * * @return mixed[] A modified list of parameters with info from a database * URL extracted into indidivual parameter parts. + * @psalm-return Params + * @phpstan-return array * * @throws Exception - * - * @phpstan-param array $params - * @phpstan-return array - * @psalm-param Params $params - * @psalm-return Params */ private static function parseDatabaseUrl(array $params): array { diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index bc9ce694be0..7e58d5f351b 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3658,10 +3658,9 @@ final public function getReservedKeywordsList() * Returns the class name of the reserved keywords list. * * @return string + * @psalm-return class-string * * @throws Exception If not supported on this platform. - * - * @psalm-return class-string */ protected function getReservedKeywordsClass() { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index b7d41ac233a..43d3af6fe7f 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -76,10 +76,6 @@ lib/Doctrine/DBAL/Events.php - - tests/Doctrine/Tests/DBAL/Tools/TestAsset/* - - lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -125,11 +121,6 @@ lib/Doctrine/DBAL/Driver/PDOConnection.php - - */lib/Doctrine/DBAL/Driver/PDOConnection.php - */lib/Doctrine/DBAL/Driver/PDOStatement.php - - lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index cfdeddff366..36a3a4b9398 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -352,10 +352,9 @@ public function testConnectionExceptionSqLite(): void /** * @param array $params + * @psalm-param Params $params * * @dataProvider getConnectionParams - * - * @psalm-param Params $params */ public function testConnectionException(array $params): void { diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index b063e8334d2..7830f7608c4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -15,7 +15,7 @@ use const CASE_LOWER; /** - * @psalm-import-type Params from \Doctrine\DBAL\DriverManager + * @psalm-import-type Params from DriverManager */ class MasterSlaveConnectionTest extends DbalFunctionalTestCase { @@ -55,7 +55,6 @@ private function createMasterSlaveConnection(bool $keepSlave = false): MasterSla /** * @return mixed[] - * * @psalm-return Params */ private function createMasterSlaveConnectionParams(bool $keepSlave = false): array diff --git a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php index d7c5d90b9a5..86990ec34b1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php @@ -16,7 +16,7 @@ /** * @group DBAL-20 - * @psalm-import-type Params from \Doctrine\DBAL\DriverManager + * @psalm-import-type Params from DriverManager */ class PrimaryReadReplicaConnectionTest extends DbalFunctionalTestCase { @@ -56,7 +56,6 @@ private function createPrimaryReadReplicaConnection(bool $keepReplica = false): /** * @return mixed[] - * * @psalm-return Params */ private function createPrimaryReadReplicaConnectionParams(bool $keepReplica = false): array diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php index c1209dedd62..882b7265456 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\MySqlSchemaManager; @@ -18,7 +19,7 @@ use function array_merge; /** - * @psalm-import-type Params from \Doctrine\DBAL\DriverManager + * @psalm-import-type Params from DriverManager */ class MySqlInheritCharsetTest extends TestCase { @@ -77,10 +78,9 @@ public function testTableOptions(): void /** * @param array $params + * @psalm-param Params $params * * @return string[] - * - * @psalm-param Params $params */ private function getTableOptionsForOverride(array $params = []): array {