From 84328cd947706210caebcaea3ca0394b3ebc4673 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 27 Jan 2020 15:10:06 +0100 Subject: [PATCH 01/93] Replace andX/orX with and/or --- UPGRADE.md | 6 ++++ docs/en/reference/query-builder.rst | 4 +-- .../Query/Expression/ExpressionBuilder.php | 36 +++++++++++-------- .../Expression/ExpressionBuilderTest.php | 16 ++++----- .../Tests/DBAL/Query/QueryBuilderTest.php | 2 +- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 205bf991974..e6f03cfc34f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,3 +1,9 @@ +# Upgrade to 2.11 + +## Deprecated `ExpressionBuilder` methods + +The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class has been deprecated. Use `and()` and `or()` instead. + # Upgrade to 2.10 ## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods diff --git a/docs/en/reference/query-builder.rst b/docs/en/reference/query-builder.rst index 059a70bef5f..3c201df41d2 100644 --- a/docs/en/reference/query-builder.rst +++ b/docs/en/reference/query-builder.rst @@ -332,13 +332,13 @@ Most notably you can use expressions to build nested And-/Or statements: ->select('id', 'name') ->from('users') ->where( - $queryBuilder->expr()->andX( + $queryBuilder->expr()->and( $queryBuilder->expr()->eq('username', '?'), $queryBuilder->expr()->eq('email', '?') ) ); -The ``andX()`` and ``orX()`` methods accept an arbitrary amount +The ``and()`` and ``or()`` methods accept an arbitrary amount of arguments and can be nested in each other. There is a bunch of methods to create comparisons and other SQL snippets diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index dfcc31ec709..b8649b5e1d8 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -39,13 +39,27 @@ public function __construct(Connection $connection) } /** - * Creates a conjunction of the given boolean expressions. + * Creates a conjunction of the given expressions. * - * Example: + * @param string|CompositeExpression ...$expressions Requires at least one defined when converting to string. + */ + public function and(...$expressions) : CompositeExpression + { + return new CompositeExpression(CompositeExpression::TYPE_AND, $expressions); + } + + /** + * Creates a disjunction of the given expressions. * - * [php] - * // (u.type = ?) AND (u.role = ?) - * $expr->andX('u.type = ?', 'u.role = ?')); + * @param string|CompositeExpression ...$expressions Requires at least one defined when converting to string. + */ + public function or(...$expressions) : CompositeExpression + { + return new CompositeExpression(CompositeExpression::TYPE_OR, $expressions); + } + + /** + * @deprecated Use `and()` instead. * * @param mixed $x Optional clause. Defaults = null, but requires * at least one defined when converting to string. @@ -54,17 +68,11 @@ public function __construct(Connection $connection) */ public function andX($x = null) { - return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); + return $this->and(...func_get_args()); } /** - * Creates a disjunction of the given boolean expressions. - * - * Example: - * - * [php] - * // (u.type = ?) OR (u.role = ?) - * $qb->where($qb->expr()->orX('u.type = ?', 'u.role = ?')); + * @deprecated Use `or()` instead. * * @param mixed $x Optional clause. Defaults = null, but requires * at least one defined when converting to string. @@ -73,7 +81,7 @@ public function andX($x = null) */ public function orX($x = null) { - return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args()); + return $this->or(...func_get_args()); } /** diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 817007d67d6..5f5d3d6aad1 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -29,11 +29,11 @@ protected function setUp() : void /** * @param string[]|CompositeExpression[] $parts * - * @dataProvider provideDataForAndX + * @dataProvider provideDataForAnd */ - public function testAndX(array $parts, string $expected) : void + public function testAnd(array $parts, string $expected) : void { - $composite = $this->expr->andX(); + $composite = $this->expr->and(); foreach ($parts as $part) { $composite->add($part); @@ -45,7 +45,7 @@ public function testAndX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForAndX() : iterable + public static function provideDataForAnd() : iterable { return [ [ @@ -90,11 +90,11 @@ public static function provideDataForAndX() : iterable /** * @param string[]|CompositeExpression[] $parts * - * @dataProvider provideDataForOrX + * @dataProvider provideDataForOr */ - public function testOrX(array $parts, string $expected) : void + public function testOr(array $parts, string $expected) : void { - $composite = $this->expr->orX(); + $composite = $this->expr->or(); foreach ($parts as $part) { $composite->add($part); @@ -106,7 +106,7 @@ public function testOrX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForOrX() : iterable + public static function provideDataForOr() : iterable { return [ [ diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index a210ef2fe73..7397ee34296 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -68,7 +68,7 @@ public function testSelectWithSimpleWhere() : void $qb->select('u.id') ->from('users', 'u') - ->where($expr->andX($expr->eq('u.nickname', '?'))); + ->where($expr->and($expr->eq('u.nickname', '?'))); self::assertEquals('SELECT u.id FROM users u WHERE u.nickname = ?', (string) $qb); } From 4566a9b6ff15d2cd4e789b6852b0d872cae6def0 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Tue, 28 Jan 2020 15:51:23 +0100 Subject: [PATCH 02/93] First parameter of ExpressionBuilder::and/or() mandatory --- .../Query/Expression/ExpressionBuilder.php | 19 +++++++------ .../Expression/ExpressionBuilderTest.php | 28 +++++++++++++++++-- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index b8649b5e1d8..b946c88f9ac 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Doctrine\DBAL\Connection; +use function array_merge; use function func_get_arg; use function func_get_args; use function func_num_args; @@ -41,21 +42,23 @@ public function __construct(Connection $connection) /** * Creates a conjunction of the given expressions. * - * @param string|CompositeExpression ...$expressions Requires at least one defined when converting to string. + * @param string|CompositeExpression $expression + * @param string|CompositeExpression ...$expressions */ - public function and(...$expressions) : CompositeExpression + public function and($expression, ...$expressions) : CompositeExpression { - return new CompositeExpression(CompositeExpression::TYPE_AND, $expressions); + return new CompositeExpression(CompositeExpression::TYPE_AND, array_merge([$expression], $expressions)); } /** * Creates a disjunction of the given expressions. * - * @param string|CompositeExpression ...$expressions Requires at least one defined when converting to string. + * @param string|CompositeExpression $expression + * @param string|CompositeExpression ...$expressions */ - public function or(...$expressions) : CompositeExpression + public function or($expression, ...$expressions) : CompositeExpression { - return new CompositeExpression(CompositeExpression::TYPE_OR, $expressions); + return new CompositeExpression(CompositeExpression::TYPE_OR, array_merge([$expression], $expressions)); } /** @@ -68,7 +71,7 @@ public function or(...$expressions) : CompositeExpression */ public function andX($x = null) { - return $this->and(...func_get_args()); + return new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); } /** @@ -81,7 +84,7 @@ public function andX($x = null) */ public function orX($x = null) { - return $this->or(...func_get_args()); + return new CompositeExpression(CompositeExpression::TYPE_OR, func_get_args()); } /** diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 5f5d3d6aad1..190ff99e4e4 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -33,7 +33,19 @@ protected function setUp() : void */ public function testAnd(array $parts, string $expected) : void { - $composite = $this->expr->and(); + $composite = $this->expr->and(...$parts); + + self::assertEquals($expected, (string) $composite); + } + + /** + * @param string[]|CompositeExpression[] $parts + * + * @dataProvider provideDataForAnd + */ + public function testAndX(array $parts, string $expected) : void + { + $composite = $this->expr->andX(); foreach ($parts as $part) { $composite->add($part); @@ -94,7 +106,19 @@ public static function provideDataForAnd() : iterable */ public function testOr(array $parts, string $expected) : void { - $composite = $this->expr->or(); + $composite = $this->expr->or(...$parts); + + self::assertEquals($expected, (string) $composite); + } + + /** + * @param string[]|CompositeExpression[] $parts + * + * @dataProvider provideDataForOr + */ + public function testOrX(array $parts, string $expected) : void + { + $composite = $this->expr->orX(); foreach ($parts as $part) { $composite->add($part); From 20324a4f39adfb71861ba910252f73f19cf5f7ea Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Mon, 27 Jan 2020 11:18:58 +0100 Subject: [PATCH 03/93] Add CompositeExpression::with(), deprecate add*() --- UPGRADE.md | 5 ++++ .../Query/Expression/CompositeExpression.php | 23 +++++++++++++++++++ lib/Doctrine/DBAL/Query/QueryBuilder.php | 8 +++---- .../Expression/CompositeExpressionTest.php | 22 +++++++++++++++++- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index e6f03cfc34f..beed13b5732 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,6 +4,11 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class has been deprecated. Use `and()` and `or()` instead. +## Deprecated `CompositeExpression` methods + +The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance. +In the future, the `add*()` methods will be removed and the class will be effectively immutable. + # Upgrade to 2.10 ## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 443d71bc37e..204a356c2f2 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -49,6 +49,8 @@ public function __construct($type, array $parts = []) /** * Adds multiple parts to composite expression. * + * @deprecated This class will be made immutable. Use with() instead. + * * @param self[]|string[] $parts * * @return \Doctrine\DBAL\Query\Expression\CompositeExpression @@ -65,6 +67,8 @@ public function addMultiple(array $parts = []) /** * Adds an expression to composite expression. * + * @deprecated This class will be made immutable. Use with() instead. + * * @param mixed $part * * @return \Doctrine\DBAL\Query\Expression\CompositeExpression @@ -84,6 +88,25 @@ public function add($part) return $this; } + /** + * Returns a new CompositeExpression with the given parts added. + * + * @param self|string $part + * @param self|string ...$parts + */ + public function with($part, ...$parts) : self + { + $that = clone $this; + + $that->parts[] = $part; + + foreach ($parts as $part) { + $that->parts[] = $part; + } + + return $that; + } + /** * Retrieves the amount of expressions on composite expression. * diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 587e26656ab..58d7062f0a7 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -823,7 +823,7 @@ public function andWhere($where) $where = $this->getQueryPart('where'); if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_AND) { - $where->addMultiple($args); + $where = $where->with(...$args); } else { array_unshift($args, $where); $where = new CompositeExpression(CompositeExpression::TYPE_AND, $args); @@ -856,7 +856,7 @@ public function orWhere($where) $where = $this->getQueryPart('where'); if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_OR) { - $where->addMultiple($args); + $where = $where->with(...$args); } else { array_unshift($args, $where); $where = new CompositeExpression(CompositeExpression::TYPE_OR, $args); @@ -998,7 +998,7 @@ public function andHaving($having) $having = $this->getQueryPart('having'); if ($having instanceof CompositeExpression && $having->getType() === CompositeExpression::TYPE_AND) { - $having->addMultiple($args); + $having = $having->with(...$args); } else { array_unshift($args, $having); $having = new CompositeExpression(CompositeExpression::TYPE_AND, $args); @@ -1021,7 +1021,7 @@ public function orHaving($having) $having = $this->getQueryPart('having'); if ($having instanceof CompositeExpression && $having->getType() === CompositeExpression::TYPE_OR) { - $having->addMultiple($args); + $having = $having->with(...$args); } else { array_unshift($args, $having); $having = new CompositeExpression(CompositeExpression::TYPE_OR, $args); diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php index 0a8492f795f..fd02e25f6f7 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php @@ -16,7 +16,7 @@ public function testCount() : void self::assertCount(1, $expr); - $expr->add('u.group_id = 2'); + $expr = $expr->with('u.group_id = 2'); self::assertCount(2, $expr); } @@ -44,6 +44,26 @@ public function testAdd() : void self::assertCount(3, $expr); } + public function testWith() : void + { + $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); + + self::assertCount(1, $expr); + + // test immutability + $expr->with(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1'])); + + self::assertCount(1, $expr); + + $expr = $expr->with(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1'])); + + self::assertCount(2, $expr); + + $expr = $expr->with('u.user_id = 1'); + + self::assertCount(3, $expr); + } + /** * @param string[]|CompositeExpression[] $parts * From ebfe1851a86f719e42d1dac40e5287251169c984 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Tue, 28 Jan 2020 23:14:41 +0100 Subject: [PATCH 04/93] Deprecate calling QueryBuilder methods with an array argument --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Query/QueryBuilder.php | 28 +++++++++++++++++------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index beed13b5732..63dd8b279dd 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -9,6 +9,10 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class h The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance. In the future, the `add*()` methods will be removed and the class will be effectively immutable. +## Deprecated calling `QueryBuilder` methods with an array argument + +Calling the `select()`, `addSelect()`, `groupBy()` and `addGroupBy()` methods with an array argument is deprecated. + # Upgrade to 2.10 ## Deprecated `Doctrine\DBAL\Event\ConnectionEventArgs` methods diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 58d7062f0a7..c6c43ea1c72 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -451,6 +451,8 @@ public function add($sqlPartName, $sqlPart, $append = false) * Specifies an item that is to be returned in the query result. * Replaces any previously specified selections, if any. * + * USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument. + * * * $qb = $conn->createQueryBuilder() * ->select('u.id', 'p.id') @@ -458,11 +460,12 @@ public function add($sqlPartName, $sqlPart, $append = false) * ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id'); * * - * @param mixed $select The selection expressions. + * @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED. + * Pass each value as an individual argument. * * @return $this This QueryBuilder instance. */ - public function select($select = null) + public function select($select = null/*, string ...$selects*/) { $this->type = self::SELECT; @@ -497,6 +500,8 @@ public function distinct() : self /** * Adds an item that is to be returned in the query result. * + * USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument. + * * * $qb = $conn->createQueryBuilder() * ->select('u.id') @@ -505,11 +510,12 @@ public function distinct() : self * ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id'); * * - * @param mixed $select The selection expression. + * @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED. + * Pass each value as an individual argument. * * @return $this This QueryBuilder instance. */ - public function addSelect($select = null) + public function addSelect($select = null/*, string ...$selects*/) { $this->type = self::SELECT; @@ -869,6 +875,8 @@ public function orWhere($where) * Specifies a grouping over the results of the query. * Replaces any previously specified groupings, if any. * + * USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument. + * * * $qb = $conn->createQueryBuilder() * ->select('u.name') @@ -876,11 +884,12 @@ public function orWhere($where) * ->groupBy('u.id'); * * - * @param mixed $groupBy The grouping expression. + * @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED. + * Pass each value as an individual argument. * * @return $this This QueryBuilder instance. */ - public function groupBy($groupBy) + public function groupBy($groupBy/*, string ...$groupBys*/) { if (empty($groupBy)) { return $this; @@ -894,6 +903,8 @@ public function groupBy($groupBy) /** * Adds a grouping expression to the query. * + * USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument. + * * * $qb = $conn->createQueryBuilder() * ->select('u.name') @@ -902,11 +913,12 @@ public function groupBy($groupBy) * ->addGroupBy('u.createdAt'); * * - * @param mixed $groupBy The grouping expression. + * @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED. + * Pass each value as an individual argument. * * @return $this This QueryBuilder instance. */ - public function addGroupBy($groupBy) + public function addGroupBy($groupBy/*, string ...$groupBys*/) { if (empty($groupBy)) { return $this; From 1d0ebf043064406225f1b4bd1bb95e8c16e189fa Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 29 Jan 2020 16:29:57 -0800 Subject: [PATCH 05/93] Deprecated the usage of the Version class --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Version.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 63dd8b279dd..49026ba922f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecated `Doctrine\DBAL\Version` class + +The usage of the `Doctrine\DBAL\Version` class is deprecated as internal implementation detail. Please refrain from checking the DBAL version at runtime. + ## Deprecated `ExpressionBuilder` methods The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class has been deprecated. Use `and()` and `or()` instead. diff --git a/lib/Doctrine/DBAL/Version.php b/lib/Doctrine/DBAL/Version.php index e5e4b9566f6..7c552d537c3 100644 --- a/lib/Doctrine/DBAL/Version.php +++ b/lib/Doctrine/DBAL/Version.php @@ -8,6 +8,9 @@ /** * Class to store and retrieve the version of Doctrine. + * + * @internal + * @deprecated Refrain from checking the DBAL version at runtime. */ class Version { From 1d503253ff57987161f10d4f2c81b5a9889d48a4 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Thu, 30 Jan 2020 13:06:36 +0100 Subject: [PATCH 06/93] CompositeExpression and()/or() factory methods --- UPGRADE.md | 3 ++- .../Query/Expression/CompositeExpression.php | 13 ++++++++++ .../Query/Expression/ExpressionBuilder.php | 5 ++-- lib/Doctrine/DBAL/Query/QueryBuilder.php | 12 +++++----- .../Expression/CompositeExpressionTest.php | 24 +++++++++---------- .../Expression/ExpressionBuilderTest.php | 24 +++++++++---------- 6 files changed, 47 insertions(+), 34 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 63dd8b279dd..964c210e888 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -6,8 +6,9 @@ The usage of the `andX()` and `orX()` methods of the `ExpressionBuilder` class h ## Deprecated `CompositeExpression` methods -The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance. +- The usage of the `add()` and `addMultiple()` methods of the `CompositeExpression` class has been deprecated. Use `with()` instead, which returns a new instance. In the future, the `add*()` methods will be removed and the class will be effectively immutable. +- The usage of the `CompositeExpression` constructor has been deprecated. Use the `and()` / `or()` factory methods. ## Deprecated calling `QueryBuilder` methods with an array argument diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 204a356c2f2..0048d228ced 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Countable; +use function array_merge; use function count; use function implode; @@ -36,6 +37,8 @@ class CompositeExpression implements Countable private $parts = []; /** + * @internal Use the and() / or() factory methods. + * * @param string $type Instance type of composite expression. * @param self[]|string[] $parts Composition of expressions to be joined on composite expression. */ @@ -46,6 +49,16 @@ public function __construct($type, array $parts = []) $this->addMultiple($parts); } + public static function and($part, ...$parts) : self + { + return new self(self::TYPE_AND, array_merge([$part], $parts)); + } + + public static function or($part, ...$parts) : self + { + return new self(self::TYPE_OR, array_merge([$part], $parts)); + } + /** * Adds multiple parts to composite expression. * diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index b946c88f9ac..ef0e6eebb00 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -3,7 +3,6 @@ namespace Doctrine\DBAL\Query\Expression; use Doctrine\DBAL\Connection; -use function array_merge; use function func_get_arg; use function func_get_args; use function func_num_args; @@ -47,7 +46,7 @@ public function __construct(Connection $connection) */ public function and($expression, ...$expressions) : CompositeExpression { - return new CompositeExpression(CompositeExpression::TYPE_AND, array_merge([$expression], $expressions)); + return CompositeExpression::and($expression, ...$expressions); } /** @@ -58,7 +57,7 @@ public function and($expression, ...$expressions) : CompositeExpression */ public function or($expression, ...$expressions) : CompositeExpression { - return new CompositeExpression(CompositeExpression::TYPE_OR, array_merge([$expression], $expressions)); + return CompositeExpression::or($expression, ...$expressions); } /** diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index c6c43ea1c72..d7b70a5d4ef 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -799,7 +799,7 @@ public function set($key, $value) public function where($predicates) { if (! (func_num_args() === 1 && $predicates instanceof CompositeExpression)) { - $predicates = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); + $predicates = CompositeExpression::and(...func_get_args()); } return $this->add('where', $predicates); @@ -832,7 +832,7 @@ public function andWhere($where) $where = $where->with(...$args); } else { array_unshift($args, $where); - $where = new CompositeExpression(CompositeExpression::TYPE_AND, $args); + $where = CompositeExpression::and(...$args); } return $this->add('where', $where, true); @@ -865,7 +865,7 @@ public function orWhere($where) $where = $where->with(...$args); } else { array_unshift($args, $where); - $where = new CompositeExpression(CompositeExpression::TYPE_OR, $args); + $where = CompositeExpression::or(...$args); } return $this->add('where', $where, true); @@ -990,7 +990,7 @@ public function values(array $values) public function having($having) { if (! (func_num_args() === 1 && $having instanceof CompositeExpression)) { - $having = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); + $having = CompositeExpression::and(...func_get_args()); } return $this->add('having', $having); @@ -1013,7 +1013,7 @@ public function andHaving($having) $having = $having->with(...$args); } else { array_unshift($args, $having); - $having = new CompositeExpression(CompositeExpression::TYPE_AND, $args); + $having = CompositeExpression::and(...$args); } return $this->add('having', $having); @@ -1036,7 +1036,7 @@ public function orHaving($having) $having = $having->with(...$args); } else { array_unshift($args, $having); - $having = new CompositeExpression(CompositeExpression::TYPE_OR, $args); + $having = CompositeExpression::or(...$args); } return $this->add('having', $having); diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php index fd02e25f6f7..1e9eee344d1 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php @@ -12,7 +12,7 @@ class CompositeExpressionTest extends DbalTestCase { public function testCount() : void { - $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); + $expr = CompositeExpression::or('u.group_id = 1'); self::assertCount(1, $expr); @@ -23,7 +23,7 @@ public function testCount() : void public function testAdd() : void { - $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); + $expr = CompositeExpression::or('u.group_id = 1'); self::assertCount(1, $expr); @@ -31,7 +31,7 @@ public function testAdd() : void self::assertCount(1, $expr); - $expr->add(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1'])); + $expr->add(CompositeExpression::or('u.user_id = 1')); self::assertCount(2, $expr); @@ -46,16 +46,16 @@ public function testAdd() : void public function testWith() : void { - $expr = new CompositeExpression(CompositeExpression::TYPE_OR, ['u.group_id = 1']); + $expr = CompositeExpression::or('u.group_id = 1'); self::assertCount(1, $expr); // test immutability - $expr->with(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1'])); + $expr->with(CompositeExpression::or('u.user_id = 1')); self::assertCount(1, $expr); - $expr = $expr->with(new CompositeExpression(CompositeExpression::TYPE_OR, ['u.user_id = 1'])); + $expr = $expr->with(CompositeExpression::or('u.user_id = 1')); self::assertCount(2, $expr); @@ -106,9 +106,9 @@ public static function provideDataForConvertToString() : iterable CompositeExpression::TYPE_AND, [ 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - ['u.group_id = 1', 'u.group_id = 2'] + CompositeExpression::or( + 'u.group_id = 1', + 'u.group_id = 2' ), ], '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))', @@ -117,9 +117,9 @@ public static function provideDataForConvertToString() : iterable CompositeExpression::TYPE_OR, [ 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - ['u.user = 1', 'u.group_id = 2'] + CompositeExpression::and( + 'u.user = 1', + 'u.group_id = 2' ), ], '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))', diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 190ff99e4e4..1c1915d7cb3 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -79,9 +79,9 @@ public static function provideDataForAnd() : iterable [ [ 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - ['u.group_id = 1', 'u.group_id = 2'] + CompositeExpression::or( + 'u.group_id = 1', + 'u.group_id = 2' ), ], '(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))', @@ -89,9 +89,9 @@ public static function provideDataForAnd() : iterable [ [ 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - ['u.user = 1', 'u.group_id = 2'] + CompositeExpression::and( + 'u.user = 1', + 'u.group_id = 2' ), ], '(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))', @@ -152,9 +152,9 @@ public static function provideDataForOr() : iterable [ [ 'u.user = 1', - new CompositeExpression( - CompositeExpression::TYPE_OR, - ['u.group_id = 1', 'u.group_id = 2'] + CompositeExpression::or( + 'u.group_id = 1', + 'u.group_id = 2' ), ], '(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))', @@ -162,9 +162,9 @@ public static function provideDataForOr() : iterable [ [ 'u.group_id = 1', - new CompositeExpression( - CompositeExpression::TYPE_AND, - ['u.user = 1', 'u.group_id = 2'] + CompositeExpression::and( + 'u.user = 1', + 'u.group_id = 2' ), ], '(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))', From 3de9903a7a526ebc0bd2bb564ee2e049749c97b1 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 16 Mar 2020 13:30:48 -0700 Subject: [PATCH 07/93] Bump version to 2.11.0-DEV --- lib/Doctrine/DBAL/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Version.php b/lib/Doctrine/DBAL/Version.php index 1326f6f07f4..454a28884e6 100644 --- a/lib/Doctrine/DBAL/Version.php +++ b/lib/Doctrine/DBAL/Version.php @@ -17,7 +17,7 @@ class Version /** * Current Doctrine Version. */ - public const VERSION = '2.10.2-DEV'; + public const VERSION = '2.11.0-DEV'; /** * Compares a Doctrine version with the current one. From 853d1cfd4f2efe4f19e62fedd11e851385ee1e72 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 17 Mar 2020 23:22:59 -0700 Subject: [PATCH 08/93] Deprecate the usage of the legacy platforms and drivers --- UPGRADE.md | 18 ++++++++++++++++ docs/en/reference/platforms.rst | 21 +++++++++---------- .../Driver/DrizzlePDOMySql/Connection.php | 3 +++ .../DBAL/Driver/DrizzlePDOMySql/Driver.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php | 2 ++ .../DBAL/Platforms/DrizzlePlatform.php | 2 ++ .../DBAL/Platforms/PostgreSQL91Platform.php | 2 ++ .../DBAL/Platforms/PostgreSQL92Platform.php | 2 ++ .../DBAL/Platforms/PostgreSqlPlatform.php | 2 ++ .../DBAL/Platforms/SQLAnywhere11Platform.php | 2 ++ .../DBAL/Platforms/SQLAnywhere12Platform.php | 2 ++ .../DBAL/Platforms/SQLAnywherePlatform.php | 2 ++ .../DBAL/Platforms/SQLAzurePlatform.php | 2 ++ .../DBAL/Platforms/SQLServer2005Platform.php | 2 ++ .../DBAL/Platforms/SQLServer2008Platform.php | 2 ++ .../DBAL/Platforms/SQLServerPlatform.php | 2 ++ .../DBAL/Sharding/PoolingShardConnection.php | 2 ++ .../DBAL/Sharding/PoolingShardManager.php | 2 ++ .../SQLAzureFederationsSynchronizer.php | 2 ++ .../SQLAzure/SQLAzureShardManager.php | 2 ++ .../SQLAzure/Schema/MultiTenantVisitor.php | 2 ++ .../ShardChoser/MultiTenantShardChoser.php | 2 ++ .../DBAL/Sharding/ShardChoser/ShardChoser.php | 2 ++ lib/Doctrine/DBAL/Sharding/ShardManager.php | 2 ++ .../DBAL/Sharding/ShardingException.php | 2 ++ 25 files changed, 75 insertions(+), 11 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 89066aaf018..6bf517e921a 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,23 @@ # Upgrade to 2.11 +## Deprecated database platforms: + +1. PostgreSQL 9.3 and older +2. MariaDB 10.0 and older +3. SQL Server 2008 and older +4. SQL Anywhere 12 and older +5. Drizzle +6. Azure SQL Database + +## Deprecated database drivers: + +1. PDO-based IBM DB2 driver +2. Drizzle MySQL driver + +## Deprecated `Doctrine\DBAL\Sharding` package + +The sharding functionality in DBAL has been effectively unmaintained for a long time. + ## Deprecated `Doctrine\DBAL\Version` class The usage of the `Doctrine\DBAL\Version` class is deprecated as internal implementation detail. Please refrain from checking the DBAL version at runtime. diff --git a/docs/en/reference/platforms.rst b/docs/en/reference/platforms.rst index 32ef74304ea..2b6516e269c 100644 --- a/docs/en/reference/platforms.rst +++ b/docs/en/reference/platforms.rst @@ -50,25 +50,25 @@ Oracle Microsoft SQL Server ^^^^^^^^^^^^^^^^^^^^ -- ``SQLServerPlatform`` for version 2000 and above. -- ``SQLServer2005Platform`` for version 2005 and above. -- ``SQLServer2008Platform`` for version 2008 and above. +- ``SQLServerPlatform`` for version 2000 and above (deprecated). +- ``SQLServer2005Platform`` for version 2005 and above (deprecated). +- ``SQLServer2008Platform`` for version 2008 and above (deprecated). - ``SQLServer2012Platform`` for version 2012 and above. PostgreSQL ^^^^^^^^^^ -- ``PostgreSqlPlatform`` for all versions. -- ``PostgreSQL91Platform`` for version 9.1 and above. -- ``PostgreSQL92Platform`` for version 9.2 and above. +- ``PostgreSqlPlatform`` for version 9.0 and below (deprecated). +- ``PostgreSQL91Platform`` for version 9.1 and above (deprecated). +- ``PostgreSQL92Platform`` for version 9.2 and above (deprecated). - ``PostgreSQL94Platform`` for version 9.4 and above. SAP Sybase SQL Anywhere ^^^^^^^^^^^^^^^^^^^^^^^ -- ``SQLAnywherePlatform`` for version 10 and above. -- ``SQLAnywhere11Platform`` for version 11 and above. -- ``SQLAnywhere12Platform`` for version 12 and above. +- ``SQLAnywherePlatform`` for version 10 and above (deprecated). +- ``SQLAnywhere11Platform`` for version 11 and above (deprecated). +- ``SQLAnywhere12Platform`` for version 12 and above (deprecated). - ``SQLAnywhere16Platform`` for version 16 and above. SQLite @@ -79,7 +79,7 @@ SQLite Drizzle ^^^^^^ -- ``DrizzlePlatform`` for all versions. +- ``DrizzlePlatform`` for all versions (deprecated). It is highly encouraged to use the platform class that matches your database vendor and version best. Otherwise it is not guaranteed @@ -113,4 +113,3 @@ all the different database vendors, for example MySQL BIGINT and Oracle NUMBER should be handled as integer. Doctrine 2 offers a powerful way to abstract the database to php and back conversion, which is described in the next section. - diff --git a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php index 4089ab26e11..058bd19e2d0 100644 --- a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php +++ b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Connection.php @@ -5,6 +5,9 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\ParameterType; +/** + * @deprecated + */ class Connection extends PDOConnection { /** diff --git a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php index dbf342814f9..37bd0729efa 100644 --- a/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/DrizzlePDOMySql/Driver.php @@ -7,6 +7,8 @@ /** * Drizzle driver using PDO MySql. + * + * @deprecated */ class Driver extends \Doctrine\DBAL\Driver\PDOMySql\Driver { diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php index 12fb14ef5cb..e57deca0c59 100644 --- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php @@ -7,6 +7,8 @@ /** * Driver for the PDO IBM extension. + * + * @deprecated Use the driver based on the ibm_db2 extension instead. */ class Driver extends AbstractDB2Driver { diff --git a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php index 8f6f0966323..8ea51c27a24 100644 --- a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php @@ -23,6 +23,8 @@ /** * Drizzle platform + * + * @deprecated */ class DrizzlePlatform extends AbstractPlatform { diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php index f558409831c..7e3aac30e07 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL91Platform.php @@ -6,6 +6,8 @@ /** * Provides the behavior, features and SQL dialect of the PostgreSQL 9.1 database platform. + * + * @deprecated Use PostgreSQL 9.4 or newer */ class PostgreSQL91Platform extends PostgreSqlPlatform { diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php index 1703056143f..c0b5675a383 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php @@ -7,6 +7,8 @@ /** * Provides the behavior, features and SQL dialect of the PostgreSQL 9.2 database platform. + * + * @deprecated Use PostgreSQL 9.4 or newer */ class PostgreSQL92Platform extends PostgreSQL91Platform { diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index dd90f2cb6b3..b5cd8f8c769 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -35,6 +35,8 @@ /** * PostgreSqlPlatform. * + * @deprecated Use PostgreSQL 9.4 or newer + * * @todo Rename: PostgreSQLPlatform */ class PostgreSqlPlatform extends AbstractPlatform diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php index a46ae9352c4..71922b22769 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywhere11Platform.php @@ -5,6 +5,8 @@ /** * The SQLAnywhere11Platform provides the behavior, features and SQL dialect of the * SAP Sybase SQL Anywhere 11 database platform. + * + * @deprecated Use SQLAnywhere 16 or newer */ class SQLAnywhere11Platform extends SQLAnywherePlatform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php index dd73ef736ad..4fb3c63f70f 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywhere12Platform.php @@ -8,6 +8,8 @@ /** * The SQLAnywhere12Platform provides the behavior, features and SQL dialect of the * SAP Sybase SQL Anywhere 12 database platform. + * + * @deprecated Use SQLAnywhere 16 or newer */ class SQLAnywhere12Platform extends SQLAnywhere11Platform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index 6e3b2fcb958..3f23733fd1f 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -33,6 +33,8 @@ /** * The SQLAnywherePlatform provides the behavior, features and SQL dialect of the * SAP Sybase SQL Anywhere 10 database platform. + * + * @deprecated Use SQLAnywhere 16 or newer */ class SQLAnywherePlatform extends AbstractPlatform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php index a104848f84e..f281f4fc4e4 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAzurePlatform.php @@ -10,6 +10,8 @@ * On top of SQL Server 2008 the following functionality is added: * * - Create tables with the FEDERATED ON syntax. + * + * @deprecated */ class SQLAzurePlatform extends SQLServer2008Platform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php index 1026a934f00..5cd3475c1e2 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2005Platform.php @@ -15,6 +15,8 @@ * NVARCHAR(max) replace the old TEXT, NTEXT and IMAGE types. See * {@link http://www.sql-server-helper.com/faq/sql-server-2005-varchar-max-p01.aspx} * for more information. + * + * @deprecated Use SQL Server 2012 or newer */ class SQLServer2005Platform extends SQLServerPlatform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php index c2e36f34e67..9cbcb3872e6 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -7,6 +7,8 @@ * * Differences to SQL Server 2005 and before are that a new DATETIME2 type was * introduced that has a higher precision. + * + * @deprecated Use SQL Server 2012 or newer */ class SQLServer2008Platform extends SQLServer2005Platform { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index a37f7c9394a..4500e973c05 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -38,6 +38,8 @@ /** * The SQLServerPlatform provides the behavior, features and SQL dialect of the * Microsoft SQL Server database platform. + * + * @deprecated Use SQL Server 2012 or newer */ class SQLServerPlatform extends AbstractPlatform { diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8d8134127d7..871b54eec9e 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -32,6 +32,8 @@ * * Instantiation through the DriverManager looks like: * + * @deprecated + * * @example * * $conn = DriverManager::getConnection(array( diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php index 5edc56b8778..2687c9d98ea 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php @@ -7,6 +7,8 @@ /** * Shard Manager for the Connection Pooling Shard Strategy + * + * @deprecated */ class PoolingShardManager implements ShardManager { diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index 417f674a3e0..e889edbc5d7 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -20,6 +20,8 @@ * by partitioning the passed schema into subschemas for the federation and the * global database and then applying the operations step by step using the * {@see \Doctrine\DBAL\Schema\Synchronizer\SingleDatabaseSynchronizer}. + * + * @deprecated */ class SQLAzureFederationsSynchronizer extends AbstractSchemaSynchronizer { diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index d8178ee07db..62a6fd48447 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -11,6 +11,8 @@ /** * Sharding using the SQL Azure Federations support. + * + * @deprecated */ class SQLAzureShardManager implements ShardManager { diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index a83b401c2cd..79ac61abdcb 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -30,6 +30,8 @@ * (otherwise they will affect the same-id rows from other tenants as well). * SQLAzure throws errors when you try to create IDENTIY columns on federated * tables. + * + * @deprecated */ class MultiTenantVisitor implements Visitor { diff --git a/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php b/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php index 584e8155ae9..f44c3af4322 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php +++ b/lib/Doctrine/DBAL/Sharding/ShardChoser/MultiTenantShardChoser.php @@ -7,6 +7,8 @@ /** * The MultiTenant Shard choser assumes that the distribution value directly * maps to the shard id. + * + * @deprecated */ class MultiTenantShardChoser implements ShardChoser { diff --git a/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php b/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php index 6f8a9d47702..92510d704b1 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php +++ b/lib/Doctrine/DBAL/Sharding/ShardChoser/ShardChoser.php @@ -7,6 +7,8 @@ /** * Given a distribution value this shard-choser strategy will pick the shard to * connect to for retrieving rows with the distribution value. + * + * @deprecated */ interface ShardChoser { diff --git a/lib/Doctrine/DBAL/Sharding/ShardManager.php b/lib/Doctrine/DBAL/Sharding/ShardManager.php index 7b37bb2c7e1..dbb229a1907 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/ShardManager.php @@ -17,6 +17,8 @@ * executed against the last shard that was selected. If a query is created for * a shard Y but then a shard X is selected when its actually executed you * will hit the wrong shard. + * + * @deprecated */ interface ShardManager { diff --git a/lib/Doctrine/DBAL/Sharding/ShardingException.php b/lib/Doctrine/DBAL/Sharding/ShardingException.php index b46bda2ff0d..419e8aa10ef 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -6,6 +6,8 @@ /** * Sharding related Exceptions + * + * @deprecated */ class ShardingException extends DBALException { From cb81e4007cec44b5a97dc573e6aff6b2fde314a1 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 28 Mar 2020 11:01:54 -0700 Subject: [PATCH 09/93] Removed performance tests --- phpunit.xml.dist | 16 +---- .../TypeConversionPerformanceTest.php | 44 ------------- .../Tests/DbalPerformanceTestCase.php | 63 ------------------ .../Tests/DbalPerformanceTestListener.php | 65 ------------------- 4 files changed, 1 insertion(+), 187 deletions(-) delete mode 100644 tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php delete mode 100644 tests/Doctrine/Tests/DbalPerformanceTestCase.php delete mode 100644 tests/Doctrine/Tests/DbalPerformanceTestListener.php diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f62532ed9f9..cef52e33c5b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -44,11 +44,7 @@ - ./tests/Doctrine/Tests/DBAL - ./tests/Doctrine/Tests/DBAL/Performance - - - ./tests/Doctrine/Tests/DBAL/Performance + tests/Doctrine/Tests/DBAL @@ -57,14 +53,4 @@ lib/Doctrine - - - - - - - - performance - - diff --git a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php b/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php deleted file mode 100644 index 6a76e90f897..00000000000 --- a/tests/Doctrine/Tests/DBAL/Performance/TypeConversionPerformanceTest.php +++ /dev/null @@ -1,44 +0,0 @@ -connection->getDatabasePlatform(); - $this->startTiming(); - for ($i = 0; $i < $count; $i++) { - $type->convertToDatabaseValue($value, $platform); - } - $this->stopTiming(); - } - - /** - * @return mixed[][] - */ - public static function itemCountProvider() : iterable - { - return [ - '100 items' => [100], - '1000 items' => [1000], - '10000 items' => [10000], - '100000 items' => [100000], - ]; - } -} diff --git a/tests/Doctrine/Tests/DbalPerformanceTestCase.php b/tests/Doctrine/Tests/DbalPerformanceTestCase.php deleted file mode 100644 index ac0beb3c5de..00000000000 --- a/tests/Doctrine/Tests/DbalPerformanceTestCase.php +++ /dev/null @@ -1,63 +0,0 @@ -startTime, 'Test timing was started'); - self::assertNotNull($this->runTime, 'Test timing was stopped'); - } - - /** - * begin timing - */ - protected function startTiming() : void - { - $this->startTime = microtime(true); - } - - /** - * end timing - */ - protected function stopTiming() : void - { - $this->runTime = microtime(true) - $this->startTime; - } - - /** - * @return float elapsed test execution time - */ - public function getTime() : float - { - return $this->runTime; - } -} diff --git a/tests/Doctrine/Tests/DbalPerformanceTestListener.php b/tests/Doctrine/Tests/DbalPerformanceTestListener.php deleted file mode 100644 index e9265c0f35f..00000000000 --- a/tests/Doctrine/Tests/DbalPerformanceTestListener.php +++ /dev/null @@ -1,65 +0,0 @@ -timings[$class])) { - $this->timings[$class] = []; - } - - // Store timing data for each test in the order they were run. - $this->timings[$class][$test->getName(true)] = $test->getTime(); - } - - /** - * Report performance test timings. - * - * Note: __destruct is used here because PHPUnit doesn't have a - * 'All tests over' hook. - */ - public function __destruct() - { - if (empty($this->timings)) { - return; - } - - // Report timings. - print "\nPerformance test results:\n\n"; - - foreach ($this->timings as $class => $tests) { - printf("%s:\n", $class); - foreach ($tests as $test => $time) { - printf("\t%s: %.3f seconds\n", $test, $time); - } - } - } -} From fcf472ad58511e8d663da3d011307f20cf6eeb6d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 28 Mar 2020 11:59:23 -0700 Subject: [PATCH 10/93] Actualize the content of the .gitattributes file 1. Removed no longer existing entries 2. Added new entries 3. Sorted using `sort` (ignores case and the leading dot, same as `ls`) --- .gitattributes | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitattributes b/.gitattributes index 5bbaf359701..54d8bd65621 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,15 +1,16 @@ /.appveyor.yml export-ignore +/composer.lock export-ignore +/docs export-ignore +/.doctrine-project.json export-ignore /.gitattributes export-ignore /.github export-ignore /.gitignore export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore -/build.properties export-ignore -/build.xml export-ignore -/composer.lock export-ignore -/docs export-ignore /phpcs.xml.dist export-ignore /phpstan.neon.dist export-ignore /phpunit.xml.dist export-ignore /run-all.sh export-ignore +/.scrutinizer.yml export-ignore +/SECURITY.md export-ignore /tests export-ignore +/.travis.yml export-ignore +/UPGRADE.md export-ignore From 32aac3bf86f4e3d36df7b094053e699b37eb122d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 30 Mar 2020 15:18:48 -0700 Subject: [PATCH 11/93] Added missing parameter types to CompositeExpression::(and|or)() --- .../DBAL/Query/Expression/CompositeExpression.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 0048d228ced..21e8d6bf2f5 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -49,11 +49,19 @@ public function __construct($type, array $parts = []) $this->addMultiple($parts); } + /** + * @param self|string $part + * @param self|string ...$parts + */ public static function and($part, ...$parts) : self { return new self(self::TYPE_AND, array_merge([$part], $parts)); } + /** + * @param self|string $part + * @param self|string ...$parts + */ public static function or($part, ...$parts) : self { return new self(self::TYPE_OR, array_merge([$part], $parts)); From f185ba487a15d80b3c7514a48e714685a4e6bfbb Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 7 Apr 2020 13:48:44 -0700 Subject: [PATCH 12/93] Deprecate EchoSQLLogger --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Logging/EchoSQLLogger.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 6bf517e921a..adb9ffd904e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecated `EchoSQLLogger` + +The `EchoSQLLogger` is has been deprecated. Implement your logger with the desired logic. + ## Deprecated database platforms: 1. PostgreSQL 9.3 and older diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php index 657abb4d378..744e524d5e3 100644 --- a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -7,6 +7,8 @@ /** * A SQL logger that logs to the standard output using echo/var_dump. + * + * @deprecated */ class EchoSQLLogger implements SQLLogger { From b10d4db882eeaeda044aa71946d87882a244a094 Mon Sep 17 00:00:00 2001 From: David Maicher Date: Wed, 15 Apr 2020 19:48:11 +0200 Subject: [PATCH 13/93] allow using multiple connections for CLI commands --- bin/doctrine-dbal.php | 15 ++--- .../Console/Command/ReservedWordsCommand.php | 56 ++++++++++++++++--- .../Tools/Console/Command/RunSqlCommand.php | 42 +++++++++++++- .../DBAL/Tools/Console/ConnectionNotFound.php | 9 +++ .../DBAL/Tools/Console/ConnectionProvider.php | 15 +++++ .../SingleConnectionProvider.php | 37 ++++++++++++ .../DBAL/Tools/Console/ConsoleRunner.php | 46 ++++++++++----- .../Tools/Console/Helper/ConnectionHelper.php | 2 + 8 files changed, 193 insertions(+), 29 deletions(-) create mode 100644 lib/Doctrine/DBAL/Tools/Console/ConnectionNotFound.php create mode 100644 lib/Doctrine/DBAL/Tools/Console/ConnectionProvider.php create mode 100644 lib/Doctrine/DBAL/Tools/Console/ConnectionProvider/SingleConnectionProvider.php diff --git a/bin/doctrine-dbal.php b/bin/doctrine-dbal.php index f3e064ffd62..61a4098c9b0 100644 --- a/bin/doctrine-dbal.php +++ b/bin/doctrine-dbal.php @@ -1,5 +1,6 @@ SQLAnywhere16Keywords::class, ]; + /** @var ConnectionProvider|null */ + private $connectionProvider; + + public function __construct(?ConnectionProvider $connectionProvider = null) + { + parent::__construct(); + $this->connectionProvider = $connectionProvider; + if ($connectionProvider !== null) { + return; + } + + @trigger_error('Not passing a connection provider as the first constructor argument is deprecated', E_USER_DEPRECATED); + } + /** * If you want to add or replace a keywords list use this command. * @@ -73,12 +92,14 @@ protected function configure() $this ->setName('dbal:reserved-words') ->setDescription('Checks if the current database contains identifiers that are reserved.') - ->setDefinition([new InputOption( - 'list', - 'l', - InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, - 'Keyword-List name.' - ), + ->setDefinition([ + new InputOption('connection', null, InputOption::VALUE_REQUIRED, 'The named database connection'), + new InputOption( + 'list', + 'l', + InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY, + 'Keyword-List name.' + ), ]) ->setHelp(<<getHelper('db')->getConnection(); - assert($conn instanceof Connection); + $conn = $this->getConnection($input); $keywordLists = (array) $input->getOption('list'); if (! $keywordLists) { @@ -178,4 +198,24 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } + + private function getConnection(InputInterface $input) : Connection + { + $connectionName = $input->getOption('connection'); + assert(is_string($connectionName) || $connectionName === null); + + if ($this->connectionProvider === null) { + if ($connectionName !== null) { + throw new Exception('Specifying a connection is only supported when a ConnectionProvider is used.'); + } + + return $this->getHelper('db')->getConnection(); + } + + if ($connectionName !== null) { + return $this->connectionProvider->getConnection($connectionName); + } + + return $this->connectionProvider->getDefaultConnection(); + } } diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 5111a6505db..37c3c8973ca 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -2,7 +2,10 @@ namespace Doctrine\DBAL\Tools\Console\Command; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\Tools\Console\ConnectionProvider; use Doctrine\DBAL\Tools\Dumper; +use Exception; use LogicException; use RuntimeException; use Symfony\Component\Console\Command\Command; @@ -14,6 +17,8 @@ use function is_numeric; use function is_string; use function stripos; +use function trigger_error; +use const E_USER_DEPRECATED; /** * Task for executing arbitrary SQL that can come from a file or directly from @@ -21,6 +26,20 @@ */ class RunSqlCommand extends Command { + /** @var ConnectionProvider|null */ + private $connectionProvider; + + public function __construct(?ConnectionProvider $connectionProvider = null) + { + parent::__construct(); + $this->connectionProvider = $connectionProvider; + if ($connectionProvider !== null) { + return; + } + + @trigger_error('Not passing a connection provider as the first constructor argument is deprecated', E_USER_DEPRECATED); + } + /** @return void */ protected function configure() { @@ -28,6 +47,7 @@ protected function configure() ->setName('dbal:run-sql') ->setDescription('Executes arbitrary SQL directly from the command line.') ->setDefinition([ + new InputOption('connection', null, InputOption::VALUE_REQUIRED, 'The named database connection'), new InputArgument('sql', InputArgument::REQUIRED, 'The SQL statement to execute.'), new InputOption('depth', null, InputOption::VALUE_REQUIRED, 'Dumping depth of result set.', 7), new InputOption('force-fetch', null, InputOption::VALUE_NONE, 'Forces fetching the result.'), @@ -43,7 +63,7 @@ protected function configure() */ protected function execute(InputInterface $input, OutputInterface $output) { - $conn = $this->getHelper('db')->getConnection(); + $conn = $this->getConnection($input); $sql = $input->getArgument('sql'); @@ -69,4 +89,24 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } + + private function getConnection(InputInterface $input) : Connection + { + $connectionName = $input->getOption('connection'); + assert(is_string($connectionName) || $connectionName === null); + + if ($this->connectionProvider === null) { + if ($connectionName !== null) { + throw new Exception('Specifying a connection is only supported when a ConnectionProvider is used.'); + } + + return $this->getHelper('db')->getConnection(); + } + + if ($connectionName !== null) { + return $this->connectionProvider->getConnection($connectionName); + } + + return $this->connectionProvider->getDefaultConnection(); + } } diff --git a/lib/Doctrine/DBAL/Tools/Console/ConnectionNotFound.php b/lib/Doctrine/DBAL/Tools/Console/ConnectionNotFound.php new file mode 100644 index 00000000000..81ca4182a03 --- /dev/null +++ b/lib/Doctrine/DBAL/Tools/Console/ConnectionNotFound.php @@ -0,0 +1,9 @@ +connection = $connection; + $this->defaultConnectionName = $defaultConnectionName; + } + + public function getDefaultConnection() : Connection + { + return $this->connection; + } + + public function getConnection(string $name) : Connection + { + if ($name !== $this->defaultConnectionName) { + throw new ConnectionNotFound(sprintf('Connection with name "%s" does not exist.', $name)); + } + + return $this->connection; + } +} diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index e028c807c01..f0e65c33928 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -11,6 +11,10 @@ use Symfony\Component\Console\Application; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; +use TypeError; +use function sprintf; +use function trigger_error; +use const E_USER_DEPRECATED; /** * Handles running the Console Tools inside Symfony Console context. @@ -20,6 +24,8 @@ class ConsoleRunner /** * Create a Symfony Console HelperSet * + * @deprecated use a ConnectionProvider instead. + * * @return HelperSet */ public static function createHelperSet(Connection $connection) @@ -30,20 +36,31 @@ public static function createHelperSet(Connection $connection) } /** - * Runs console with the given helperset. + * Runs console with the given connection provider or helperset (deprecated). * - * @param Command[] $commands + * @param ConnectionProvider|HelperSet $helperSetOrConnectionProvider + * @param Command[] $commands * * @return void */ - public static function run(HelperSet $helperSet, $commands = []) + public static function run($helperSetOrConnectionProvider, $commands = []) { $cli = new Application('Doctrine Command Line Interface', Version::VERSION); $cli->setCatchExceptions(true); - $cli->setHelperSet($helperSet); - self::addCommands($cli); + $connectionProvider = null; + if ($helperSetOrConnectionProvider instanceof HelperSet) { + @trigger_error(sprintf('Passing an instance of "%s" as the first argument is deprecated. Pass an instance of "%s" instead.', HelperSet::class, ConnectionProvider::class), E_USER_DEPRECATED); + $connectionProvider = null; + $cli->setHelperSet($helperSetOrConnectionProvider); + } elseif ($helperSetOrConnectionProvider instanceof ConnectionProvider) { + $connectionProvider = $helperSetOrConnectionProvider; + } else { + throw new TypeError(sprintf('First argument must be an instance of "%s" or "%s"', HelperSet::class, ConnectionProvider::class)); + } + + self::addCommands($cli, $connectionProvider); $cli->addCommands($commands); $cli->run(); @@ -52,12 +69,12 @@ public static function run(HelperSet $helperSet, $commands = []) /** * @return void */ - public static function addCommands(Application $cli) + public static function addCommands(Application $cli, ?ConnectionProvider $connectionProvider = null) { $cli->addCommands([ - new RunSqlCommand(), + new RunSqlCommand($connectionProvider), new ImportCommand(), - new ReservedWordsCommand(), + new ReservedWordsCommand($connectionProvider), ]); } @@ -74,14 +91,17 @@ public static function printCliConfigTemplate() following sample as a template: Date: Thu, 21 May 2020 12:13:59 +0200 Subject: [PATCH 14/93] Improve help of dbal:run-sql command This makes it consistent with doctrine-bundle command --- lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 37c3c8973ca..02b15cc1fc3 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -53,7 +53,10 @@ protected function configure() new InputOption('force-fetch', null, InputOption::VALUE_NONE, 'Forces fetching the result.'), ]) ->setHelp(<<%command.name% command executes the given SQL query and +outputs the results: + +php %command.full_name% "SELECT * FROM users" EOT ); } From 3c72aeb73475bed66607319f7a9b479ca107a389 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 22 May 2020 20:50:48 -0700 Subject: [PATCH 15/93] Deprecated Connection::project(), Statement::errorCode() and errorInfo() --- UPGRADE.md | 10 +++++++++- lib/Doctrine/DBAL/Connection.php | 6 ++++++ lib/Doctrine/DBAL/Driver/Connection.php | 4 ++++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php | 4 ++++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php | 4 ++++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 4 ++++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php | 4 ++++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php | 4 ++++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | 4 ++++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php | 4 ++++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php | 4 ++++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php | 4 ++++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php | 4 ++++ lib/Doctrine/DBAL/Driver/Statement.php | 4 ++++ lib/Doctrine/DBAL/Portability/Statement.php | 4 ++++ lib/Doctrine/DBAL/Statement.php | 4 ++++ 16 files changed, 71 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index adb9ffd904e..a6d4c85004e 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,8 +1,16 @@ # Upgrade to 2.11 +## Deprecated `Connection::project()` + +The `Connection::project()` method is deprecated. Implement data transformation outside of DBAL. + +## Deprecated `Statement::errorCode()` and `errorInfo()` + +The `Statement::errorCode()` and `errorInfo()` methods are deprecated. The error information is available via exceptions. + ## Deprecated `EchoSQLLogger` -The `EchoSQLLogger` is has been deprecated. Implement your logger with the desired logic. +The `EchoSQLLogger` class is deprecated. Implement your logger with the desired logic. ## Deprecated database platforms: diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 4a9a8cd959c..f49ba0ba951 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -973,6 +973,8 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc * Executes an, optionally parametrized, SQL query and returns the result, * applying a given projection/transformation function on each row of the result. * + * @deprecated + * * @param string $query The SQL query to execute. * @param mixed[] $params The parameters, if any. * @param Closure $function The transformation function that is applied on each row. @@ -1123,6 +1125,8 @@ public function getTransactionNestingLevel() /** * Fetches the SQLSTATE associated with the last database operation. * + * @deprecated The error information is available via exceptions. + * * @return string|null The last error code. */ public function errorCode() @@ -1132,6 +1136,8 @@ public function errorCode() /** * {@inheritDoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/Connection.php b/lib/Doctrine/DBAL/Driver/Connection.php index 1574581c2ad..5e7382d0b8c 100644 --- a/lib/Doctrine/DBAL/Driver/Connection.php +++ b/lib/Doctrine/DBAL/Driver/Connection.php @@ -80,6 +80,8 @@ public function rollBack(); /** * Returns the error code associated with the last operation on the database handle. * + * @deprecated The error information is available via exceptions. + * * @return string|null The error code, or null if no operation has been run on the database handle. */ public function errorCode(); @@ -87,6 +89,8 @@ public function errorCode(); /** * Returns extended error information associated with the last operation on the database handle. * + * @deprecated The error information is available via exceptions. + * * @return mixed[] */ public function errorInfo(); diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 841ea4c9c61..533617b2c87 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -180,6 +180,8 @@ public function rollBack() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -188,6 +190,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 6222facf1e4..eb30651fc51 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -167,6 +167,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -175,6 +177,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index f1b687aaec6..95e99f4aa1d 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -200,6 +200,8 @@ public function rollBack() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -208,6 +210,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 86e846af702..738bd8e1b4f 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -393,6 +393,8 @@ public function fetchColumn($columnIndex = 0) /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -401,6 +403,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index ae1b3599642..44e2e21a707 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -216,6 +216,8 @@ public function rollBack() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -229,6 +231,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 74607ddec76..d64f55919d1 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -352,6 +352,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -365,6 +367,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index d47782003e6..cca9df5fac0 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -90,6 +90,8 @@ public function commit() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -98,6 +100,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index bac9abf7850..c5d8e5d9eee 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -152,6 +152,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -160,6 +162,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index ca7ce0c9ad3..6c8864fa03a 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -182,6 +182,8 @@ public function rollBack() /** * {@inheritDoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -195,6 +197,8 @@ public function errorCode() /** * {@inheritDoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index e728575fa4f..956b497aa95 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -216,6 +216,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -229,6 +231,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Driver/Statement.php b/lib/Doctrine/DBAL/Driver/Statement.php index 388983e46a6..2fc527b3b4e 100644 --- a/lib/Doctrine/DBAL/Driver/Statement.php +++ b/lib/Doctrine/DBAL/Driver/Statement.php @@ -61,6 +61,8 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l /** * Fetches the SQLSTATE associated with the last operation on the statement handle. * + * @deprecated The error information is available via exceptions. + * * @see Doctrine_Adapter_Interface::errorCode() * * @return string|int|bool The error code string. @@ -70,6 +72,8 @@ public function errorCode(); /** * Fetches extended error information associated with the last operation on the statement handle. * + * @deprecated The error information is available via exceptions. + * * @return mixed[] The error info array. */ public function errorInfo(); diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 514b3be2d74..96727b2448a 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -81,6 +81,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorCode() { @@ -91,6 +93,8 @@ public function errorCode() /** * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index ee8dcfcfceb..cb6fbde7a71 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -198,6 +198,8 @@ public function columnCount() /** * Fetches the SQLSTATE associated with the last operation on the statement. * + * @deprecated The error information is available via exceptions. + * * @return string|int|bool */ public function errorCode() @@ -207,6 +209,8 @@ public function errorCode() /** * {@inheritDoc} + * + * @deprecated The error information is available via exceptions. */ public function errorInfo() { From 3fe4d3cf0fd75986d9de37e3212386cc534bf65d Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 22 May 2020 21:41:53 -0700 Subject: [PATCH 16/93] Update slevomat/coding-standard to 6.3.6 --- composer.json | 1 + composer.lock | 16 ++++++++-------- .../Tests/DBAL/Driver/StatementIteratorTest.php | 6 ++++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index eb5f95c8eb0..a2d8ede2829 100644 --- a/composer.json +++ b/composer.json @@ -43,6 +43,7 @@ "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^8.4.1", + "slevomat/coding-standard": "^6.3.6", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "vimeo/psalm": "^3.11" }, diff --git a/composer.lock b/composer.lock index 0073213a8c6..d626f4ec2f6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6bf4905b268231ccd58bdbe30d4ecf81", + "content-hash": "ae54b78f0088f88dbcfa8e179be7c43b", "packages": [ { "name": "doctrine/cache", @@ -2416,16 +2416,16 @@ }, { "name": "slevomat/coding-standard", - "version": "6.3.3", + "version": "6.3.6", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "b905a82255749de847fd4de607c7a4c8163f058d" + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/b905a82255749de847fd4de607c7a4c8163f058d", - "reference": "b905a82255749de847fd4de607c7a4c8163f058d", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee", "shasum": "" }, "require": { @@ -2469,7 +2469,7 @@ "type": "tidelift" } ], - "time": "2020-04-28T07:15:08+00:00" + "time": "2020-05-22T15:11:14+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2920,8 +2920,8 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", diff --git a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php index b3d8abc6b85..c65db5ecc05 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php @@ -97,8 +97,10 @@ public static function statementProvider() : iterable yield [PortabilityStatement::class]; yield [SQLAnywhereStatement::class]; - if (extension_loaded('sqlsrv')) { - yield [SQLSrvStatement::class]; + if (! extension_loaded('sqlsrv')) { + return; } + + yield [SQLSrvStatement::class]; } } From 5af3709a1a407429120611f8e843de4b22a149a3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 22 May 2020 16:19:17 -0700 Subject: [PATCH 17/93] Deprecated the concept of the fetch mode --- UPGRADE.md | 10 + lib/Doctrine/DBAL/Cache/ArrayStatement.php | 78 +++++- .../DBAL/Cache/ResultCacheStatement.php | 118 ++++++++- lib/Doctrine/DBAL/Connection.php | 229 ++++++++++++++++++ lib/Doctrine/DBAL/Driver/FetchUtils.php | 61 +++++ .../DBAL/Driver/IBMDB2/DB2Statement.php | 10 + .../DBAL/Driver/Mysqli/MysqliStatement.php | 80 +++++- .../DBAL/Driver/OCI8/OCI8Statement.php | 93 ++++++- .../DBAL/Driver/PDOSqlsrv/Connection.php | 5 + lib/Doctrine/DBAL/Driver/PDOStatement.php | 51 +++- lib/Doctrine/DBAL/Driver/ResultStatement.php | 8 + .../SQLAnywhere/SQLAnywhereConnection.php | 17 +- .../SQLAnywhere/SQLAnywhereStatement.php | 69 +++++- .../DBAL/Driver/SQLSrv/SQLSrvConnection.php | 5 + .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 68 +++++- .../DBAL/Driver/StatementIterator.php | 3 + lib/Doctrine/DBAL/FetchMode.php | 2 + .../Driver/ResultStatement.php | 59 +++++ .../ForwardCompatibility/ResultStatement.php | 42 ++++ lib/Doctrine/DBAL/Id/TableGenerator.php | 4 +- lib/Doctrine/DBAL/Portability/Statement.php | 142 +++++++++-- .../DBAL/Schema/AbstractSchemaManager.php | 16 +- lib/Doctrine/DBAL/Schema/DB2SchemaManager.php | 4 +- .../DBAL/Schema/MySqlSchemaManager.php | 2 +- .../DBAL/Schema/OracleSchemaManager.php | 4 +- .../DBAL/Schema/PostgreSqlSchemaManager.php | 3 +- .../DBAL/Schema/SQLServerSchemaManager.php | 6 +- .../DBAL/Schema/SqliteSchemaManager.php | 15 +- .../DBAL/Sharding/PoolingShardManager.php | 2 +- .../SQLAzure/SQLAzureShardManager.php | 4 +- lib/Doctrine/DBAL/Statement.php | 177 +++++++++++++- .../Tools/Console/Command/RunSqlCommand.php | 2 +- .../BackwardCompatibility/Connection.php | 37 +++ .../BackwardCompatibility/FetchTest.php | 23 ++ .../BackwardCompatibility/Statement.php | 158 ++++++++++++ .../DBAL/Functional/Connection/FetchTest.php | 114 +++++++++ .../DBAL/Schema/DB2SchemaManagerTest.php | 12 +- .../DBAL/Schema/MySqlSchemaManagerTest.php | 14 +- .../DBAL/Sharding/PoolingShardManagerTest.php | 10 +- .../DBAL/Tools/Console/RunSqlCommandTest.php | 12 +- tests/Doctrine/Tests/TestUtil.php | 26 ++ 41 files changed, 1714 insertions(+), 81 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/FetchUtils.php create mode 100644 lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php create mode 100644 lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/FetchTest.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php diff --git a/UPGRADE.md b/UPGRADE.md index a6d4c85004e..1a5b80cafdc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,15 @@ # Upgrade to 2.11 +## Deprecated `FetchMode` and the corresponding methods + +1. The `FetchMode` class and the `setFetchMode()` method of the `Connection` and `Statement` interfaces are deprecated. +2. The `Statement::fetch()` method is deprecated in favor of `fetchNumeric()`, `fetchAssociative()` and `fetchOne()`. +3. The `Statement::fetchAll()` method is deprecated in favor of `fetchAllNumeric()` and `fetchAllAssociative()`. There is no currently replacement for `Statement::fetchAll(FETCH_MODE::COLUMN)`. In a future major version, `fetchColumn()` will be used as a replacement. +4. The `Statement::fetchColumn()` method is deprecated in favor of `fetchOne()`. +5. The `Connection::fetchArray()` and `fetchAssoc()` method are deprecated in favor of `fetchNumeric()` and `fetchAssociative()` respectively. +6. The `StatementIterator` class and the usage of a `Statement` object as `Traversable` is deprecated in favor of `iterateNumeric()`, `iterateAssociative()` and `iterateColumn()`. +7. Fetching data in mixed mode (`FetchMode::MIXED`) is deprecated. + ## Deprecated `Connection::project()` The `Connection::project()` method is deprecated. Implement data transformation outside of DBAL. diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 5b72e599ac3..1e17b766e27 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -3,8 +3,10 @@ namespace Doctrine\DBAL\Cache; use ArrayIterator; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use InvalidArgumentException; use IteratorAggregate; use PDO; @@ -13,7 +15,7 @@ use function count; use function reset; -class ArrayStatement implements IteratorAggregate, ResultStatement +class ArrayStatement implements IteratorAggregate, ResultStatement, ForwardCompatibleResultStatement { /** @var mixed[] */ private $data; @@ -60,6 +62,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -74,6 +78,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -84,6 +90,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -115,6 +123,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -128,6 +138,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -136,4 +148,68 @@ public function fetchColumn($columnIndex = 0) // TODO: verify that return false is the correct behavior return $row[$columnIndex] ?? false; } + + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + $row = $this->doFetch(); + + if ($row === false) { + return false; + } + + return array_values($row); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + return $this->doFetch(); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + $row = $this->doFetch(); + + if ($row === false) { + return false; + } + + return reset($row); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** + * @return mixed|false + */ + private function doFetch() + { + if (! isset($this->data[$this->num])) { + return false; + } + + return $this->data[$this->num++]; + } } diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index cbb44a94a1a..1a4382dd178 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -4,9 +4,12 @@ use ArrayIterator; use Doctrine\Common\Cache\Cache; +use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use InvalidArgumentException; use IteratorAggregate; use PDO; @@ -28,7 +31,7 @@ * Also you have to realize that the cache will load the whole result into memory at once to ensure 2. * This means that the memory usage for cached results might increase by using this feature. */ -class ResultCacheStatement implements IteratorAggregate, ResultStatement +class ResultCacheStatement implements IteratorAggregate, ResultStatement, ForwardCompatibleResultStatement { /** @var Cache */ private $resultCache; @@ -105,6 +108,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -115,6 +120,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -125,6 +132,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -165,6 +174,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -184,6 +195,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -193,6 +206,64 @@ public function fetchColumn($columnIndex = 0) return $row[$columnIndex] ?? false; } + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + $row = $this->doFetch(); + + if ($row === false) { + return false; + } + + return array_values($row); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + return $this->doFetch(); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + if ($this->statement instanceof ForwardCompatibleResultStatement) { + $data = $this->statement->fetchAllAssociative(); + } else { + $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); + } + + return $this->store($data); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + if ($this->statement instanceof ForwardCompatibleResultStatement) { + $data = $this->statement->fetchAllAssociative(); + } else { + $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); + } + + return $this->store($data); + } + /** * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement * executed by the corresponding object. @@ -210,4 +281,49 @@ public function rowCount() return $this->statement->rowCount(); } + + /** + * @return array|false + * + * @throws DriverException + */ + private function doFetch() + { + if ($this->data === null) { + $this->data = []; + } + + if ($this->statement instanceof ForwardCompatibleResultStatement) { + $row = $this->statement->fetchAssociative(); + } else { + $row = $this->statement->fetch(FetchMode::ASSOCIATIVE); + } + + if ($row !== false) { + $this->data[] = $row; + + return $row; + } + + $this->emptied = true; + + return false; + } + + /** + * @param array> $data + * + * @return array> + */ + private function store(array $data) : array + { + foreach ($data as $key => $value) { + $data[$key] = [$value]; + } + + $this->data = $data; + $this->emptied = true; + + return $this->data; + } } diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index f49ba0ba951..c4f0c3727d0 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Exception\InvalidArgumentException; +use Doctrine\DBAL\ForwardCompatibility\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\QueryBuilder; @@ -21,6 +22,7 @@ use Doctrine\DBAL\Types\Type; use Exception; use Throwable; +use Traversable; use function array_key_exists; use function assert; use function func_get_args; @@ -529,6 +531,8 @@ public function setAutoCommit($autoCommit) /** * Sets the fetch mode. * + * @deprecated Use one of the fetch- or iterate-related methods. + * * @param int $fetchMode * * @return void @@ -542,6 +546,8 @@ public function setFetchMode($fetchMode) * Prepares and executes an SQL query and returns the first row of the result * as an associative array. * + * @deprecated Use fetchAllAssociative() + * * @param string $statement The SQL query. * @param mixed[] $params The query parameters. * @param int[]|string[] $types The query parameter types. @@ -559,6 +565,8 @@ public function fetchAssoc($statement, array $params = [], array $types = []) * Prepares and executes an SQL query and returns the first row of the result * as a numerically indexed array. * + * @deprecated Use fetchAllNumeric() + * * @param string $statement The SQL query to be executed. * @param mixed[] $params The prepared statement params. * @param int[]|string[] $types The query parameter types. @@ -574,6 +582,8 @@ public function fetchArray($statement, array $params = [], array $types = []) * Prepares and executes an SQL query and returns the value of a single column * of the first row of the result. * + * @deprecated Use fetchOne() instead. + * * @param string $statement The SQL query to be executed. * @param mixed[] $params The prepared statement params. * @param int $column The 0-indexed column number to retrieve. @@ -588,6 +598,87 @@ public function fetchColumn($statement, array $params = [], $column = 0, array $ return $this->executeQuery($statement, $params, $types)->fetchColumn($column); } + /** + * Prepares and executes an SQL query and returns the first row of the result + * as an associative array. + * + * @param string $query The SQL query. + * @param array|array $params The prepared statement params. + * @param array|array $types The query parameter types. + * + * @return array|false False is returned if no rows are found. + * + * @throws DBALException + */ + public function fetchAssociative(string $query, array $params = [], array $types = []) + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchAssociative(); + } + + return $stmt->fetch(FetchMode::ASSOCIATIVE); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the first row of the result + * as a numerically indexed array. + * + * @param string $query The SQL query to be executed. + * @param array|array $params The prepared statement params. + * @param array|array $types The query parameter types. + * + * @return array|false False is returned if no rows are found. + * + * @throws DBALException + */ + public function fetchNumeric(string $query, array $params = [], array $types = []) + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchNumeric(); + } + + return $stmt->fetch(FetchMode::NUMERIC); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the value of a single column + * of the first row of the result. + * + * @param string $query The SQL query to be executed. + * @param array|array $params The prepared statement params. + * @param array|array $types The query parameter types. + * + * @return mixed|false False is returned if no rows are found. + * + * @throws DBALException + */ + public function fetchOne(string $query, array $params = [], array $types = []) + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchOne(); + } + + return $stmt->fetch(FetchMode::COLUMN); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + /** * Whether an actual connection to the database is established. * @@ -835,6 +926,8 @@ public function quote($input, $type = ParameterType::STRING) /** * Prepares and executes an SQL query and returns the result as an associative array. * + * @deprecated Use fetchAllAssociative() + * * @param string $sql The SQL query. * @param mixed[] $params The query parameters. * @param int[]|string[] $types The query parameter types. @@ -846,6 +939,142 @@ public function fetchAll($sql, array $params = [], $types = []) return $this->executeQuery($sql, $params, $types)->fetchAll(); } + /** + * Prepares and executes an SQL query and returns the result as an array of numeric arrays. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return array> + * + * @throws DBALException + */ + public function fetchAllNumeric(string $query, array $params = [], array $types = []) : array + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchAllNumeric(); + } + + return $stmt->fetchAll(FetchMode::NUMERIC); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the result as an array of associative arrays. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return array> + * + * @throws DBALException + */ + public function fetchAllAssociative(string $query, array $params = [], array $types = []) : array + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchAllAssociative(); + } + + return $stmt->fetchAll(FetchMode::ASSOCIATIVE); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the result as an iterator over rows represented as numeric arrays. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return Traversable> + * + * @throws DBALException + */ + public function iterateNumeric(string $query, array $params = [], array $types = []) : Traversable + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + yield from $stmt->iterateNumeric(); + } else { + while (($row = $stmt->fetch(FetchMode::NUMERIC)) !== false) { + yield $row; + } + } + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the result as an iterator over rows represented as associative arrays. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return Traversable> + * + * @throws DBALException + */ + public function iterateAssociative(string $query, array $params = [], array $types = []) : Traversable + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + yield from $stmt->iterateAssociative(); + } else { + while (($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) !== false) { + yield $row; + } + } + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + + /** + * Prepares and executes an SQL query and returns the result as an iterator over the first column values. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return Traversable + * + * @throws DBALException + */ + public function iterateColumn(string $query, array $params = [], array $types = []) : Traversable + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + yield from $stmt->iterateColumn(); + } else { + while (($value = $stmt->fetch(FetchMode::COLUMN)) !== false) { + yield $value; + } + } + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + /** * Prepares an SQL statement. * diff --git a/lib/Doctrine/DBAL/Driver/FetchUtils.php b/lib/Doctrine/DBAL/Driver/FetchUtils.php new file mode 100644 index 00000000000..358429255f0 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/FetchUtils.php @@ -0,0 +1,61 @@ +fetchNumeric(); + + if ($row === false) { + return false; + } + + return $row[0]; + } + + /** + * @return array> + * + * @throws DriverException + */ + public static function fetchAllNumeric(ResultStatement $stmt) : array + { + $rows = []; + + while (($row = $stmt->fetchNumeric()) !== false) { + $rows[] = $row; + } + + return $rows; + } + + /** + * @return array> + * + * @throws DriverException + */ + public static function fetchAllAssociative(ResultStatement $stmt) : array + { + $rows = []; + + while (($row = $stmt->fetchAssociative()) !== false) { + $rows[] = $row; + } + + return $rows; + } +} diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index eb30651fc51..3a01b3ad9d1 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -232,6 +232,8 @@ public function execute($params = null) /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -244,6 +246,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -252,6 +256,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -303,6 +309,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -334,6 +342,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 738bd8e1b4f..9a3c76ce55d 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -2,10 +2,12 @@ namespace Doctrine\DBAL\Driver\Mysqli; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use mysqli; @@ -24,7 +26,7 @@ use function sprintf; use function str_repeat; -class MysqliStatement implements IteratorAggregate, Statement +class MysqliStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement { /** @var string[] */ protected static $_paramTypeMap = [ @@ -307,6 +309,8 @@ private function _fetch() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -357,6 +361,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -379,6 +385,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -396,6 +404,72 @@ public function fetchColumn($columnIndex = 0) * * @deprecated The error information is available via exceptions. */ + public function fetchNumeric() + { + // do not try fetching from the statement if it's not expected to contain the result + // in order to prevent exceptional situation + if (! $this->result) { + return false; + } + + $values = $this->_fetch(); + + if ($values === null) { + return false; + } + + if ($values === false) { + throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + } + + return $values; + } + + /** + * {@inheritDoc} + */ + public function fetchAssociative() + { + $values = $this->fetchNumeric(); + + if ($values === false) { + return false; + } + + assert(is_array($this->_columnNames)); + $row = array_combine($this->_columnNames, $values); + assert(is_array($row)); + + return $row; + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return FetchUtils::fetchAllAssociative($this); + } + + /** + * {@inheritdoc} + */ public function errorCode() { return $this->_stmt->errno; @@ -444,6 +518,8 @@ public function columnCount() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -454,6 +530,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index d64f55919d1..1be74545b2a 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -2,9 +2,11 @@ namespace Doctrine\DBAL\Driver\OCI8; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use InvalidArgumentException; use IteratorAggregate; @@ -47,7 +49,7 @@ /** * The OCI8 implementation of the Statement interface. */ -class OCI8Statement implements IteratorAggregate, Statement +class OCI8Statement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement { /** @var resource */ protected $_dbh; @@ -410,6 +412,8 @@ public function execute($params = null) /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -420,6 +424,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -428,6 +434,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -459,6 +467,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -513,6 +523,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -538,4 +550,83 @@ public function rowCount() { return oci_num_rows($this->_sth) ?: 0; } + + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + return $this->doFetch(OCI_NUM); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + return $this->doFetch(OCI_ASSOC); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return $this->doFetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_ROW); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return $this->doFetchAll(OCI_ASSOC, OCI_FETCHSTATEMENT_BY_ROW); + } + + /** + * @return mixed|false + */ + private function doFetch(int $mode) + { + // do not try fetching from the statement if it's not expected to contain the result + // in order to prevent exceptional situation + if (! $this->result) { + return false; + } + + return oci_fetch_array( + $this->_sth, + $mode | OCI_RETURN_NULLS | OCI_RETURN_LOBS + ); + } + + /** + * @return array + */ + private function doFetchAll(int $mode, int $fetchStructure) : array + { + // do not try fetching from the statement if it's not expected to contain the result + // in order to prevent exceptional situation + if (! $this->result) { + return []; + } + + oci_fetch_all( + $this->_sth, + $result, + 0, + -1, + $mode | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS + ); + + return $result; + } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index bd3894477b5..56cca064068 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use PDO; use function strpos; @@ -34,6 +35,10 @@ public function lastInsertId($name = null) $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); $stmt->execute([$name]); + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchOne(); + } + return $stmt->fetchColumn(); } diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index c7db7d4eb87..1922c4c0e3a 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use PDO; use function array_slice; @@ -17,7 +18,7 @@ * The PDO implementation of the Statement interface. * Used by all PDO-based drivers. */ -class PDOStatement extends \PDOStatement implements Statement +class PDOStatement extends \PDOStatement implements Statement, ForwardCompatibleResultStatement { private const PARAM_TYPE_MAP = [ ParameterType::NULL => PDO::PARAM_NULL, @@ -46,6 +47,8 @@ protected function __construct() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -132,6 +135,8 @@ public function execute($params = null) /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -150,6 +155,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -181,6 +188,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -191,6 +200,46 @@ public function fetchColumn($columnIndex = 0) } } + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + return $this->fetch(PDO::FETCH_NUM); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + return $this->fetch(PDO::FETCH_ASSOC); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return $this->fetch(PDO::FETCH_COLUMN); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return $this->fetchAll(PDO::FETCH_NUM); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return $this->fetchAll(PDO::FETCH_ASSOC); + } + /** * Converts DBAL parameter type to PDO parameter type * diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php index 1e6df0269b8..c48e0e28400 100644 --- a/lib/Doctrine/DBAL/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php @@ -29,6 +29,8 @@ public function columnCount(); /** * Sets the fetch mode to use while iterating this statement. * + * @deprecated Use one of the fetch- or iterate-related methods. + * * @param int $fetchMode The fetch mode must be one of the {@link \Doctrine\DBAL\FetchMode} constants. * @param mixed $arg2 * @param mixed $arg3 @@ -40,6 +42,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null); /** * Returns the next row of a result set. * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. + * * @param int|null $fetchMode Controls how the next row will be returned to the caller. * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. @@ -67,6 +71,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * Returns an array containing all of the result set rows. * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * * @param int|null $fetchMode Controls how the next row will be returned to the caller. * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, * defaulting to {@link \Doctrine\DBAL\FetchMode::MIXED}. @@ -89,6 +95,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * Returns a single column from the next row of a result set or FALSE if there are no more rows. * + * @deprecated Use fetchOne() instead. + * * @param int $columnIndex 0-indexed number of the column you wish to retrieve from the row. * If no value is supplied, fetches the first column. * diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index cca9df5fac0..37d99c328be 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use function assert; use function func_get_args; @@ -125,7 +126,13 @@ public function exec($statement) */ public function getServerVersion() { - $version = $this->query("SELECT PROPERTY('ProductVersion')")->fetchColumn(); + $stmt = $this->query("SELECT PROPERTY('ProductVersion')"); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + $version = $stmt->fetchOne(); + } else { + $version = $stmt->fetchColumn(); + } assert(is_string($version)); @@ -141,7 +148,13 @@ public function lastInsertId($name = null) return sasql_insert_id($this->connection); } - return $this->query('SELECT ' . $name . '.CURRVAL')->fetchColumn(); + $stmt = $this->query('SELECT ' . $name . '.CURRVAL'); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchOne(); + } + + return $stmt->fetchColumn(); } /** diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index c5d8e5d9eee..74e9b5745ab 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -2,9 +2,12 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; +use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -39,7 +42,7 @@ /** * SAP SQL Anywhere implementation of the Statement interface. */ -class SQLAnywhereStatement implements IteratorAggregate, Statement +class SQLAnywhereStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement { /** @var resource The connection resource. */ private $conn; @@ -201,6 +204,8 @@ public function execute($params = null) /** * {@inheritdoc} * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. + * * @throws SQLAnywhereException */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) @@ -252,6 +257,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -283,6 +290,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -297,12 +306,68 @@ public function fetchColumn($columnIndex = 0) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { return new StatementIterator($this); } + /** + * {@inheritDoc} + */ + public function fetchNumeric() + { + if (! is_resource($this->result)) { + return false; + } + + return sasql_fetch_row($this->result); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + if (! is_resource($this->result)) { + return false; + } + + return sasql_fetch_assoc($this->result); + } + + /** + * {@inheritdoc} + * + * @throws DriverException + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * @return array> + * + * @throws DriverException + */ + public function fetchAllNumeric() : array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * @return array> + * + * @throws DriverException + */ + public function fetchAllAssociative() : array + { + return FetchUtils::fetchAllAssociative($this); + } + /** * {@inheritdoc} */ @@ -313,6 +378,8 @@ public function rowCount() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 6c8864fa03a..b5b0f0518e8 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\Connection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use function func_get_args; use function is_float; @@ -141,6 +142,10 @@ public function lastInsertId($name = null) $stmt = $this->query('SELECT @@IDENTITY'); } + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchOne(); + } + return $stmt->fetchColumn(); } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 956b497aa95..8292a62c311 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -2,9 +2,11 @@ namespace Doctrine\DBAL\Driver\SQLSrv; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -38,7 +40,7 @@ /** * SQL Server Statement. */ -class SQLSrvStatement implements IteratorAggregate, Statement +class SQLSrvStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement { /** * The SQLSRV Resource. @@ -322,6 +324,8 @@ private function prepare() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -334,6 +338,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -343,6 +349,8 @@ public function getIterator() /** * {@inheritdoc} * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. + * * @throws SQLSrvException */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) @@ -381,6 +389,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -412,6 +422,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { @@ -424,6 +436,46 @@ public function fetchColumn($columnIndex = 0) return $row[$columnIndex] ?? null; } + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + return $this->doFetch(SQLSRV_FETCH_NUMERIC); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + return $this->doFetch(SQLSRV_FETCH_ASSOC); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return FetchUtils::fetchAllAssociative($this); + } + /** * {@inheritdoc} */ @@ -435,4 +487,18 @@ public function rowCount() return sqlsrv_rows_affected($this->stmt) ?: 0; } + + /** + * @return mixed|false + */ + private function doFetch(int $fetchType) + { + // do not try fetching from the statement if it's not expected to contain the result + // in order to prevent exceptional situation + if ($this->stmt === null || ! $this->result) { + return false; + } + + return sqlsrv_fetch_array($this->stmt, $fetchType) ?? false; + } } diff --git a/lib/Doctrine/DBAL/Driver/StatementIterator.php b/lib/Doctrine/DBAL/Driver/StatementIterator.php index 6b3307da2af..cb1ac3a6253 100644 --- a/lib/Doctrine/DBAL/Driver/StatementIterator.php +++ b/lib/Doctrine/DBAL/Driver/StatementIterator.php @@ -4,6 +4,9 @@ use IteratorAggregate; +/** + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn(). + */ class StatementIterator implements IteratorAggregate { /** @var ResultStatement */ diff --git a/lib/Doctrine/DBAL/FetchMode.php b/lib/Doctrine/DBAL/FetchMode.php index b3fe42f4ceb..440bd12e673 100644 --- a/lib/Doctrine/DBAL/FetchMode.php +++ b/lib/Doctrine/DBAL/FetchMode.php @@ -6,6 +6,8 @@ /** * Contains statement fetch modes. + * + * @deprecated Use one of the fetch- or iterate-related methods on the Statement. */ final class FetchMode { diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php new file mode 100644 index 00000000000..ef0f88bd511 --- /dev/null +++ b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php @@ -0,0 +1,59 @@ +|false + * + * @throws DriverException + */ + public function fetchNumeric(); + + /** + * Returns the next row of a result set as an associative array or FALSE if there are no more rows. + * + * @return array|false + * + * @throws DriverException + */ + public function fetchAssociative(); + + /** + * Returns the first value of the next row of a result set or FALSE if there are no more rows. + * + * @return mixed|false + * + * @throws DriverException + */ + public function fetchOne(); + + /** + * Returns an array containing all of the result set rows represented as numeric arrays. + * + * @return array> + * + * @throws DriverException + */ + public function fetchAllNumeric() : array; + + /** + * Returns an array containing all of the result set rows represented as associative arrays. + * + * @return array> + * + * @throws DriverException + */ + public function fetchAllAssociative() : array; +} diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php b/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php new file mode 100644 index 00000000000..2ba19fa5324 --- /dev/null +++ b/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php @@ -0,0 +1,42 @@ +> + * + * @throws DBALException + */ + public function iterateNumeric() : Traversable; + + /** + * Returns an iterator over the result set rows represented as associative arrays. + * + * @return Traversable> + * + * @throws DBALException + */ + public function iterateAssociative() : Traversable; + + /** + * Returns an iterator over the values of the first column of the result set. + * + * @return Traversable + * + * @throws DBALException + */ + public function iterateColumn() : Traversable; +} diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 97bc70282f3..e3b4c4d2ee6 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -5,7 +5,6 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\LockMode; use Throwable; use function array_change_key_case; @@ -105,8 +104,7 @@ public function nextValue($sequenceName) $sql = 'SELECT sequence_value, sequence_increment_by' . ' FROM ' . $platform->appendLockHint($this->generatorTableName, LockMode::PESSIMISTIC_WRITE) . ' WHERE sequence_name = ? ' . $platform->getWriteLockSQL(); - $stmt = $this->conn->executeQuery($sql, [$sequenceName]); - $row = $stmt->fetch(FetchMode::ASSOCIATIVE); + $row = $this->conn->fetchAssociative($sql, [$sequenceName]); if ($row !== false) { $row = array_change_key_case($row, CASE_LOWER); diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 96727b2448a..d2ad241d099 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -17,7 +18,7 @@ /** * Portability wrapper for a Statement. */ -class Statement implements IteratorAggregate, DriverStatement +class Statement implements IteratorAggregate, DriverStatement, ForwardCompatibleResultStatement { /** @var int */ private $portability; @@ -115,6 +116,8 @@ public function execute($params = null) /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) { @@ -125,6 +128,8 @@ public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) /** * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. */ public function getIterator() { @@ -133,6 +138,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -140,7 +147,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX $row = $this->stmt->fetch($fetchMode); - $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; $fixCase = $this->case !== null && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($this->portability & Connection::PORTABILITY_FIX_CASE); @@ -152,6 +159,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -163,37 +172,138 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n $rows = $this->stmt->fetchAll($fetchMode); } - $iterateRow = $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM); - $fixCase = $this->case !== null + $fixCase = $this->case !== null && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($this->portability & Connection::PORTABILITY_FIX_CASE); + return $this->fixResultSet($rows, $fixCase, $fetchMode !== FetchMode::COLUMN); + } + + /** + * {@inheritdoc} + */ + public function fetchNumeric() + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $row = $this->stmt->fetchNumeric(); + } else { + $row = $this->stmt->fetch(FetchMode::NUMERIC); + } + + return $this->fixResult($row, false); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $row = $this->stmt->fetchAssociative(); + } else { + $row = $this->stmt->fetch(FetchMode::ASSOCIATIVE); + } + + return $this->fixResult($row, true); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $value = $this->stmt->fetchOne(); + } else { + $value = $this->stmt->fetch(FetchMode::COLUMN); + } + + if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) !== 0 && $value === '') { + $value = null; + } elseif (($this->portability & Connection::PORTABILITY_RTRIM) !== 0 && is_string($value)) { + $value = rtrim($value); + } + + return $value; + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $data = $this->stmt->fetchAllNumeric(); + } else { + $data = $this->stmt->fetchAll(FetchMode::NUMERIC); + } + + return $this->fixResultSet($data, false, true); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $data = $this->stmt->fetchAllAssociative(); + } else { + $data = $this->stmt->fetchAll(FetchMode::ASSOCIATIVE); + } + + return $this->fixResultSet($data, true, true); + } + + /** + * @param mixed $result + * + * @return mixed + */ + private function fixResult($result, bool $fixCase) + { + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; + $fixCase = $fixCase && $this->case !== null && ($this->portability & Connection::PORTABILITY_FIX_CASE) !== 0; + + return $this->fixRow($result, $iterateRow, $fixCase); + } + + /** + * @param array $resultSet + * + * @return array + */ + private function fixResultSet(array $resultSet, bool $fixCase, bool $isArray) : array + { + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; + $fixCase = $fixCase && $this->case !== null && ($this->portability & Connection::PORTABILITY_FIX_CASE) !== 0; + if (! $iterateRow && ! $fixCase) { - return $rows; + return $resultSet; } - if ($fetchMode === FetchMode::COLUMN) { - foreach ($rows as $num => $row) { - $rows[$num] = [$row]; + if (! $isArray) { + foreach ($resultSet as $num => $value) { + $resultSet[$num] = [$value]; } } - foreach ($rows as $num => $row) { - $rows[$num] = $this->fixRow($row, $iterateRow, $fixCase); + foreach ($resultSet as $num => $row) { + $resultSet[$num] = $this->fixRow($row, $iterateRow, $fixCase); } - if ($fetchMode === FetchMode::COLUMN) { - foreach ($rows as $num => $row) { - $rows[$num] = $row[0]; + if (! $isArray) { + foreach ($resultSet as $num => $row) { + $resultSet[$num] = $row[0]; } } - return $rows; + return $resultSet; } /** * @param mixed $row - * @param int $iterateRow + * @param bool $iterateRow * @param bool $fixCase * * @return mixed @@ -223,6 +333,8 @@ protected function fixRow($row, $iterateRow, $fixCase) /** * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index b90994e0e64..c1c23cdae5b 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -101,7 +101,7 @@ public function listDatabases() { $sql = $this->_platform->getListDatabasesSQL(); - $databases = $this->_conn->fetchAll($sql); + $databases = $this->_conn->fetchAllAssociative($sql); return $this->_getPortableDatabasesList($databases); } @@ -115,7 +115,7 @@ public function listNamespaceNames() { $sql = $this->_platform->getListNamespacesSQL(); - $namespaces = $this->_conn->fetchAll($sql); + $namespaces = $this->_conn->fetchAllAssociative($sql); return $this->getPortableNamespacesList($namespaces); } @@ -135,7 +135,7 @@ public function listSequences($database = null) $sql = $this->_platform->getListSequencesSQL($database); - $sequences = $this->_conn->fetchAll($sql); + $sequences = $this->_conn->fetchAllAssociative($sql); return $this->filterAssetNames($this->_getPortableSequencesList($sequences)); } @@ -163,7 +163,7 @@ public function listTableColumns($table, $database = null) $sql = $this->_platform->getListTableColumnsSQL($table, $database); - $tableColumns = $this->_conn->fetchAll($sql); + $tableColumns = $this->_conn->fetchAllAssociative($sql); return $this->_getPortableTableColumnList($table, $database, $tableColumns); } @@ -181,7 +181,7 @@ public function listTableIndexes($table) { $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase()); - $tableIndexes = $this->_conn->fetchAll($sql); + $tableIndexes = $this->_conn->fetchAllAssociative($sql); return $this->_getPortableTableIndexesList($tableIndexes, $table); } @@ -211,7 +211,7 @@ public function listTableNames() { $sql = $this->_platform->getListTablesSQL(); - $tables = $this->_conn->fetchAll($sql); + $tables = $this->_conn->fetchAllAssociative($sql); $tableNames = $this->_getPortableTablesList($tables); return $this->filterAssetNames($tableNames); @@ -289,7 +289,7 @@ public function listViews() { $database = $this->_conn->getDatabase(); $sql = $this->_platform->getListViewsSQL($database); - $views = $this->_conn->fetchAll($sql); + $views = $this->_conn->fetchAllAssociative($sql); return $this->_getPortableViewsList($views); } @@ -309,7 +309,7 @@ public function listTableForeignKeys($table, $database = null) } $sql = $this->_platform->getListTableForeignKeysSQL($table, $database); - $tableForeignKeys = $this->_conn->fetchAll($sql); + $tableForeignKeys = $this->_conn->fetchAllAssociative($sql); return $this->_getPortableTableForeignKeysList($tableForeignKeys); } diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index d2d6cef0743..60f95cb9cea 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -30,7 +30,7 @@ public function listTableNames() $sql = $this->_platform->getListTablesSQL(); $sql .= ' AND CREATOR = UPPER(' . $this->_conn->quote($this->_conn->getUsername()) . ')'; - $tables = $this->_conn->fetchAll($sql); + $tables = $this->_conn->fetchAllAssociative($sql); return $this->filterAssetNames($this->_getPortableTablesList($tables)); } @@ -228,7 +228,7 @@ public function listTableDetails($tableName) : Table assert($platform instanceof DB2Platform); $sql = $platform->getListTableCommentsSQL($tableName); - $tableOptions = $this->_conn->fetchAssoc($sql); + $tableOptions = $this->_conn->fetchAssociative($sql); if ($tableOptions !== false) { $table->addOption('comment', $tableOptions['REMARKS']); diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 15866efae9e..cd469f38c6a 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -326,7 +326,7 @@ public function listTableDetails($tableName) assert($platform instanceof MySqlPlatform); $sql = $platform->getListTableMetadataSQL($tableName); - $tableOptions = $this->_conn->fetchAssoc($sql); + $tableOptions = $this->_conn->fetchAssociative($sql); if ($tableOptions === false) { return $table; diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index e2816caeb00..108ae4d53e9 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -380,7 +380,7 @@ private function killUserSessions($user) AND p.addr(+) = s.paddr SQL; - $activeUserSessions = $this->_conn->fetchAll($sql, [strtoupper($user)]); + $activeUserSessions = $this->_conn->fetchAllAssociative($sql, [strtoupper($user)]); foreach ($activeUserSessions as $activeUserSession) { $activeUserSession = array_change_key_case($activeUserSession, CASE_LOWER); @@ -406,7 +406,7 @@ public function listTableDetails($tableName) : Table assert($platform instanceof OraclePlatform); $sql = $platform->getListTableCommentsSQL($tableName); - $tableOptions = $this->_conn->fetchAssoc($sql); + $tableOptions = $this->_conn->fetchAssociative($sql); if ($tableOptions !== false) { $table->addOption('comment', $tableOptions['COMMENTS']); diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index 287a7dac6ba..ceeb99d84c3 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -221,8 +221,7 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null implode(' ,', $colNumbers) ); - $stmt = $this->_conn->executeQuery($columnNameSql); - $indexColumns = $stmt->fetchAll(); + $indexColumns = $this->_conn->fetchAllAssociative($columnNameSql); // required for getting the order of the columns right. foreach ($colNumbers as $colNum) { diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index 54960657dd3..f14961f6b6d 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -248,7 +248,7 @@ public function listTableIndexes($table) $sql = $this->_platform->getListTableIndexesSQL($table, $this->_conn->getDatabase()); try { - $tableIndexes = $this->_conn->fetchAll($sql); + $tableIndexes = $this->_conn->fetchAllAssociative($sql); } catch (PDOException $e) { if ($e->getCode() === 'IMSSP') { return []; @@ -274,7 +274,7 @@ public function alterTable(TableDiff $tableDiff) if (count($tableDiff->removedColumns) > 0) { foreach ($tableDiff->removedColumns as $col) { $columnConstraintSql = $this->getColumnConstraintSQL($tableDiff->name, $col->getName()); - foreach ($this->_conn->fetchAll($columnConstraintSql) as $constraint) { + foreach ($this->_conn->fetchAllAssociative($columnConstraintSql) as $constraint) { $this->_conn->exec( sprintf( 'ALTER TABLE %s DROP CONSTRAINT %s', @@ -340,7 +340,7 @@ public function listTableDetails($tableName) : Table assert($platform instanceof SQLServerPlatform); $sql = $platform->getListTableMetadataSQL($tableName); - $tableOptions = $this->_conn->fetchAssoc($sql); + $tableOptions = $this->_conn->fetchAssociative($sql); if ($tableOptions !== false) { $table->addOption('comment', $tableOptions['table_comment']); diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 03076d96b6a..efdd5f9f4c8 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -4,7 +4,6 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; @@ -115,7 +114,7 @@ public function listTableForeignKeys($table, $database = null) } $sql = $this->_platform->getListTableForeignKeysSQL($table, $database); - $tableForeignKeys = $this->_conn->fetchAll($sql); + $tableForeignKeys = $this->_conn->fetchAllAssociative($sql); if (! empty($tableForeignKeys)) { $createSql = $this->getCreateTableSQL($table); @@ -169,11 +168,10 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null $indexBuffer = []; // fetch primary - $stmt = $this->_conn->executeQuery(sprintf( + $indexArray = $this->_conn->fetchAllAssociative(sprintf( 'PRAGMA TABLE_INFO (%s)', $this->_conn->quote($tableName) )); - $indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE); usort($indexArray, static function ($a, $b) { if ($a['pk'] === $b['pk']) { @@ -208,11 +206,10 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null $idx['primary'] = false; $idx['non_unique'] = ! $tableIndex['unique']; - $stmt = $this->_conn->executeQuery(sprintf( - 'PRAGMA INDEX_INFO (%s)', - $this->_conn->quote($keyName) - )); - $indexArray = $stmt->fetchAll(FetchMode::ASSOCIATIVE); + $indexArray = $this->_conn->fetchAllAssociative(sprintf( + 'PRAGMA INDEX_INFO (%s)', + $this->_conn->quote($keyName) + )); foreach ($indexArray as $indexColumnRow) { $idx['column_name'] = $indexColumnRow['name']; diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php index 2687c9d98ea..81a197ee117 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardManager.php @@ -87,7 +87,7 @@ public function queryAll($sql, array $params, array $types) foreach ($shards as $shard) { $this->conn->connect($shard['id']); - foreach ($this->conn->fetchAll($sql, $params, $types) as $row) { + foreach ($this->conn->fetchAllAssociative($sql, $params, $types) as $row) { $result[] = $row; } } diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index 62a6fd48447..a7d1ea5db17 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -159,7 +159,7 @@ public function getShards() INNER JOIN sys.federations f ON f.federation_id = d.federation_id WHERE f.name = ' . $this->conn->quote($this->federationName); - return $this->conn->fetchAll($sql); + return $this->conn->fetchAllAssociative($sql); } /** @@ -177,7 +177,7 @@ public function queryAll($sql, array $params = [], array $types = []) foreach ($shards as $shard) { $this->selectShard($shard['rangeLow']); - foreach ($this->conn->fetchAll($sql, $params, $types) as $row) { + foreach ($this->conn->fetchAllAssociative($sql, $params, $types) as $row) { $result[] = $row; } } diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index cb6fbde7a71..1c593478254 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -2,12 +2,15 @@ namespace Doctrine\DBAL; +use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Statement as DriverStatement; +use Doctrine\DBAL\ForwardCompatibility\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; use IteratorAggregate; use PDO; use Throwable; +use Traversable; use function is_array; use function is_string; @@ -15,7 +18,7 @@ * A thin wrapper around a Doctrine\DBAL\Driver\Statement that adds support * for logging, DBAL mapping types, etc. */ -class Statement implements IteratorAggregate, DriverStatement +class Statement implements IteratorAggregate, DriverStatement, ForwardCompatibleResultStatement { /** * The SQL statement. @@ -219,6 +222,8 @@ public function errorInfo() /** * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. */ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { @@ -236,6 +241,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) /** * Required by interface IteratorAggregate. * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. + * * {@inheritdoc} */ public function getIterator() @@ -245,6 +252,8 @@ public function getIterator() /** * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. */ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) { @@ -253,6 +262,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { @@ -261,12 +272,176 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n /** * {@inheritDoc} + * + * @deprecated Use fetchOne() instead. */ public function fetchColumn($columnIndex = 0) { return $this->stmt->fetchColumn($columnIndex); } + /** + * {@inheritdoc} + * + * @throws DBALException + */ + public function fetchNumeric() + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchNumeric(); + } + + return $this->stmt->fetch(FetchMode::NUMERIC); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritdoc} + * + * @throws DBALException + */ + public function fetchAssociative() + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchAssociative(); + } + + return $this->stmt->fetch(FetchMode::ASSOCIATIVE); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritDoc} + * + * @throws DBALException + */ + public function fetchOne() + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchOne(); + } + + return $this->stmt->fetch(FetchMode::COLUMN); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritdoc} + * + * @throws DBALException + */ + public function fetchAllNumeric() : array + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchAllNumeric(); + } + + return $this->stmt->fetchAll(FetchMode::NUMERIC); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritdoc} + * + * @throws DBALException + */ + public function fetchAllAssociative() : array + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchAllAssociative(); + } + + return $this->stmt->fetchAll(FetchMode::ASSOCIATIVE); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritDoc} + * + * @return Traversable> + * + * @throws DBALException + */ + public function iterateNumeric() : Traversable + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + while (($row = $this->stmt->fetchNumeric()) !== false) { + yield $row; + } + } else { + while (($row = $this->stmt->fetch(FetchMode::NUMERIC)) !== false) { + yield $row; + } + } + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritDoc} + * + * @return Traversable> + * + * @throws DBALException + */ + public function iterateAssociative() : Traversable + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + while (($row = $this->stmt->fetchAssociative()) !== false) { + yield $row; + } + } else { + while (($row = $this->stmt->fetch(FetchMode::ASSOCIATIVE)) !== false) { + yield $row; + } + } + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + + /** + * {@inheritDoc} + * + * @return Traversable + * + * @throws DBALException + */ + public function iterateColumn() : Traversable + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + while (($value = $this->stmt->fetchOne()) !== false) { + yield $value; + } + } else { + while (($value = $this->stmt->fetch(FetchMode::COLUMN)) !== false) { + yield $value; + } + } + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + /** * Returns the number of rows affected by the last execution of this statement. * diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 02b15cc1fc3..79c333dd89c 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } if (stripos($sql, 'select') === 0 || $input->getOption('force-fetch')) { - $resultSet = $conn->fetchAll($sql); + $resultSet = $conn->fetchAllAssociative($sql); } else { $resultSet = $conn->executeUpdate($sql); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php new file mode 100644 index 00000000000..27c672bcb46 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php @@ -0,0 +1,37 @@ +connection = DriverManager::getConnection( + array_merge($this->connection->getParams(), [ + 'wrapperClass' => Connection::class, + ]), + $this->connection->getConfiguration(), + $this->connection->getEventManager() + ); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php new file mode 100644 index 00000000000..2fe0d98d95b --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php @@ -0,0 +1,158 @@ +stmt = $stmt; + } + + /** + * {@inheritdoc} + */ + public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->bindParam($column, $variable, $type, $length); + } + + /** + * {@inheritdoc} + */ + public function bindValue($param, $value, $type = ParameterType::STRING) + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->bindValue($param, $value, $type); + } + + /** + * {@inheritdoc} + */ + public function closeCursor() + { + return $this->stmt->closeCursor(); + } + + /** + * {@inheritdoc} + */ + public function columnCount() + { + return $this->stmt->columnCount(); + } + + /** + * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. + */ + public function errorCode() + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->errorCode(); + } + + /** + * {@inheritdoc} + * + * @deprecated The error information is available via exceptions. + */ + public function errorInfo() + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->errorInfo(); + } + + /** + * {@inheritdoc} + */ + public function execute($params = null) + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->execute($params); + } + + /** + * {@inheritdoc} + * + * @deprecated Use one of the fetch- or iterate-related methods. + */ + public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) + { + return $this->stmt->setFetchMode($fetchMode, $arg1, $arg2); + } + + /** + * {@inheritdoc} + * + * @deprecated Use iterateNumeric(), iterateAssociative() or iterateColumn() instead. + */ + public function getIterator() + { + return new StatementIterator($this); + } + + /** + * {@inheritdoc} + * + * @deprecated Use fetchNumeric(), fetchAssociative() or fetchOne() instead. + */ + public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0) + { + return $this->stmt->fetch($fetchMode); + } + + /** + * {@inheritdoc} + * + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + */ + public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) + { + return $this->stmt->fetchAll($fetchMode, $fetchArgument); + } + + /** + * {@inheritdoc} + * + * @deprecated Use fetchOne() instead. + */ + public function fetchColumn($columnIndex = 0) + { + return $this->stmt->fetchColumn($columnIndex); + } + + /** + * {@inheritdoc} + */ + public function rowCount() + { + assert($this->stmt instanceof DriverStatement); + + return $this->stmt->rowCount(); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php new file mode 100644 index 00000000000..8d4c315670f --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php @@ -0,0 +1,114 @@ +query = TestUtil::generateResultSetQuery([ + [ + 'a' => 'foo', + 'b' => 1, + ], + [ + 'a' => 'bar', + 'b' => 2, + ], + [ + 'a' => 'baz', + 'b' => 3, + ], + ], $this->connection->getDatabasePlatform()); + } + + public function testFetchNumeric() : void + { + self::assertEquals(['foo', 1], $this->connection->fetchNumeric($this->query)); + } + + public function testFetchOne() : void + { + self::assertEquals('foo', $this->connection->fetchOne($this->query)); + } + + public function testFetchAssociative() : void + { + self::assertEquals([ + 'a' => 'foo', + 'b' => 1, + ], $this->connection->fetchAssociative($this->query)); + } + + public function testFetchAllNumeric() : void + { + self::assertEquals([ + ['foo', 1], + ['bar', 2], + ['baz', 3], + ], $this->connection->fetchAllNumeric($this->query)); + } + + public function testFetchAllAssociative() : void + { + self::assertEquals([ + [ + 'a' => 'foo', + 'b' => 1, + ], + [ + 'a' => 'bar', + 'b' => 2, + ], + [ + 'a' => 'baz', + 'b' => 3, + ], + ], $this->connection->fetchAllAssociative($this->query)); + } + + public function testIterateNumeric() : void + { + self::assertEquals([ + ['foo', 1], + ['bar', 2], + ['baz', 3], + ], iterator_to_array($this->connection->iterateNumeric($this->query))); + } + + public function testIterateAssociative() : void + { + self::assertEquals([ + [ + 'a' => 'foo', + 'b' => 1, + ], + [ + 'a' => 'bar', + 'b' => 2, + ], + [ + 'a' => 'baz', + 'b' => 3, + ], + ], iterator_to_array($this->connection->iterateAssociative($this->query))); + } + + public function testIterateColumn() : void + { + self::assertEquals([ + 'foo', + 'bar', + 'baz', + ], iterator_to_array($this->connection->iterateColumn($this->query))); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index 53f9a41cbda..86fe190c790 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -30,7 +30,7 @@ protected function setUp() : void $platform = $this->createMock(DB2Platform::class); $this->conn = $this ->getMockBuilder(Connection::class) - ->onlyMethods(['fetchAll', 'quote']) + ->onlyMethods(['fetchAllAssociative', 'quote']) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->getMock(); $this->manager = new DB2SchemaManager($this->conn); @@ -44,7 +44,7 @@ protected function setUp() : void public function testListTableNamesFiltersAssetNamesCorrectly() : void { $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); - $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ + $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], ['name' => 'BAR'], @@ -67,7 +67,7 @@ public function testAssetFilteringSetsACallable() : void { $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); - $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ + $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], ['name' => 'BAR'], @@ -96,7 +96,7 @@ public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : voi return in_array($assetName, $accepted); }); $this->conn->expects($this->any())->method('quote'); - $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ + $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], ['name' => 'BAR'], @@ -121,7 +121,7 @@ public function testSettingNullExpressionWillResetCallable() : void return in_array($assetName, $accepted); }); $this->conn->expects($this->any())->method('quote'); - $this->conn->expects($this->atLeastOnce())->method('fetchAll')->will($this->returnValue([ + $this->conn->expects($this->atLeastOnce())->method('fetchAllAssociative')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], ['name' => 'BAR'], @@ -156,7 +156,7 @@ public function testSettingNullAsCallableClearsExpression() : void $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); - $this->conn->expects($this->exactly(2))->method('fetchAll')->will($this->returnValue([ + $this->conn->expects($this->exactly(2))->method('fetchAllAssociative')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], ['name' => 'BAR'], diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php index 934b3e97bef..3cd1f928d0b 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -23,11 +23,15 @@ class MySqlSchemaManagerTest extends TestCase protected function setUp() : void { - $eventManager = new EventManager(); - $driverMock = $this->createMock(Driver::class); - $platform = $this->createMock(MySqlPlatform::class); + $eventManager = new EventManager(); + $driverMock = $this->createMock(Driver::class); + + $platform = $this->createMock(MySqlPlatform::class); + $platform->method('getListTableForeignKeysSQL') + ->willReturn(''); + $this->conn = $this->getMockBuilder(Connection::class) - ->onlyMethods(['fetchAll']) + ->onlyMethods(['fetchAllAssociative']) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->getMock(); $this->manager = new MySqlSchemaManager($this->conn); @@ -35,7 +39,7 @@ protected function setUp() : void public function testCompositeForeignKeys() : void { - $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue($this->getFKDefinition())); + $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue($this->getFKDefinition())); $fkeys = $this->manager->listTableForeignKeys('dummy'); self::assertCount(1, $fkeys, 'Table has to have one foreign key.'); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index eafbd69cfcb..2143bb2be7f 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -16,7 +16,7 @@ class PoolingShardManagerTest extends TestCase private function createConnectionMock() : PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) - ->onlyMethods(['connect', 'getParams', 'fetchAll']) + ->onlyMethods(['connect', 'getParams', 'fetchAllAssociative']) ->disableOriginalConstructor() ->getMock(); } @@ -101,12 +101,12 @@ public function testQueryAll() : void )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) - ->method('fetchAll') + ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) ->will($this->returnValue([ ['id' => 1] ])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) - ->method('fetchAll') + ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) ->will($this->returnValue([ ['id' => 2] ])); @@ -131,12 +131,12 @@ public function testQueryAllWithStaticShardChoser() : void )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) - ->method('fetchAll') + ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) ->will($this->returnValue([ ['id' => 1] ])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) - ->method('fetchAll') + ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) ->will($this->returnValue([ ['id' => 2] ])); diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index 202748be6d8..2f67996acdf 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -30,7 +30,7 @@ protected function setUp() : void $this->commandTester = new CommandTester($this->command); $this->connectionMock = $this->createMock(Connection::class); - $this->connectionMock->method('fetchAll') + $this->connectionMock->method('fetchAllAssociative') ->willReturn([[1]]); $this->connectionMock->method('executeUpdate') ->willReturn(42); @@ -68,7 +68,7 @@ public function testIncorrectDepthOption() : void public function testSelectStatementsPrintsResult() : void { - $this->expectConnectionFetchAll(); + $this->expectConnectionFetchAllAssociative(); $exitCode = $this->commandTester->execute([ 'command' => $this->command->getName(), @@ -100,22 +100,22 @@ private function expectConnectionExecuteUpdate() : void ->method('executeUpdate'); $this->connectionMock ->expects($this->exactly(0)) - ->method('fetchAll'); + ->method('fetchAllAssociative'); } - private function expectConnectionFetchAll() : void + private function expectConnectionFetchAllAssociative() : void { $this->connectionMock ->expects($this->exactly(0)) ->method('executeUpdate'); $this->connectionMock ->expects($this->exactly(1)) - ->method('fetchAll'); + ->method('fetchAllAssociative'); } public function testStatementsWithFetchResultPrintsResult() : void { - $this->expectConnectionFetchAll(); + $this->expectConnectionFetchAllAssociative(); $this->commandTester->execute([ 'command' => $this->command->getName(), diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index b5f4dd010c2..ad070abf491 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -4,9 +4,15 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Platforms\AbstractPlatform; use PHPUnit\Framework\Assert; +use function array_keys; +use function array_map; +use function array_values; use function explode; use function extension_loaded; +use function implode; +use function is_string; use function unlink; /** @@ -207,4 +213,24 @@ public static function getTempConnection() : Connection { return DriverManager::getConnection(self::getParamsForTemporaryConnection()); } + + /** + * Generates a query that will return the given rows without the need to create a temporary table. + * + * @param array> $rows + */ + public static function generateResultSetQuery(array $rows, AbstractPlatform $platform) : string + { + return implode(' UNION ALL ', array_map(static function (array $row) use ($platform) : string { + return $platform->getDummySelectSQL( + implode(', ', array_map(static function (string $column, $value) use ($platform) : string { + if (is_string($value)) { + $value = $platform->quoteStringLiteral($value); + } + + return $value . ' ' . $platform->quoteIdentifier($column); + }, array_keys($row), array_values($row))) + ); + }, $rows)); + } } From e0421d1592dc6271e2abf6a75c0a89d238e30fad Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 9 May 2020 15:09:30 -0700 Subject: [PATCH 18/93] Update documentation to use the new fetch API --- docs/en/reference/caching.rst | 2 +- .../data-retrieval-and-manipulation.rst | 34 +++++++++---------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/en/reference/caching.rst b/docs/en/reference/caching.rst index 5a2daf0b317..5e6885deae8 100644 --- a/docs/en/reference/caching.rst +++ b/docs/en/reference/caching.rst @@ -42,7 +42,7 @@ object is closed: executeCacheQuery($query, $params, $types, new QueryCacheProfile(0, "some key")); - $data = $stmt->fetchAll(); + $data = $stmt->fetchAllAssociative(); $stmt->closeCursor(); // at this point the result is cached .. warning:: diff --git a/docs/en/reference/data-retrieval-and-manipulation.rst b/docs/en/reference/data-retrieval-and-manipulation.rst index 31397a532b9..e1afd8ec322 100644 --- a/docs/en/reference/data-retrieval-and-manipulation.rst +++ b/docs/en/reference/data-retrieval-and-manipulation.rst @@ -41,7 +41,7 @@ the query until there are no more rows: fetch()) { + while (($row = $stmt->fetchAssociative()) !== false) { echo $row['headline']; } @@ -308,7 +308,7 @@ Prepare a given SQL statement and return the prepare('SELECT * FROM user'); $statement->execute(); - $users = $statement->fetchAll(); + $users = $statement->fetchAllAssociative(); /* array( @@ -346,7 +346,7 @@ parameters to the execute method, then returning the statement: executeQuery('SELECT * FROM user WHERE username = ?', array('jwage')); - $user = $statement->fetch(); + $user = $statement->fetchAssociative(); /* array( @@ -360,15 +360,15 @@ to perform necessary type conversions between actual input parameters and expected database values. See the :ref:`Types ` section for more information. -fetchAll() -~~~~~~~~~~ +fetchAllAssociative() +~~~~~~~~~~~~~~~~~~~~~ Execute the query and fetch all results into an array: .. code-block:: php fetchAll('SELECT * FROM user'); + $users = $conn->fetchAllAssociative('SELECT * FROM user'); /* array( @@ -379,15 +379,15 @@ Execute the query and fetch all results into an array: ) */ -fetchArray() -~~~~~~~~~~~~ +fetchNumeric() +~~~~~~~~~~~~~~ Numeric index retrieval of first result row of the given query: .. code-block:: php fetchArray('SELECT * FROM user WHERE username = ?', array('jwage')); + $user = $conn->fetchNumeric('SELECT * FROM user WHERE username = ?', array('jwage')); /* array( @@ -396,26 +396,26 @@ Numeric index retrieval of first result row of the given query: ) */ -fetchColumn() -~~~~~~~~~~~~~ +fetchOne() +~~~~~~~~~~ -Retrieve only the given column of the first result row. +Retrieve only the value of the first column of the first result row. .. code-block:: php fetchColumn('SELECT username FROM user WHERE id = ?', array(1), 0); + $username = $conn->fetchOne('SELECT username FROM user WHERE id = ?', array(1), 0); echo $username; // jwage -fetchAssoc() -~~~~~~~~~~~~ +fetchAssociative() +~~~~~~~~~~~~~~~~~~ -Retrieve assoc row of the first result row. +Retrieve associative array of the first result row. .. code-block:: php fetchAssoc('SELECT * FROM user WHERE username = ?', array('jwage')); + $user = $conn->fetchAssociative('SELECT * FROM user WHERE username = ?', array('jwage')); /* array( 'username' => 'jwage', From 4af4999b4ab57362c19cdfd2740d8470a4576471 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 9 May 2020 15:09:30 -0700 Subject: [PATCH 19/93] ResultCacheStatement::fetchAllNumeric() should return numeric arrays --- .../DBAL/Cache/ResultCacheStatement.php | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 1a4382dd178..28a7fa8162d 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -13,6 +13,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; +use function array_map; use function array_merge; use function array_values; use function assert; @@ -55,7 +56,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement, Forwar */ private $emptied = false; - /** @var mixed[] */ + /** @var array> */ private $data; /** @var int */ @@ -247,7 +248,9 @@ public function fetchAllNumeric() : array $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); } - return $this->store($data); + $this->store($data); + + return array_map('array_values', $this->data); } /** @@ -261,7 +264,9 @@ public function fetchAllAssociative() : array $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); } - return $this->store($data); + $this->store($data); + + return $this->data; } /** @@ -311,19 +316,11 @@ private function doFetch() } /** - * @param array> $data - * - * @return array> + * @param array> $data */ - private function store(array $data) : array + private function store(array $data) : void { - foreach ($data as $key => $value) { - $data[$key] = [$value]; - } - $this->data = $data; $this->emptied = true; - - return $this->data; } } From 3eb6f0a2cbc0f44fa5ca2a96ddfd6e4cdf5b0716 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 27 May 2020 09:24:49 -0700 Subject: [PATCH 20/93] Refactored ResultCacheTest for better coverage --- .../Tests/DBAL/Functional/ResultCacheTest.php | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 6d03a736e13..3786ccc2955 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -102,13 +102,13 @@ public function testMixingFetch() : void $numExpectedResult[] = array_values($v); } - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = $this->hydrateStmt($stmt, FetchMode::ASSOCIATIVE); self::assertEquals($this->expectedResult, $data); - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = $this->hydrateStmt($stmt, FetchMode::NUMERIC); @@ -124,10 +124,10 @@ public function testIteratorFetch() : void private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = $this->hydrateStmt($stmt, $fetchMode); - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $dataIterator = $this->hydrateStmtIterator($stmt, $fetchMode); self::assertEquals($data, $dataIterator); @@ -135,7 +135,7 @@ private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void public function testDontCloseNoCache() : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = []; @@ -143,7 +143,7 @@ public function testDontCloseNoCache() : void $data[] = $row; } - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = []; @@ -156,12 +156,12 @@ public function testDontCloseNoCache() : void public function testDontFinishNoCache() : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $stmt->fetch(FetchMode::ASSOCIATIVE); $stmt->closeCursor(); - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $this->hydrateStmt($stmt, FetchMode::NUMERIC); @@ -171,7 +171,7 @@ public function testDontFinishNoCache() : void public function testFetchAllAndFinishSavesCache() : void { $layerCache = new ArrayCache(); - $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'testcachekey', $layerCache)); + $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'testcachekey', $layerCache)); $stmt->fetchAll(); $stmt->closeCursor(); @@ -199,13 +199,13 @@ public function testFetchAllColumn() : void */ private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); self::assertEquals(2, $stmt->columnCount()); $data = $this->hydrateStmt($stmt, $fetchMode); self::assertEquals($expectedResult, $data); - $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey')); + $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); self::assertEquals(2, $stmt->columnCount()); $data = $this->hydrateStmt($stmt, $fetchMode); @@ -215,23 +215,24 @@ private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedR public function testEmptyResultCache() : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey')); - $data = $this->hydrateStmt($stmt); + $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey')); + $this->hydrateStmt($stmt); - $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey')); - $data = $this->hydrateStmt($stmt); + $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey')); + $this->hydrateStmt($stmt); self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit'); } public function testChangeCacheImpl() : void { - $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey')); - $data = $this->hydrateStmt($stmt); + $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey')); + $this->hydrateStmt($stmt); $secondCache = new ArrayCache(); - $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey', $secondCache)); - $data = $this->hydrateStmt($stmt); + + $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey', $secondCache)); + $this->hydrateStmt($stmt); self::assertCount(2, $this->sqlLogger->queries, 'two hits'); self::assertCount(1, $secondCache->fetch('emptycachekey')); @@ -243,7 +244,8 @@ public function testChangeCacheImpl() : void private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array { $data = []; - while ($row = $stmt->fetch($fetchMode)) { + + foreach ($stmt->fetchAll($fetchMode) as $row) { $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; } From e74b97c24bbe18651fbed967e2af29deeacdd13e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 27 May 2020 15:57:59 -0700 Subject: [PATCH 21/93] ResultCacheStatement should always fetch in associative mode This will allow for subsequent fetches in different modes. --- .../DBAL/Cache/ResultCacheStatement.php | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 28a7fa8162d..5cbb59e337c 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -180,18 +180,26 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { - $data = $this->statement->fetchAll($fetchMode, $fetchArgument, $ctorArgs); - - if ($fetchMode === FetchMode::COLUMN) { - foreach ($data as $key => $value) { - $data[$key] = [$value]; - } - } + $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE, $fetchArgument, $ctorArgs); $this->data = $data; $this->emptied = true; - return $this->data; + if ($fetchMode === FetchMode::NUMERIC) { + foreach ($data as $i => $row) { + $data[$i] = array_values($row); + } + } elseif ($fetchMode === FetchMode::MIXED) { + foreach ($data as $i => $row) { + $data[$i] = array_merge($row, array_values($row)); + } + } elseif ($fetchMode === FetchMode::COLUMN) { + foreach ($data as $i => $row) { + $data[$i] = reset($row); + } + } + + return $data; } /** From 5e8192df0c53cf2ac73d491b3393b27a8875b365 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 29 May 2020 12:13:35 -0700 Subject: [PATCH 22/93] Make DB2Statement forward-compatible as well --- .../DBAL/Driver/IBMDB2/DB2Statement.php | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 3a01b3ad9d1..30d7d9b7c8f 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -2,9 +2,11 @@ namespace Doctrine\DBAL\Driver\IBMDB2; +use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; +use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -46,7 +48,7 @@ use const DB2_PARAM_FILE; use const DB2_PARAM_IN; -class DB2Statement implements IteratorAggregate, Statement +class DB2Statement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement { /** @var resource */ private $stmt; @@ -356,6 +358,56 @@ public function fetchColumn($columnIndex = 0) return $row[$columnIndex] ?? null; } + /** + * {@inheritDoc} + */ + public function fetchNumeric() + { + if (! $this->result) { + return false; + } + + return db2_fetch_array($this->stmt); + } + + /** + * {@inheritdoc} + */ + public function fetchAssociative() + { + // do not try fetching from the statement if it's not expected to contain the result + // in order to prevent exceptional situation + if (! $this->result) { + return false; + } + + return db2_fetch_assoc($this->stmt); + } + + /** + * {@inheritdoc} + */ + public function fetchOne() + { + return FetchUtils::fetchOne($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllNumeric() : array + { + return FetchUtils::fetchAllNumeric($this); + } + + /** + * {@inheritdoc} + */ + public function fetchAllAssociative() : array + { + return FetchUtils::fetchAllAssociative($this); + } + /** * {@inheritdoc} */ From 23e569ea84e89007ac368f4b3040ce1a73fcf083 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 29 May 2020 11:56:12 -0700 Subject: [PATCH 23/93] Introduce Statement::fetchFirstColumn() --- UPGRADE.md | 2 +- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 8 ++++++ .../DBAL/Cache/ResultCacheStatement.php | 8 ++++++ lib/Doctrine/DBAL/Connection.php | 26 +++++++++++++++++++ lib/Doctrine/DBAL/Driver/FetchUtils.php | 16 ++++++++++++ .../DBAL/Driver/IBMDB2/DB2Statement.php | 8 ++++++ .../DBAL/Driver/Mysqli/MysqliStatement.php | 8 ++++++ .../DBAL/Driver/OCI8/OCI8Statement.php | 8 ++++++ lib/Doctrine/DBAL/Driver/PDOStatement.php | 8 ++++++ .../SQLAnywhere/SQLAnywhereStatement.php | 10 +++++++ .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 8 ++++++ .../Driver/ResultStatement.php | 9 +++++++ lib/Doctrine/DBAL/Portability/Statement.php | 14 ++++++++++ lib/Doctrine/DBAL/Statement.php | 18 +++++++++++++ .../DBAL/Functional/Connection/FetchTest.php | 9 +++++++ 15 files changed, 159 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 1a5b80cafdc..15f11853f02 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,7 +4,7 @@ 1. The `FetchMode` class and the `setFetchMode()` method of the `Connection` and `Statement` interfaces are deprecated. 2. The `Statement::fetch()` method is deprecated in favor of `fetchNumeric()`, `fetchAssociative()` and `fetchOne()`. -3. The `Statement::fetchAll()` method is deprecated in favor of `fetchAllNumeric()` and `fetchAllAssociative()`. There is no currently replacement for `Statement::fetchAll(FETCH_MODE::COLUMN)`. In a future major version, `fetchColumn()` will be used as a replacement. +3. The `Statement::fetchAll()` method is deprecated in favor of `fetchAllNumeric()`, `fetchAllAssociative()` and `fetchFirstColumn()`. 4. The `Statement::fetchColumn()` method is deprecated in favor of `fetchOne()`. 5. The `Connection::fetchArray()` and `fetchAssoc()` method are deprecated in favor of `fetchNumeric()` and `fetchAssociative()` respectively. 6. The `StatementIterator` class and the usage of a `Statement` object as `Traversable` is deprecated in favor of `iterateNumeric()`, `iterateAssociative()` and `iterateColumn()`. diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 1e17b766e27..aaddf7ec847 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -201,6 +201,14 @@ public function fetchAllAssociative() : array return FetchUtils::fetchAllAssociative($this); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * @return mixed|false */ diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 5cbb59e337c..dc2f8a0f8c5 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -277,6 +277,14 @@ public function fetchAllAssociative() : array return $this->data; } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement * executed by the corresponding object. diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 3ec360b839a..4319c0688ed 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -991,6 +991,32 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty } } + /** + * Prepares and executes an SQL query and returns the result as an array of the first column values. + * + * @param string $query The SQL query. + * @param array|array $params The query parameters. + * @param array|array $types The query parameter types. + * + * @return array + * + * @throws DBALException + */ + public function fetchFirstColumn(string $query, array $params = [], array $types = []) : array + { + try { + $stmt = $this->executeQuery($query, $params, $types); + + if ($stmt instanceof ForwardCompatibleResultStatement) { + return $stmt->fetchFirstColumn(); + } + + return $stmt->fetchAll(FetchMode::COLUMN); + } catch (Throwable $e) { + throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + } + } + /** * Prepares and executes an SQL query and returns the result as an iterator over rows represented as numeric arrays. * diff --git a/lib/Doctrine/DBAL/Driver/FetchUtils.php b/lib/Doctrine/DBAL/Driver/FetchUtils.php index 358429255f0..e9054d150f3 100644 --- a/lib/Doctrine/DBAL/Driver/FetchUtils.php +++ b/lib/Doctrine/DBAL/Driver/FetchUtils.php @@ -58,4 +58,20 @@ public static function fetchAllAssociative(ResultStatement $stmt) : array return $rows; } + + /** + * @return array + * + * @throws DriverException + */ + public static function fetchFirstColumn(ResultStatement $stmt) : array + { + $rows = []; + + while (($row = $stmt->fetchOne()) !== false) { + $rows[] = $row; + } + + return $rows; + } } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 30d7d9b7c8f..f882bce3b4e 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -408,6 +408,14 @@ public function fetchAllAssociative() : array return FetchUtils::fetchAllAssociative($this); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 88b73de7f07..cec330a4624 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -467,6 +467,14 @@ public function fetchAllAssociative() : array return FetchUtils::fetchAllAssociative($this); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 1be74545b2a..b73287589f7 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -591,6 +591,14 @@ public function fetchAllAssociative() : array return $this->doFetchAll(OCI_ASSOC, OCI_FETCHSTATEMENT_BY_ROW); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return $this->doFetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_COLUMN)[0]; + } + /** * @return mixed|false */ diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 1922c4c0e3a..63d023e7eaf 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -240,6 +240,14 @@ public function fetchAllAssociative() : array return $this->fetchAll(PDO::FETCH_ASSOC); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return $this->fetchAll(PDO::FETCH_COLUMN); + } + /** * Converts DBAL parameter type to PDO parameter type * diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index 74e9b5745ab..d8282870281 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -368,6 +368,16 @@ public function fetchAllAssociative() : array return FetchUtils::fetchAllAssociative($this); } + /** + * @return array + * + * @throws DriverException + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 8292a62c311..3ac77d6446b 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -476,6 +476,14 @@ public function fetchAllAssociative() : array return FetchUtils::fetchAllAssociative($this); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + return FetchUtils::fetchFirstColumn($this); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php index ef0f88bd511..a6802c8b2f9 100644 --- a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php @@ -56,4 +56,13 @@ public function fetchAllNumeric() : array; * @throws DriverException */ public function fetchAllAssociative() : array; + + /** + * Returns an array containing the values of the first column of the result set. + * + * @return array + * + * @throws DriverException + */ + public function fetchFirstColumn() : array; } diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index d2ad241d099..74f2574b47a 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -255,6 +255,20 @@ public function fetchAllAssociative() : array return $this->fixResultSet($data, true, true); } + /** + * {@inheritdoc} + */ + public function fetchFirstColumn() : array + { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + $data = $this->stmt->fetchFirstColumn(); + } else { + $data = $this->stmt->fetchAll(FetchMode::COLUMN); + } + + return $this->fixResultSet($data, true, false); + } + /** * @param mixed $result * diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 1c593478254..24a88123709 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -370,6 +370,24 @@ public function fetchAllAssociative() : array } } + /** + * {@inheritdoc} + * + * @throws DBALException + */ + public function fetchFirstColumn() : array + { + try { + if ($this->stmt instanceof ForwardCompatibleResultStatement) { + return $this->stmt->fetchFirstColumn(); + } + + return $this->stmt->fetchAll(FetchMode::COLUMN); + } catch (DriverException $e) { + throw DBALException::driverException($this->conn->getDriver(), $e); + } + } + /** * {@inheritDoc} * diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php index 8d4c315670f..b53b0b27509 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php @@ -76,6 +76,15 @@ public function testFetchAllAssociative() : void ], $this->connection->fetchAllAssociative($this->query)); } + public function testFetchFirstColumn() : void + { + self::assertEquals([ + 'foo', + 'bar', + 'baz', + ], $this->connection->fetchFirstColumn($this->query)); + } + public function testIterateNumeric() : void { self::assertEquals([ From 76a8caecc3d3b3ed9ca3d21f10d4cc354e7655ed Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 29 May 2020 12:16:18 -0700 Subject: [PATCH 24/93] Fix deprecation message for Statement::fetchAll() --- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 2 +- lib/Doctrine/DBAL/Cache/ResultCacheStatement.php | 2 +- lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php | 2 +- lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php | 2 +- lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | 2 +- lib/Doctrine/DBAL/Driver/PDOStatement.php | 2 +- lib/Doctrine/DBAL/Driver/ResultStatement.php | 2 +- lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php | 2 +- lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php | 2 +- lib/Doctrine/DBAL/Portability/Statement.php | 2 +- lib/Doctrine/DBAL/Statement.php | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index aaddf7ec847..bc3345e568e 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -124,7 +124,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index dc2f8a0f8c5..53d43117ef3 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -176,7 +176,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index f882bce3b4e..488053865f7 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -312,7 +312,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index cec330a4624..21a41e7e7b0 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -362,7 +362,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index b73287589f7..278d9f2b681 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -468,7 +468,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 63d023e7eaf..8dfcd3b4475 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -156,7 +156,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php index c48e0e28400..442552040cc 100644 --- a/lib/Doctrine/DBAL/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php @@ -71,7 +71,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * Returns an array containing all of the result set rows. * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. * * @param int|null $fetchMode Controls how the next row will be returned to the caller. * The value must be one of the {@link \Doctrine\DBAL\FetchMode} constants, diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index d8282870281..bc4113fb9d5 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -258,7 +258,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 3ac77d6446b..1bf4f6337bb 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -390,7 +390,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 74f2574b47a..366b8288084 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -160,7 +160,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 24a88123709..009558bfc93 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -263,7 +263,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX /** * {@inheritdoc} * - * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchColumn() instead. + * @deprecated Use fetchAllNumeric(), fetchAllAssociative() or fetchFirstColumn() instead. */ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null) { From dbc623d40ad18c24274735c1c85fdaa1dee3323f Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 6 Jun 2020 07:43:13 -0700 Subject: [PATCH 25/93] Update doctrine/coding-standard to 8.0 --- composer.json | 3 +- composer.lock | 63 ++-- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 7 +- lib/Doctrine/DBAL/Cache/QueryCacheProfile.php | 1 + .../DBAL/Cache/ResultCacheStatement.php | 9 +- lib/Doctrine/DBAL/Configuration.php | 7 +- lib/Doctrine/DBAL/Connection.php | 19 +- .../Connections/MasterSlaveConnection.php | 1 + lib/Doctrine/DBAL/DBALException.php | 9 +- .../DBAL/Driver/AbstractMySQLDriver.php | 29 +- .../EasyConnectString.php | 10 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 1 + .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 13 +- .../DBAL/Driver/AbstractSQLServerDriver.php | 13 +- .../DBAL/Driver/AbstractSQLiteDriver.php | 7 +- lib/Doctrine/DBAL/Driver/FetchUtils.php | 6 +- .../DBAL/Driver/IBMDB2/DB2Connection.php | 2 + .../DBAL/Driver/IBMDB2/DB2Statement.php | 14 +- .../DBAL/Driver/Mysqli/MysqliConnection.php | 9 +- .../DBAL/Driver/Mysqli/MysqliStatement.php | 11 +- lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 1 + .../DBAL/Driver/OCI8/OCI8Connection.php | 2 + .../DBAL/Driver/OCI8/OCI8Statement.php | 12 +- lib/Doctrine/DBAL/Driver/PDOConnection.php | 1 + lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 1 + .../DBAL/Driver/PDOSqlsrv/Connection.php | 1 + lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 3 +- .../DBAL/Driver/PDOSqlsrv/Statement.php | 3 +- lib/Doctrine/DBAL/Driver/PDOStatement.php | 12 +- .../DBAL/Driver/SQLAnywhere/Driver.php | 1 + .../SQLAnywhere/SQLAnywhereConnection.php | 1 + .../SQLAnywhere/SQLAnywhereException.php | 1 + .../SQLAnywhere/SQLAnywhereStatement.php | 8 +- .../DBAL/Driver/SQLSrv/SQLSrvConnection.php | 2 + .../DBAL/Driver/SQLSrv/SQLSrvException.php | 2 + .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 8 +- lib/Doctrine/DBAL/DriverManager.php | 21 +- .../Event/Listeners/OracleSessionInit.php | 2 + .../SchemaAlterTableAddColumnEventArgs.php | 1 + .../SchemaAlterTableChangeColumnEventArgs.php | 1 + .../DBAL/Event/SchemaAlterTableEventArgs.php | 1 + .../SchemaAlterTableRemoveColumnEventArgs.php | 1 + .../SchemaAlterTableRenameColumnEventArgs.php | 1 + .../SchemaCreateTableColumnEventArgs.php | 1 + .../DBAL/Event/SchemaCreateTableEventArgs.php | 1 + .../Driver/ResultStatement.php | 6 +- .../ForwardCompatibility/ResultStatement.php | 6 +- lib/Doctrine/DBAL/Id/TableGenerator.php | 2 + .../Internal/DependencyOrderCalculator.php | 10 +- lib/Doctrine/DBAL/Logging/EchoSQLLogger.php | 1 + .../DBAL/Platforms/AbstractPlatform.php | 22 +- lib/Doctrine/DBAL/Platforms/DB2Platform.php | 13 +- .../DBAL/Platforms/DrizzlePlatform.php | 4 +- .../Platforms/Keywords/MariaDb102Keywords.php | 4 +- .../Keywords/PostgreSQL100Keywords.php | 2 +- .../Keywords/ReservedKeywordsValidator.php | 1 + .../DBAL/Platforms/MariaDb1027Platform.php | 6 +- lib/Doctrine/DBAL/Platforms/MySqlPlatform.php | 8 +- .../DBAL/Platforms/OraclePlatform.php | 12 +- .../DBAL/Platforms/PostgreSQL100Platform.php | 4 +- .../DBAL/Platforms/PostgreSQL92Platform.php | 1 + .../DBAL/Platforms/PostgreSqlPlatform.php | 16 +- .../DBAL/Platforms/SQLAnywherePlatform.php | 3 +- .../DBAL/Platforms/SQLServer2008Platform.php | 2 +- .../DBAL/Platforms/SQLServer2012Platform.php | 5 +- .../DBAL/Platforms/SQLServerPlatform.php | 5 +- .../DBAL/Platforms/SqlitePlatform.php | 13 +- lib/Doctrine/DBAL/Portability/Connection.php | 2 + lib/Doctrine/DBAL/Portability/Statement.php | 17 +- .../Query/Expression/CompositeExpression.php | 7 +- .../Query/Expression/ExpressionBuilder.php | 5 +- lib/Doctrine/DBAL/Query/QueryBuilder.php | 5 +- lib/Doctrine/DBAL/Query/QueryException.php | 1 + lib/Doctrine/DBAL/SQLParserUtils.php | 11 +- lib/Doctrine/DBAL/Schema/AbstractAsset.php | 1 + .../DBAL/Schema/AbstractSchemaManager.php | 3 +- lib/Doctrine/DBAL/Schema/Column.php | 2 + lib/Doctrine/DBAL/Schema/Comparator.php | 18 +- lib/Doctrine/DBAL/Schema/DB2SchemaManager.php | 6 +- .../DBAL/Schema/DrizzleSchemaManager.php | 1 + .../DBAL/Schema/ForeignKeyConstraint.php | 3 +- lib/Doctrine/DBAL/Schema/Index.php | 5 +- .../DBAL/Schema/MySqlSchemaManager.php | 6 +- .../DBAL/Schema/OracleSchemaManager.php | 4 +- .../DBAL/Schema/PostgreSqlSchemaManager.php | 6 +- .../DBAL/Schema/SQLAnywhereSchemaManager.php | 1 + .../DBAL/Schema/SQLServerSchemaManager.php | 5 +- lib/Doctrine/DBAL/Schema/Schema.php | 13 +- lib/Doctrine/DBAL/Schema/SchemaDiff.php | 1 + lib/Doctrine/DBAL/Schema/SchemaException.php | 1 + lib/Doctrine/DBAL/Schema/Sequence.php | 1 + .../DBAL/Schema/SqliteSchemaManager.php | 28 +- .../SingleDatabaseSynchronizer.php | 1 + lib/Doctrine/DBAL/Schema/Table.php | 9 +- .../Visitor/CreateSchemaSqlCollector.php | 1 + .../Schema/Visitor/DropSchemaSqlCollector.php | 1 + lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php | 1 + .../DBAL/Sharding/PoolingShardConnection.php | 1 + .../SQLAzureFederationsSynchronizer.php | 1 + .../SQLAzure/SQLAzureShardManager.php | 1 + .../SQLAzure/Schema/MultiTenantVisitor.php | 1 + lib/Doctrine/DBAL/Statement.php | 13 +- .../Tools/Console/Command/ImportCommand.php | 2 + .../Console/Command/ReservedWordsCommand.php | 4 +- .../Tools/Console/Command/RunSqlCommand.php | 4 +- .../DBAL/Tools/Console/ConnectionProvider.php | 4 +- .../SingleConnectionProvider.php | 5 +- .../DBAL/Tools/Console/ConsoleRunner.php | 2 + lib/Doctrine/DBAL/Tools/Dumper.php | 5 +- lib/Doctrine/DBAL/Types/ArrayType.php | 3 +- lib/Doctrine/DBAL/Types/BinaryType.php | 1 + lib/Doctrine/DBAL/Types/BlobType.php | 1 + .../DBAL/Types/ConversionException.php | 3 +- lib/Doctrine/DBAL/Types/DateIntervalType.php | 1 + .../DBAL/Types/DateTimeImmutableType.php | 1 + lib/Doctrine/DBAL/Types/DateTimeType.php | 1 + lib/Doctrine/DBAL/Types/JsonArrayType.php | 1 + lib/Doctrine/DBAL/Types/JsonType.php | 2 + lib/Doctrine/DBAL/Types/ObjectType.php | 3 +- lib/Doctrine/DBAL/Types/SimpleArrayType.php | 1 + lib/Doctrine/DBAL/Types/TextType.php | 1 + lib/Doctrine/DBAL/Types/Type.php | 7 +- lib/Doctrine/DBAL/Types/TypeRegistry.php | 15 +- .../DBAL/Types/VarDateTimeImmutableType.php | 1 + lib/Doctrine/DBAL/Types/VarDateTimeType.php | 1 + phpcs.xml.dist | 1 + .../DBAL/Cache/QueryCacheProfileTest.php | 13 +- .../Doctrine/Tests/DBAL/ConfigurationTest.php | 6 +- .../Tests/DBAL/Connection/LoggingTest.php | 8 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 99 +++---- .../Doctrine/Tests/DBAL/DBALExceptionTest.php | 13 +- .../DBAL/Driver/AbstractDB2DriverTest.php | 6 +- .../Tests/DBAL/Driver/AbstractDriverTest.php | 29 +- .../DBAL/Driver/AbstractMySQLDriverTest.php | 12 +- .../EasyConnectStringTest.php | 4 +- .../DBAL/Driver/AbstractOracleDriverTest.php | 12 +- .../Driver/AbstractPostgreSQLDriverTest.php | 12 +- .../Driver/AbstractSQLAnywhereDriverTest.php | 10 +- .../Driver/AbstractSQLServerDriverTest.php | 8 +- .../DBAL/Driver/AbstractSQLiteDriverTest.php | 10 +- .../Driver/DrizzlePDOMySql/DriverTest.php | 12 +- .../DBAL/Driver/IBMDB2/DB2ConnectionTest.php | 5 +- .../DBAL/Driver/IBMDB2/DB2DriverTest.php | 4 +- .../Tests/DBAL/Driver/Mysqli/DriverTest.php | 4 +- .../Driver/Mysqli/MysqliConnectionTest.php | 9 +- .../Tests/DBAL/Driver/OCI8/DriverTest.php | 4 +- .../DBAL/Driver/OCI8/OCI8ConnectionTest.php | 5 +- .../DBAL/Driver/OCI8/OCI8StatementTest.php | 11 +- .../Tests/DBAL/Driver/PDOExceptionTest.php | 13 +- .../Tests/DBAL/Driver/PDOIbm/DriverTest.php | 4 +- .../Tests/DBAL/Driver/PDOMySql/DriverTest.php | 4 +- .../DBAL/Driver/PDOOracle/DriverTest.php | 4 +- .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 13 +- .../DBAL/Driver/PDOSqlite/DriverTest.php | 4 +- .../DBAL/Driver/PDOSqlsrv/DriverTest.php | 4 +- .../DBAL/Driver/SQLAnywhere/DriverTest.php | 4 +- .../SQLAnywhere/SQLAnywhereConnectionTest.php | 5 +- .../Tests/DBAL/Driver/SQLSrv/DriverTest.php | 4 +- .../Driver/SQLSrv/SQLSrvConnectionTest.php | 5 +- .../DBAL/Driver/StatementIteratorTest.php | 13 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 29 +- .../DBAL/Events/MysqlSessionInitTest.php | 4 +- .../DBAL/Events/OracleSessionInitTest.php | 9 +- .../Tests/DBAL/Events/SQLSessionInitTest.php | 4 +- .../InvalidArgumentExceptionTest.php | 2 +- .../Tests/DBAL/Functional/BlobTest.php | 17 +- .../BackwardCompatibility/Connection.php | 1 + .../BackwardCompatibility/FetchTest.php | 3 +- .../BackwardCompatibility/Statement.php | 1 + .../DBAL/Functional/Connection/FetchTest.php | 21 +- .../Tests/DBAL/Functional/ConnectionTest.php | 53 ++-- .../Tests/DBAL/Functional/DataAccessTest.php | 120 ++++---- .../Functional/Driver/AbstractDriverTest.php | 10 +- .../Driver/IBMDB2/DB2DriverTest.php | 9 +- .../Driver/IBMDB2/DB2StatementTest.php | 5 +- .../Driver/Mysqli/ConnectionTest.php | 14 +- .../Functional/Driver/Mysqli/DriverTest.php | 5 +- .../Functional/Driver/OCI8/DriverTest.php | 9 +- .../Driver/OCI8/OCI8ConnectionTest.php | 5 +- .../Functional/Driver/OCI8/StatementTest.php | 9 +- .../Functional/Driver/PDOConnectionTest.php | 18 +- .../Functional/Driver/PDOMySql/DriverTest.php | 5 +- .../Driver/PDOOracle/DriverTest.php | 9 +- .../Functional/Driver/PDOPgSql/DriverTest.php | 13 +- .../Driver/PDOPgsqlConnectionTest.php | 7 +- .../Driver/PDOSqlite/DriverTest.php | 5 +- .../Driver/PDOSqlsrv/DriverTest.php | 13 +- .../Driver/SQLAnywhere/ConnectionTest.php | 7 +- .../Driver/SQLAnywhere/DriverTest.php | 7 +- .../Driver/SQLAnywhere/StatementTest.php | 7 +- .../Functional/Driver/SQLSrv/DriverTest.php | 7 +- .../Driver/SQLSrv/StatementTest.php | 5 +- .../Tests/DBAL/Functional/ExceptionTest.php | 42 +-- .../Functional/LikeWildcardsEscapingTest.php | 3 +- .../Functional/MasterSlaveConnectionTest.php | 26 +- .../DBAL/Functional/ModifyLimitQueryTest.php | 22 +- .../DBAL/Functional/NamedParametersTest.php | 8 +- .../DBAL/Functional/PDOStatementTest.php | 5 +- .../Platform/DateExpressionTest.php | 5 +- .../Platform/DefaultExpressionTest.php | 15 +- ...imaryKeyWithNewAutoIncrementColumnTest.php | 7 +- .../DBAL/Functional/Platform/QuotingTest.php | 4 +- .../Tests/DBAL/Functional/PortabilityTest.php | 19 +- .../Tests/DBAL/Functional/ResultCacheTest.php | 38 +-- .../DBAL/Functional/Schema/ComparatorTest.php | 6 +- .../Schema/Db2SchemaManagerTest.php | 4 +- .../Functional/Schema/DefaultValueTest.php | 9 +- .../Schema/DrizzleSchemaManagerTest.php | 4 +- .../DBAL/Functional/Schema/ForeignKeyTest.php | 2 +- .../Schema/MySqlSchemaManagerTest.php | 48 +-- .../Schema/OracleSchemaManagerTest.php | 21 +- .../Schema/PostgreSqlSchemaManagerTest.php | 55 ++-- .../Schema/SQLAnywhereSchemaManagerTest.php | 8 +- .../Schema/SQLServerSchemaManagerTest.php | 13 +- .../SchemaManagerFunctionalTestCase.php | 163 ++++++----- .../Schema/SqliteSchemaManagerTest.php | 29 +- .../Tests/DBAL/Functional/StatementTest.php | 33 ++- .../DBAL/Functional/TableGeneratorTest.php | 6 +- .../DBAL/Functional/TemporaryTableTest.php | 20 +- .../DBAL/Functional/Ticket/DBAL168Test.php | 2 +- .../DBAL/Functional/Ticket/DBAL202Test.php | 6 +- .../DBAL/Functional/Ticket/DBAL421Test.php | 9 +- .../DBAL/Functional/Ticket/DBAL461Test.php | 2 +- .../DBAL/Functional/Ticket/DBAL510Test.php | 4 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 19 +- .../DBAL/Functional/Ticket/DBAL752Test.php | 5 +- .../Tests/DBAL/Functional/TransactionTest.php | 7 +- .../DBAL/Functional/TypeConversionTest.php | 31 +- .../DBAL/Functional/Types/BinaryTest.php | 7 +- .../Tests/DBAL/Functional/WriteTest.php | 43 +-- .../DependencyOrderCalculatorTest.php | 4 +- .../Tests/DBAL/Logging/DebugStackTest.php | 8 +- .../Tests/DBAL/Logging/LoggerChainTest.php | 8 +- .../AbstractMySQLPlatformTestCase.php | 161 +++++----- .../Platforms/AbstractPlatformTestCase.php | 275 +++++++++--------- .../AbstractPostgreSqlPlatformTestCase.php | 165 +++++------ .../AbstractSQLServerPlatformTestCase.php | 199 ++++++------- .../Tests/DBAL/Platforms/DB2PlatformTest.php | 118 ++++---- .../Platforms/MariaDb1027PlatformTest.php | 10 +- .../DBAL/Platforms/MySQL57PlatformTest.php | 18 +- .../DBAL/Platforms/MySqlPlatformTest.php | 4 +- .../DBAL/Platforms/OraclePlatformTest.php | 163 +++++------ .../Platforms/PostgreSQL100PlatformTest.php | 4 +- .../Platforms/PostgreSQL91PlatformTest.php | 8 +- .../Platforms/PostgreSQL92PlatformTest.php | 12 +- .../Platforms/PostgreSQL94PlatformTest.php | 6 +- .../DBAL/Platforms/PostgreSqlPlatformTest.php | 6 +- .../ReservedKeywordsValidatorTest.php | 6 +- .../Platforms/SQLAnywhere11PlatformTest.php | 6 +- .../Platforms/SQLAnywhere12PlatformTest.php | 16 +- .../Platforms/SQLAnywhere16PlatformTest.php | 6 +- .../Platforms/SQLAnywherePlatformTest.php | 207 ++++++------- .../DBAL/Platforms/SQLAzurePlatformTest.php | 4 +- .../Platforms/SQLServer2008PlatformTest.php | 4 +- .../Platforms/SQLServer2012PlatformTest.php | 58 ++-- .../DBAL/Platforms/SQLServerPlatformTest.php | 10 +- .../DBAL/Platforms/SqlitePlatformTest.php | 126 ++++---- .../Tests/DBAL/Portability/StatementTest.php | 25 +- .../Expression/CompositeExpressionTest.php | 10 +- .../Expression/ExpressionBuilderTest.php | 50 ++-- .../Tests/DBAL/Query/QueryBuilderTest.php | 140 ++++----- .../Tests/DBAL/SQLParserUtilsTest.php | 12 +- .../Tests/DBAL/Schema/ColumnDiffTest.php | 2 +- .../Doctrine/Tests/DBAL/Schema/ColumnTest.php | 18 +- .../Tests/DBAL/Schema/ComparatorTest.php | 115 ++++---- .../DBAL/Schema/DB2SchemaManagerTest.php | 13 +- .../DBAL/Schema/ForeignKeyConstraintTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/IndexTest.php | 28 +- .../DBAL/Schema/MySqlInheritCharsetTest.php | 7 +- .../DBAL/Schema/MySqlSchemaManagerTest.php | 7 +- .../DBAL/Schema/Platforms/MySQLSchemaTest.php | 8 +- .../Tests/DBAL/Schema/SchemaDiffTest.php | 6 +- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 47 +-- .../Tests/DBAL/Schema/SequenceTest.php | 4 +- .../DBAL/Schema/SqliteSchemaManagerTest.php | 8 +- .../SingleDatabaseSynchronizerTest.php | 10 +- .../Tests/DBAL/Schema/TableDiffTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/TableTest.php | 111 +++---- .../Visitor/CreateSchemaSqlCollectorTest.php | 12 +- .../Visitor/DropSchemaSqlCollectorTest.php | 6 +- .../Visitor/RemoveNamespacedAssetsTest.php | 7 +- .../Schema/Visitor/SchemaSqlCollectorTest.php | 6 +- .../Sharding/PoolingShardConnectionTest.php | 30 +- .../DBAL/Sharding/PoolingShardManagerTest.php | 34 +-- .../Sharding/SQLAzure/AbstractTestCase.php | 5 +- .../DBAL/Sharding/SQLAzure/FunctionalTest.php | 3 +- .../SQLAzure/MultiTenantVisitorTest.php | 4 +- .../SQLAzureFederationsSynchronizerTest.php | 6 +- .../SQLAzure/SQLAzureShardManagerTest.php | 16 +- .../MultiTenantShardChoserTest.php | 4 +- tests/Doctrine/Tests/DBAL/StatementTest.php | 12 +- .../DBAL/Tools/Console/RunSqlCommandTest.php | 16 +- .../Doctrine/Tests/DBAL/Tools/DumperTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/ArrayTest.php | 13 +- .../Tests/DBAL/Types/BaseDateTypeTestCase.php | 19 +- .../Doctrine/Tests/DBAL/Types/BinaryTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/BlobTest.php | 11 +- .../Doctrine/Tests/DBAL/Types/BooleanTest.php | 8 +- .../DBAL/Types/ConversionExceptionTest.php | 15 +- .../DBAL/Types/DateImmutableTypeTest.php | 27 +- .../Tests/DBAL/Types/DateIntervalTest.php | 24 +- tests/Doctrine/Tests/DBAL/Types/DateTest.php | 11 +- .../DBAL/Types/DateTimeImmutableTypeTest.php | 27 +- .../Tests/DBAL/Types/DateTimeTest.php | 10 +- .../Types/DateTimeTzImmutableTypeTest.php | 25 +- .../Tests/DBAL/Types/DateTimeTzTest.php | 8 +- .../Doctrine/Tests/DBAL/Types/DecimalTest.php | 6 +- tests/Doctrine/Tests/DBAL/Types/FloatTest.php | 10 +- .../Tests/DBAL/Types/GuidTypeTest.php | 8 +- .../Doctrine/Tests/DBAL/Types/IntegerTest.php | 6 +- .../Tests/DBAL/Types/JsonArrayTest.php | 19 +- tests/Doctrine/Tests/DBAL/Types/JsonTest.php | 23 +- .../Doctrine/Tests/DBAL/Types/ObjectTest.php | 13 +- .../Tests/DBAL/Types/SmallIntTest.php | 6 +- .../Doctrine/Tests/DBAL/Types/StringTest.php | 12 +- .../DBAL/Types/TimeImmutableTypeTest.php | 27 +- tests/Doctrine/Tests/DBAL/Types/TimeTest.php | 8 +- .../Tests/DBAL/Types/TypeRegistryTest.php | 26 +- tests/Doctrine/Tests/DBAL/Types/TypeTest.php | 4 +- .../Types/VarDateTimeImmutableTypeTest.php | 22 +- .../Tests/DBAL/Types/VarDateTimeTest.php | 14 +- tests/Doctrine/Tests/DBAL/UtilTest.php | 4 +- .../Doctrine/Tests/DbalFunctionalTestCase.php | 10 +- tests/Doctrine/Tests/TestUtil.php | 25 +- tests/Doctrine/Tests/Types/CommentedType.php | 1 + tests/Doctrine/Tests/Types/MySqlPointType.php | 1 + tests/continuousphp/bootstrap.php | 2 +- 328 files changed, 2745 insertions(+), 2430 deletions(-) diff --git a/composer.json b/composer.json index 05a594661a6..2d1bc1cc6b2 100644 --- a/composer.json +++ b/composer.json @@ -38,13 +38,12 @@ "doctrine/event-manager": "^1.0" }, "require-dev": { - "doctrine/coding-standard": "^7.0", + "doctrine/coding-standard": "^8.0", "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", "phpunit/phpunit": "^8.5.5", "psalm/plugin-phpunit": "^0.10.0", - "slevomat/coding-standard": "^6.3.6", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "vimeo/psalm": "^3.11.4" }, diff --git a/composer.lock b/composer.lock index 42076d79c12..3f82ebef974 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b30dd3ec95a2106c83cd9a9b72fbff75", + "content-hash": "a5c06fdb9d602a1498b1eba6aa45f1d4", "packages": [ { "name": "doctrine/cache", @@ -412,16 +412,16 @@ }, { "name": "dealerdirect/phpcodesniffer-composer-installer", - "version": "v0.5.0", + "version": "v0.6.2", "source": { "type": "git", "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132" + "reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132", - "reference": "e749410375ff6fb7a040a68878c656c2e610b132", + "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/8001af8eb107fbfcedc31a8b51e20b07d85b457a", + "reference": "8001af8eb107fbfcedc31a8b51e20b07d85b457a", "shasum": "" }, "require": { @@ -474,27 +474,27 @@ "stylecheck", "tests" ], - "time": "2018-10-26T13:21:45+00:00" + "time": "2020-01-29T20:22:20+00:00" }, { "name": "doctrine/coding-standard", - "version": "7.0.2", + "version": "8.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/coding-standard.git", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de" + "reference": "742200e29fb8ffd58ba9abec8a9ec33db0884677" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/d8a60ec4da68025c42795b714f66e277dd3e11de", - "reference": "d8a60ec4da68025c42795b714f66e277dd3e11de", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/742200e29fb8ffd58ba9abec8a9ec33db0884677", + "reference": "742200e29fb8ffd58ba9abec8a9ec33db0884677", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0", - "php": "^7.2", - "slevomat/coding-standard": "^6.0", - "squizlabs/php_codesniffer": "^3.5.3" + "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2", + "php": "^7.2 || ^8.0", + "slevomat/coding-standard": "^6.3.8", + "squizlabs/php_codesniffer": "^3.5.5" }, "type": "phpcodesniffer-standard", "extra": { @@ -502,11 +502,6 @@ "dev-master": "7.0.x-dev" } }, - "autoload": { - "psr-4": { - "Doctrine\\Sniffs\\": "lib/Doctrine/Sniffs" - } - }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" @@ -535,7 +530,7 @@ "standard", "style" ], - "time": "2019-12-11T07:59:21+00:00" + "time": "2020-06-02T17:58:43+00:00" }, { "name": "doctrine/instantiator", @@ -1369,6 +1364,20 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpstan", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", + "type": "tidelift" + } + ], "time": "2020-03-22T16:51:47+00:00" }, { @@ -2480,16 +2489,16 @@ }, { "name": "slevomat/coding-standard", - "version": "6.3.6", + "version": "6.3.8", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee" + "reference": "500f55b5e2dee1dcef8e88f2038990acdba29f1c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/7876032a4f55acf2de2cf3cd538feaf98a8a0fee", - "reference": "7876032a4f55acf2de2cf3cd538feaf98a8a0fee", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/500f55b5e2dee1dcef8e88f2038990acdba29f1c", + "reference": "500f55b5e2dee1dcef8e88f2038990acdba29f1c", "shasum": "" }, "require": { @@ -2533,7 +2542,7 @@ "type": "tidelift" } ], - "time": "2020-05-22T15:11:14+00:00" + "time": "2020-05-27T06:28:47+00:00" }, { "name": "squizlabs/php_codesniffer", @@ -2998,8 +3007,8 @@ "authors": [ { "name": "Arne Blankerts", - "email": "arne@blankerts.de", - "role": "Developer" + "role": "Developer", + "email": "arne@blankerts.de" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index bc3345e568e..50c4edae861 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -10,6 +10,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_merge; use function array_values; use function count; @@ -188,7 +189,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return FetchUtils::fetchAllNumeric($this); } @@ -196,7 +197,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return FetchUtils::fetchAllAssociative($this); } @@ -204,7 +205,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } diff --git a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php index aef70b4624b..cebffa565c0 100644 --- a/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php +++ b/lib/Doctrine/DBAL/Cache/QueryCacheProfile.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Cache; use Doctrine\Common\Cache\Cache; + use function hash; use function serialize; use function sha1; diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 53d43117ef3..cb36ff9974b 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -13,6 +13,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_map; use function array_merge; use function array_values; @@ -248,7 +249,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { if ($this->statement instanceof ForwardCompatibleResultStatement) { $data = $this->statement->fetchAllAssociative(); @@ -264,7 +265,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { if ($this->statement instanceof ForwardCompatibleResultStatement) { $data = $this->statement->fetchAllAssociative(); @@ -280,7 +281,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } @@ -334,7 +335,7 @@ private function doFetch() /** * @param array> $data */ - private function store(array $data) : void + private function store(array $data): void { $this->data = $data; $this->emptied = true; diff --git a/lib/Doctrine/DBAL/Configuration.php b/lib/Doctrine/DBAL/Configuration.php index 13260cd08bb..dcb93c39548 100644 --- a/lib/Doctrine/DBAL/Configuration.php +++ b/lib/Doctrine/DBAL/Configuration.php @@ -5,6 +5,7 @@ use Doctrine\Common\Cache\Cache; use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\Schema\AbstractAsset; + use function preg_match; /** @@ -101,7 +102,7 @@ public function getFilterSchemaAssetsExpression() /** * @param string $filterExpression */ - private function buildSchemaAssetsFilterFromExpression($filterExpression) : callable + private function buildSchemaAssetsFilterFromExpression($filterExpression): callable { return static function ($assetName) use ($filterExpression) { if ($assetName instanceof AbstractAsset) { @@ -115,7 +116,7 @@ private function buildSchemaAssetsFilterFromExpression($filterExpression) : call /** * Sets the callable to use to filter schema assets. */ - public function setSchemaAssetsFilter(?callable $callable = null) : ?callable + public function setSchemaAssetsFilter(?callable $callable = null): ?callable { $this->_attributes['filterSchemaAssetsExpression'] = null; @@ -125,7 +126,7 @@ public function setSchemaAssetsFilter(?callable $callable = null) : ?callable /** * Returns the callable to use to filter schema assets. */ - public function getSchemaAssetsFilter() : ?callable + public function getSchemaAssetsFilter(): ?callable { return $this->_attributes['filterSchemaAssetsExpressionCallable'] ?? null; } diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 4319c0688ed..32a97d85809 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -23,6 +23,7 @@ use Exception; use Throwable; use Traversable; + use function array_key_exists; use function assert; use function func_get_args; @@ -385,7 +386,7 @@ public function connect() * * @throws DBALException If an invalid platform was specified for this connection. */ - private function detectDatabasePlatform() : void + private function detectDatabasePlatform(): void { $version = $this->getDatabasePlatformVersion(); @@ -714,7 +715,7 @@ private function addIdentifierCondition( array &$columns, array &$values, array &$conditions - ) : void { + ): void { $platform = $this->getDatabasePlatform(); foreach ($identifier as $columnName => $value) { @@ -950,7 +951,7 @@ public function fetchAll($sql, array $params = [], $types = []) * * @throws DBALException */ - public function fetchAllNumeric(string $query, array $params = [], array $types = []) : array + public function fetchAllNumeric(string $query, array $params = [], array $types = []): array { try { $stmt = $this->executeQuery($query, $params, $types); @@ -976,7 +977,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types * * @throws DBALException */ - public function fetchAllAssociative(string $query, array $params = [], array $types = []) : array + public function fetchAllAssociative(string $query, array $params = [], array $types = []): array { try { $stmt = $this->executeQuery($query, $params, $types); @@ -1002,7 +1003,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty * * @throws DBALException */ - public function fetchFirstColumn(string $query, array $params = [], array $types = []) : array + public function fetchFirstColumn(string $query, array $params = [], array $types = []): array { try { $stmt = $this->executeQuery($query, $params, $types); @@ -1028,7 +1029,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types * * @throws DBALException */ - public function iterateNumeric(string $query, array $params = [], array $types = []) : Traversable + public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable { try { $stmt = $this->executeQuery($query, $params, $types); @@ -1056,7 +1057,7 @@ public function iterateNumeric(string $query, array $params = [], array $types = * * @throws DBALException */ - public function iterateAssociative(string $query, array $params = [], array $types = []) : Traversable + public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable { try { $stmt = $this->executeQuery($query, $params, $types); @@ -1084,7 +1085,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ * * @throws DBALException */ - public function iterateColumn(string $query, array $params = [], array $types = []) : Traversable + public function iterateColumn(string $query, array $params = [], array $types = []): Traversable { try { $stmt = $this->executeQuery($query, $params, $types); @@ -1585,7 +1586,7 @@ public function commit() /** * Commits all current nesting transactions. */ - private function commitAll() : void + private function commitAll(): void { while ($this->transactionNestingLevel !== 0) { if ($this->autoCommit === false && $this->transactionNestingLevel === 1) { diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 0a21d31b035..9362bc0c636 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; use InvalidArgumentException; + use function array_rand; use function assert; use function count; diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 30ada6c5ecd..dda63310675 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Type; use Exception; use Throwable; + use function array_map; use function bin2hex; use function get_class; @@ -37,7 +38,7 @@ public static function notSupported($method) return new self(sprintf("Operation '%s' is not supported by platform.", $method)); } - public static function invalidPlatformSpecified() : self + public static function invalidPlatformSpecified(): self { return new self( "Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.' @@ -47,7 +48,7 @@ public static function invalidPlatformSpecified() : self /** * @param mixed $invalidPlatform */ - public static function invalidPlatformType($invalidPlatform) : self + public static function invalidPlatformType($invalidPlatform): self { if (is_object($invalidPlatform)) { return new self( @@ -285,12 +286,12 @@ public static function typeNotFound($name) return new self('Type to be overwritten ' . $name . ' does not exist.'); } - public static function typeNotRegistered(Type $type) : self + public static function typeNotRegistered(Type $type): self { return new self(sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type))); } - public static function typeAlreadyRegistered(Type $type) : self + public static function typeAlreadyRegistered(Type $type): self { return new self( sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type)) diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 866e5d04617..4199581b00f 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Schema\MySqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function preg_match; use function stripos; use function version_compare; @@ -142,13 +143,15 @@ public function createDatabasePlatformForVersion($version) * * @throws DBALException */ - private function getOracleMysqlVersionNumber(string $versionString) : string + private function getOracleMysqlVersionNumber(string $versionString): string { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', - $versionString, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', + $versionString, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $versionString, '..' @@ -174,13 +177,15 @@ private function getOracleMysqlVersionNumber(string $versionString) : string * * @throws DBALException */ - private function getMariaDbMysqlVersionNumber(string $versionString) : string + private function getMariaDbMysqlVersionNumber(string $versionString): string { - if (! preg_match( - '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', - $versionString, - $versionParts - )) { + if ( + ! preg_match( + '/^(?:5\.5\.5-)?(mariadb-)?(?P\d+)\.(?P\d+)\.(?P\d+)/i', + $versionString, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $versionString, '^(?:5\.5\.5-)?(mariadb-)?..' diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php index 01f648b3b85..ba439744c01 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver/EasyConnectString.php @@ -23,7 +23,7 @@ private function __construct(string $string) $this->string = $string; } - public function __toString() : string + public function __toString(): string { return $this->string; } @@ -33,7 +33,7 @@ public function __toString() : string * * @param mixed[] $params */ - public static function fromArray(array $params) : self + public static function fromArray(array $params): self { return new self(self::renderParams($params)); } @@ -43,7 +43,7 @@ public static function fromArray(array $params) : self * * @param mixed[] $params */ - public static function fromConnectionParameters(array $params) : self + public static function fromConnectionParameters(array $params): self { if (! empty($params['connectstring'])) { return new self($params['connectstring']); @@ -90,7 +90,7 @@ public static function fromConnectionParameters(array $params) : self /** * @param mixed[] $params */ - private static function renderParams(array $params) : string + private static function renderParams(array $params): string { $chunks = []; @@ -110,7 +110,7 @@ private static function renderParams(array $params) : string /** * @param mixed $value */ - private static function renderValue($value) : string + private static function renderValue($value): string { if (is_array($value)) { return self::renderParams($value); diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index e5753fcf76b..2b16c5822e1 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Schema\PostgreSqlSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function preg_match; use function strpos; use function version_compare; diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 60cfb046ee6..ff53552d379 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function preg_match; use function version_compare; @@ -80,11 +81,13 @@ public function convertException($message, DriverException $exception) */ public function createDatabasePlatformForVersion($version) { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', - $version, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', + $version, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $version, '...' diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 421d82b3951..b624acd2454 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\SQLServerSchemaManager; use Doctrine\DBAL\VersionAwarePlatformDriver; + use function preg_match; use function version_compare; @@ -24,11 +25,13 @@ abstract class AbstractSQLServerDriver implements Driver, VersionAwarePlatformDr */ public function createDatabasePlatformForVersion($version) { - if (! preg_match( - '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', - $version, - $versionParts - )) { + if ( + ! preg_match( + '/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?)?/', + $version, + $versionParts + ) + ) { throw DBALException::invalidPlatformVersionSpecified( $version, '...' diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index 13c4a83e909..1c0def3a0f3 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\SqliteSchemaManager; + use function strpos; /** @@ -25,7 +26,8 @@ public function convertException($message, DriverException $exception) return new Exception\LockWaitTimeoutException($message, $exception); } - if (strpos($exception->getMessage(), 'must be unique') !== false || + if ( + strpos($exception->getMessage(), 'must be unique') !== false || strpos($exception->getMessage(), 'is not unique') !== false || strpos($exception->getMessage(), 'are not unique') !== false || strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false @@ -33,7 +35,8 @@ public function convertException($message, DriverException $exception) return new Exception\UniqueConstraintViolationException($message, $exception); } - if (strpos($exception->getMessage(), 'may not be NULL') !== false || + if ( + strpos($exception->getMessage(), 'may not be NULL') !== false || strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false ) { return new Exception\NotNullConstraintViolationException($message, $exception); diff --git a/lib/Doctrine/DBAL/Driver/FetchUtils.php b/lib/Doctrine/DBAL/Driver/FetchUtils.php index e9054d150f3..428b8174397 100644 --- a/lib/Doctrine/DBAL/Driver/FetchUtils.php +++ b/lib/Doctrine/DBAL/Driver/FetchUtils.php @@ -32,7 +32,7 @@ public static function fetchOne(ResultStatement $stmt) * * @throws DriverException */ - public static function fetchAllNumeric(ResultStatement $stmt) : array + public static function fetchAllNumeric(ResultStatement $stmt): array { $rows = []; @@ -48,7 +48,7 @@ public static function fetchAllNumeric(ResultStatement $stmt) : array * * @throws DriverException */ - public static function fetchAllAssociative(ResultStatement $stmt) : array + public static function fetchAllAssociative(ResultStatement $stmt): array { $rows = []; @@ -64,7 +64,7 @@ public static function fetchAllAssociative(ResultStatement $stmt) : array * * @throws DriverException */ - public static function fetchFirstColumn(ResultStatement $stmt) : array + public static function fetchFirstColumn(ResultStatement $stmt): array { $rows = []; diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 533617b2c87..60dbe59f58d 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use stdClass; + use function assert; use function db2_autocommit; use function db2_commit; @@ -23,6 +24,7 @@ use function db2_stmt_errormsg; use function func_get_args; use function is_bool; + use const DB2_AUTOCOMMIT_OFF; use const DB2_AUTOCOMMIT_ON; diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 488053865f7..45959bdc35e 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -14,6 +14,7 @@ use ReflectionObject; use ReflectionProperty; use stdClass; + use function array_change_key_case; use function db2_bind_param; use function db2_execute; @@ -41,6 +42,7 @@ use function stream_get_meta_data; use function strtolower; use function tmpfile; + use const CASE_LOWER; use const DB2_BINARY; use const DB2_CHAR; @@ -134,7 +136,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l * * @throws DB2Exception */ - private function bind($position, &$variable, int $parameterType, int $dataType) : void + private function bind($position, &$variable, int $parameterType, int $dataType): void { $this->bindParam[$position] =& $variable; @@ -395,7 +397,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return FetchUtils::fetchAllNumeric($this); } @@ -403,7 +405,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return FetchUtils::fetchAllAssociative($this); } @@ -411,7 +413,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } @@ -511,7 +513,7 @@ private function createTemporaryFile() * * @throws DB2Exception */ - private function copyStreamToStream($source, $target) : void + private function copyStreamToStream($source, $target): void { if (@stream_copy_to_stream($source, $target) === false) { throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']); @@ -523,7 +525,7 @@ private function copyStreamToStream($source, $target) : void * * @throws DB2Exception */ - private function writeStringToStream(string $string, $target) : void + private function writeStringToStream(string $string, $target): void { if (@fwrite($target, $string) === false) { throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']); diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 3ef5942a108..ffdc205a237 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use mysqli; + use function defined; use function floor; use function func_get_args; @@ -20,6 +21,7 @@ use function set_error_handler; use function sprintf; use function stripos; + use const MYSQLI_INIT_COMMAND; use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_LOCAL_INFILE; @@ -230,7 +232,7 @@ public function errorInfo() * @throws MysqliException When one of of the options is not supported. * @throws MysqliException When applying doesn't work - e.g. due to incorrect value. */ - private function setDriverOptions(array $driverOptions = []) : void + private function setDriverOptions(array $driverOptions = []): void { $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, @@ -289,9 +291,10 @@ public function ping() * * @throws MysqliException */ - private function setSecureConnection(array $params) : void + private function setSecureConnection(array $params): void { - if (! isset($params['ssl_key']) && + if ( + ! isset($params['ssl_key']) && ! isset($params['ssl_cert']) && ! isset($params['ssl_ca']) && ! isset($params['ssl_capath']) && diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 21a41e7e7b0..16a0cf767f1 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -13,6 +13,7 @@ use mysqli; use mysqli_stmt; use PDO; + use function array_combine; use function array_fill; use function assert; @@ -209,7 +210,7 @@ public function execute($params = null) /** * Binds parameters with known types previously bound to the statement */ - private function bindTypedParameters() : void + private function bindTypedParameters(): void { $streams = $values = []; $types = $this->types; @@ -252,7 +253,7 @@ private function bindTypedParameters() : void * * @throws MysqliException */ - private function sendLongData(array $streams) : void + private function sendLongData(array $streams): void { foreach ($streams as $paramNr => $stream) { while (! feof($stream)) { @@ -454,7 +455,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return FetchUtils::fetchAllNumeric($this); } @@ -462,7 +463,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return FetchUtils::fetchAllAssociative($this); } @@ -470,7 +471,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index 0f2ebf362cb..b749154845e 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; + use const OCI_NO_AUTO_COMMIT; /** diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 359e80e6304..cd30f3045c6 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use UnexpectedValueException; + use function addcslashes; use function func_get_args; use function is_float; @@ -19,6 +20,7 @@ use function preg_match; use function sprintf; use function str_replace; + use const OCI_COMMIT_ON_SUCCESS; use const OCI_NO_AUTO_COMMIT; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 278d9f2b681..38a5a14bafe 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -11,6 +11,7 @@ use InvalidArgumentException; use IteratorAggregate; use PDO; + use function array_key_exists; use function assert; use function count; @@ -32,6 +33,7 @@ use function preg_quote; use function sprintf; use function substr; + use const OCI_ASSOC; use const OCI_B_BIN; use const OCI_B_BLOB; @@ -313,7 +315,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le /** * Converts DBAL parameter type to oci8 parameter type */ - private function convertParameterType(int $type) : int + private function convertParameterType(int $type): int { switch ($type) { case ParameterType::BINARY: @@ -578,7 +580,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return $this->doFetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_ROW); } @@ -586,7 +588,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return $this->doFetchAll(OCI_ASSOC, OCI_FETCHSTATEMENT_BY_ROW); } @@ -594,7 +596,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return $this->doFetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_COLUMN)[0]; } @@ -619,7 +621,7 @@ private function doFetch(int $mode) /** * @return array */ - private function doFetchAll(int $mode, int $fetchStructure) : array + private function doFetchAll(int $mode, int $fetchStructure): array { // do not try fetching from the statement if it's not expected to contain the result // in order to prevent exceptional situation diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index e3d586edb8d..35e99729756 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use PDO; + use function assert; use function func_get_args; diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index f25cd5cded3..43f06cb7b7f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOConnection; use PDO; use PDOException; + use function defined; /** @@ -27,7 +28,8 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); - if (defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') + if ( + defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true ) diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index d08c6a2c848..4566f649578 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 56cca064068..ab4078e05a9 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use PDO; + use function strpos; use function substr; diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index 6d6c4844d57..4316e4c350e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\AbstractSQLServerDriver; + use function is_int; use function sprintf; @@ -70,7 +71,7 @@ private function _constructPdoDsn(array $params, array $connectionOptions) * * @param string[] $connectionOptions */ - private function getConnectionOptionsDsn(array $connectionOptions) : string + private function getConnectionOptionsDsn(array $connectionOptions): string { $connectionOptionsDsn = ''; diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 6803bb14ed7..8d6521ff56c 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -16,7 +16,8 @@ class Statement extends PDOStatement */ public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) { - if (($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) + if ( + ($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) && $driverOptions === null ) { $driverOptions = PDO::SQLSRV_ENCODING_BINARY; diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 8dfcd3b4475..c55a79925d7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -6,12 +6,14 @@ use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use PDO; + use function array_slice; use function assert; use function func_get_args; use function is_array; use function sprintf; use function trigger_error; + use const E_USER_DEPRECATED; /** @@ -227,7 +229,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return $this->fetchAll(PDO::FETCH_NUM); } @@ -235,7 +237,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return $this->fetchAll(PDO::FETCH_ASSOC); } @@ -243,7 +245,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return $this->fetchAll(PDO::FETCH_COLUMN); } @@ -253,7 +255,7 @@ public function fetchFirstColumn() : array * * @param int $type Parameter type */ - private function convertParamType(int $type) : int + private function convertParamType(int $type): int { if (! isset(self::PARAM_TYPE_MAP[$type])) { // TODO: next major: throw an exception @@ -273,7 +275,7 @@ private function convertParamType(int $type) : int * * @param int $fetchMode Fetch mode */ - private function convertFetchMode(int $fetchMode) : int + private function convertFetchMode(int $fetchMode): int { if (! isset(self::FETCH_MODE_MAP[$fetchMode])) { // TODO: next major: throw an exception diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index 9564dc2981d..5ec94f6c9a0 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; + use function array_keys; use function array_map; use function implode; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index 37d99c328be..b3657e41350 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; + use function assert; use function func_get_args; use function is_float; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php index 022cfe2dfa7..5446a3b142c 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereException.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException; use InvalidArgumentException; + use function sasql_error; use function sasql_errorcode; use function sasql_sqlstate; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index bc4113fb9d5..a8eddb7fdad 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -14,6 +14,7 @@ use ReflectionClass; use ReflectionObject; use stdClass; + use function array_key_exists; use function func_get_args; use function func_num_args; @@ -37,6 +38,7 @@ use function sasql_stmt_reset; use function sasql_stmt_result_metadata; use function sprintf; + use const SASQL_BOTH; /** @@ -353,7 +355,7 @@ public function fetchOne() * * @throws DriverException */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return FetchUtils::fetchAllNumeric($this); } @@ -363,7 +365,7 @@ public function fetchAllNumeric() : array * * @throws DriverException */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return FetchUtils::fetchAllAssociative($this); } @@ -373,7 +375,7 @@ public function fetchAllAssociative() : array * * @throws DriverException */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index b5b0f0518e8..912b63336a7 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; + use function func_get_args; use function is_float; use function is_int; @@ -20,6 +21,7 @@ use function sqlsrv_rows_affected; use function sqlsrv_server_info; use function str_replace; + use const SQLSRV_ERR_ERRORS; /** diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index 4dfe548f87a..af70c6852ff 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -3,8 +3,10 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\AbstractDriverException; + use function rtrim; use function sqlsrv_errors; + use const SQLSRV_ERR_ERRORS; /** diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 1bf4f6337bb..1042bb18cb5 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; + use function array_key_exists; use function count; use function func_get_args; @@ -30,6 +31,7 @@ use function sqlsrv_rows_affected; use function SQLSRV_SQLTYPE_VARBINARY; use function stripos; + use const SQLSRV_ENC_BINARY; use const SQLSRV_ERR_ERRORS; use const SQLSRV_FETCH_ASSOC; @@ -463,7 +465,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { return FetchUtils::fetchAllNumeric($this); } @@ -471,7 +473,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { return FetchUtils::fetchAllAssociative($this); } @@ -479,7 +481,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { return FetchUtils::fetchFirstColumn($this); } diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index d3ed63a7f39..f7462bbd462 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use PDO; + use function array_keys; use function array_map; use function array_merge; @@ -129,7 +130,7 @@ public static function getConnection( array $params, ?Configuration $config = null, ?EventManager $eventManager = null - ) : Connection { + ): Connection { // create default config and event manager, if not set if (! $config) { $config = new Configuration(); @@ -196,7 +197,7 @@ public static function getConnection( * * @return string[] */ - public static function getAvailableDrivers() : array + public static function getAvailableDrivers(): array { return array_keys(self::$_driverMap); } @@ -208,7 +209,7 @@ public static function getAvailableDrivers() : array * * @throws DBALException */ - private static function _checkParams(array $params) : void + private static function _checkParams(array $params): void { // check existence of mandatory parameters @@ -234,7 +235,7 @@ private static function _checkParams(array $params) : void * * @return string The normalized connection URL path */ - private static function normalizeDatabaseUrlPath(string $urlPath) : string + private static function normalizeDatabaseUrlPath(string $urlPath): string { // Trim leading slash from URL path. return substr($urlPath, 1); @@ -251,7 +252,7 @@ private static function normalizeDatabaseUrlPath(string $urlPath) : string * * @throws DBALException */ - private static function parseDatabaseUrl(array $params) : array + private static function parseDatabaseUrl(array $params): array { if (! isset($params['url'])) { return $params; @@ -310,7 +311,7 @@ private static function parseDatabaseUrl(array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseDatabaseUrlPath(array $url, array $params) : array + private static function parseDatabaseUrlPath(array $url, array $params): array { if (! isset($url['path'])) { return $params; @@ -339,7 +340,7 @@ private static function parseDatabaseUrlPath(array $url, array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseDatabaseUrlQuery(array $url, array $params) : array + private static function parseDatabaseUrlQuery(array $url, array $params): array { if (! isset($url['query'])) { return $params; @@ -364,7 +365,7 @@ private static function parseDatabaseUrlQuery(array $url, array $params) : array * * @return mixed[] The resolved connection parameters. */ - private static function parseRegularDatabaseUrlPath(array $url, array $params) : array + private static function parseRegularDatabaseUrlPath(array $url, array $params): array { $params['dbname'] = $url['path']; @@ -383,7 +384,7 @@ private static function parseRegularDatabaseUrlPath(array $url, array $params) : * * @return mixed[] The resolved connection parameters. */ - private static function parseSqliteDatabaseUrlPath(array $url, array $params) : array + private static function parseSqliteDatabaseUrlPath(array $url, array $params): array { if ($url['path'] === ':memory:') { $params['memory'] = true; @@ -406,7 +407,7 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params) : * * @throws DBALException If parsing failed or resolution is not possible. */ - private static function parseDatabaseUrlScheme(array $url, array $params) : array + private static function parseDatabaseUrlScheme(array $url, array $params): array { if (isset($url['scheme'])) { // The requested driver from the URL scheme takes precedence diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index abcf42a5ac9..3e382f72c61 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -5,10 +5,12 @@ use Doctrine\Common\EventSubscriber; use Doctrine\DBAL\Event\ConnectionEventArgs; use Doctrine\DBAL\Events; + use function array_change_key_case; use function array_merge; use function count; use function implode; + use const CASE_UPPER; /** diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php index 1aee06f8e27..1460d0bf1d9 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableAddColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php index e806c9a6cb1..ac01acccbed 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableChangeColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php index 505d2a3600a..cde0cc553af 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableEventArgs.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php index 7a2fe596a46..f9413e37068 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRemoveColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php index 3f65e62ecab..b1c015115f9 100644 --- a/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaAlterTableRenameColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\TableDiff; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php index d24ff439595..ce88deda5cc 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableColumnEventArgs.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Table; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php index ee4061b4543..3fd8149f5f8 100644 --- a/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php +++ b/lib/Doctrine/DBAL/Event/SchemaCreateTableEventArgs.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Table; + use function array_merge; use function func_get_args; use function is_array; diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php index a6802c8b2f9..c0c7dffc667 100644 --- a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php @@ -46,7 +46,7 @@ public function fetchOne(); * * @throws DriverException */ - public function fetchAllNumeric() : array; + public function fetchAllNumeric(): array; /** * Returns an array containing all of the result set rows represented as associative arrays. @@ -55,7 +55,7 @@ public function fetchAllNumeric() : array; * * @throws DriverException */ - public function fetchAllAssociative() : array; + public function fetchAllAssociative(): array; /** * Returns an array containing the values of the first column of the result set. @@ -64,5 +64,5 @@ public function fetchAllAssociative() : array; * * @throws DriverException */ - public function fetchFirstColumn() : array; + public function fetchFirstColumn(): array; } diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php b/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php index 2ba19fa5324..041c4098419 100644 --- a/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php +++ b/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php @@ -20,7 +20,7 @@ interface ResultStatement extends BaseResultStatement * * @throws DBALException */ - public function iterateNumeric() : Traversable; + public function iterateNumeric(): Traversable; /** * Returns an iterator over the result set rows represented as associative arrays. @@ -29,7 +29,7 @@ public function iterateNumeric() : Traversable; * * @throws DBALException */ - public function iterateAssociative() : Traversable; + public function iterateAssociative(): Traversable; /** * Returns an iterator over the values of the first column of the result set. @@ -38,5 +38,5 @@ public function iterateAssociative() : Traversable; * * @throws DBALException */ - public function iterateColumn() : Traversable; + public function iterateColumn(): Traversable; } diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index e3b4c4d2ee6..35cda11431b 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -7,9 +7,11 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\LockMode; use Throwable; + use function array_change_key_case; use function assert; use function is_int; + use const CASE_LOWER; /** diff --git a/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php b/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php index c1026993be8..55b70c190ab 100644 --- a/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php +++ b/lib/Doctrine/DBAL/Internal/DependencyOrderCalculator.php @@ -35,7 +35,7 @@ final class DependencyOrderCalculator /** * Checks for node (vertex) existence in graph. */ - public function hasNode(string $hash) : bool + public function hasNode(string $hash): bool { return isset($this->nodeList[$hash]); } @@ -45,7 +45,7 @@ public function hasNode(string $hash) : bool * * @param object $node */ - public function addNode(string $hash, $node) : void + public function addNode(string $hash, $node): void { $vertex = new DependencyOrderNode(); @@ -59,7 +59,7 @@ public function addNode(string $hash, $node) : void /** * Adds a new dependency (edge) to the graph using their hashes. */ - public function addDependency(string $fromHash, string $toHash) : void + public function addDependency(string $fromHash, string $toHash): void { $vertex = $this->nodeList[$fromHash]; $edge = new DependencyOrderEdge(); @@ -78,7 +78,7 @@ public function addDependency(string $fromHash, string $toHash) : void * * @return array */ - public function sort() : array + public function sort(): array { foreach ($this->nodeList as $vertex) { if ($vertex->state !== self::NOT_VISITED) { @@ -101,7 +101,7 @@ public function sort() : array * * {@internal Highly performance-sensitive method.} */ - private function visit(DependencyOrderNode $vertex) : void + private function visit(DependencyOrderNode $vertex): void { $vertex->state = self::IN_PROGRESS; diff --git a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php index bd2d2f93eab..9499d2ce643 100644 --- a/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php +++ b/lib/Doctrine/DBAL/Logging/EchoSQLLogger.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Logging; use function var_dump; + use const PHP_EOL; /** diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index bb4a3a569e8..38d934550d3 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -28,6 +28,7 @@ use Doctrine\DBAL\Types\Type; use InvalidArgumentException; use UnexpectedValueException; + use function addcslashes; use function array_map; use function array_merge; @@ -54,6 +55,7 @@ use function strtolower; use function strtoupper; use function trigger_error; + use const E_USER_DEPRECATED; /** @@ -574,7 +576,7 @@ public function getSqlCommentEndString() /** * Gets the maximum length of a char field. */ - public function getCharMaxLength() : int + public function getCharMaxLength(): int { return $this->getVarcharMaxLength(); } @@ -1550,7 +1552,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $options['indexes'] = []; $options['primary'] = []; - if (($createFlags&self::CREATE_INDEXES) > 0) { + if (($createFlags & self::CREATE_INDEXES) > 0) { foreach ($table->getIndexes() as $index) { if ($index->isPrimary()) { $options['primary'] = $index->getQuotedColumns($this); @@ -1592,7 +1594,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE $columns[$columnData['name']] = $columnData; } - if (($createFlags&self::CREATE_FOREIGNKEYS) > 0) { + if (($createFlags & self::CREATE_FOREIGNKEYS) > 0) { $options['foreignKeys'] = []; foreach ($table->getForeignKeys() as $fkConstraint) { $options['foreignKeys'][] = $fkConstraint; @@ -1628,7 +1630,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE return array_merge($sql, $columnSql); } - protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string + protected function getCommentOnTableSQL(string $tableName, ?string $comment): string { $tableName = new Identifier($tableName); @@ -2437,7 +2439,7 @@ public function getCustomTypeDeclarationSQL(array $columnDef) * * @param mixed[]|Index $columnsOrIndex array declaration is deprecated, prefer passing Index to this method */ - public function getIndexFieldDeclarationListSQL($columnsOrIndex) : string + public function getIndexFieldDeclarationListSQL($columnsOrIndex): string { if ($columnsOrIndex instanceof Index) { return implode(', ', $columnsOrIndex->getQuotedColumns($this)); @@ -2692,7 +2694,7 @@ public function convertBooleans($item) */ public function convertFromBoolean($item) { - return $item === null ? null: (bool) $item; + return $item === null ? null : (bool) $item; } /** @@ -3133,7 +3135,7 @@ public function supportsPartialIndexes() /** * Whether the platform supports indexes with column length definitions. */ - public function supportsColumnLengthIndexes() : bool + public function supportsColumnLengthIndexes(): bool { return false; } @@ -3203,7 +3205,7 @@ public function supportsForeignKeyConstraints() * * If false, then getDropForeignKeySQL() throws exception. */ - public function supportsCreateDropForeignKeyConstraints() : bool + public function supportsCreateDropForeignKeyConstraints(): bool { return true; } @@ -3647,7 +3649,7 @@ public function getStringLiteralQuoteCharacter() * @param string $escapeChar should be reused by the caller in the LIKE * expression. */ - final public function escapeStringForLike(string $inputString, string $escapeChar) : string + final public function escapeStringForLike(string $inputString, string $escapeChar): string { return preg_replace( '~([' . preg_quote($this->getLikeWildcardCharacters() . $escapeChar, '~') . '])~u', @@ -3656,7 +3658,7 @@ final public function escapeStringForLike(string $inputString, string $escapeCha ); } - protected function getLikeWildcardCharacters() : string + protected function getLikeWildcardCharacters(): string { return '%_'; } diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 6f3931ec84c..297e43ced6a 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_merge; use function count; use function current; @@ -22,7 +23,7 @@ class DB2Platform extends AbstractPlatform { - public function getCharMaxLength() : int + public function getCharMaxLength(): int { return 254; } @@ -523,7 +524,8 @@ public function getAlterTableSQL(TableDiff $diff) $queryPart = 'ADD COLUMN ' . $this->getColumnDeclarationSQL($column->getQuotedName($this), $columnDef); // Adding non-nullable columns to a table requires a default value to be specified. - if (! empty($columnDef['notnull']) && + if ( + ! empty($columnDef['notnull']) && ! isset($columnDef['default']) && empty($columnDef['autoincrement']) ) { @@ -626,7 +628,7 @@ public function getAlterTableSQL(TableDiff $diff) * @param string[] $sql The sequence of table alteration statements to fill. * @param mixed[] $queryParts The sequence of column alteration clauses to fill. */ - private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts) : void + private function gatherAlterColumnSQL(Identifier $table, ColumnDiff $columnDiff, array &$sql, array &$queryParts): void { $alterColumnClauses = $this->getAlterColumnClausesSQL($columnDiff); @@ -668,7 +670,8 @@ private function getAlterColumnClausesSQL(ColumnDiff $columnDiff) $clauses = []; - if ($columnDiff->hasChanged('type') || + if ( + $columnDiff->hasChanged('type') || $columnDiff->hasChanged('length') || $columnDiff->hasChanged('precision') || $columnDiff->hasChanged('scale') || @@ -901,7 +904,7 @@ protected function getReservedKeywordsClass() return Keywords\DB2Keywords::class; } - public function getListTableCommentsSQL(string $table) : string + public function getListTableCommentsSQL(string $table): string { return sprintf( <<<'SQL' diff --git a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php index b13676775a1..3a877aab4c0 100644 --- a/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/DrizzlePlatform.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\BinaryType; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -520,7 +521,8 @@ public function getAlterTableSQL(TableDiff $diff) // Do not generate column alteration clause if type is binary and only fixed property has changed. // Drizzle only supports binary type columns with variable length. // Avoids unnecessary table alteration statements. - if ($columnArray['type'] instanceof BinaryType && + if ( + $columnArray['type'] instanceof BinaryType && $columnDiff->hasChanged('fixed') && count($columnDiff->changedProperties) === 1 ) { diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php index 0efd5f9a7fc..8cb2befe8e9 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/MariaDb102Keywords.php @@ -9,7 +9,7 @@ */ final class MariaDb102Keywords extends MySQLKeywords { - public function getName() : string + public function getName(): string { return 'MariaDb102'; } @@ -17,7 +17,7 @@ public function getName() : string /** * {@inheritdoc} */ - protected function getKeywords() : array + protected function getKeywords(): array { return [ 'ACCESSIBLE', diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php index 07d87efba30..dad68ead2df 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/PostgreSQL100Keywords.php @@ -9,7 +9,7 @@ */ class PostgreSQL100Keywords extends PostgreSQL94Keywords { - public function getName() : string + public function getName(): string { return 'PostgreSQL100'; } diff --git a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php index 68cdf3d15d8..c9053125d7f 100644 --- a/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php +++ b/lib/Doctrine/DBAL/Platforms/Keywords/ReservedKeywordsValidator.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function implode; use function str_replace; diff --git a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php index 2fff4e87ee7..03b59e2322e 100644 --- a/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php +++ b/lib/Doctrine/DBAL/Platforms/MariaDb1027Platform.php @@ -16,17 +16,17 @@ final class MariaDb1027Platform extends MySqlPlatform * * @link https://mariadb.com/kb/en/library/json-data-type/ */ - public function getJsonTypeDeclarationSQL(array $field) : string + public function getJsonTypeDeclarationSQL(array $field): string { return 'LONGTEXT'; } - protected function getReservedKeywordsClass() : string + protected function getReservedKeywordsClass(): string { return Keywords\MariaDb102Keywords::class; } - protected function initializeDoctrineTypeMappings() : void + protected function initializeDoctrineTypeMappings(): void { parent::initializeDoctrineTypeMappings(); diff --git a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index 6c8defc7e07..efda7ee0017 100644 --- a/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\TextType; use InvalidArgumentException; + use function array_diff_key; use function array_merge; use function array_unique; @@ -383,7 +384,7 @@ public function getListTableColumnsSQL($table, $database = null) ' ORDER BY ORDINAL_POSITION ASC'; } - public function getListTableMetadataSQL(string $table, ?string $database = null) : string + public function getListTableMetadataSQL(string $table, ?string $database = null): string { return sprintf( <<<'SQL' @@ -587,7 +588,8 @@ public function getAlterTableSQL(TableDiff $diff) $columnArray = $column->toArray(); // Don't propagate default value changes for unsupported column types. - if ($columnDiff->hasChanged('default') && + if ( + $columnDiff->hasChanged('default') && count($columnDiff->changedProperties) === 1 && ($columnArray['type'] instanceof TextType || $columnArray['type'] instanceof BlobType) ) { @@ -1184,7 +1186,7 @@ public function getDefaultTransactionIsolationLevel() return TransactionIsolationLevel::REPEATABLE_READ; } - public function supportsColumnLengthIndexes() : bool + public function supportsColumnLengthIndexes(): bool { return true; } diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 1c21e219010..b0cdce3f03f 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\BinaryType; use InvalidArgumentException; + use function array_merge; use function count; use function explode; @@ -394,8 +395,10 @@ protected function _getCreateTableSQL($table, array $columns, array $options = [ $sql[] = $this->getCreateSequenceSQL($column['sequence']); } - if (! isset($column['autoincrement']) || ! $column['autoincrement'] && - (! isset($column['autoinc']) || ! $column['autoinc'])) { + if ( + ! isset($column['autoincrement']) || ! $column['autoincrement'] && + (! isset($column['autoinc']) || ! $column['autoinc']) + ) { continue; } @@ -814,7 +817,8 @@ public function getAlterTableSQL(TableDiff $diff) // Do not generate column alteration clause if type is binary and only fixed property has changed. // Oracle only supports binary type columns with variable length. // Avoids unnecessary table alteration statements. - if ($column->getType() instanceof BinaryType && + if ( + $column->getType() instanceof BinaryType && $columnDiff->hasChanged('fixed') && count($columnDiff->changedProperties) === 1 ) { @@ -1190,7 +1194,7 @@ public function getBlobTypeDeclarationSQL(array $field) return 'BLOB'; } - public function getListTableCommentsSQL(string $table, ?string $database = null) : string + public function getListTableCommentsSQL(string $table, ?string $database = null): string { $tableCommentsName = 'user_tab_comments'; $ownerCondition = ''; diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php index 957f9f42458..f5610056230 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL100Platform.php @@ -11,7 +11,7 @@ */ class PostgreSQL100Platform extends PostgreSQL94Platform { - protected function getReservedKeywordsClass() : string + protected function getReservedKeywordsClass(): string { return PostgreSQL100Keywords::class; } @@ -19,7 +19,7 @@ protected function getReservedKeywordsClass() : string /** * {@inheritDoc} */ - public function getListSequencesSQL($database) : string + public function getListSequencesSQL($database): string { return 'SELECT sequence_name AS relname, sequence_schema AS schemaname, diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php index c0b5675a383..fdf28ff3131 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Types\Types; + use function sprintf; /** diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 9d17a2bb5c1..22f77ff18f2 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -15,6 +15,7 @@ use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\Type; use UnexpectedValueException; + use function array_diff; use function array_merge; use function array_unique; @@ -115,7 +116,7 @@ public function getLocateExpression($str, $substr, $startPos = false) if ($startPos !== false) { $str = $this->getSubstringExpression($str, $startPos); - return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos-1) . ') END'; + return 'CASE WHEN (POSITION(' . $substr . ' IN ' . $str . ') = 0) THEN 0 ELSE (POSITION(' . $substr . ' IN ' . $str . ') + ' . ($startPos - 1) . ') END'; } return 'POSITION(' . $substr . ' IN ' . $str . ')'; @@ -482,7 +483,8 @@ public function getAdvancedForeignKeyOptionsSQL(ForeignKeyConstraint $foreignKey $query .= ' NOT DEFERRABLE'; } - if (($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) + if ( + ($foreignKey->hasOption('feferred') && $foreignKey->getOption('feferred') !== false) || ($foreignKey->hasOption('deferred') && $foreignKey->getOption('deferred') !== false) ) { $query .= ' INITIALLY DEFERRED'; @@ -1225,7 +1227,7 @@ public function getDefaultValueDeclarationSQL($field) /** * @param mixed[] $field */ - private function isSerialField(array $field) : bool + private function isSerialField(array $field): bool { return isset($field['type'], $field['autoincrement']) && $field['autoincrement'] === true @@ -1235,7 +1237,7 @@ private function isSerialField(array $field) : bool /** * Check whether the type of a column is changed in a way that invalidates the default value for the column */ - private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool + private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff): bool { if (! $columnDiff->fromColumn) { return $columnDiff->hasChanged('type'); @@ -1249,17 +1251,17 @@ private function typeChangeBreaksDefaultValue(ColumnDiff $columnDiff) : bool && ! ($oldTypeIsNumeric && $newTypeIsNumeric && $columnDiff->column->getAutoincrement()); } - private function isNumericType(Type $type) : bool + private function isNumericType(Type $type): bool { return $type instanceof IntegerType || $type instanceof BigIntType; } - private function getOldColumnComment(ColumnDiff $columnDiff) : ?string + private function getOldColumnComment(ColumnDiff $columnDiff): ?string { return $columnDiff->fromColumn ? $this->getColumnComment($columnDiff->fromColumn) : null; } - public function getListTableMetadataSQL(string $table, ?string $schema = null) : string + public function getListTableMetadataSQL(string $table, ?string $schema = null): string { if ($schema !== null) { $table = $schema . '.' . $table; diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index 4deda5238a0..3c265824231 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -1335,7 +1336,7 @@ protected function doModifyLimitQuery($query, $limit, $offset) return $matches[1] . $limitOffsetClause . ' ' . $matches[3]; } - private function getTopClauseSQL(?int $limit, ?int $offset) : string + private function getTopClauseSQL(?int $limit, ?int $offset): string { if ($offset > 0) { return sprintf('TOP %s START AT %d', $limit ?? 'ALL', $offset + 1); diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php index 9cbcb3872e6..ba1678ab8a8 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2008Platform.php @@ -112,7 +112,7 @@ protected function getReservedKeywordsClass() return Keywords\SQLServer2008Keywords::class; } - protected function getLikeWildcardCharacters() : string + protected function getLikeWildcardCharacters(): string { return parent::getLikeWildcardCharacters() . '[]^'; } diff --git a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index 0e1250542b6..4aa29f5ffb6 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -3,9 +3,11 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\DBAL\Schema\Sequence; + use function preg_match; use function preg_match_all; use function substr_count; + use const PREG_OFFSET_CAPTURE; /** @@ -108,7 +110,8 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) $orderByPos = $matches[0][$matchesCount - 1][1]; } - if ($orderByPos === false + if ( + $orderByPos === false || substr_count($query, '(', $orderByPos) - substr_count($query, ')', $orderByPos) ) { if (preg_match('/^SELECT\s+DISTINCT/im', $query)) { diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 2bccffbfdd3..149f47b726d 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use InvalidArgumentException; + use function array_merge; use function array_unique; use function array_values; @@ -1669,7 +1670,7 @@ private function generateIdentifierName($identifier) return strtoupper(dechex(crc32($identifier->getName()))); } - protected function getCommentOnTableSQL(string $tableName, ?string $comment) : string + protected function getCommentOnTableSQL(string $tableName, ?string $comment): string { return sprintf( <<<'SQL' @@ -1683,7 +1684,7 @@ protected function getCommentOnTableSQL(string $tableName, ?string $comment) : s ); } - public function getListTableMetadataSQL(string $table) : string + public function getListTableMetadataSQL(string $table): string { return sprintf( <<<'SQL' diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index 3f8746cc14a..04c1fe50b57 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types; + use function array_merge; use function array_unique; use function array_values; @@ -376,7 +377,7 @@ protected function _getCreateTableSQL($name, array $columns, array $options = [] * @param mixed[][] $columns * @param mixed[] $options */ - private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options) : string + private function getNonAutoincrementPrimaryKeyDefinition(array $columns, array $options): string { if (empty($options['primary'])) { return ''; @@ -622,7 +623,7 @@ public function getInlineColumnCommentSQL($comment) return '--' . str_replace("\n", "\n--", $comment) . "\n"; } - private function getInlineTableCommentSQL(string $comment) : string + private function getInlineTableCommentSQL(string $comment): string { return $this->getInlineColumnCommentSQL($comment); } @@ -776,7 +777,7 @@ public function supportsForeignKeyConstraints() return true; } - public function supportsCreateDropForeignKeyConstraints() : bool + public function supportsCreateDropForeignKeyConstraints(): bool { return false; } @@ -968,7 +969,8 @@ private function getSimpleAlterTableSQL(TableDiff $diff) { // Suppress changes on integer type autoincrement columns. foreach ($diff->changedColumns as $oldColumnName => $columnDiff) { - if (! $columnDiff->fromColumn instanceof Column || + if ( + ! $columnDiff->fromColumn instanceof Column || ! $columnDiff->column instanceof Column || ! $columnDiff->column->getAutoincrement() || ! $columnDiff->column->getType() instanceof Types\IntegerType @@ -991,7 +993,8 @@ private function getSimpleAlterTableSQL(TableDiff $diff) unset($diff->changedColumns[$oldColumnName]); } - if (! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) + if ( + ! empty($diff->renamedColumns) || ! empty($diff->addedForeignKeys) || ! empty($diff->addedIndexes) || ! empty($diff->changedColumns) || ! empty($diff->changedForeignKeys) || ! empty($diff->changedIndexes) || ! empty($diff->removedColumns) || ! empty($diff->removedForeignKeys) || ! empty($diff->removedIndexes) || ! empty($diff->renamedIndexes) diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php index ce8bfee248c..266b8ad095b 100644 --- a/lib/Doctrine/DBAL/Portability/Connection.php +++ b/lib/Doctrine/DBAL/Portability/Connection.php @@ -6,7 +6,9 @@ use Doctrine\DBAL\ColumnCase; use Doctrine\DBAL\Driver\PDOConnection; use PDO; + use function func_get_args; + use const CASE_LOWER; use const CASE_UPPER; diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 366b8288084..02b598fc9ee 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; + use function array_change_key_case; use function assert; use function is_string; @@ -147,7 +148,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX $row = $this->stmt->fetch($fetchMode); - $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) !== 0; $fixCase = $this->case !== null && ($fetchMode === FetchMode::ASSOCIATIVE || $fetchMode === FetchMode::MIXED) && ($this->portability & Connection::PORTABILITY_FIX_CASE); @@ -230,7 +231,7 @@ public function fetchOne() /** * {@inheritdoc} */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { if ($this->stmt instanceof ForwardCompatibleResultStatement) { $data = $this->stmt->fetchAllNumeric(); @@ -244,7 +245,7 @@ public function fetchAllNumeric() : array /** * {@inheritdoc} */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { if ($this->stmt instanceof ForwardCompatibleResultStatement) { $data = $this->stmt->fetchAllAssociative(); @@ -258,7 +259,7 @@ public function fetchAllAssociative() : array /** * {@inheritdoc} */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { if ($this->stmt instanceof ForwardCompatibleResultStatement) { $data = $this->stmt->fetchFirstColumn(); @@ -276,7 +277,7 @@ public function fetchFirstColumn() : array */ private function fixResult($result, bool $fixCase) { - $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) !== 0; $fixCase = $fixCase && $this->case !== null && ($this->portability & Connection::PORTABILITY_FIX_CASE) !== 0; return $this->fixRow($result, $iterateRow, $fixCase); @@ -287,9 +288,9 @@ private function fixResult($result, bool $fixCase) * * @return array */ - private function fixResultSet(array $resultSet, bool $fixCase, bool $isArray) : array + private function fixResultSet(array $resultSet, bool $fixCase, bool $isArray): array { - $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) !== 0; + $iterateRow = ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) !== 0; $fixCase = $fixCase && $this->case !== null && ($this->portability & Connection::PORTABILITY_FIX_CASE) !== 0; if (! $iterateRow && ! $fixCase) { @@ -354,7 +355,7 @@ public function fetchColumn($columnIndex = 0) { $value = $this->stmt->fetchColumn($columnIndex); - if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL|Connection::PORTABILITY_RTRIM)) { + if ($this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM)) { if (($this->portability & Connection::PORTABILITY_EMPTY_TO_NULL) && $value === '') { $value = null; } elseif (($this->portability & Connection::PORTABILITY_RTRIM) && is_string($value)) { diff --git a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php index 41f9f74e22c..596e9fb3afc 100644 --- a/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php +++ b/lib/Doctrine/DBAL/Query/Expression/CompositeExpression.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Countable; + use function array_merge; use function count; use function implode; @@ -53,7 +54,7 @@ public function __construct($type, array $parts = []) * @param self|string $part * @param self|string ...$parts */ - public static function and($part, ...$parts) : self + public static function and($part, ...$parts): self { return new self(self::TYPE_AND, array_merge([$part], $parts)); } @@ -62,7 +63,7 @@ public static function and($part, ...$parts) : self * @param self|string $part * @param self|string ...$parts */ - public static function or($part, ...$parts) : self + public static function or($part, ...$parts): self { return new self(self::TYPE_OR, array_merge([$part], $parts)); } @@ -115,7 +116,7 @@ public function add($part) * @param self|string $part * @param self|string ...$parts */ - public function with($part, ...$parts) : self + public function with($part, ...$parts): self { $that = clone $this; diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index ef0e6eebb00..342cf840eff 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query\Expression; use Doctrine\DBAL\Connection; + use function func_get_arg; use function func_get_args; use function func_num_args; @@ -44,7 +45,7 @@ public function __construct(Connection $connection) * @param string|CompositeExpression $expression * @param string|CompositeExpression ...$expressions */ - public function and($expression, ...$expressions) : CompositeExpression + public function and($expression, ...$expressions): CompositeExpression { return CompositeExpression::and($expression, ...$expressions); } @@ -55,7 +56,7 @@ public function and($expression, ...$expressions) : CompositeExpression * @param string|CompositeExpression $expression * @param string|CompositeExpression ...$expressions */ - public function or($expression, ...$expressions) : CompositeExpression + public function or($expression, ...$expressions): CompositeExpression { return CompositeExpression::or($expression, ...$expressions); } diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index a2fa05f422a..64736c64af4 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; + use function array_key_exists; use function array_keys; use function array_unshift; @@ -490,7 +491,7 @@ public function select($select = null/*, string ...$selects*/) * * @return $this This QueryBuilder instance. */ - public function distinct() : self + public function distinct(): self { $this->sqlParts['distinct'] = true; @@ -1187,7 +1188,7 @@ private function getFromClauses() * * @throws QueryException */ - private function verifyAllAliasesAreKnown(array $knownAliases) : void + private function verifyAllAliasesAreKnown(array $knownAliases): void { foreach ($this->sqlParts['join'] as $fromAlias => $joins) { if (! isset($knownAliases[$fromAlias])) { diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php index a9bb52d8102..76bb9ba7559 100644 --- a/lib/Doctrine/DBAL/Query/QueryException.php +++ b/lib/Doctrine/DBAL/Query/QueryException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Query; use Doctrine\DBAL\DBALException; + use function implode; /** diff --git a/lib/Doctrine/DBAL/SQLParserUtils.php b/lib/Doctrine/DBAL/SQLParserUtils.php index 7bfe71e4d97..0cb9dd6ae4d 100644 --- a/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/lib/Doctrine/DBAL/SQLParserUtils.php @@ -19,6 +19,7 @@ use function strlen; use function strpos; use function substr; + use const PREG_OFFSET_CAPTURE; /** @@ -65,13 +66,13 @@ public static function getPlaceholderPositions($statement, $isPositional = true) * * @return int[] */ - private static function getPositionalPlaceholderPositions(string $statement) : array + private static function getPositionalPlaceholderPositions(string $statement): array { return self::collectPlaceholders( $statement, '?', self::POSITIONAL_TOKEN, - static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { + static function (string $_, int $placeholderPosition, int $fragmentPosition, array &$carry): void { $carry[] = $placeholderPosition + $fragmentPosition; } ); @@ -82,13 +83,13 @@ static function (string $_, int $placeholderPosition, int $fragmentPosition, arr * * @return string[] */ - private static function getNamedPlaceholderPositions(string $statement) : array + private static function getNamedPlaceholderPositions(string $statement): array { return self::collectPlaceholders( $statement, ':', self::NAMED_TOKEN, - static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry) : void { + static function (string $placeholder, int $placeholderPosition, int $fragmentPosition, array &$carry): void { $carry[$placeholderPosition + $fragmentPosition] = substr($placeholder, 1); } ); @@ -97,7 +98,7 @@ static function (string $placeholder, int $placeholderPosition, int $fragmentPos /** * @return mixed[] */ - private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector) : array + private static function collectPlaceholders(string $statement, string $match, string $token, callable $collector): array { if (strpos($statement, $match) === false) { return []; diff --git a/lib/Doctrine/DBAL/Schema/AbstractAsset.php b/lib/Doctrine/DBAL/Schema/AbstractAsset.php index b64cb42e208..3424b17c544 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractAsset.php +++ b/lib/Doctrine/DBAL/Schema/AbstractAsset.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_map; use function crc32; use function dechex; diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index c1c23cdae5b..7f9b8ad6572 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Events; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; + use function array_filter; use function array_intersect; use function array_map; @@ -429,7 +430,7 @@ public function createDatabase($database) */ public function createTable(Table $table) { - $createFlags = AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS; + $createFlags = AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS; $this->_execSql($this->_platform->getCreateTableSQL($table, $createFlags)); } diff --git a/lib/Doctrine/DBAL/Schema/Column.php b/lib/Doctrine/DBAL/Schema/Column.php index 81dbef70975..be9399a3b07 100644 --- a/lib/Doctrine/DBAL/Schema/Column.php +++ b/lib/Doctrine/DBAL/Schema/Column.php @@ -3,11 +3,13 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; + use function array_merge; use function is_numeric; use function method_exists; use function sprintf; use function trigger_error; + use const E_USER_DEPRECATED; /** diff --git a/lib/Doctrine/DBAL/Schema/Comparator.php b/lib/Doctrine/DBAL/Schema/Comparator.php index e241cf658c5..c224e1142c7 100644 --- a/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/lib/Doctrine/DBAL/Schema/Comparator.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types; + use function array_intersect_key; use function array_key_exists; use function array_keys; @@ -248,7 +249,8 @@ public function diffTable(Table $table1, Table $table2) /* See if there are any removed indexes in table 2 */ foreach ($table1Indexes as $indexName => $index) { // See if index is removed in table 2. - if (($index->isPrimary() && ! $table2->hasPrimaryKey()) || + if ( + ($index->isPrimary() && ! $table2->hasPrimaryKey()) || ! $index->isPrimary() && ! $table2->hasIndex($indexName) ) { $tableDifferences->removedIndexes[$indexName] = $index; @@ -447,12 +449,15 @@ public function diffColumn(Column $column1, Column $column2) // Null values need to be checked additionally as they tell whether to create or drop a default value. // null != 0, null != false, null != '' etc. This affects platform's table alteration SQL generation. - if (($properties1['default'] === null) !== ($properties2['default'] === null) - || $properties1['default'] != $properties2['default']) { + if ( + ($properties1['default'] === null) !== ($properties2['default'] === null) + || $properties1['default'] != $properties2['default'] + ) { $changedProperties[] = 'default'; } - if (($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) || + if ( + ($properties1['type'] instanceof Types\StringType && ! $properties1['type'] instanceof Types\GuidType) || $properties1['type'] instanceof Types\BinaryType ) { // check if value of length is set at all, default value assumed otherwise. @@ -476,7 +481,8 @@ public function diffColumn(Column $column1, Column $column2) } // A null value and an empty string are actually equal for a comment so they should not trigger a change. - if ($properties1['comment'] !== $properties2['comment'] && + if ( + $properties1['comment'] !== $properties2['comment'] && ! ($properties1['comment'] === null && $properties2['comment'] === '') && ! ($properties2['comment'] === null && $properties1['comment'] === '') ) { @@ -513,7 +519,7 @@ public function diffColumn(Column $column1, Column $column2) * * @deprecated */ - private function isALegacyJsonComparison(Types\Type $one, Types\Type $other) : bool + private function isALegacyJsonComparison(Types\Type $one, Types\Type $other): bool { if (! $one instanceof Types\JsonType || ! $other instanceof Types\JsonType) { return false; diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index 60f95cb9cea..500aec47f18 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function assert; use function is_resource; @@ -12,6 +13,7 @@ use function strpos; use function strtolower; use function substr; + use const CASE_LOWER; /** @@ -209,7 +211,7 @@ protected function _getPortableViewDefinition($view) //$view['text'] = (is_resource($view['text']) ? stream_get_contents($view['text']) : $view['text']); if (! is_resource($view['text'])) { $pos = strpos($view['text'], ' AS '); - $sql = substr($view['text'], $pos+4); + $sql = substr($view['text'], $pos + 4); } else { $sql = ''; } @@ -220,7 +222,7 @@ protected function _getPortableViewDefinition($view) /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php b/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php index c334db2797b..47a2e2f0bc7 100644 --- a/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DrizzleSchemaManager.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Types\Type; + use function explode; use function strtolower; use function trim; diff --git a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php index 3611b77dccd..b3b628f3e6f 100644 --- a/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php +++ b/lib/Doctrine/DBAL/Schema/ForeignKeyConstraint.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_keys; use function array_map; use function in_array; @@ -85,7 +86,7 @@ public function __construct(array $localColumnNames, $foreignTableName, array $f * * @return Identifier[] */ - private function createIdentifierMap(array $names) : array + private function createIdentifierMap(array $names): array { $identifiers = []; diff --git a/lib/Doctrine/DBAL/Schema/Index.php b/lib/Doctrine/DBAL/Schema/Index.php index 07b1c008c19..81299353011 100644 --- a/lib/Doctrine/DBAL/Schema/Index.php +++ b/lib/Doctrine/DBAL/Schema/Index.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use InvalidArgumentException; + use function array_filter; use function array_keys; use function array_map; @@ -348,9 +349,9 @@ private function samePartialIndex(Index $other) /** * Returns whether the index has the same column lengths as the other */ - private function hasSameColumnLengths(self $other) : bool + private function hasSameColumnLengths(self $other): bool { - $filter = static function (?int $length) : bool { + $filter = static function (?int $length): bool { return $length !== null; }; diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index cd469f38c6a..06ee88e9f34 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function array_shift; use function array_values; @@ -16,6 +17,7 @@ use function strtok; use function strtolower; use function strtr; + use const CASE_LOWER; /** @@ -243,7 +245,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) * * @param string|null $columnDefault default value as stored in information_schema for MariaDB >= 10.2.7 */ - private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault) : ?string + private function getMariaDb1027ColumnDefault(MariaDb1027Platform $platform, ?string $columnDefault): ?string { if ($columnDefault === 'NULL' || $columnDefault === null) { return null; @@ -351,7 +353,7 @@ public function listTableDetails($tableName) /** * @return string[]|true[] */ - private function parseCreateOptions(?string $string) : array + private function parseCreateOptions(?string $string): array { $options = []; diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 108ae4d53e9..4f463c0ad3a 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Types\Type; use Throwable; + use function array_change_key_case; use function array_values; use function assert; @@ -17,6 +18,7 @@ use function strtolower; use function strtoupper; use function trim; + use const CASE_LOWER; /** @@ -398,7 +400,7 @@ private function killUserSessions($user) /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index ceeb99d84c3..a6d9fe03a01 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_change_key_case; use function array_filter; use function array_keys; @@ -24,6 +25,7 @@ use function strpos; use function strtolower; use function trim; + use const CASE_LOWER; /** @@ -491,7 +493,7 @@ private function fixVersion94NegativeNumericDefaultValue($defaultValue) /** * Parses a default value expression as given by PostgreSQL */ - private function parseDefaultExpression(?string $default) : ?string + private function parseDefaultExpression(?string $default): ?string { if ($default === null) { return $default; @@ -503,7 +505,7 @@ private function parseDefaultExpression(?string $default) : ?string /** * {@inheritdoc} */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php index 9825a759755..3f83b93e9e4 100644 --- a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\SQLAnywherePlatform; use Doctrine\DBAL\Types\Type; + use function assert; use function is_string; use function preg_replace; diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index f14961f6b6d..3fac92d70a6 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use PDOException; use Throwable; + use function assert; use function count; use function in_array; @@ -126,7 +127,7 @@ protected function _getPortableTableColumnDefinition($tableColumn) return $column; } - private function parseDefaultExpression(string $value) : ?string + private function parseDefaultExpression(string $value): ?string { while (preg_match('/^\((.*)\)$/s', $value, $matches)) { $value = $matches[1]; @@ -332,7 +333,7 @@ private function closeActiveDatabaseConnections($database) /** * @param string $tableName */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/Schema.php b/lib/Doctrine/DBAL/Schema/Schema.php index ff09ef52cf1..8afe816f6b6 100644 --- a/lib/Doctrine/DBAL/Schema/Schema.php +++ b/lib/Doctrine/DBAL/Schema/Schema.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; use Doctrine\DBAL\Schema\Visitor\NamespaceVisitor; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function array_keys; use function strpos; use function strtolower; @@ -106,9 +107,11 @@ protected function _addTable(Table $table) throw SchemaException::tableAlreadyExists($tableName); } - if ($namespaceName !== null + if ( + $namespaceName !== null && ! $table->isInDefaultNamespace($this->getName()) - && ! $this->hasNamespace($namespaceName)) { + && ! $this->hasNamespace($namespaceName) + ) { $this->createNamespace($namespaceName); } @@ -130,9 +133,11 @@ protected function _addSequence(Sequence $sequence) throw SchemaException::sequenceAlreadyExists($seqName); } - if ($namespaceName !== null + if ( + $namespaceName !== null && ! $sequence->isInDefaultNamespace($this->getName()) - && ! $this->hasNamespace($namespaceName)) { + && ! $this->hasNamespace($namespaceName) + ) { $this->createNamespace($namespaceName); } diff --git a/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/lib/Doctrine/DBAL/Schema/SchemaDiff.php index 4e5dc91f621..fa643aec912 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Internal\DependencyOrderCalculator; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php index c7465eee4ad..4543334ba43 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\DBALException; + use function implode; use function sprintf; diff --git a/lib/Doctrine/DBAL/Schema/Sequence.php b/lib/Doctrine/DBAL/Schema/Sequence.php index 2301c8ae7e1..19dec9cd57a 100644 --- a/lib/Doctrine/DBAL/Schema/Sequence.php +++ b/lib/Doctrine/DBAL/Schema/Sequence.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Visitor\Visitor; + use function count; use function sprintf; diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index efdd5f9f4c8..906a544b522 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; + use function array_change_key_case; use function array_map; use function array_reverse; @@ -25,6 +26,7 @@ use function trim; use function unlink; use function usort; + use const CASE_LOWER; /** @@ -119,8 +121,9 @@ public function listTableForeignKeys($table, $database = null) if (! empty($tableForeignKeys)) { $createSql = $this->getCreateTableSQL($table); - if ($createSql !== null && preg_match_all( - '# + if ( + $createSql !== null && preg_match_all( + '# (?:CONSTRAINT\s+([^\s]+)\s+)? (?:FOREIGN\s+KEY[^\)]+\)\s*)? REFERENCES\s+[^\s]+\s+(?:\([^\)]+\))? @@ -129,9 +132,10 @@ public function listTableForeignKeys($table, $database = null) (NOT\s+DEFERRABLE|DEFERRABLE) (?:\s+INITIALLY\s+(DEFERRED|IMMEDIATE))? )?#isx', - $createSql, - $match - )) { + $createSql, + $match + ) + ) { $names = array_reverse($match[1]); $deferrable = array_reverse($match[2]); $deferred = array_reverse($match[3]); @@ -412,7 +416,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'onDelete' => $value['on_delete'], 'onUpdate' => $value['on_update'], 'deferrable' => $value['deferrable'], - 'deferred'=> $value['deferred'], + 'deferred' => $value['deferred'], ]; } @@ -431,7 +435,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) 'onDelete' => $constraint['onDelete'], 'onUpdate' => $constraint['onUpdate'], 'deferrable' => $constraint['deferrable'], - 'deferred'=> $constraint['deferred'], + 'deferred' => $constraint['deferred'], ] ); } @@ -464,7 +468,7 @@ private function getTableDiffForAlterForeignKey($table) return $tableDiff; } - private function parseColumnCollationFromSQL(string $column, string $sql) : ?string + private function parseColumnCollationFromSQL(string $column, string $sql): ?string { $pattern = '{(?:\W' . preg_quote($column) . '\W|\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W)[^,(]+(?:\([^()]+\)[^,]*)?(?:(?:DEFAULT|CHECK)\s*(?:\(.*?\))?[^,]*)*COLLATE\s+["\']?([^\s,"\')]+)}is'; @@ -476,7 +480,7 @@ private function parseColumnCollationFromSQL(string $column, string $sql) : ?str return $match[1]; } - private function parseTableCommentFromSQL(string $table, string $sql) : ?string + private function parseTableCommentFromSQL(string $table, string $sql): ?string { $pattern = '/\s* # Allow whitespace characters at start of line CREATE\sTABLE # Match "CREATE TABLE" @@ -495,7 +499,7 @@ private function parseTableCommentFromSQL(string $table, string $sql) : ?string return $comment === '' ? null : $comment; } - private function parseColumnCommentFromSQL(string $column, string $sql) : ?string + private function parseColumnCommentFromSQL(string $column, string $sql): ?string { $pattern = '{[\s(,](?:\W' . preg_quote($this->_platform->quoteSingleIdentifier($column)) . '\W|\W' . preg_quote($column) . '\W)(?:\([^)]*?\)|[^,(])*?,?((?:(?!\n))(?:\s*--[^\n]*\n?)+)}i'; @@ -509,7 +513,7 @@ private function parseColumnCommentFromSQL(string $column, string $sql) : ?strin return $comment === '' ? null : $comment; } - private function getCreateTableSQL(string $table) : ?string + private function getCreateTableSQL(string $table): ?string { return $this->_conn->fetchColumn( <<<'SQL' @@ -532,7 +536,7 @@ private function getCreateTableSQL(string $table) : ?string /** * @param string $tableName */ - public function listTableDetails($tableName) : Table + public function listTableDetails($tableName): Table { $table = parent::listTableDetails($tableName); diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php index dd4b1ca5f40..43c0fc6a544 100644 --- a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php +++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Comparator; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Visitor\DropSchemaSqlCollector; + use function count; /** diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 6fa660efd5e..a6be32c68a4 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -5,12 +5,14 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Types\Type; + use function array_filter; use function array_merge; use function in_array; use function preg_match; use function strlen; use function strtolower; + use const ARRAY_FILTER_USE_KEY; /** @@ -475,7 +477,8 @@ protected function _addIndex(Index $indexCandidate) $replacedImplicitIndexes[] = $name; } - if ((isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) || + if ( + (isset($this->_indexes[$indexName]) && ! in_array($indexName, $replacedImplicitIndexes, true)) || ($this->_primaryKeyName !== false && $indexCandidate->isPrimary()) ) { throw SchemaException::indexAlreadyExists($indexName, $this->_name); @@ -846,7 +849,7 @@ private function normalizeIdentifier($identifier) return $this->trimQuotes(strtolower($identifier)); } - public function setComment(?string $comment) : self + public function setComment(?string $comment): self { // For keeping backward compatibility with MySQL in previous releases, table comments are stored as options. $this->addOption('comment', $comment); @@ -854,7 +857,7 @@ public function setComment(?string $comment) : self return $this; } - public function getComment() : ?string + public function getComment(): ?string { return $this->_options['comment'] ?? null; } diff --git a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php index 12f417119fc..c3428ce58ac 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/CreateSchemaSqlCollector.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; + use function array_merge; class CreateSchemaSqlCollector extends AbstractVisitor diff --git a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php index 05b87fb16b0..a2355ac7de3 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/DropSchemaSqlCollector.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; use SplObjectStorage; + use function assert; use function strlen; diff --git a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php index 84a009f8a1e..b36e009ca26 100644 --- a/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php +++ b/lib/Doctrine/DBAL/Schema/Visitor/Graphviz.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Schema\Table; + use function current; use function file_put_contents; use function in_array; diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 871b54eec9e..8c20139ac42 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Events; use Doctrine\DBAL\Sharding\ShardChoser\ShardChoser; use InvalidArgumentException; + use function array_merge; use function is_numeric; use function is_string; diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php index e889edbc5d7..42a060f1134 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizer.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use RuntimeException; + use function array_merge; /** diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index a7d1ea5db17..d511553c155 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Sharding\ShardManager; use Doctrine\DBAL\Types\Type; use RuntimeException; + use function sprintf; /** diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php index 7d8307ec920..d9ef9e8964e 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/Schema/MultiTenantVisitor.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Visitor\Visitor; use RuntimeException; + use function in_array; /** diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 009558bfc93..907e631d064 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -11,6 +11,7 @@ use PDO; use Throwable; use Traversable; + use function is_array; use function is_string; @@ -339,7 +340,7 @@ public function fetchOne() * * @throws DBALException */ - public function fetchAllNumeric() : array + public function fetchAllNumeric(): array { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { @@ -357,7 +358,7 @@ public function fetchAllNumeric() : array * * @throws DBALException */ - public function fetchAllAssociative() : array + public function fetchAllAssociative(): array { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { @@ -375,7 +376,7 @@ public function fetchAllAssociative() : array * * @throws DBALException */ - public function fetchFirstColumn() : array + public function fetchFirstColumn(): array { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { @@ -395,7 +396,7 @@ public function fetchFirstColumn() : array * * @throws DBALException */ - public function iterateNumeric() : Traversable + public function iterateNumeric(): Traversable { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { @@ -419,7 +420,7 @@ public function iterateNumeric() : Traversable * * @throws DBALException */ - public function iterateAssociative() : Traversable + public function iterateAssociative(): Traversable { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { @@ -443,7 +444,7 @@ public function iterateAssociative() : Traversable * * @throws DBALException */ - public function iterateColumn() : Traversable + public function iterateColumn(): Traversable { try { if ($this->stmt instanceof ForwardCompatibleResultStatement) { diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php index eb15dd96a48..c53c9ccf172 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -11,6 +11,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function error_get_last; use function file_exists; @@ -18,6 +19,7 @@ use function is_readable; use function realpath; use function sprintf; + use const PHP_EOL; /** diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php index 5d19cb5e40b..4a8ade77c75 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ReservedWordsCommand.php @@ -28,12 +28,14 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function array_keys; use function assert; use function count; use function implode; use function is_string; use function trigger_error; + use const E_USER_DEPRECATED; class ReservedWordsCommand extends Command @@ -199,7 +201,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - private function getConnection(InputInterface $input) : Connection + private function getConnection(InputInterface $input): Connection { $connectionName = $input->getOption('connection'); assert(is_string($connectionName) || $connectionName === null); diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 79c333dd89c..68d5a136fdd 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -13,11 +13,13 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; + use function assert; use function is_numeric; use function is_string; use function stripos; use function trigger_error; + use const E_USER_DEPRECATED; /** @@ -93,7 +95,7 @@ protected function execute(InputInterface $input, OutputInterface $output) return 0; } - private function getConnection(InputInterface $input) : Connection + private function getConnection(InputInterface $input): Connection { $connectionName = $input->getOption('connection'); assert(is_string($connectionName) || $connectionName === null); diff --git a/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider.php b/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider.php index 2701365ba12..9919e481f65 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider.php @@ -6,10 +6,10 @@ interface ConnectionProvider { - public function getDefaultConnection() : Connection; + public function getDefaultConnection(): Connection; /** * @throws ConnectionNotFound in case a connection with the given name does not exist. */ - public function getConnection(string $name) : Connection; + public function getConnection(string $name): Connection; } diff --git a/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider/SingleConnectionProvider.php b/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider/SingleConnectionProvider.php index 8387371c0a0..368e0ff3cc6 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider/SingleConnectionProvider.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConnectionProvider/SingleConnectionProvider.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Tools\Console\ConnectionNotFound; use Doctrine\DBAL\Tools\Console\ConnectionProvider; + use function sprintf; class SingleConnectionProvider implements ConnectionProvider @@ -21,12 +22,12 @@ public function __construct(Connection $connection, string $defaultConnectionNam $this->defaultConnectionName = $defaultConnectionName; } - public function getDefaultConnection() : Connection + public function getDefaultConnection(): Connection { return $this->connection; } - public function getConnection(string $name) : Connection + public function getConnection(string $name): Connection { if ($name !== $this->defaultConnectionName) { throw new ConnectionNotFound(sprintf('Connection with name "%s" does not exist.', $name)); diff --git a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php index f0e65c33928..da586947577 100644 --- a/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php +++ b/lib/Doctrine/DBAL/Tools/Console/ConsoleRunner.php @@ -12,8 +12,10 @@ use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\HelperSet; use TypeError; + use function sprintf; use function trigger_error; + use const E_USER_DEPRECATED; /** diff --git a/lib/Doctrine/DBAL/Tools/Dumper.php b/lib/Doctrine/DBAL/Tools/Dumper.php index 25c165901f9..d7559d8fb20 100644 --- a/lib/Doctrine/DBAL/Tools/Dumper.php +++ b/lib/Doctrine/DBAL/Tools/Dumper.php @@ -8,6 +8,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\Common\Persistence\Proxy; use stdClass; + use function array_keys; use function assert; use function class_exists; @@ -52,7 +53,7 @@ private function __construct() * @param mixed $var The variable to dump. * @param int $maxDepth The maximum nesting level for object properties. */ - public static function dump($var, int $maxDepth = 2) : string + public static function dump($var, int $maxDepth = 2): string { $html = ini_set('html_errors', '1'); assert(is_string($html)); @@ -160,7 +161,7 @@ private static function fillReturnWithClassAttributes($var, stdClass $return, in /** * @param object $object */ - private static function getClass($object) : string + private static function getClass($object): string { $class = get_class($object); diff --git a/lib/Doctrine/DBAL/Types/ArrayType.php b/lib/Doctrine/DBAL/Types/ArrayType.php index 78325ad95c9..e915ca8e387 100644 --- a/lib/Doctrine/DBAL/Types/ArrayType.php +++ b/lib/Doctrine/DBAL/Types/ArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function restore_error_handler; use function serialize; @@ -43,7 +44,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $value = is_resource($value) ? stream_get_contents($value) : $value; - set_error_handler(function (int $code, string $message) : bool { + set_error_handler(function (int $code, string $message): bool { throw ConversionException::conversionFailedUnserialization($this->getName(), $message); }); diff --git a/lib/Doctrine/DBAL/Types/BinaryType.php b/lib/Doctrine/DBAL/Types/BinaryType.php index d604b3bff69..bf537e8ddb3 100644 --- a/lib/Doctrine/DBAL/Types/BinaryType.php +++ b/lib/Doctrine/DBAL/Types/BinaryType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function assert; use function fopen; use function fseek; diff --git a/lib/Doctrine/DBAL/Types/BlobType.php b/lib/Doctrine/DBAL/Types/BlobType.php index e4bb22f08d8..fedb0f245ac 100644 --- a/lib/Doctrine/DBAL/Types/BlobType.php +++ b/lib/Doctrine/DBAL/Types/BlobType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function assert; use function fopen; use function fseek; diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php index 4733b572257..55dfedee754 100644 --- a/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/lib/Doctrine/DBAL/Types/ConversionException.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\DBALException; use Throwable; + use function get_class; use function gettype; use function implode; @@ -111,7 +112,7 @@ public static function conversionFailedSerialization($value, $format, $error) )); } - public static function conversionFailedUnserialization(string $format, string $error) : self + public static function conversionFailedUnserialization(string $format, string $error): self { return new self(sprintf( "Could not convert database value to '%s' as an error was triggered by the unserialization: '%s'", diff --git a/lib/Doctrine/DBAL/Types/DateIntervalType.php b/lib/Doctrine/DBAL/Types/DateIntervalType.php index 96a446e8607..239dcf7481e 100644 --- a/lib/Doctrine/DBAL/Types/DateIntervalType.php +++ b/lib/Doctrine/DBAL/Types/DateIntervalType.php @@ -5,6 +5,7 @@ use DateInterval; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; + use function substr; /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php index 51960a8c344..9af4fc34908 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeImmutableType.php @@ -4,6 +4,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create_immutable; /** diff --git a/lib/Doctrine/DBAL/Types/DateTimeType.php b/lib/Doctrine/DBAL/Types/DateTimeType.php index 65071a6b188..069a03d4e7a 100644 --- a/lib/Doctrine/DBAL/Types/DateTimeType.php +++ b/lib/Doctrine/DBAL/Types/DateTimeType.php @@ -5,6 +5,7 @@ use DateTime; use DateTimeInterface; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create; /** diff --git a/lib/Doctrine/DBAL/Types/JsonArrayType.php b/lib/Doctrine/DBAL/Types/JsonArrayType.php index bc468fba0f3..400e0ef3837 100644 --- a/lib/Doctrine/DBAL/Types/JsonArrayType.php +++ b/lib/Doctrine/DBAL/Types/JsonArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function json_decode; use function stream_get_contents; diff --git a/lib/Doctrine/DBAL/Types/JsonType.php b/lib/Doctrine/DBAL/Types/JsonType.php index 5fc00937fef..b40b3334513 100644 --- a/lib/Doctrine/DBAL/Types/JsonType.php +++ b/lib/Doctrine/DBAL/Types/JsonType.php @@ -3,12 +3,14 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function json_decode; use function json_encode; use function json_last_error; use function json_last_error_msg; use function stream_get_contents; + use const JSON_ERROR_NONE; /** diff --git a/lib/Doctrine/DBAL/Types/ObjectType.php b/lib/Doctrine/DBAL/Types/ObjectType.php index 82b1a752ee1..4ca1cf4d531 100644 --- a/lib/Doctrine/DBAL/Types/ObjectType.php +++ b/lib/Doctrine/DBAL/Types/ObjectType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function restore_error_handler; use function serialize; @@ -42,7 +43,7 @@ public function convertToPHPValue($value, AbstractPlatform $platform) $value = is_resource($value) ? stream_get_contents($value) : $value; - set_error_handler(function (int $code, string $message) : bool { + set_error_handler(function (int $code, string $message): bool { throw ConversionException::conversionFailedUnserialization($this->getName(), $message); }); diff --git a/lib/Doctrine/DBAL/Types/SimpleArrayType.php b/lib/Doctrine/DBAL/Types/SimpleArrayType.php index 31c22b8e6f6..bdf08249a49 100644 --- a/lib/Doctrine/DBAL/Types/SimpleArrayType.php +++ b/lib/Doctrine/DBAL/Types/SimpleArrayType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function explode; use function implode; use function is_resource; diff --git a/lib/Doctrine/DBAL/Types/TextType.php b/lib/Doctrine/DBAL/Types/TextType.php index 76dd7c48cf0..3eb8047ed62 100644 --- a/lib/Doctrine/DBAL/Types/TextType.php +++ b/lib/Doctrine/DBAL/Types/TextType.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function is_resource; use function stream_get_contents; diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index 18c893dbcaf..6dd4e9abb30 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function array_map; use function get_class; use function str_replace; @@ -196,7 +197,7 @@ abstract public function getName(); /** * @internal This method is only to be used within DBAL for forward compatibility purposes. Do not use directly. */ - final public static function getTypeRegistry() : TypeRegistry + final public static function getTypeRegistry(): TypeRegistry { if (self::$typeRegistry === null) { self::$typeRegistry = self::createTypeRegistry(); @@ -205,7 +206,7 @@ final public static function getTypeRegistry() : TypeRegistry return self::$typeRegistry; } - private static function createTypeRegistry() : TypeRegistry + private static function createTypeRegistry(): TypeRegistry { $registry = new TypeRegistry(); @@ -295,7 +296,7 @@ public function getBindingType() public static function getTypesMap() { return array_map( - static function (Type $type) : string { + static function (Type $type): string { return get_class($type); }, self::getTypeRegistry()->getMap() diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index 7e8093cf749..362a5ccc9a4 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -5,6 +5,7 @@ namespace Doctrine\DBAL\Types; use Doctrine\DBAL\DBALException; + use function array_search; use function in_array; @@ -24,7 +25,7 @@ final class TypeRegistry * * @throws DBALException */ - public function get(string $name) : Type + public function get(string $name): Type { if (! isset($this->instances[$name])) { throw DBALException::unknownColumnType($name); @@ -38,7 +39,7 @@ public function get(string $name) : Type * * @throws DBALException */ - public function lookupName(Type $type) : string + public function lookupName(Type $type): string { $name = $this->findTypeName($type); @@ -52,7 +53,7 @@ public function lookupName(Type $type) : string /** * Checks if there is a type of the given name. */ - public function has(string $name) : bool + public function has(string $name): bool { return isset($this->instances[$name]); } @@ -62,7 +63,7 @@ public function has(string $name) : bool * * @throws DBALException */ - public function register(string $name, Type $type) : void + public function register(string $name, Type $type): void { if (isset($this->instances[$name])) { throw DBALException::typeExists($name); @@ -80,7 +81,7 @@ public function register(string $name, Type $type) : void * * @throws DBALException */ - public function override(string $name, Type $type) : void + public function override(string $name, Type $type): void { if (! isset($this->instances[$name])) { throw DBALException::typeNotFound($name); @@ -100,12 +101,12 @@ public function override(string $name, Type $type) : void * * @return array */ - public function getMap() : array + public function getMap(): array { return $this->instances; } - private function findTypeName(Type $type) : ?string + private function findTypeName(Type $type): ?string { $name = array_search($type, $this->instances, true); diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php index 38beb3badf6..23f8b572d09 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeImmutableType.php @@ -4,6 +4,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create_immutable; /** diff --git a/lib/Doctrine/DBAL/Types/VarDateTimeType.php b/lib/Doctrine/DBAL/Types/VarDateTimeType.php index 1d9dbd3a6c6..20960579afd 100644 --- a/lib/Doctrine/DBAL/Types/VarDateTimeType.php +++ b/lib/Doctrine/DBAL/Types/VarDateTimeType.php @@ -4,6 +4,7 @@ use DateTime; use Doctrine\DBAL\Platforms\AbstractPlatform; + use function date_create; /** diff --git a/phpcs.xml.dist b/phpcs.xml.dist index ad39355ad24..bfbfafd31e4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -23,6 +23,7 @@ + diff --git a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php index 6078fb1ab8c..185fac138c0 100644 --- a/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php +++ b/tests/Doctrine/Tests/DBAL/Cache/QueryCacheProfileTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalTestCase; + use function parse_str; class QueryCacheProfileTest extends DbalTestCase @@ -33,12 +34,12 @@ class QueryCacheProfileTest extends DbalTestCase 'driver' => 'database_driver', ]; - protected function setUp() : void + protected function setUp(): void { $this->queryCacheProfile = new QueryCacheProfile(self::LIFETIME, self::CACHE_KEY); } - public function testShouldUseTheGivenCacheKeyIfPresent() : void + public function testShouldUseTheGivenCacheKeyIfPresent(): void { [$cacheKey] = $this->queryCacheProfile->generateCacheKeys( $this->query, @@ -50,7 +51,7 @@ public function testShouldUseTheGivenCacheKeyIfPresent() : void self::assertEquals(self::CACHE_KEY, $cacheKey, 'The returned cache key should match the given one'); } - public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() : void + public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -70,7 +71,7 @@ public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() : void self::assertNotEmpty($cacheKey, 'The generated cache key should not be empty'); } - public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections() : void + public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -93,7 +94,7 @@ public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferent self::assertNotEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be different'); } - public function testConnectionParamsShouldBeHashed() : void + public function testConnectionParamsShouldBeHashed(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); @@ -114,7 +115,7 @@ public function testConnectionParamsShouldBeHashed() : void } } - public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges() : void + public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges(): void { $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); diff --git a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php index bde98cfa4b5..7ebfc5b1982 100644 --- a/tests/Doctrine/Tests/DBAL/ConfigurationTest.php +++ b/tests/Doctrine/Tests/DBAL/ConfigurationTest.php @@ -17,7 +17,7 @@ class ConfigurationTest extends DbalTestCase */ protected $config; - protected function setUp() : void + protected function setUp(): void { $this->config = new Configuration(); } @@ -27,7 +27,7 @@ protected function setUp() : void * * @group DBAL-81 */ - public function testReturnsDefaultConnectionAutoCommitMode() : void + public function testReturnsDefaultConnectionAutoCommitMode(): void { self::assertTrue($this->config->getAutoCommit()); } @@ -37,7 +37,7 @@ public function testReturnsDefaultConnectionAutoCommitMode() : void * * @group DBAL-81 */ - public function testSetsDefaultConnectionAutoCommitMode() : void + public function testSetsDefaultConnectionAutoCommitMode(): void { $this->config->setAutoCommit(false); diff --git a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php index a7b04f94994..7ffc32b6e06 100644 --- a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php +++ b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php @@ -12,7 +12,7 @@ final class LoggingTest extends TestCase { - public function testLogExecuteQuery() : void + public function testLogExecuteQuery(): void { $driverConnection = $this->createStub(DriverConnection::class); $driverConnection->method('query') @@ -22,7 +22,7 @@ public function testLogExecuteQuery() : void ->executeQuery('SELECT * FROM table'); } - public function testLogExecuteUpdate() : void + public function testLogExecuteUpdate(): void { $this->createConnection( $this->createStub(DriverConnection::class), @@ -31,7 +31,7 @@ public function testLogExecuteUpdate() : void ->executeUpdate('UPDATE table SET foo = ?'); } - public function testLogPrepareExecute() : void + public function testLogPrepareExecute(): void { $driverConnection = $this->createStub(DriverConnection::class); $driverConnection->method('prepare') @@ -42,7 +42,7 @@ public function testLogPrepareExecute() : void ->execute(); } - private function createConnection(DriverConnection $driverConnection, string $expectedSQL) : Connection + private function createConnection(DriverConnection $driverConnection, string $expectedSQL): Connection { $driver = $this->createStub(Driver::class); $driver->method('connect') diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index fc018fcc072..2cba7534710 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -26,6 +26,7 @@ use Exception; use PHPUnit\Framework\MockObject\MockObject; use stdClass; + use function call_user_func_array; /** @@ -45,7 +46,7 @@ class ConnectionTest extends DbalTestCase 'port' => '1234', ]; - protected function setUp() : void + protected function setUp(): void { $this->connection = DriverManager::getConnection($this->params); } @@ -71,78 +72,78 @@ private function getExecuteUpdateMockConnection() ->getMock(); } - public function testIsConnected() : void + public function testIsConnected(): void { self::assertFalse($this->connection->isConnected()); } - public function testNoTransactionActiveByDefault() : void + public function testNoTransactionActiveByDefault(): void { self::assertFalse($this->connection->isTransactionActive()); } - public function testCommitWithNoActiveTransactionThrowsException() : void + public function testCommitWithNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->commit(); } - public function testRollbackWithNoActiveTransactionThrowsException() : void + public function testRollbackWithNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->rollBack(); } - public function testSetRollbackOnlyNoActiveTransactionThrowsException() : void + public function testSetRollbackOnlyNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->setRollbackOnly(); } - public function testIsRollbackOnlyNoActiveTransactionThrowsException() : void + public function testIsRollbackOnlyNoActiveTransactionThrowsException(): void { $this->expectException(ConnectionException::class); $this->connection->isRollbackOnly(); } - public function testGetConfiguration() : void + public function testGetConfiguration(): void { $config = $this->connection->getConfiguration(); self::assertInstanceOf(Configuration::class, $config); } - public function testGetHost() : void + public function testGetHost(): void { self::assertEquals('localhost', $this->connection->getHost()); } - public function testGetPort() : void + public function testGetPort(): void { self::assertEquals('1234', $this->connection->getPort()); } - public function testGetUsername() : void + public function testGetUsername(): void { self::assertEquals('root', $this->connection->getUsername()); } - public function testGetPassword() : void + public function testGetPassword(): void { self::assertEquals('password', $this->connection->getPassword()); } - public function testGetDriver() : void + public function testGetDriver(): void { self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); } - public function testGetEventManager() : void + public function testGetEventManager(): void { self::assertInstanceOf(EventManager::class, $this->connection->getEventManager()); } - public function testConnectDispatchEvent() : void + public function testConnectDispatchEvent(): void { $listenerMock = $this->createMock(ConnectDispatchEventListener::class); $listenerMock->expects($this->once())->method('postConnect'); @@ -158,7 +159,7 @@ public function testConnectDispatchEvent() : void $conn->connect(); } - public function testEventManagerPassedToPlatform() : void + public function testEventManagerPassedToPlatform(): void { $eventManager = new EventManager(); @@ -180,7 +181,7 @@ public function testEventManagerPassedToPlatform() : void * @requires extension pdo_sqlite * @dataProvider getQueryMethods */ - public function testDriverExceptionIsWrapped(string $method) : void + public function testDriverExceptionIsWrapped(string $method): void { $this->expectException(DBALException::class); $this->expectExceptionMessage("An exception occurred while executing 'MUUHAAAAHAAAA':\n\nSQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\""); @@ -196,7 +197,7 @@ public function testDriverExceptionIsWrapped(string $method) : void /** * @return array> */ - public static function getQueryMethods() : iterable + public static function getQueryMethods(): iterable { return [ ['exec'], @@ -212,7 +213,7 @@ public static function getQueryMethods() : iterable * * @group DBAL-11 */ - public function testEchoSQLLogger() : void + public function testEchoSQLLogger(): void { $logger = new EchoSQLLogger(); $this->connection->getConfiguration()->setSQLLogger($logger); @@ -224,7 +225,7 @@ public function testEchoSQLLogger() : void * * @group DBAL-11 */ - public function testDebugSQLStack() : void + public function testDebugSQLStack(): void { $logger = new DebugStack(); $this->connection->getConfiguration()->setSQLLogger($logger); @@ -234,7 +235,7 @@ public function testDebugSQLStack() : void /** * @group DBAL-81 */ - public function testIsAutoCommit() : void + public function testIsAutoCommit(): void { self::assertTrue($this->connection->isAutoCommit()); } @@ -242,7 +243,7 @@ public function testIsAutoCommit() : void /** * @group DBAL-81 */ - public function testSetAutoCommit() : void + public function testSetAutoCommit(): void { $this->connection->setAutoCommit(false); self::assertFalse($this->connection->isAutoCommit()); @@ -253,7 +254,7 @@ public function testSetAutoCommit() : void /** * @group DBAL-81 */ - public function testConnectStartsTransactionInNoAutoCommitMode() : void + public function testConnectStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -275,7 +276,7 @@ public function testConnectStartsTransactionInNoAutoCommitMode() : void /** * @group DBAL-81 */ - public function testCommitStartsTransactionInNoAutoCommitMode() : void + public function testCommitStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -295,7 +296,7 @@ public function testCommitStartsTransactionInNoAutoCommitMode() : void /** * @dataProvider resultProvider */ - public function testCommitReturn(bool $expectedResult) : void + public function testCommitReturn(bool $expectedResult): void { $driverConnection = $this->createMock(DriverConnection::class); $driverConnection->expects($this->once()) @@ -317,7 +318,7 @@ public function testCommitReturn(bool $expectedResult) : void /** * @return bool[][] */ - public function resultProvider() : array + public function resultProvider(): array { return [[true], [false]]; } @@ -325,7 +326,7 @@ public function resultProvider() : array /** * @group DBAL-81 */ - public function testRollBackStartsTransactionInNoAutoCommitMode() : void + public function testRollBackStartsTransactionInNoAutoCommitMode(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -345,7 +346,7 @@ public function testRollBackStartsTransactionInNoAutoCommitMode() : void /** * @group DBAL-81 */ - public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions() : void + public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions(): void { $driverMock = $this->createMock(Driver::class); $driverMock->expects($this->any()) @@ -369,7 +370,7 @@ public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions() : voi self::assertFalse($conn->isTransactionActive()); } - public function testEmptyInsert() : void + public function testEmptyInsert(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -383,7 +384,7 @@ public function testEmptyInsert() : void /** * @group DBAL-2511 */ - public function testUpdateWithDifferentColumnsInDataAndIdentifiers() : void + public function testUpdateWithDifferentColumnsInDataAndIdentifiers(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -427,7 +428,7 @@ public function testUpdateWithDifferentColumnsInDataAndIdentifiers() : void /** * @group DBAL-2511 */ - public function testUpdateWithSameColumnInDataAndIdentifiers() : void + public function testUpdateWithSameColumnInDataAndIdentifiers(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -470,7 +471,7 @@ public function testUpdateWithSameColumnInDataAndIdentifiers() : void /** * @group DBAL-2688 */ - public function testUpdateWithIsNull() : void + public function testUpdateWithIsNull(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -512,7 +513,7 @@ public function testUpdateWithIsNull() : void /** * @group DBAL-2688 */ - public function testDeleteWithIsNull() : void + public function testDeleteWithIsNull(): void { $conn = $this->getExecuteUpdateMockConnection(); @@ -537,7 +538,7 @@ public function testDeleteWithIsNull() : void ); } - public function testFetchAssoc() : void + public function testFetchAssoc(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -572,7 +573,7 @@ public function testFetchAssoc() : void self::assertSame($result, $conn->fetchAssoc($statement, $params, $types)); } - public function testFetchArray() : void + public function testFetchArray(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -607,7 +608,7 @@ public function testFetchArray() : void self::assertSame($result, $conn->fetchArray($statement, $params, $types)); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -643,7 +644,7 @@ public function testFetchColumn() : void self::assertSame($result, $conn->fetchColumn($statement, $params, $column, $types)); } - public function testFetchAll() : void + public function testFetchAll(): void { $statement = 'SELECT * FROM foo WHERE bar = ?'; $params = [666]; @@ -677,7 +678,7 @@ public function testFetchAll() : void self::assertSame($result, $conn->fetchAll($statement, $params, $types)); } - public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() : void + public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO(): void { $params['pdo'] = new stdClass(); @@ -688,7 +689,7 @@ public function testConnectionDoesNotMaintainTwoReferencesToExternalPDO() : void self::assertArrayNotHasKey('pdo', $conn->getParams(), 'Connection is maintaining additional reference to the PDO connection'); } - public function testPassingExternalPDOMeansConnectionIsConnected() : void + public function testPassingExternalPDOMeansConnectionIsConnected(): void { $params['pdo'] = new stdClass(); @@ -699,7 +700,7 @@ public function testPassingExternalPDOMeansConnectionIsConnected() : void self::assertTrue($conn->isConnected(), 'Connection is not connected after passing external PDO'); } - public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException() : void + public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentException(): void { $driver = $this->createMock(Driver::class); $pdoMock = $this->createMock(\Doctrine\DBAL\Driver\Connection::class); @@ -717,7 +718,7 @@ public function testCallingDeleteWithNoDeletionCriteriaResultsInInvalidArgumentE /** * @return array> */ - public static function dataCallConnectOnce() : iterable + public static function dataCallConnectOnce(): iterable { return [ ['delete', ['tbl', ['id' => 12345]]], @@ -733,7 +734,7 @@ public static function dataCallConnectOnce() : iterable * * @dataProvider dataCallConnectOnce */ - public function testCallConnectOnce(string $method, array $params) : void + public function testCallConnectOnce(string $method, array $params): void { $driverMock = $this->createMock(Driver::class); $pdoMock = $this->createMock(Connection::class); @@ -757,7 +758,7 @@ public function testCallConnectOnce(string $method, array $params) : void /** * @group DBAL-1127 */ - public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : void + public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform(): void { $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); @@ -787,7 +788,7 @@ public function testPlatformDetectionIsTriggerOnlyOnceOnRetrievingPlatform() : v self::assertSame($platformMock, $connection->getDatabasePlatform()); } - public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery() : void + public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCacheQuery(): void { $resultCacheDriverMock = $this->createMock(Cache::class); @@ -826,7 +827,7 @@ public function testConnectionParamsArePassedToTheQueryCacheProfileInExecuteCach /** * @group #2821 */ - public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery() : void + public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecuteCacheQuery(): void { $resultCacheDriverMock = $this->createMock(Cache::class); @@ -863,7 +864,7 @@ public function testShouldNotPassPlatformInParamsToTheQueryCacheProfileInExecute /** * @group #2821 */ - public function testThrowsExceptionWhenInValidPlatformSpecified() : void + public function testThrowsExceptionWhenInValidPlatformSpecified(): void { $connectionParams = $this->params; $connectionParams['platform'] = new stdClass(); @@ -878,7 +879,7 @@ public function testThrowsExceptionWhenInValidPlatformSpecified() : void /** * @group DBAL-990 */ - public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase() : void + public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnectingToNonExistentDatabase(): void { $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); @@ -902,7 +903,7 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting /** * @group #3194 */ - public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys() : void + public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGeneratingCacheKeys(): void { $driver = $this->createMock(Driver::class); @@ -949,5 +950,5 @@ public function testExecuteCacheQueryStripsPlatformFromConnectionParamsBeforeGen interface ConnectDispatchEventListener { - public function postConnect() : void; + public function postConnect(): void; } diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index de37397dd91..386614d78ec 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -9,27 +9,28 @@ use Doctrine\Tests\DbalTestCase; use Exception; use stdClass; + use function chr; use function fopen; use function sprintf; class DBALExceptionTest extends DbalTestCase { - public function testDriverExceptionDuringQueryAcceptsBinaryData() : void + public function testDriverExceptionDuringQueryAcceptsBinaryData(): void { $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); } - public function testDriverExceptionDuringQueryAcceptsResource() : void + public function testDriverExceptionDuringQueryAcceptsResource(): void { $driver = $this->createMock(Driver::class); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]); self::assertStringContainsString('Resource', $e->getMessage()); } - public function testAvoidOverWrappingOnDriverException() : void + public function testAvoidOverWrappingOnDriverException(): void { $driver = $this->createMock(Driver::class); @@ -40,7 +41,7 @@ public function testAvoidOverWrappingOnDriverException() : void self::assertSame($ex, $e); } - public function testDriverRequiredWithUrl() : void + public function testDriverRequiredWithUrl(): void { $url = 'mysql://localhost'; $exception = DBALException::driverRequired($url); @@ -59,7 +60,7 @@ public function testDriverRequiredWithUrl() : void /** * @group #2821 */ - public function testInvalidPlatformTypeObject() : void + public function testInvalidPlatformTypeObject(): void { $exception = DBALException::invalidPlatformType(new stdClass()); @@ -72,7 +73,7 @@ public function testInvalidPlatformTypeObject() : void /** * @group #2821 */ - public function testInvalidPlatformTypeScalar() : void + public function testInvalidPlatformTypeScalar(): void { $exception = DBALException::invalidPlatformType('some string'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php index 7038f5f8340..25133b6394a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDB2DriverTest.php @@ -12,17 +12,17 @@ class AbstractDB2DriverTest extends AbstractDriverTest { - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractDB2Driver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new DB2Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new DB2SchemaManager($connection); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index 5c8a5dd29ba..29a8441f646 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -30,6 +30,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; + use function array_merge; use function get_class; use function sprintf; @@ -61,7 +62,7 @@ abstract class AbstractDriverTest extends DbalTestCase */ protected $driver; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -73,7 +74,7 @@ protected function setUp() : void * * @dataProvider exceptionConversionProvider */ - public function testConvertsException($errorCode, ?string $sqlState, ?string $message, string $expectedClass) : void + public function testConvertsException($errorCode, ?string $sqlState, ?string $message, string $expectedClass): void { if (! $this->driver instanceof ExceptionConverterDriver) { $this->markTestSkipped('This test is only intended for exception converter drivers.'); @@ -98,7 +99,7 @@ public function testConvertsException($errorCode, ?string $sqlState, ?string $me self::assertSame($dbalMessage, $dbalException->getMessage()); } - public function testCreatesDatabasePlatformForVersion() : void + public function testCreatesDatabasePlatformForVersion(): void { if (! $this->driver instanceof VersionAwarePlatformDriver) { $this->markTestSkipped('This test is only intended for version aware platform drivers.'); @@ -131,7 +132,7 @@ public function testCreatesDatabasePlatformForVersion() : void } } - public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void + public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(): void { if (! $this->driver instanceof VersionAwarePlatformDriver) { $this->markTestSkipped('This test is only intended for version aware platform drivers.'); @@ -141,7 +142,7 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion( $this->driver->createDatabasePlatformForVersion('foo'); } - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -158,12 +159,12 @@ public function testReturnsDatabaseName() : void self::assertSame($params['dbname'], $this->driver->getDatabase($connection)); } - public function testReturnsDatabasePlatform() : void + public function testReturnsDatabasePlatform(): void { self::assertEquals($this->createPlatform(), $this->driver->getDatabasePlatform()); } - public function testReturnsSchemaManager() : void + public function testReturnsSchemaManager(): void { $connection = $this->getConnectionMock(); $schemaManager = $this->driver->getSchemaManager($connection); @@ -179,7 +180,7 @@ public function testReturnsSchemaManager() : void /** * Factory method for creating the driver instance under test. */ - abstract protected function createDriver() : Driver; + abstract protected function createDriver(): Driver; /** * Factory method for creating the the platform instance return by the driver under test. @@ -187,7 +188,7 @@ abstract protected function createDriver() : Driver; * The platform instance returned by this method must be the same as returned by * the driver's getDatabasePlatform() method. */ - abstract protected function createPlatform() : AbstractPlatform; + abstract protected function createPlatform(): AbstractPlatform; /** * Factory method for creating the the schema manager instance return by the driver under test. @@ -197,12 +198,12 @@ abstract protected function createPlatform() : AbstractPlatform; * * @param Connection $connection The underlying connection to use. */ - abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager; + abstract protected function createSchemaManager(Connection $connection): AbstractSchemaManager; /** * @return Connection&MockObject */ - protected function getConnectionMock() : Connection + protected function getConnectionMock(): Connection { return $this->createMock(Connection::class); } @@ -210,7 +211,7 @@ protected function getConnectionMock() : Connection /** * @return array> */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return []; } @@ -218,7 +219,7 @@ protected function getDatabasePlatformsForVersions() : array /** * @return iterable */ - public static function exceptionConversionProvider() : iterable + public static function exceptionConversionProvider(): iterable { foreach (static::getExceptionConversionData() as $expectedClass => $items) { foreach ($items as $item) { @@ -232,7 +233,7 @@ public static function exceptionConversionProvider() : iterable /** * @return array */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return []; } diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php index 4982a189e05..094c7506f87 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractMySQLDriverTest.php @@ -16,7 +16,7 @@ class AbstractMySQLDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { parent::testReturnsDatabaseName(); @@ -45,17 +45,17 @@ public function testReturnsDatabaseName() : void self::assertSame($database, $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractMySQLDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new MySqlPlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new MySqlSchemaManager($connection); } @@ -63,7 +63,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['5.6.9', MySqlPlatform::class], @@ -89,7 +89,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php index efb250d1ac7..a549477ae98 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriver/EasyConnectStringTest.php @@ -12,7 +12,7 @@ class EasyConnectStringTest extends TestCase * * @dataProvider connectionParametersProvider */ - public function testFromConnectionParameters(array $params, string $expected) : void + public function testFromConnectionParameters(array $params, string $expected): void { $string = EasyConnectString::fromConnectionParameters($params); @@ -22,7 +22,7 @@ public function testFromConnectionParameters(array $params, string $expected) : /** * @return mixed[] */ - public static function connectionParametersProvider() : iterable + public static function connectionParametersProvider(): iterable { return [ 'empty-params' => [[],''], diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php index f95705a8a88..390607696da 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractOracleDriverTest.php @@ -12,7 +12,7 @@ class AbstractOracleDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -29,7 +29,7 @@ public function testReturnsDatabaseName() : void self::assertSame($params['user'], $this->driver->getDatabase($connection)); } - public function testReturnsDatabaseNameWithConnectDescriptor() : void + public function testReturnsDatabaseNameWithConnectDescriptor(): void { $params = [ 'user' => 'foo', @@ -48,17 +48,17 @@ public function testReturnsDatabaseNameWithConnectDescriptor() : void self::assertSame($params['user'], $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractOracleDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new OraclePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new OracleSchemaManager($connection); } @@ -66,7 +66,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php index 2ba6a732bd4..4276ee9f447 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractPostgreSQLDriverTest.php @@ -17,7 +17,7 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { parent::testReturnsDatabaseName(); @@ -46,17 +46,17 @@ public function testReturnsDatabaseName() : void self::assertSame($database, $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractPostgreSQLDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new PostgreSqlPlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new PostgreSqlSchemaManager($connection); } @@ -64,7 +64,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['9.0.9', PostgreSqlPlatform::class], @@ -86,7 +86,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php index 4c51e7cb35f..e57daa2b66a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLAnywhereDriverTest.php @@ -15,17 +15,17 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest { - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractSQLAnywhereDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SQLAnywhere12Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SQLAnywhereSchemaManager($connection); } @@ -33,7 +33,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['10', SQLAnywherePlatform::class], @@ -71,7 +71,7 @@ protected function getDatabasePlatformsForVersions() : array /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php index 0d34df8e81b..a81165114ba 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php @@ -15,17 +15,17 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest { - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractSQLServerDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SQLServer2008Platform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SQLServerSchemaManager($connection); } @@ -33,7 +33,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['9', SQLServerPlatform::class], diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php index 338f9126077..c5f2f353207 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLiteDriverTest.php @@ -12,7 +12,7 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest { - public function testReturnsDatabaseName() : void + public function testReturnsDatabaseName(): void { $params = [ 'user' => 'foo', @@ -30,17 +30,17 @@ public function testReturnsDatabaseName() : void self::assertSame($params['path'], $this->driver->getDatabase($connection)); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return $this->getMockForAbstractClass(AbstractSQLiteDriver::class); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new SqlitePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new SqliteSchemaManager($connection); } @@ -48,7 +48,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * {@inheritDoc} */ - protected static function getExceptionConversionData() : array + protected static function getExceptionConversionData(): array { return [ self::EXCEPTION_CONNECTION => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php index 5af24b8454a..99e81ee2779 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/DrizzlePDOMySql/DriverTest.php @@ -13,27 +13,27 @@ class DriverTest extends PDOMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('drizzle_pdo_mysql', $this->driver->getName()); } - public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void + public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion(): void { $this->markTestSkipped('This test does not work on Drizzle as it is not version aware.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected function createPlatform() : AbstractPlatform + protected function createPlatform(): AbstractPlatform { return new DrizzlePlatform(); } - protected function createSchemaManager(Connection $connection) : AbstractSchemaManager + protected function createSchemaManager(Connection $connection): AbstractSchemaManager { return new DrizzleSchemaManager($connection); } @@ -41,7 +41,7 @@ protected function createSchemaManager(Connection $connection) : AbstractSchemaM /** * @return mixed[][] */ - protected function getDatabasePlatformsForVersions() : array + protected function getDatabasePlatformsForVersions(): array { return [ ['foo', DrizzlePlatform::class], diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php index cf2db940b33..5b0f522e9be 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2ConnectionTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Connection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; class DB2ConnectionTest extends DbalTestCase @@ -16,7 +17,7 @@ class DB2ConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); @@ -29,7 +30,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php index dcf9f6083e3..e48d3c40b66 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php @@ -8,12 +8,12 @@ class DB2DriverTest extends AbstractDB2DriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('ibm_db2', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new DB2Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php index bbe16b34717..0a5265cf9c7 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('mysqli', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php index 5e4b43aff8c..f47daf271c4 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/Mysqli/MysqliConnectionTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; use function restore_error_handler; use function set_error_handler; @@ -20,7 +21,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); @@ -37,14 +38,14 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } - public function testRestoresErrorHandlerOnException() : void + public function testRestoresErrorHandlerOnException(): void { - $handler = static function () : bool { + $handler = static function (): bool { self::fail('Never expected this to be called'); }; diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php index 7b6ed1d5a55..eedfdec6844 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractOracleDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('oci8', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php index 4c3868f4a95..434aa71b009 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8ConnectionTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; class OCI8ConnectionTest extends DbalTestCase @@ -16,7 +17,7 @@ class OCI8ConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -29,7 +30,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index f90f86d6eb3..6ab31682f37 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Statement; use Doctrine\Tests\DbalTestCase; use ReflectionProperty; + use function extension_loaded; class OCI8StatementTest extends DbalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -33,7 +34,7 @@ protected function setUp() : void * * @dataProvider executeDataProvider */ - public function testExecute(array $params) : void + public function testExecute(array $params): void { $statement = $this->getMockBuilder(OCI8Statement::class) ->onlyMethods(['bindValue', 'errorInfo']) @@ -84,7 +85,7 @@ public function testExecute(array $params) : void /** * @return array> */ - public static function executeDataProvider() : iterable + public static function executeDataProvider(): iterable { return [ // $hasZeroIndex = isset($params[0]); == true @@ -101,7 +102,7 @@ public static function executeDataProvider() : iterable /** * @dataProvider nonTerminatedLiteralProvider */ - public function testConvertNonTerminatedLiteral(string $sql, string $message) : void + public function testConvertNonTerminatedLiteral(string $sql, string $message): void { $this->expectException(OCI8Exception::class); $this->expectExceptionMessageRegExp($message); @@ -111,7 +112,7 @@ public function testConvertNonTerminatedLiteral(string $sql, string $message) : /** * @return array> */ - public static function nonTerminatedLiteralProvider() : iterable + public static function nonTerminatedLiteralProvider(): iterable { return [ 'no-matching-quote' => [ diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php index 9ed9a06aa5b..6cd2396e679 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\PDOException; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; class PDOExceptionTest extends DbalTestCase @@ -29,7 +30,7 @@ class PDOExceptionTest extends DbalTestCase */ private $wrappedException; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('PDO')) { $this->markTestSkipped('PDO is not installed.'); @@ -44,27 +45,27 @@ protected function setUp() : void $this->exception = new PDOException($this->wrappedException); } - public function testReturnsCode() : void + public function testReturnsCode(): void { self::assertSame(self::SQLSTATE, $this->exception->getCode()); } - public function testReturnsErrorCode() : void + public function testReturnsErrorCode(): void { self::assertSame(self::ERROR_CODE, $this->exception->getErrorCode()); } - public function testReturnsMessage() : void + public function testReturnsMessage(): void { self::assertSame(self::MESSAGE, $this->exception->getMessage()); } - public function testReturnsSQLState() : void + public function testReturnsSQLState(): void { self::assertSame(self::SQLSTATE, $this->exception->getSQLState()); } - public function testOriginalExceptionIsInChain() : void + public function testOriginalExceptionIsInChain(): void { self::assertSame($this->wrappedException, $this->exception->getPrevious()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php index 9eeeafb78aa..bd9ea3f2080 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOIbm/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractDB2DriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_ibm', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php index 6e3ef7d5a03..e67a0673402 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractMySQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_mysql', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php index 42353be376d..ae647cbe0cd 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractOracleDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_oracle', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index b4f244a721d..e8edca780ab 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -8,11 +8,12 @@ use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use PDO; use PDOException; + use function defined; class DriverTest extends AbstractPostgreSQLDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_pgsql', $this->driver->getName()); } @@ -20,7 +21,7 @@ public function testReturnsName() : void /** * @group DBAL-920 */ - public function testConnectionDisablesPreparesOnPhp56() : void + public function testConnectionDisablesPreparesOnPhp56(): void { $this->skipWhenNotUsingPhp56AndPdoPgsql(); @@ -46,7 +47,7 @@ public function testConnectionDisablesPreparesOnPhp56() : void /** * @group DBAL-920 */ - public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() : void + public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined(): void { $this->skipWhenNotUsingPhp56AndPdoPgsql(); @@ -73,7 +74,7 @@ public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined( /** * @group DBAL-920 */ - public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() : void + public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined(): void { $this->skipWhenNotUsingPhp56AndPdoPgsql(); @@ -97,12 +98,12 @@ public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplici } } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - private function skipWhenNotUsingPhp56AndPdoPgsql() : void + private function skipWhenNotUsingPhp56AndPdoPgsql(): void { if (! defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) { $this->markTestSkipped('Test requires PHP 5.6+'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php index 9092b091e3a..b360a46cba6 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLiteDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_sqlite', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php index c92dc86d5ba..e3ee50ff293 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLServerDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('pdo_sqlsrv', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php index d6f1595a45e..a1bebb72b25 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLAnywhereDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('sqlanywhere', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php index effeb483362..7b5fa7741bd 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLAnywhere/SQLAnywhereConnectionTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; class SQLAnywhereConnectionTest extends DbalTestCase @@ -16,7 +17,7 @@ class SQLAnywhereConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); @@ -29,7 +30,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testRequiresQueryForServerVersion() : void + public function testRequiresQueryForServerVersion(): void { self::assertTrue($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php index 9ab6635ecf4..d2549a6e344 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/DriverTest.php @@ -8,12 +8,12 @@ class DriverTest extends AbstractSQLServerDriverTest { - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('sqlsrv', $this->driver->getName()); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php index 8d457d8eb23..feb87d78d1d 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/SQLSrv/SQLSrvConnectionTest.php @@ -5,6 +5,7 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function extension_loaded; class SQLSrvConnectionTest extends DbalTestCase @@ -16,7 +17,7 @@ class SQLSrvConnectionTest extends DbalTestCase */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlsrv')) { $this->markTestSkipped('sqlsrv is not installed.'); @@ -29,7 +30,7 @@ protected function setUp() : void ->getMockForAbstractClass(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->connectionMock->requiresQueryForServerVersion()); } diff --git a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php index f6bd2c7be6b..24f7132f8da 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/StatementIteratorTest.php @@ -13,6 +13,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use Traversable; + use function extension_loaded; class StatementIteratorTest extends DbalTestCase @@ -20,7 +21,7 @@ class StatementIteratorTest extends DbalTestCase /** * @dataProvider statementProvider() */ - public function testGettingIteratorDoesNotCallFetch(string $class) : void + public function testGettingIteratorDoesNotCallFetch(string $class): void { $stmt = $this->createPartialMock($class, ['fetch', 'fetchAll', 'fetchColumn']); $stmt->expects($this->never())->method('fetch'); @@ -30,7 +31,7 @@ public function testGettingIteratorDoesNotCallFetch(string $class) : void $stmt->getIterator(); } - public function testIteratorIterationCallsFetchOncePerStep() : void + public function testIteratorIterationCallsFetchOncePerStep(): void { $stmt = $this->createMock(Statement::class); @@ -47,7 +48,7 @@ public function testIteratorIterationCallsFetchOncePerStep() : void * * @dataProvider statementProvider() */ - public function testStatementIterationCallsFetchOncePerStep(string $class) : void + public function testStatementIterationCallsFetchOncePerStep(string $class): void { $stmt = $this->createPartialMock($class, ['fetch']); @@ -56,7 +57,7 @@ public function testStatementIterationCallsFetchOncePerStep(string $class) : voi $this->assertIterationCallsFetchOncePerStep($stmt, $calls); } - private function configureStatement(MockObject $stmt, int &$calls) : void + private function configureStatement(MockObject $stmt, int &$calls): void { $values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible']; $calls = 0; @@ -74,7 +75,7 @@ private function configureStatement(MockObject $stmt, int &$calls) : void /** * @param Traversable $iterator */ - private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void + private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls): void { foreach ($iterator as $i => $_) { $this->assertEquals($i + 1, $calls); @@ -84,7 +85,7 @@ private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int /** * @return iterable}> */ - public static function statementProvider() : iterable + public static function statementProvider(): iterable { if (extension_loaded('ibm_db2')) { yield [DB2Statement::class]; diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index 7577d5504b6..524e03031c4 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -17,6 +17,7 @@ use Doctrine\Tests\DbalTestCase; use PDO; use stdClass; + use function extension_loaded; use function get_class; use function in_array; @@ -27,7 +28,7 @@ class DriverManagerTest extends DbalTestCase /** * @requires extension pdo_sqlite */ - public function testInvalidPdoInstance() : void + public function testInvalidPdoInstance(): void { $this->expectException(DBALException::class); DriverManager::getConnection(['pdo' => 'test']); @@ -36,7 +37,7 @@ public function testInvalidPdoInstance() : void /** * @requires extension pdo_sqlite */ - public function testValidPdoInstance() : void + public function testValidPdoInstance(): void { $conn = DriverManager::getConnection([ 'pdo' => new PDO('sqlite::memory:'), @@ -49,7 +50,7 @@ public function testValidPdoInstance() : void * @group DBAL-32 * @requires extension pdo_sqlite */ - public function testPdoInstanceSetErrorMode() : void + public function testPdoInstanceSetErrorMode(): void { $pdo = new PDO('sqlite::memory:'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); @@ -59,14 +60,14 @@ public function testPdoInstanceSetErrorMode() : void self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE)); } - public function testCheckParams() : void + public function testCheckParams(): void { $this->expectException(DBALException::class); DriverManager::getConnection([]); } - public function testInvalidDriver() : void + public function testInvalidDriver(): void { $this->expectException(DBALException::class); @@ -76,7 +77,7 @@ public function testInvalidDriver() : void /** * @requires extension pdo_sqlite */ - public function testCustomPlatform() : void + public function testCustomPlatform(): void { $platform = $this->createMock(AbstractPlatform::class); $options = [ @@ -91,7 +92,7 @@ public function testCustomPlatform() : void /** * @requires extension pdo_sqlite */ - public function testCustomWrapper() : void + public function testCustomWrapper(): void { $wrapper = $this->createMock(Connection::class); $wrapperClass = get_class($wrapper); @@ -109,7 +110,7 @@ public function testCustomWrapper() : void * @requires extension pdo_sqlite * @psalm-suppress InvalidArgument */ - public function testInvalidWrapperClass() : void + public function testInvalidWrapperClass(): void { $this->expectException(DBALException::class); @@ -121,7 +122,7 @@ public function testInvalidWrapperClass() : void DriverManager::getConnection($options); } - public function testInvalidDriverClass() : void + public function testInvalidDriverClass(): void { $this->expectException(DBALException::class); @@ -130,7 +131,7 @@ public function testInvalidDriverClass() : void DriverManager::getConnection($options); } - public function testValidDriverClass() : void + public function testValidDriverClass(): void { $options = ['driverClass' => PDOMySQLDriver::class]; @@ -138,7 +139,7 @@ public function testValidDriverClass() : void self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver()); } - public function testDatabaseUrlMasterSlave() : void + public function testDatabaseUrlMasterSlave(): void { $options = [ 'driver' => 'pdo_mysql', @@ -170,7 +171,7 @@ public function testDatabaseUrlMasterSlave() : void self::assertEquals('baz_slave', $params['slaves']['slave1']['dbname']); } - public function testDatabaseUrlShard() : void + public function testDatabaseUrlShard(): void { $options = [ 'driver' => 'pdo_mysql', @@ -212,7 +213,7 @@ public function testDatabaseUrlShard() : void * * @dataProvider databaseUrls */ - public function testDatabaseUrl($url, $expected) : void + public function testDatabaseUrl($url, $expected): void { $options = is_array($url) ? $url : ['url' => $url]; @@ -245,7 +246,7 @@ public function testDatabaseUrl($url, $expected) : void /** * @return array> */ - public function databaseUrls() : iterable + public function databaseUrls(): iterable { $driver = $this->createMock(Driver::class); $driverClass = get_class($driver); diff --git a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php index daea3a754c6..73df349a832 100644 --- a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php @@ -10,7 +10,7 @@ class MysqlSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -23,7 +23,7 @@ public function testPostConnect() : void $listener->postConnect($eventArgs); } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new MysqlSessionInit(); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php index 998b1dc916e..a9dc64b8855 100644 --- a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Event\Listeners\OracleSessionInit; use Doctrine\DBAL\Events; use Doctrine\Tests\DbalTestCase; + use function sprintf; class OracleSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -28,7 +29,7 @@ public function testPostConnect() : void * @group DBAL-1824 * @dataProvider getPostConnectWithSessionParameterValuesData */ - public function testPostConnectQuotesSessionParameterValues(string $name, string $value) : void + public function testPostConnectQuotesSessionParameterValues(string $name, string $value): void { $connectionMock = $this->getMockBuilder(Connection::class) ->disableOriginalConstructor() @@ -46,14 +47,14 @@ public function testPostConnectQuotesSessionParameterValues(string $name, string /** * @return array> */ - public static function getPostConnectWithSessionParameterValuesData() : iterable + public static function getPostConnectWithSessionParameterValuesData(): iterable { return [ ['CURRENT_SCHEMA', 'foo'], ]; } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new OracleSessionInit(); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php index c69b2996827..efa098a2b22 100644 --- a/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/SQLSessionInitTest.php @@ -13,7 +13,7 @@ */ class SQLSessionInitTest extends DbalTestCase { - public function testPostConnect() : void + public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) @@ -26,7 +26,7 @@ public function testPostConnect() : void $listener->postConnect($eventArgs); } - public function testGetSubscribedEvents() : void + public function testGetSubscribedEvents(): void { $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents()); diff --git a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php index 7718a6bc9d8..024b0bb20cc 100644 --- a/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Exception/InvalidArgumentExceptionTest.php @@ -12,7 +12,7 @@ */ class InvalidArgumentExceptionTest extends TestCase { - public function testFromEmptyCriteria() : void + public function testFromEmptyCriteria(): void { $exception = InvalidArgumentException::fromEmptyCriteria(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php index a12d0600201..20ea0870476 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function fopen; use function str_repeat; use function stream_get_contents; @@ -18,7 +19,7 @@ */ class BlobTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -38,7 +39,7 @@ protected function setUp() : void $sm->dropAndCreateTable($table); } - public function testInsert() : void + public function testInsert(): void { $ret = $this->connection->insert('blob_table', [ 'id' => 1, @@ -53,7 +54,7 @@ public function testInsert() : void self::assertEquals(1, $ret); } - public function testInsertProcessesStream() : void + public function testInsertProcessesStream(): void { // https://github.com/doctrine/dbal/issues/3290 if ($this->connection->getDriver() instanceof OCI8Driver) { @@ -74,7 +75,7 @@ public function testInsertProcessesStream() : void $this->assertBlobContains($longBlob); } - public function testSelect() : void + public function testSelect(): void { $this->connection->insert('blob_table', [ 'id' => 1, @@ -89,7 +90,7 @@ public function testSelect() : void $this->assertBlobContains('test'); } - public function testUpdate() : void + public function testUpdate(): void { $this->connection->insert('blob_table', [ 'id' => 1, @@ -109,7 +110,7 @@ public function testUpdate() : void $this->assertBlobContains('test2'); } - public function testUpdateProcessesStream() : void + public function testUpdateProcessesStream(): void { // https://github.com/doctrine/dbal/issues/3290 if ($this->connection->getDriver() instanceof OCI8Driver) { @@ -137,7 +138,7 @@ public function testUpdateProcessesStream() : void $this->assertBlobContains('test2'); } - public function testBindParamProcessesStream() : void + public function testBindParamProcessesStream(): void { if ($this->connection->getDriver() instanceof OCI8Driver) { $this->markTestIncomplete('The oci8 driver does not support stream resources as parameters'); @@ -156,7 +157,7 @@ public function testBindParamProcessesStream() : void $this->assertBlobContains('test'); } - private function assertBlobContains(string $text) : void + private function assertBlobContains(string $text): void { $rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php index 27c672bcb46..ff86f9f93ce 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Connection as BaseConnection; + use function func_get_args; /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/FetchTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/FetchTest.php index a929910f490..4fa13c9ce5b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/FetchTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/FetchTest.php @@ -4,11 +4,12 @@ use Doctrine\DBAL\DriverManager; use Doctrine\Tests\DBAL\Functional\Connection\FetchTest as BaseFetchTest; + use function array_merge; class FetchTest extends BaseFetchTest { - public function setUp() : void + public function setUp(): void { parent::setUp(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php index 2fe0d98d95b..16e28595b84 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; + use function assert; /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php index b53b0b27509..d33fc1708e9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/FetchTest.php @@ -4,6 +4,7 @@ use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\TestUtil; + use function iterator_to_array; class FetchTest extends DbalFunctionalTestCase @@ -11,7 +12,7 @@ class FetchTest extends DbalFunctionalTestCase /** @var string */ private $query; - public function setUp() : void + public function setUp(): void { parent::setUp(); @@ -31,17 +32,17 @@ public function setUp() : void ], $this->connection->getDatabasePlatform()); } - public function testFetchNumeric() : void + public function testFetchNumeric(): void { self::assertEquals(['foo', 1], $this->connection->fetchNumeric($this->query)); } - public function testFetchOne() : void + public function testFetchOne(): void { self::assertEquals('foo', $this->connection->fetchOne($this->query)); } - public function testFetchAssociative() : void + public function testFetchAssociative(): void { self::assertEquals([ 'a' => 'foo', @@ -49,7 +50,7 @@ public function testFetchAssociative() : void ], $this->connection->fetchAssociative($this->query)); } - public function testFetchAllNumeric() : void + public function testFetchAllNumeric(): void { self::assertEquals([ ['foo', 1], @@ -58,7 +59,7 @@ public function testFetchAllNumeric() : void ], $this->connection->fetchAllNumeric($this->query)); } - public function testFetchAllAssociative() : void + public function testFetchAllAssociative(): void { self::assertEquals([ [ @@ -76,7 +77,7 @@ public function testFetchAllAssociative() : void ], $this->connection->fetchAllAssociative($this->query)); } - public function testFetchFirstColumn() : void + public function testFetchFirstColumn(): void { self::assertEquals([ 'foo', @@ -85,7 +86,7 @@ public function testFetchFirstColumn() : void ], $this->connection->fetchFirstColumn($this->query)); } - public function testIterateNumeric() : void + public function testIterateNumeric(): void { self::assertEquals([ ['foo', 1], @@ -94,7 +95,7 @@ public function testIterateNumeric() : void ], iterator_to_array($this->connection->iterateNumeric($this->query))); } - public function testIterateAssociative() : void + public function testIterateAssociative(): void { self::assertEquals([ [ @@ -112,7 +113,7 @@ public function testIterateAssociative() : void ], iterator_to_array($this->connection->iterateAssociative($this->query))); } - public function testIterateColumn() : void + public function testIterateColumn(): void { self::assertEquals([ 'foo', diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php index 5ea675c9e1a..8573ecab686 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -15,19 +15,20 @@ use PDO; use RuntimeException; use Throwable; + use function file_exists; use function in_array; use function unlink; class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { $this->resetSharedConn(); parent::setUp(); } - protected function tearDown() : void + protected function tearDown(): void { if (file_exists('/tmp/test_nesting.sqlite')) { unlink('/tmp/test_nesting.sqlite'); @@ -37,12 +38,12 @@ protected function tearDown() : void $this->resetSharedConn(); } - public function testGetWrappedConnection() : void + public function testGetWrappedConnection(): void { self::assertInstanceOf(DriverConnection::class, $this->connection->getWrappedConnection()); } - public function testCommitWithRollbackOnlyThrowsException() : void + public function testCommitWithRollbackOnlyThrowsException(): void { $this->connection->beginTransaction(); $this->connection->setRollbackOnly(); @@ -51,7 +52,7 @@ public function testCommitWithRollbackOnlyThrowsException() : void $this->connection->commit(); } - public function testTransactionNestingBehavior() : void + public function testTransactionNestingBehavior(): void { try { $this->connection->beginTransaction(); @@ -86,7 +87,7 @@ public function testTransactionNestingBehavior() : void self::assertEquals(1, $this->connection->getTransactionNestingLevel()); } - public function testTransactionNestingLevelIsResetOnReconnect() : void + public function testTransactionNestingLevelIsResetOnReconnect(): void { if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') { $params = $this->connection->getParams(); @@ -115,7 +116,7 @@ public function testTransactionNestingLevelIsResetOnReconnect() : void self::assertEquals(0, $connection->fetchColumn('select count(*) from test_nesting')); } - public function testTransactionNestingBehaviorWithSavepoints() : void + public function testTransactionNestingBehaviorWithSavepoints(): void { if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform to support savepoints.'); @@ -158,7 +159,7 @@ public function testTransactionNestingBehaviorWithSavepoints() : void } } - public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() : void + public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction(): void { if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform to support savepoints.'); @@ -169,7 +170,7 @@ public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() $this->connection->setNestTransactionsWithSavepoints(true); } - public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException() : void + public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -181,7 +182,7 @@ public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsExce $this->connection->setNestTransactionsWithSavepoints(true); } - public function testCreateSavepointsNotSupportedThrowsException() : void + public function testCreateSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -193,7 +194,7 @@ public function testCreateSavepointsNotSupportedThrowsException() : void $this->connection->createSavepoint('foo'); } - public function testReleaseSavepointsNotSupportedThrowsException() : void + public function testReleaseSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -205,7 +206,7 @@ public function testReleaseSavepointsNotSupportedThrowsException() : void $this->connection->releaseSavepoint('foo'); } - public function testRollbackSavepointsNotSupportedThrowsException() : void + public function testRollbackSavepointsNotSupportedThrowsException(): void { if ($this->connection->getDatabasePlatform()->supportsSavepoints()) { $this->markTestSkipped('This test requires the platform not to support savepoints.'); @@ -217,7 +218,7 @@ public function testRollbackSavepointsNotSupportedThrowsException() : void $this->connection->rollbackSavepoint('foo'); } - public function testTransactionBehaviorWithRollback() : void + public function testTransactionBehaviorWithRollback(): void { try { $this->connection->beginTransaction(); @@ -233,7 +234,7 @@ public function testTransactionBehaviorWithRollback() : void } } - public function testTransactionBehaviour() : void + public function testTransactionBehaviour(): void { try { $this->connection->beginTransaction(); @@ -247,10 +248,10 @@ public function testTransactionBehaviour() : void self::assertEquals(0, $this->connection->getTransactionNestingLevel()); } - public function testTransactionalWithException() : void + public function testTransactionalWithException(): void { try { - $this->connection->transactional(static function ($conn) : void { + $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); @@ -262,10 +263,10 @@ public function testTransactionalWithException() : void } } - public function testTransactionalWithThrowable() : void + public function testTransactionalWithThrowable(): void { try { - $this->connection->transactional(static function ($conn) : void { + $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); @@ -277,9 +278,9 @@ public function testTransactionalWithThrowable() : void } } - public function testTransactional() : void + public function testTransactional(): void { - $res = $this->connection->transactional(static function ($conn) : void { + $res = $this->connection->transactional(static function ($conn): void { /** @var Connection $conn */ $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); }); @@ -287,7 +288,7 @@ public function testTransactional() : void self::assertNull($res); } - public function testTransactionalReturnValue() : void + public function testTransactionalReturnValue(): void { $res = $this->connection->transactional(static function () { return 42; @@ -299,7 +300,7 @@ public function testTransactionalReturnValue() : void /** * Tests that the quote function accepts DBAL and PDO types. */ - public function testQuote() : void + public function testQuote(): void { self::assertEquals( $this->connection->quote('foo', Types::STRING), @@ -307,7 +308,7 @@ public function testQuote() : void ); } - public function testPingDoesTriggersConnect() : void + public function testPingDoesTriggersConnect(): void { self::assertTrue($this->connection->ping()); self::assertTrue($this->connection->isConnected()); @@ -316,7 +317,7 @@ public function testPingDoesTriggersConnect() : void /** * @group DBAL-1025 */ - public function testConnectWithoutExplicitDatabaseName() : void + public function testConnectWithoutExplicitDatabaseName(): void { if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) { $this->markTestSkipped('Platform does not support connecting without database name.'); @@ -339,7 +340,7 @@ public function testConnectWithoutExplicitDatabaseName() : void /** * @group DBAL-990 */ - public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase() : void + public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase(): void { if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) { $this->markTestSkipped('Platform does not support connecting without database name.'); @@ -365,7 +366,7 @@ public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabas /** * @requires extension pdo_sqlite */ - public function testUserProvidedPDOConnection() : void + public function testUserProvidedPDOConnection(): void { self::assertTrue( DriverManager::getConnection([ diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 29d82fdbe19..1fe74ad4075 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function array_change_key_case; use function array_filter; use function array_keys; @@ -30,6 +31,7 @@ use function property_exists; use function sprintf; use function strtotime; + use const CASE_LOWER; use const PHP_EOL; @@ -38,7 +40,7 @@ class DataAccessTest extends DbalFunctionalTestCase /** @var bool */ private static $generated = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -59,7 +61,7 @@ protected function setUp() : void self::$generated = true; } - public function testPrepareWithBindValue() : void + public function testPrepareWithBindValue(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $stmt = $this->connection->prepare($sql); @@ -74,7 +76,7 @@ public function testPrepareWithBindValue() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testPrepareWithBindParam() : void + public function testPrepareWithBindParam(): void { $paramInt = 1; $paramStr = 'foo'; @@ -92,7 +94,7 @@ public function testPrepareWithBindParam() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testPrepareWithFetchAll() : void + public function testPrepareWithFetchAll(): void { $paramInt = 1; $paramStr = 'foo'; @@ -113,7 +115,7 @@ public function testPrepareWithFetchAll() : void /** * @group DBAL-228 */ - public function testPrepareWithFetchAllBoth() : void + public function testPrepareWithFetchAllBoth(): void { $paramInt = 1; $paramStr = 'foo'; @@ -131,7 +133,7 @@ public function testPrepareWithFetchAllBoth() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'], $rows[0]); } - public function testPrepareWithFetchColumn() : void + public function testPrepareWithFetchColumn(): void { $paramInt = 1; $paramStr = 'foo'; @@ -148,7 +150,7 @@ public function testPrepareWithFetchColumn() : void self::assertEquals(1, $column); } - public function testPrepareWithIterator() : void + public function testPrepareWithIterator(): void { $paramInt = 1; $paramStr = 'foo'; @@ -170,7 +172,7 @@ public function testPrepareWithIterator() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $rows[0]); } - public function testPrepareWithQuoted() : void + public function testPrepareWithQuoted(): void { $table = 'fetch_table'; $paramInt = 1; @@ -185,7 +187,7 @@ public function testPrepareWithQuoted() : void self::assertInstanceOf(Statement::class, $stmt); } - public function testPrepareWithExecuteParams() : void + public function testPrepareWithExecuteParams(): void { $paramInt = 1; $paramStr = 'foo'; @@ -201,7 +203,7 @@ public function testPrepareWithExecuteParams() : void self::assertEquals(['test_int' => 1, 'test_string' => 'foo'], $row); } - public function testFetchAll() : void + public function testFetchAll(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $data = $this->connection->fetchAll($sql, [1, 'foo']); @@ -219,7 +221,7 @@ public function testFetchAll() : void /** * @group DBAL-209 */ - public function testFetchAllWithTypes() : void + public function testFetchAllWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -244,10 +246,12 @@ public function testFetchAllWithTypes() : void /** * @group DBAL-209 */ - public function testFetchAllWithMissingTypes() : void + public function testFetchAllWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -260,7 +264,7 @@ public function testFetchAllWithMissingTypes() : void $this->connection->fetchAll($sql, [1, $datetime]); } - public function testFetchBoth() : void + public function testFetchBoth(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->executeQuery($sql, [1, 'foo'])->fetch(FetchMode::MIXED); @@ -275,14 +279,14 @@ public function testFetchBoth() : void self::assertEquals('foo', $row[1]); } - public function testFetchNoResult() : void + public function testFetchNoResult(): void { self::assertFalse( $this->connection->executeQuery('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])->fetch() ); } - public function testFetchAssoc() : void + public function testFetchAssoc(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->fetchAssoc($sql, [1, 'foo']); @@ -295,7 +299,7 @@ public function testFetchAssoc() : void self::assertEquals('foo', $row['test_string']); } - public function testFetchAssocWithTypes() : void + public function testFetchAssocWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -315,10 +319,12 @@ public function testFetchAssocWithTypes() : void self::assertStringStartsWith($datetimeString, $row['test_datetime']); } - public function testFetchAssocWithMissingTypes() : void + public function testFetchAssocWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -331,7 +337,7 @@ public function testFetchAssocWithMissingTypes() : void $this->connection->fetchAssoc($sql, [1, $datetime]); } - public function testFetchArray() : void + public function testFetchArray(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $row = $this->connection->fetchArray($sql, [1, 'foo']); @@ -340,7 +346,7 @@ public function testFetchArray() : void self::assertEquals('foo', $row[1]); } - public function testFetchArrayWithTypes() : void + public function testFetchArrayWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -360,10 +366,12 @@ public function testFetchArrayWithTypes() : void self::assertStringStartsWith($datetimeString, $row[1]); } - public function testFetchArrayWithMissingTypes() : void + public function testFetchArrayWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -376,7 +384,7 @@ public function testFetchArrayWithMissingTypes() : void $this->connection->fetchArray($sql, [1, $datetime]); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $testInt = $this->connection->fetchColumn($sql, [1, 'foo'], 0); @@ -389,7 +397,7 @@ public function testFetchColumn() : void self::assertEquals('foo', $testString); } - public function testFetchColumnWithTypes() : void + public function testFetchColumnWithTypes(): void { $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); @@ -407,10 +415,12 @@ public function testFetchColumnWithTypes() : void self::assertStringStartsWith($datetimeString, $column); } - public function testFetchColumnWithMissingTypes() : void + public function testFetchColumnWithMissingTypes(): void { - if ($this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver) { + if ( + $this->connection->getDriver() instanceof MySQLiDriver || + $this->connection->getDriver() instanceof SQLSrvDriver + ) { $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } @@ -426,7 +436,7 @@ public function testFetchColumnWithMissingTypes() : void /** * @group DDC-697 */ - public function testExecuteQueryBindDateTimeType() : void + public function testExecuteQueryBindDateTimeType(): void { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; $stmt = $this->connection->executeQuery( @@ -441,7 +451,7 @@ public function testExecuteQueryBindDateTimeType() : void /** * @group DDC-697 */ - public function testExecuteUpdateBindDateTimeType() : void + public function testExecuteUpdateBindDateTimeType(): void { $datetime = new DateTime('2010-02-02 20:20:20'); @@ -467,7 +477,7 @@ public function testExecuteUpdateBindDateTimeType() : void /** * @group DDC-697 */ - public function testPrepareQueryBindValueDateTimeType() : void + public function testPrepareQueryBindValueDateTimeType(): void { $sql = 'SELECT count(*) AS c FROM fetch_table WHERE test_datetime = ?'; $stmt = $this->connection->prepare($sql); @@ -480,7 +490,7 @@ public function testPrepareQueryBindValueDateTimeType() : void /** * @group DBAL-78 */ - public function testNativeArrayListSupport() : void + public function testNativeArrayListSupport(): void { for ($i = 100; $i < 110; $i++) { $this->connection->insert('fetch_table', ['test_int' => $i, 'test_string' => 'foo' . $i, 'test_datetime' => '2010-01-01 10:10:10']); @@ -512,7 +522,7 @@ public function testNativeArrayListSupport() : void * * @dataProvider getTrimExpressionData */ - public function testTrimExpression(string $value, int $position, $char, string $expectedResult) : void + public function testTrimExpression(string $value, int $position, $char, string $expectedResult): void { $sql = 'SELECT ' . $this->connection->getDatabasePlatform()->getTrimExpression($value, $position, $char) . ' AS trimmed ' . @@ -527,7 +537,7 @@ public function testTrimExpression(string $value, int $position, $char, string $ /** * @return array> */ - public static function getTrimExpressionData() : iterable + public static function getTrimExpressionData(): iterable { return [ ['test_string', TrimMode::UNSPECIFIED, false, 'foo'], @@ -572,7 +582,7 @@ public static function getTrimExpressionData() : iterable /** * @group DDC-1014 */ - public function testDateArithmetics() : void + public function testDateArithmetics(): void { $p = $this->connection->getDatabasePlatform(); $sql = 'SELECT '; @@ -615,7 +625,7 @@ public function testDateArithmetics() : void self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])), 'Subtracting years should end up on 2004-01-01'); } - public function testSqliteDateArithmeticWithDynamicInterval() : void + public function testSqliteDateArithmeticWithDynamicInterval(): void { $platform = $this->connection->getDatabasePlatform(); @@ -642,7 +652,7 @@ public function testSqliteDateArithmeticWithDynamicInterval() : void $this->assertEquals(1, $rowCount); } - public function testLocateExpression() : void + public function testLocateExpression(): void { $platform = $this->connection->getDatabasePlatform(); @@ -672,7 +682,7 @@ public function testLocateExpression() : void self::assertEquals(0, $row['locate9']); } - public function testQuoteSQLInjection() : void + public function testQuoteSQLInjection(): void { $sql = 'SELECT * FROM fetch_table WHERE test_string = ' . $this->connection->quote("bar' OR '1'='1"); $rows = $this->connection->fetchAll($sql); @@ -683,7 +693,7 @@ public function testQuoteSQLInjection() : void /** * @group DDC-1213 */ - public function testBitComparisonExpressionSupport() : void + public function testBitComparisonExpressionSupport(): void { $this->connection->exec('DELETE FROM fetch_table'); $platform = $this->connection->getDatabasePlatform(); @@ -731,7 +741,7 @@ public function testBitComparisonExpressionSupport() : void } } - public function testSetDefaultFetchMode() : void + public function testSetDefaultFetchMode(): void { $stmt = $this->connection->query('SELECT * FROM fetch_table'); $stmt->setFetchMode(FetchMode::NUMERIC); @@ -745,7 +755,7 @@ public function testSetDefaultFetchMode() : void /** * @group DBAL-1091 */ - public function testFetchAllStyleObject() : void + public function testFetchAllStyleObject(): void { $this->setupFixture(); @@ -776,7 +786,7 @@ public function testFetchAllStyleObject() : void /** * @group DBAL-196 */ - public function testFetchAllSupportFetchClass() : void + public function testFetchAllSupportFetchClass(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -801,7 +811,7 @@ public function testFetchAllSupportFetchClass() : void /** * @group DBAL-241 */ - public function testFetchAllStyleColumn() : void + public function testFetchAllStyleColumn(): void { $sql = 'DELETE FROM fetch_table'; $this->connection->executeUpdate($sql); @@ -818,7 +828,7 @@ public function testFetchAllStyleColumn() : void /** * @group DBAL-214 */ - public function testSetFetchModeClassFetchAll() : void + public function testSetFetchModeClassFetchAll(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -840,7 +850,7 @@ public function testSetFetchModeClassFetchAll() : void /** * @group DBAL-214 */ - public function testSetFetchModeClassFetch() : void + public function testSetFetchModeClassFetch(): void { $this->beforeFetchClassTest(); $this->setupFixture(); @@ -865,7 +875,7 @@ public function testSetFetchModeClassFetch() : void /** * @group DBAL-257 */ - public function testEmptyFetchColumnReturnsFalse() : void + public function testEmptyFetchColumnReturnsFalse(): void { $this->connection->beginTransaction(); $this->connection->exec('DELETE FROM fetch_table'); @@ -877,7 +887,7 @@ public function testEmptyFetchColumnReturnsFalse() : void /** * @group DBAL-339 */ - public function testSetFetchModeOnDbalStatement() : void + public function testSetFetchModeOnDbalStatement(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; $stmt = $this->connection->executeQuery($sql, [1, 'foo']); @@ -893,7 +903,7 @@ public function testSetFetchModeOnDbalStatement() : void /** * @group DBAL-435 */ - public function testEmptyParameters() : void + public function testEmptyParameters(): void { $sql = 'SELECT * FROM fetch_table WHERE test_int IN (?)'; $stmt = $this->connection->executeQuery($sql, [[]], [Connection::PARAM_INT_ARRAY]); @@ -905,7 +915,7 @@ public function testEmptyParameters() : void /** * @group DBAL-1028 */ - public function testFetchColumnNullValue() : void + public function testFetchColumnNullValue(): void { $this->connection->executeUpdate( 'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)', @@ -920,14 +930,14 @@ public function testFetchColumnNullValue() : void /** * @group DBAL-1028 */ - public function testFetchColumnNoResult() : void + public function testFetchColumnNoResult(): void { self::assertFalse( $this->connection->fetchColumn('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1]) ); } - private function setupFixture() : void + private function setupFixture(): void { $this->connection->exec('DELETE FROM fetch_table'); $this->connection->insert('fetch_table', [ @@ -937,7 +947,7 @@ private function setupFixture() : void ]); } - private function beforeFetchClassTest() : void + private function beforeFetchClassTest(): void { $driver = $this->connection->getDriver(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php index 3adf3c2bb89..61ef8ffc8ee 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/AbstractDriverTest.php @@ -16,7 +16,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase */ protected $driver; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -26,7 +26,7 @@ protected function setUp() : void /** * @group DBAL-1215 */ - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -42,7 +42,7 @@ public function testConnectsWithoutDatabaseNameParameter() : void /** * @group DBAL-1215 */ - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -60,9 +60,9 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void ); } - abstract protected function createDriver() : Driver; + abstract protected function createDriver(): Driver; - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return null; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php index b029cabba31..214251b76ee 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DB2DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); @@ -24,17 +25,17 @@ protected function setUp() : void $this->markTestSkipped('ibm_db2 only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - protected function createDriver() : Driver + protected function createDriver(): Driver { return new DB2Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index c839d20d916..927b85356da 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\Tests\DbalFunctionalTestCase; use PHPUnit\Framework\Error\Notice; + use function extension_loaded; class DB2StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('ibm_db2')) { $this->markTestSkipped('ibm_db2 is not installed.'); @@ -26,7 +27,7 @@ protected function setUp() : void $this->markTestSkipped('ibm_db2 only test.'); } - public function testExecutionErrorsAreNotSuppressed() : void + public function testExecutionErrorsAreNotSuppressed(): void { $stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index 4a8745c06e8..d84cec64941 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -6,12 +6,14 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; + use const MYSQLI_OPT_CONNECT_TIMEOUT; class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); @@ -26,12 +28,12 @@ protected function setUp() : void $this->markTestSkipped('MySQLi only test.'); } - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); } - public function testDriverOptions() : void + public function testDriverOptions(): void { $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1]; @@ -39,14 +41,14 @@ public function testDriverOptions() : void self::assertInstanceOf(MysqliConnection::class, $connection); } - public function testUnsupportedDriverOption() : void + public function testUnsupportedDriverOption(): void { $this->expectException(MysqliException::class); $this->getConnection(['hello' => 'world']); // use local infile } - public function testPing() : void + public function testPing(): void { $conn = $this->getConnection([]); self::assertTrue($conn->ping()); @@ -55,7 +57,7 @@ public function testPing() : void /** * @param mixed[] $driverOptions */ - private function getConnection(array $driverOptions) : MysqliConnection + private function getConnection(array $driverOptions): MysqliConnection { return new MysqliConnection( [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php index 549535be6ee..caf546e6508 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\Mysqli\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('mysqli')) { $this->markTestSkipped('mysqli is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void $this->markTestSkipped('MySQLi only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php index bf587cab186..2e19f6ef64e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -24,17 +25,17 @@ protected function setUp() : void $this->markTestSkipped('oci8 only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php index d6184316fac..eb6b767dd88 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class OCI8ConnectionTest extends DbalFunctionalTestCase @@ -13,7 +14,7 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase /** @var OCI8Connection */ protected $driverConnection; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -31,7 +32,7 @@ protected function setUp() : void /** * @group DBAL-2595 */ - public function testLastInsertIdAcceptsFqn() : void + public function testLastInsertIdAcceptsFqn(): void { $platform = $this->connection->getDatabasePlatform(); $schemaManager = $this->connection->getSchemaManager(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php index 70f829e7b71..90df89eff94 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -4,11 +4,12 @@ use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('oci8')) { $this->markTestSkipped('oci8 is not installed.'); @@ -29,7 +30,7 @@ protected function setUp() : void * * @dataProvider queryConversionProvider */ - public function testQueryConversion(string $query, array $params, array $expected) : void + public function testQueryConversion(string $query, array $params, array $expected): void { self::assertEquals( $expected, @@ -45,7 +46,7 @@ public function testQueryConversion(string $query, array $params, array $expecte * * @dataProvider queryConversionProvider */ - public function testStatementBindParameters(string $query, array $params, array $expected) : void + public function testStatementBindParameters(string $query, array $params, array $expected): void { $stmt = $this->connection->prepare($query); $stmt->execute($params); @@ -59,7 +60,7 @@ public function testStatementBindParameters(string $query, array $params, array /** * @return array> */ - public static function queryConversionProvider() : iterable + public static function queryConversionProvider(): iterable { return [ 'positional' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index 6dfb1b85c3d..f0104e5abd6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function extension_loaded; use function get_class; use function sprintf; @@ -22,7 +23,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase */ protected $driverConnection; - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('PDO')) { $this->markTestSkipped('PDO is not installed.'); @@ -39,19 +40,19 @@ protected function setUp() : void $this->markTestSkipped('PDO connection only test.'); } - protected function tearDown() : void + protected function tearDown(): void { $this->resetSharedConn(); parent::tearDown(); } - public function testDoesNotRequireQueryForServerVersion() : void + public function testDoesNotRequireQueryForServerVersion(): void { self::assertFalse($this->driverConnection->requiresQueryForServerVersion()); } - public function testThrowsWrappedExceptionOnConstruct() : void + public function testThrowsWrappedExceptionOnConstruct(): void { $this->expectException(PDOException::class); @@ -61,14 +62,14 @@ public function testThrowsWrappedExceptionOnConstruct() : void /** * @group DBAL-1022 */ - public function testThrowsWrappedExceptionOnExec() : void + public function testThrowsWrappedExceptionOnExec(): void { $this->expectException(PDOException::class); $this->driverConnection->exec('foo'); } - public function testThrowsWrappedExceptionOnPrepare() : void + public function testThrowsWrappedExceptionOnPrepare(): void { $driver = $this->connection->getDriver(); @@ -79,7 +80,8 @@ public function testThrowsWrappedExceptionOnPrepare() : void // Some PDO adapters do not check the query server-side // even though emulated prepared statements are disabled, // so an exception is thrown only eventually. - if ($driver instanceof PDOOracleDriver + if ( + $driver instanceof PDOOracleDriver || $driver instanceof PDOPgSQLDriver ) { self::markTestSkipped(sprintf( @@ -97,7 +99,7 @@ public function testThrowsWrappedExceptionOnPrepare() : void $this->driverConnection->prepare('foo'); } - public function testThrowsWrappedExceptionOnQuery() : void + public function testThrowsWrappedExceptionOnQuery(): void { $this->expectException(PDOException::class); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index 641f515c7ec..ebe6461c20a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOMySql\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo_mysql')) { $this->markTestSkipped('pdo_mysql is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void $this->markTestSkipped('pdo_mysql only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index f33c6669865..0aa54ac92e0 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOOracle\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('PDO_OCI')) { $this->markTestSkipped('PDO_OCI is not installed.'); @@ -24,17 +25,17 @@ protected function setUp() : void $this->markTestSkipped('PDO_OCI only test.'); } - public function testConnectsWithoutDatabaseNameParameter() : void + public function testConnectsWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $this->markTestSkipped('Oracle does not support connecting without database name.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 638e855c970..3dc08b7e6e7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; + use function array_key_exists; use function extension_loaded; use function microtime; @@ -14,7 +15,7 @@ class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo_pgsql')) { $this->markTestSkipped('pdo_pgsql is not installed.'); @@ -32,7 +33,7 @@ protected function setUp() : void /** * @dataProvider getDatabaseParameter */ - public function testDatabaseParameters(?string $databaseName, ?string $defaultDatabaseName, ?string $expectedDatabaseName) : void + public function testDatabaseParameters(?string $databaseName, ?string $defaultDatabaseName, ?string $expectedDatabaseName): void { $params = $this->connection->getParams(); $params['dbname'] = $databaseName; @@ -54,7 +55,7 @@ public function testDatabaseParameters(?string $databaseName, ?string $defaultDa /** * @return mixed[][] */ - public static function getDatabaseParameter() : iterable + public static function getDatabaseParameter(): iterable { $params = TestUtil::getConnectionParams(); $realDatabaseName = $params['dbname'] ?? ''; @@ -72,7 +73,7 @@ public static function getDatabaseParameter() : iterable /** * @group DBAL-1146 */ - public function testConnectsWithApplicationNameParameter() : void + public function testConnectsWithApplicationNameParameter(): void { $parameters = $this->connection->getParams(); $parameters['application_name'] = 'doctrine'; @@ -101,12 +102,12 @@ public function testConnectsWithApplicationNameParameter() : void $this->fail(sprintf('Query result does not contain a record where column "query" equals "%s".', $sql)); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'postgres'; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php index 8336a3900d1..3dbeb6edee1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php @@ -6,11 +6,12 @@ use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Platforms\PostgreSqlPlatform; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class PDOPgsqlConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo_pgsql')) { $this->markTestSkipped('pdo_pgsql is not loaded.'); @@ -30,7 +31,7 @@ protected function setUp() : void * @group DBAL-1189 * @dataProvider getValidCharsets */ - public function testConnectsWithValidCharsetOption(string $charset) : void + public function testConnectsWithValidCharsetOption(string $charset): void { $params = $this->connection->getParams(); $params['charset'] = $charset; @@ -51,7 +52,7 @@ public function testConnectsWithValidCharsetOption(string $charset) : void /** * @return mixed[][] */ - public static function getValidCharsets() : iterable + public static function getValidCharsets(): iterable { return [ ['UTF8'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index 295831b8bf4..d659815cac6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDOSqlite\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo_sqlite')) { $this->markTestSkipped('pdo_sqlite is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlite only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index 236cb6b5875..564d0e9b6ed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use PDO; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo_sqlsrv')) { $this->markTestSkipped('pdo_sqlsrv is not installed.'); @@ -26,12 +27,12 @@ protected function setUp() : void $this->markTestSkipped('pdo_sqlsrv only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'master'; } @@ -39,7 +40,7 @@ protected static function getDatabaseNameForConnectionWithoutDatabaseNameParamet /** * @param int[]|string[] $driverOptions */ - protected function getConnection(array $driverOptions) : Connection + protected function getConnection(array $driverOptions): Connection { return $this->connection->getDriver()->connect( [ @@ -52,7 +53,7 @@ protected function getConnection(array $driverOptions) : Connection ); } - public function testConnectionOptions() : void + public function testConnectionOptions(): void { $connection = $this->getConnection(['APP' => 'APP_NAME']); $result = $connection->query('SELECT APP_NAME()')->fetchColumn(); @@ -60,7 +61,7 @@ public function testConnectionOptions() : void self::assertSame('APP_NAME', $result); } - public function testDriverOptions() : void + public function testDriverOptions(): void { $connection = $this->getConnection([PDO::ATTR_CASE => PDO::CASE_UPPER]); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php index 4de7b7cde03..e9a94451222 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/ConnectionTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\DriverManager; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class ConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testNonPersistentConnection() : void + public function testNonPersistentConnection(): void { $params = $this->connection->getParams(); $params['persistent'] = false; @@ -36,7 +37,7 @@ public function testNonPersistentConnection() : void self::assertTrue($conn->isConnected(), 'No SQLAnywhere-nonpersistent connection established'); } - public function testPersistentConnection() : void + public function testPersistentConnection(): void { $params = $this->connection->getParams(); $params['persistent'] = true; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php index 960acfc003c..27069ef34be 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/DriverTest.php @@ -6,11 +6,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); @@ -25,7 +26,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void + public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void { $params = $this->connection->getParams(); unset($params['dbname']); @@ -42,7 +43,7 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void self::assertIsString($this->driver->getDatabase($connection)); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php index c09eb0a5d56..69d0c5799fb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLAnywhere/StatementTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\DriverManager; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlanywhere')) { $this->markTestSkipped('sqlanywhere is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void $this->markTestSkipped('sqlanywhere only test.'); } - public function testNonPersistentStatement() : void + public function testNonPersistentStatement(): void { $params = $this->connection->getParams(); $params['persistent'] = false; @@ -39,7 +40,7 @@ public function testNonPersistentStatement() : void self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed'); } - public function testPersistentStatement() : void + public function testPersistentStatement(): void { $params = $this->connection->getParams(); $params['persistent'] = true; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php index de8b37cb683..e8b36d0b665 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/DriverTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; + use function extension_loaded; class DriverTest extends AbstractDriverTest { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlsrv')) { $this->markTestSkipped('sqlsrv is not installed.'); @@ -24,12 +25,12 @@ protected function setUp() : void $this->markTestSkipped('sqlsrv only test.'); } - protected function createDriver() : DriverInterface + protected function createDriver(): DriverInterface { return new Driver(); } - protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string + protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter(): ?string { return 'master'; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php index 29df5aea958..da1204da6be 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/SQLSrv/StatementTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Driver\SQLSrv\Driver; use Doctrine\DBAL\Driver\SQLSrv\SQLSrvException; use Doctrine\Tests\DbalFunctionalTestCase; + use function extension_loaded; class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('sqlsrv')) { self::markTestSkipped('sqlsrv is not installed.'); @@ -24,7 +25,7 @@ protected function setUp() : void self::markTestSkipped('sqlsrv only test'); } - public function testFailureToPrepareResultsInException() : void + public function testFailureToPrepareResultsInException(): void { // use the driver connection directly to avoid having exception wrapped $stmt = $this->connection->getWrappedConnection()->prepare(''); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index 46950e7db80..70ce747fca1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_merge; use function assert; use function chmod; @@ -26,11 +27,12 @@ use function touch; use function unlink; use function version_compare; + use const PHP_OS; class ExceptionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -41,7 +43,7 @@ protected function setUp() : void $this->markTestSkipped('Driver does not support special exception handling.'); } - public function testPrimaryConstraintViolationException() : void + public function testPrimaryConstraintViolationException(): void { $table = new Table('duplicatekey_table'); $table->addColumn('id', 'integer', []); @@ -55,7 +57,7 @@ public function testPrimaryConstraintViolationException() : void $this->connection->insert('duplicatekey_table', ['id' => 1]); } - public function testTableNotFoundException() : void + public function testTableNotFoundException(): void { $sql = 'SELECT * FROM unknown_table'; @@ -63,7 +65,7 @@ public function testTableNotFoundException() : void $this->connection->executeQuery($sql); } - public function testTableExistsException() : void + public function testTableExistsException(): void { $schemaManager = $this->connection->getSchemaManager(); $table = new Table('alreadyexist_table'); @@ -75,7 +77,7 @@ public function testTableExistsException() : void $schemaManager->createTable($table); } - public function testForeignKeyConstraintViolationExceptionOnInsert() : void + public function testForeignKeyConstraintViolationExceptionOnInsert(): void { if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') { $this->connection->exec('PRAGMA foreign_keys=ON'); @@ -109,7 +111,7 @@ public function testForeignKeyConstraintViolationExceptionOnInsert() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnUpdate() : void + public function testForeignKeyConstraintViolationExceptionOnUpdate(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); @@ -143,7 +145,7 @@ public function testForeignKeyConstraintViolationExceptionOnUpdate() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnDelete() : void + public function testForeignKeyConstraintViolationExceptionOnDelete(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Only fails on platforms with foreign key constraints.'); @@ -177,7 +179,7 @@ public function testForeignKeyConstraintViolationExceptionOnDelete() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testForeignKeyConstraintViolationExceptionOnTruncate() : void + public function testForeignKeyConstraintViolationExceptionOnTruncate(): void { $platform = $this->connection->getDatabasePlatform(); @@ -213,7 +215,7 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate() : void $this->tearDownForeignKeyConstraintViolationExceptionTest(); } - public function testNotNullConstraintViolationException() : void + public function testNotNullConstraintViolationException(): void { $schema = new Schema(); @@ -230,7 +232,7 @@ public function testNotNullConstraintViolationException() : void $this->connection->insert('notnull_table', ['id' => 1, 'value' => null]); } - public function testInvalidFieldNameException() : void + public function testInvalidFieldNameException(): void { $schema = new Schema(); @@ -245,7 +247,7 @@ public function testInvalidFieldNameException() : void $this->connection->insert('bad_fieldname_table', ['name' => 5]); } - public function testNonUniqueFieldNameException() : void + public function testNonUniqueFieldNameException(): void { $schema = new Schema(); @@ -264,7 +266,7 @@ public function testNonUniqueFieldNameException() : void $this->connection->executeQuery($sql); } - public function testUniqueConstraintViolationException() : void + public function testUniqueConstraintViolationException(): void { $schema = new Schema(); @@ -281,7 +283,7 @@ public function testUniqueConstraintViolationException() : void $this->connection->insert('unique_field_table', ['id' => 5]); } - public function testSyntaxErrorException() : void + public function testSyntaxErrorException(): void { $table = new Table('syntax_error_table'); $table->addColumn('id', 'integer', []); @@ -294,7 +296,7 @@ public function testSyntaxErrorException() : void $this->connection->executeQuery($sql); } - public function testConnectionExceptionSqLite() : void + public function testConnectionExceptionSqLite(): void { if (! ($this->connection->getDatabasePlatform() instanceof SqlitePlatform)) { $this->markTestSkipped('Only fails this way on sqlite'); @@ -349,7 +351,7 @@ public function testConnectionExceptionSqLite() : void * * @dataProvider getConnectionParams */ - public function testConnectionException(array $params) : void + public function testConnectionException(array $params): void { $platform = $this->connection->getDatabasePlatform(); @@ -393,7 +395,7 @@ public function testConnectionException(array $params) : void /** * @return array> */ - public static function getConnectionParams() : iterable + public static function getConnectionParams(): iterable { return [ [['user' => 'not_existing']], @@ -402,7 +404,7 @@ public static function getConnectionParams() : iterable ]; } - private function setUpForeignKeyConstraintViolationExceptionTest() : void + private function setUpForeignKeyConstraintViolationExceptionTest(): void { $schemaManager = $this->connection->getSchemaManager(); @@ -420,7 +422,7 @@ private function setUpForeignKeyConstraintViolationExceptionTest() : void $schemaManager->createTable($owningTable); } - private function tearDownForeignKeyConstraintViolationExceptionTest() : void + private function tearDownForeignKeyConstraintViolationExceptionTest(): void { $schemaManager = $this->connection->getSchemaManager(); @@ -428,12 +430,12 @@ private function tearDownForeignKeyConstraintViolationExceptionTest() : void $schemaManager->dropTable('constraint_error_table'); } - private function isLinuxRoot() : bool + private function isLinuxRoot(): bool { return PHP_OS === 'Linux' && posix_getpwuid(posix_geteuid())['name'] === 'root'; } - private function cleanupReadOnlyFile(string $filename) : void + private function cleanupReadOnlyFile(string $filename): void { if ($this->isLinuxRoot()) { exec(sprintf('chattr -i %s', $filename)); diff --git a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php index e172816f2af..f6852c3dc34 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/LikeWildcardsEscapingTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\DBAL\Functional; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase { - public function testFetchLikeExpressionResult() : void + public function testFetchLikeExpressionResult(): void { $string = '_25% off_ your next purchase \o/ [$̲̅(̲̅5̲̅)̲̅$̲̅] (^̮^)'; $escapeChar = '!'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index 8315c18c37a..ac7d84d030e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -8,11 +8,13 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_change_key_case; use function sprintf; use function strlen; use function strtolower; use function substr; + use const CASE_LOWER; /** @@ -20,7 +22,7 @@ */ class MasterSlaveConnectionTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -45,7 +47,7 @@ protected function setUp() : void $this->connection->insert('master_slave_table', ['test_int' => 1]); } - private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection + private function createMasterSlaveConnection(bool $keepSlave = false): MasterSlaveConnection { return DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave)); } @@ -53,7 +55,7 @@ private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSl /** * @return mixed[] */ - private function createMasterSlaveConnectionParams(bool $keepSlave = false) : array + private function createMasterSlaveConnectionParams(bool $keepSlave = false): array { $params = $this->connection->getParams(); $params['master'] = $params; @@ -64,7 +66,7 @@ private function createMasterSlaveConnectionParams(bool $keepSlave = false) : ar return $params; } - public function testInheritCharsetFromMaster() : void + public function testInheritCharsetFromMaster(): void { $charsets = [ 'utf8', @@ -98,7 +100,7 @@ public function testInheritCharsetFromMaster() : void } } - public function testMasterOnConnect() : void + public function testMasterOnConnect(): void { $conn = $this->createMasterSlaveConnection(); @@ -109,7 +111,7 @@ public function testMasterOnConnect() : void self::assertTrue($conn->isConnectedToMaster()); } - public function testNoMasterOnExecuteQuery() : void + public function testNoMasterOnExecuteQuery(): void { $conn = $this->createMasterSlaveConnection(); @@ -121,7 +123,7 @@ public function testNoMasterOnExecuteQuery() : void self::assertFalse($conn->isConnectedToMaster()); } - public function testMasterOnWriteOperation() : void + public function testMasterOnWriteOperation(): void { $conn = $this->createMasterSlaveConnection(); $conn->insert('master_slave_table', ['test_int' => 30]); @@ -139,7 +141,7 @@ public function testMasterOnWriteOperation() : void /** * @group DBAL-335 */ - public function testKeepSlaveBeginTransactionStaysOnMaster() : void + public function testKeepSlaveBeginTransactionStaysOnMaster(): void { $conn = $this->createMasterSlaveConnection($keepSlave = true); $conn->connect('slave'); @@ -160,7 +162,7 @@ public function testKeepSlaveBeginTransactionStaysOnMaster() : void /** * @group DBAL-335 */ - public function testKeepSlaveInsertStaysOnMaster() : void + public function testKeepSlaveInsertStaysOnMaster(): void { $conn = $this->createMasterSlaveConnection($keepSlave = true); $conn->connect('slave'); @@ -176,7 +178,7 @@ public function testKeepSlaveInsertStaysOnMaster() : void self::assertFalse($conn->isConnectedToMaster()); } - public function testMasterSlaveConnectionCloseAndReconnect() : void + public function testMasterSlaveConnectionCloseAndReconnect(): void { $conn = $this->createMasterSlaveConnection(); $conn->connect('master'); @@ -189,7 +191,7 @@ public function testMasterSlaveConnectionCloseAndReconnect() : void self::assertTrue($conn->isConnectedToMaster()); } - public function testQueryOnMaster() : void + public function testQueryOnMaster(): void { $conn = $this->createMasterSlaveConnection(); @@ -213,7 +215,7 @@ public function testQueryOnMaster() : void self::assertEquals(1, $data[0]['num']); } - public function testQueryOnSlave() : void + public function testQueryOnSlave(): void { $conn = $this->createMasterSlaveConnection(); $conn->connect('slave'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php index 73d258b31d9..3ab1efb1b6b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ModifyLimitQueryTest.php @@ -4,8 +4,10 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_change_key_case; use function count; + use const CASE_LOWER; class ModifyLimitQueryTest extends DbalFunctionalTestCase @@ -13,7 +15,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase /** @var bool */ private static $tableCreated = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -37,7 +39,7 @@ protected function setUp() : void $this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2')); } - public function testModifyLimitQuerySimpleQuery() : void + public function testModifyLimitQuerySimpleQuery(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -52,7 +54,7 @@ public function testModifyLimitQuerySimpleQuery() : void $this->assertLimitResult([2, 3, 4], $sql, null, 1); } - public function testModifyLimitQueryJoinQuery() : void + public function testModifyLimitQueryJoinQuery(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -70,7 +72,7 @@ public function testModifyLimitQueryJoinQuery() : void $this->assertLimitResult([2, 2], $sql, 2, 0); } - public function testModifyLimitQueryNonDeterministic() : void + public function testModifyLimitQueryNonDeterministic(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -84,7 +86,7 @@ public function testModifyLimitQueryNonDeterministic() : void $this->assertLimitResult([2, 1], $sql, 2, 2, false); } - public function testModifyLimitQueryGroupBy() : void + public function testModifyLimitQueryGroupBy(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -104,7 +106,7 @@ public function testModifyLimitQueryGroupBy() : void $this->assertLimitResult([2], $sql, 1, 1); } - public function testModifyLimitQuerySubSelect() : void + public function testModifyLimitQuerySubSelect(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -118,7 +120,7 @@ public function testModifyLimitQuerySubSelect() : void $this->assertLimitResult([2, 1], $sql, 2, 2); } - public function testModifyLimitQueryFromSubSelect() : void + public function testModifyLimitQueryFromSubSelect(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -132,7 +134,7 @@ public function testModifyLimitQueryFromSubSelect() : void $this->assertLimitResult([2, 1], $sql, 2, 2); } - public function testModifyLimitQueryLineBreaks() : void + public function testModifyLimitQueryLineBreaks(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -152,7 +154,7 @@ public function testModifyLimitQueryLineBreaks() : void $this->assertLimitResult([2], $sql, 1, 1); } - public function testModifyLimitQueryZeroOffsetNoLimit() : void + public function testModifyLimitQueryZeroOffsetNoLimit(): void { $this->connection->insert('modify_limit_table', ['test_int' => 1]); $this->connection->insert('modify_limit_table', ['test_int' => 2]); @@ -165,7 +167,7 @@ public function testModifyLimitQueryZeroOffsetNoLimit() : void /** * @param array $expectedResults */ - private function assertLimitResult(array $expectedResults, string $sql, ?int $limit, int $offset, bool $deterministic = true) : void + private function assertLimitResult(array $expectedResults, string $sql, ?int $limit, int $offset, bool $deterministic = true): void { $p = $this->connection->getDatabasePlatform(); $data = []; diff --git a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php index 8946db53308..59404a2a2a6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php @@ -8,7 +8,9 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_change_key_case; + use const CASE_LOWER; /** @@ -19,7 +21,7 @@ class NamedParametersTest extends DbalFunctionalTestCase /** * @return iterable> */ - public static function ticketProvider() : iterable + public static function ticketProvider(): iterable { return [ [ @@ -150,7 +152,7 @@ public static function ticketProvider() : iterable ]; } - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -210,7 +212,7 @@ protected function setUp() : void * * @dataProvider ticketProvider */ - public function testTicket(string $query, array $params, array $types, array $expected) : void + public function testTicket(string $query, array $params, array $types, array $expected): void { $stmt = $this->connection->executeQuery($query, $params, $types); $result = $stmt->fetchAll(FetchMode::ASSOCIATIVE); diff --git a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php index 2ea5fa49284..74a2463962a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PDOStatementTest.php @@ -6,11 +6,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function extension_loaded; class PDOStatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { if (! extension_loaded('pdo')) { $this->markTestSkipped('PDO is not installed'); @@ -32,7 +33,7 @@ protected function setUp() : void * @group legacy * @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testPDOSpecificModeIsAccepted() : void + public function testPDOSpecificModeIsAccepted(): void { $this->connection->insert('stmt_test', [ 'id' => 1, diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php index 5c1789e192d..36f2a071f90 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/DateExpressionTest.php @@ -5,6 +5,7 @@ use DateTimeImmutable; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DateExpressionTest extends DbalFunctionalTestCase @@ -12,7 +13,7 @@ class DateExpressionTest extends DbalFunctionalTestCase /** * @dataProvider differenceProvider */ - public function testDifference(string $date1, string $date2, int $expected) : void + public function testDifference(string $date1, string $date2, int $expected): void { $table = new Table('date_expr_test'); $table->addColumn('date1', 'datetime'); @@ -34,7 +35,7 @@ public function testDifference(string $date1, string $date2, int $expected) : vo /** * @return string[][]|int[][] */ - public static function differenceProvider() : iterable + public static function differenceProvider(): iterable { $date1 = new DateTimeImmutable(); $date2 = new DateTimeImmutable('2018-04-10 10:10:10'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php index 5365693af43..38fa03fb7b9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/DefaultExpressionTest.php @@ -11,11 +11,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DefaultExpressionTest extends DbalFunctionalTestCase { - public function testCurrentDate() : void + public function testCurrentDate(): void { $platform = $this->connection->getDatabasePlatform(); @@ -23,12 +24,12 @@ public function testCurrentDate() : void self::markTestSkipped('Not supported on MySQL'); } - $this->assertDefaultExpression(Types::DATE_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::DATE_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentDateSQL(); }); } - public function testCurrentTime() : void + public function testCurrentTime(): void { $platform = $this->connection->getDatabasePlatform(); @@ -40,19 +41,19 @@ public function testCurrentTime() : void self::markTestSkipped('Not supported on Oracle'); } - $this->assertDefaultExpression(Types::TIME_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::TIME_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentTimeSQL(); }); } - public function testCurrentTimestamp() : void + public function testCurrentTimestamp(): void { - $this->assertDefaultExpression(Types::DATETIME_MUTABLE, static function (AbstractPlatform $platform) : string { + $this->assertDefaultExpression(Types::DATETIME_MUTABLE, static function (AbstractPlatform $platform): string { return $platform->getCurrentTimestampSQL(); }); } - private function assertDefaultExpression(string $type, callable $expression) : void + private function assertDefaultExpression(string $type, callable $expression): void { $platform = $this->connection->getDatabasePlatform(); $defaultSql = $expression($platform, $this); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php index faac5f4a6b2..b55751bde63 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/NewPrimaryKeyWithNewAutoIncrementColumnTest.php @@ -5,11 +5,12 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Schema\Comparator; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -28,7 +29,7 @@ protected function setUp() : void * SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto * column and it must be defined as a key */ - public function testAlterPrimaryKeyToAutoIncrementColumn() : void + public function testAlterPrimaryKeyToAutoIncrementColumn(): void { $schemaManager = $this->connection->getSchemaManager(); $schema = $schemaManager->createSchema(); @@ -60,7 +61,7 @@ public function testAlterPrimaryKeyToAutoIncrementColumn() : void $this->assertSame(['new_id'], $validationTable->getPrimaryKeyColumns()); } - private function getPlatform() : AbstractPlatform + private function getPlatform(): AbstractPlatform { return $this->connection->getDatabasePlatform(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php b/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php index 3a1ae7c8440..fee5b33f0c6 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Platform/QuotingTest.php @@ -9,7 +9,7 @@ class QuotingTest extends DbalFunctionalTestCase /** * @dataProvider stringLiteralProvider */ - public function testQuoteStringLiteral(string $string) : void + public function testQuoteStringLiteral(string $string): void { $platform = $this->connection->getDatabasePlatform(); $query = $platform->getDummySelectSQL( @@ -22,7 +22,7 @@ public function testQuoteStringLiteral(string $string) : void /** * @return mixed[][] */ - public static function stringLiteralProvider() : iterable + public static function stringLiteralProvider(): iterable { return [ 'backslash' => ['\\'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php index 72fb9dd2213..981120a8d24 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function strlen; /** @@ -20,7 +21,7 @@ class PortabilityTest extends DbalFunctionalTestCase /** @var Connection */ private $portableConnection; - protected function tearDown() : void + protected function tearDown(): void { if ($this->portableConnection) { $this->portableConnection->close(); @@ -32,7 +33,7 @@ protected function tearDown() : void private function getPortableConnection( int $portabilityMode = ConnectionPortability::PORTABILITY_ALL, int $case = ColumnCase::LOWER - ) : Connection { + ): Connection { if (! $this->portableConnection) { $params = $this->connection->getParams(); @@ -61,7 +62,7 @@ private function getPortableConnection( return $this->portableConnection; } - public function testFullFetchMode() : void + public function testFullFetchMode(): void { $rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table'); $this->assertFetchResultRows($rows); @@ -87,7 +88,7 @@ public function testFullFetchMode() : void } } - public function testConnFetchMode() : void + public function testConnFetchMode(): void { $conn = $this->getPortableConnection(); $conn->setFetchMode(FetchMode::ASSOCIATIVE); @@ -115,7 +116,7 @@ public function testConnFetchMode() : void /** * @param array> $rows */ - private function assertFetchResultRows(array $rows) : void + private function assertFetchResultRows(array $rows): void { self::assertCount(2, $rows); foreach ($rows as $row) { @@ -126,7 +127,7 @@ private function assertFetchResultRows(array $rows) : void /** * @param array $row */ - public function assertFetchResultRow(array $row) : void + public function assertFetchResultRow(array $row): void { self::assertContains($row['test_int'], [1, 2], 'Primary key test_int should either be 1 or 2.'); self::assertArrayHasKey('test_string', $row, 'Case should be lowered.'); @@ -140,7 +141,7 @@ public function assertFetchResultRow(array $row) : void * * @dataProvider fetchAllColumnProvider */ - public function testFetchAllColumn(string $field, array $expected) : void + public function testFetchAllColumn(string $field, array $expected): void { $conn = $this->getPortableConnection(); $stmt = $conn->query('SELECT ' . $field . ' FROM portability_table'); @@ -152,7 +153,7 @@ public function testFetchAllColumn(string $field, array $expected) : void /** * @return iterable> */ - public static function fetchAllColumnProvider() : iterable + public static function fetchAllColumnProvider(): iterable { return [ 'int' => [ @@ -166,7 +167,7 @@ public static function fetchAllColumnProvider() : iterable ]; } - public function testFetchAllNullColumn() : void + public function testFetchAllNullColumn(): void { $conn = $this->getPortableConnection(); $stmt = $conn->query('SELECT Test_Null FROM portability_table'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 1683f154bea..21b30304677 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -9,11 +9,13 @@ use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_change_key_case; use function array_merge; use function array_shift; use function array_values; use function is_array; + use const CASE_LOWER; /** @@ -27,7 +29,7 @@ class ResultCacheTest extends DbalFunctionalTestCase /** @var DebugStack */ private $sqlLogger; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -50,14 +52,14 @@ protected function setUp() : void $config->setResultCacheImpl($cache); } - protected function tearDown() : void + protected function tearDown(): void { $this->connection->getSchemaManager()->dropTable('caching'); parent::tearDown(); } - public function testCacheFetchAssoc() : void + public function testCacheFetchAssoc(): void { $this->assertCacheNonCacheSelectSameFetchModeAreEqual( $this->expectedResult, @@ -65,7 +67,7 @@ public function testCacheFetchAssoc() : void ); } - public function testFetchNum() : void + public function testFetchNum(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -75,7 +77,7 @@ public function testFetchNum() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::NUMERIC); } - public function testFetchBoth() : void + public function testFetchBoth(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -85,7 +87,7 @@ public function testFetchBoth() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::MIXED); } - public function testFetchColumn() : void + public function testFetchColumn(): void { $expectedResult = []; foreach ($this->expectedResult as $v) { @@ -95,7 +97,7 @@ public function testFetchColumn() : void $this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::COLUMN); } - public function testMixingFetch() : void + public function testMixingFetch(): void { $numExpectedResult = []; foreach ($this->expectedResult as $v) { @@ -115,14 +117,14 @@ public function testMixingFetch() : void self::assertEquals($numExpectedResult, $data); } - public function testIteratorFetch() : void + public function testIteratorFetch(): void { self::assertStandardAndIteratorFetchAreEqual(FetchMode::MIXED); self::assertStandardAndIteratorFetchAreEqual(FetchMode::ASSOCIATIVE); self::assertStandardAndIteratorFetchAreEqual(FetchMode::NUMERIC); } - private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void + private function assertStandardAndIteratorFetchAreEqual(int $fetchMode): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $data = $this->hydrateStmt($stmt, $fetchMode); @@ -133,7 +135,7 @@ private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void self::assertEquals($data, $dataIterator); } - public function testDontCloseNoCache() : void + public function testDontCloseNoCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); @@ -154,7 +156,7 @@ public function testDontCloseNoCache() : void self::assertCount(2, $this->sqlLogger->queries); } - public function testDontFinishNoCache() : void + public function testDontFinishNoCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); @@ -168,7 +170,7 @@ public function testDontFinishNoCache() : void self::assertCount(2, $this->sqlLogger->queries); } - public function testFetchAllAndFinishSavesCache() : void + public function testFetchAllAndFinishSavesCache(): void { $layerCache = new ArrayCache(); $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'testcachekey', $layerCache)); @@ -178,7 +180,7 @@ public function testFetchAllAndFinishSavesCache() : void self::assertCount(1, $layerCache->fetch('testcachekey')); } - public function testFetchAllColumn() : void + public function testFetchAllColumn(): void { $query = $this->connection->getDatabasePlatform() ->getDummySelectSQL('1'); @@ -197,7 +199,7 @@ public function testFetchAllColumn() : void /** * @param array>|list $expectedResult */ - private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void + private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); @@ -213,7 +215,7 @@ private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedR self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit'); } - public function testEmptyResultCache() : void + public function testEmptyResultCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey')); $this->hydrateStmt($stmt); @@ -224,7 +226,7 @@ public function testEmptyResultCache() : void self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit'); } - public function testChangeCacheImpl() : void + public function testChangeCacheImpl(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'emptycachekey')); $this->hydrateStmt($stmt); @@ -241,7 +243,7 @@ public function testChangeCacheImpl() : void /** * @return array */ - private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array + private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE): array { $data = []; @@ -257,7 +259,7 @@ private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode:: /** * @return array */ - private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array + private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE): array { $data = []; $stmt->setFetchMode($fetchMode); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php index 13503e3187b..e909995fcae 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ComparatorTest.php @@ -17,7 +17,7 @@ class ComparatorTest extends DbalFunctionalTestCase /** @var Comparator */ private $comparator; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -30,7 +30,7 @@ protected function setUp() : void * * @dataProvider defaultValueProvider */ - public function testDefaultValueComparison(string $type, $value) : void + public function testDefaultValueComparison(string $type, $value): void { $table = new Table('default_value'); $table->addColumn('test', $type, ['default' => $value]); @@ -45,7 +45,7 @@ public function testDefaultValueComparison(string $type, $value) : void /** * @return mixed[][] */ - public static function defaultValueProvider() : iterable + public static function defaultValueProvider(): iterable { return [ ['integer', 1], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php index 330198e9ca9..b8814b15680 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/Db2SchemaManagerTest.php @@ -10,7 +10,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase /** * @group DBAL-939 */ - public function testGetBooleanColumn() : void + public function testGetBooleanColumn(): void { $table = new Table('boolean_column_test'); $table->addColumn('bool', 'boolean'); @@ -27,7 +27,7 @@ public function testGetBooleanColumn() : void self::assertSame("That's a comment", $columns['bool_commented']->getComment()); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { self::markTestSkipped('Binary data type is currently not supported on DB2 LUW'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php index 3dd362e2263..ec408583f7b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DefaultValueTest.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function sprintf; class DefaultValueTest extends DbalFunctionalTestCase @@ -13,7 +14,7 @@ class DefaultValueTest extends DbalFunctionalTestCase /** @var bool */ private static $initialized = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -44,7 +45,7 @@ protected function setUp() : void * * @dataProvider columnProvider */ - public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault) : void + public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault): void { self::assertSame( $expectedDefault, @@ -61,7 +62,7 @@ public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $ * * @dataProvider columnProvider */ - public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expectedDefault) : void + public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expectedDefault): void { $value = $this->connection->fetchColumn( sprintf('SELECT %s FROM default_value', $name) @@ -79,7 +80,7 @@ public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expe * * @return mixed[][] */ - public static function columnProvider() : iterable + public static function columnProvider(): iterable { return [ 'Single quote' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php index b1a47bc417c..0943124b86b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/DrizzleSchemaManagerTest.php @@ -7,7 +7,7 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase { - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -28,7 +28,7 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table('test_collation'); $table->addOption('collate', $collation = 'utf8_unicode_ci'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php index 7f86d8fc254..c0c82286e36 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/ForeignKeyTest.php @@ -9,7 +9,7 @@ class ForeignKeyTest extends DbalFunctionalTestCase { - public function testCreatingATableWithAForeignKey() : void + public function testCreatingATableWithAForeignKey(): void { $schema = new Schema(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index 1e3d620c02a..ce175add9de 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -15,7 +15,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -28,7 +28,7 @@ protected function setUp() : void Type::addType('point', MySqlPointType::class); } - public function testSwitchPrimaryKeyColumns() : void + public function testSwitchPrimaryKeyColumns(): void { $tableOld = new Table('switch_primary_key_columns'); $tableOld->addColumn('foo_id', 'integer'); @@ -50,7 +50,7 @@ public function testSwitchPrimaryKeyColumns() : void self::assertContains('foo_id', $primaryKey); } - public function testDiffTableBug() : void + public function testDiffTableBug(): void { $schema = new Schema(); $table = $schema->createTable('diffbug_routing_translations'); @@ -73,7 +73,7 @@ public function testDiffTableBug() : void self::assertFalse($diff, 'no changes expected.'); } - public function testFulltextIndex() : void + public function testFulltextIndex(): void { $table = new Table('fulltext_index'); $table->addColumn('text', 'text'); @@ -90,7 +90,7 @@ public function testFulltextIndex() : void self::assertTrue($indexes['f_index']->hasFlag('fulltext')); } - public function testSpatialIndex() : void + public function testSpatialIndex(): void { $table = new Table('spatial_index'); $table->addColumn('point', 'point'); @@ -107,7 +107,7 @@ public function testSpatialIndex() : void self::assertTrue($indexes['s_index']->hasFlag('spatial')); } - public function testIndexWithLength() : void + public function testIndexWithLength(): void { $table = new Table('index_length'); $table->addColumn('text', 'string', ['length' => 255]); @@ -123,7 +123,7 @@ public function testIndexWithLength() : void /** * @group DBAL-400 */ - public function testAlterTableAddPrimaryKey() : void + public function testAlterTableAddPrimaryKey(): void { $table = new Table('alter_table_add_pk'); $table->addColumn('id', 'integer'); @@ -149,7 +149,7 @@ public function testAlterTableAddPrimaryKey() : void /** * @group DBAL-464 */ - public function testDropPrimaryKeyWithAutoincrementColumn() : void + public function testDropPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('drop_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -175,7 +175,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-789 */ - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { if ($this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) { $this->markTestSkipped( @@ -214,7 +214,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : v self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull()); } - public function testColumnCharset() : void + public function testColumnCharset(): void { $table = new Table('test_column_charset'); $table->addColumn('id', 'integer'); @@ -231,7 +231,7 @@ public function testColumnCharset() : void self::assertEquals('latin1', $columns['bar']->getPlatformOption('charset')); } - public function testAlterColumnCharset() : void + public function testAlterColumnCharset(): void { $tableName = 'test_alter_column_charset'; @@ -252,7 +252,7 @@ public function testAlterColumnCharset() : void self::assertEquals('ascii', $table->getColumn('col_text')->getPlatformOption('charset')); } - public function testColumnCharsetChange() : void + public function testColumnCharsetChange(): void { $table = new Table('test_column_charset_change'); $table->addColumn('col_string', 'string')->setLength(100)->setNotnull(true)->setPlatformOption('charset', 'utf8'); @@ -267,7 +267,7 @@ public function testColumnCharsetChange() : void self::assertContains('ALTER TABLE test_column_charset_change CHANGE col_string col_string VARCHAR(100) CHARACTER SET ascii NOT NULL', $diff); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table('test_collation'); $table->addOption('collate', $collation = 'latin1_swedish_ci'); @@ -291,7 +291,7 @@ public function testColumnCollation() : void /** * @group DBAL-843 */ - public function testListLobTypeColumns() : void + public function testListLobTypeColumns(): void { $tableName = 'lob_type_columns'; $table = new Table($tableName); @@ -350,7 +350,7 @@ public function testListLobTypeColumns() : void /** * @group DBAL-423 */ - public function testDiffListGuidTableColumn() : void + public function testDiffListGuidTableColumn(): void { $offlineTable = new Table('list_guid_table_column'); $offlineTable->addColumn('col_guid', 'guid'); @@ -370,7 +370,7 @@ public function testDiffListGuidTableColumn() : void /** * @group DBAL-1082 */ - public function testListDecimalTypeColumns() : void + public function testListDecimalTypeColumns(): void { $tableName = 'test_list_decimal_columns'; $table = new Table($tableName); @@ -391,7 +391,7 @@ public function testListDecimalTypeColumns() : void /** * @group DBAL-1082 */ - public function testListFloatTypeColumns() : void + public function testListFloatTypeColumns(): void { $tableName = 'test_list_float_columns'; $table = new Table($tableName); @@ -409,7 +409,7 @@ public function testListFloatTypeColumns() : void self::assertTrue($columns['col_unsigned']->getUnsigned()); } - public function testJsonColumnType() : void + public function testJsonColumnType(): void { $table = new Table('test_mysql_json'); $table->addColumn('col_json', 'json'); @@ -420,7 +420,7 @@ public function testJsonColumnType() : void self::assertSame(Types::JSON, $columns['col_json']->getType()->getName()); } - public function testColumnDefaultCurrentTimestamp() : void + public function testColumnDefaultCurrentTimestamp(): void { $platform = $this->schemaManager->getDatabasePlatform(); @@ -443,7 +443,7 @@ public function testColumnDefaultCurrentTimestamp() : void self::assertFalse($diff, 'Tables should be identical with column defaults.'); } - public function testColumnDefaultsAreValid() : void + public function testColumnDefaultsAreValid(): void { $table = new Table('test_column_defaults_are_valid'); @@ -486,7 +486,7 @@ public function testColumnDefaultsAreValid() : void * CURRENT_TIME as 'currtime()' and CURRENT_DATE as 'currdate()'. * This test also ensure proper aliasing to not trigger a table diff. */ - public function testColumnDefaultValuesCurrentTimeAndDate() : void + public function testColumnDefaultValuesCurrentTimeAndDate(): void { if (! $this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) { $this->markTestSkipped('Only relevant for MariaDb102Platform.'); @@ -518,7 +518,7 @@ public function testColumnDefaultValuesCurrentTimeAndDate() : void self::assertFalse($diff, 'Tables should be identical with column defauts time and date.'); } - public function testEnsureTableOptionsAreReflectedInMetadata() : void + public function testEnsureTableOptionsAreReflectedInMetadata(): void { $this->connection->query('DROP TABLE IF EXISTS test_table_metadata'); @@ -547,7 +547,7 @@ public function testEnsureTableOptionsAreReflectedInMetadata() : void ], $onlineTable->getOption('create_options')); } - public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void + public function testEnsureTableWithoutOptionsAreReflectedInMetadata(): void { $this->connection->query('DROP TABLE IF EXISTS test_table_empty_metadata'); @@ -561,7 +561,7 @@ public function testEnsureTableWithoutOptionsAreReflectedInMetadata() : void self::assertEquals([], $onlineTable->getOption('create_options')); } - public function testParseNullCreateOptions() : void + public function testParseNullCreateOptions(): void { $table = $this->schemaManager->listTableDetails('sys.processlist'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php index b2363b639f0..607d8096e68 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\Types; use Doctrine\Tests\TestUtil; + use function array_map; class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase @@ -14,7 +15,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase /** @var bool */ private static $privilegesGranted = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -32,7 +33,7 @@ protected function setUp() : void self::$privilegesGranted = true; } - public function testRenameTable() : void + public function testRenameTable(): void { $this->schemaManager->tryMethod('DropTable', 'list_tables_test'); $this->schemaManager->tryMethod('DropTable', 'list_tables_test_new_name'); @@ -45,7 +46,7 @@ public function testRenameTable() : void self::assertHasTable($tables, 'list_tables_test_new_name'); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -70,7 +71,7 @@ public function testListTableWithBinary() : void * @group DBAL-472 * @group DBAL-1001 */ - public function testAlterTableColumnNotNull() : void + public function testAlterTableColumnNotNull(): void { $comparator = new Schema\Comparator(); $tableName = 'list_table_column_notnull'; @@ -102,7 +103,7 @@ public function testAlterTableColumnNotNull() : void self::assertTrue($columns['bar']->getNotnull()); } - public function testListDatabases() : void + public function testListDatabases(): void { // We need the temp connection that has privileges to create a database. $sm = TestUtil::getTempConnection()->getSchemaManager(); @@ -118,7 +119,7 @@ public function testListDatabases() : void /** * @group DBAL-831 */ - public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() : void + public function testListTableDetailsWithDifferentIdentifierQuotingRequirements(): void { $primaryTableName = '"Primary_Table"'; $offlinePrimaryTable = new Schema\Table($primaryTableName); @@ -226,7 +227,7 @@ public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() ); } - public function testListTableColumnsSameTableNamesInDifferentSchemas() : void + public function testListTableColumnsSameTableNamesInDifferentSchemas(): void { $table = $this->createListTableColumns(); $this->schemaManager->dropAndCreateTable($table); @@ -242,7 +243,7 @@ public function testListTableColumnsSameTableNamesInDifferentSchemas() : void /** * @group DBAL-1234 */ - public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName() : void + public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName(): void { $table = new Table('list_table_indexes_pk_id_test'); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -265,7 +266,7 @@ public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName /** * @group DBAL-2555 */ - public function testListTableDateTypeColumns() : void + public function testListTableDateTypeColumns(): void { $table = new Table('tbl_date'); $table->addColumn('col_date', 'date'); @@ -281,7 +282,7 @@ public function testListTableDateTypeColumns() : void self::assertSame('datetimetz', $columns['col_datetimetz']->getType()->getName()); } - public function testCreateAndListSequences() : void + public function testCreateAndListSequences(): void { self::markTestSkipped("Skipped for uppercase letters are contained in sequences' names. Fix the schema manager in 3.0."); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php index 956192fe661..09e8b04c8c3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Types\DecimalType; use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; + use function array_map; use function array_pop; use function count; @@ -24,7 +25,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase /** @var PostgreSqlSchemaManager */ protected $schemaManager; - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); @@ -38,7 +39,7 @@ protected function tearDown() : void /** * @group DBAL-177 */ - public function testGetSearchPath() : void + public function testGetSearchPath(): void { $params = $this->connection->getParams(); @@ -49,7 +50,7 @@ public function testGetSearchPath() : void /** * @group DBAL-244 */ - public function testGetSchemaNames() : void + public function testGetSchemaNames(): void { $names = $this->schemaManager->getSchemaNames(); @@ -61,7 +62,7 @@ public function testGetSchemaNames() : void /** * @group DBAL-21 */ - public function testSupportDomainTypeFallback() : void + public function testSupportDomainTypeFallback(): void { $createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)'; $this->connection->exec($createDomainTypeSQL); @@ -82,7 +83,7 @@ public function testSupportDomainTypeFallback() : void /** * @group DBAL-37 */ - public function testDetectsAutoIncrement() : void + public function testDetectsAutoIncrement(): void { $autoincTable = new Table('autoinc_table'); $column = $autoincTable->addColumn('id', 'integer'); @@ -96,7 +97,7 @@ public function testDetectsAutoIncrement() : void /** * @group DBAL-37 */ - public function testAlterTableAutoIncrementAdd() : void + public function testAlterTableAutoIncrementAdd(): void { $tableFrom = new Table('autoinc_table_add'); $column = $tableFrom->addColumn('id', 'integer'); @@ -125,7 +126,7 @@ public function testAlterTableAutoIncrementAdd() : void /** * @group DBAL-37 */ - public function testAlterTableAutoIncrementDrop() : void + public function testAlterTableAutoIncrementDrop(): void { $tableFrom = new Table('autoinc_table_drop'); $column = $tableFrom->addColumn('id', 'integer'); @@ -150,7 +151,7 @@ public function testAlterTableAutoIncrementDrop() : void /** * @group DBAL-75 */ - public function testTableWithSchema() : void + public function testTableWithSchema(): void { $this->connection->exec('CREATE SCHEMA nested'); @@ -185,7 +186,7 @@ public function testTableWithSchema() : void * @group DBAL-91 * @group DBAL-88 */ - public function testReturnQuotedAssets() : void + public function testReturnQuotedAssets(): void { $sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );'; $this->connection->exec($sql); @@ -207,7 +208,7 @@ public function testReturnQuotedAssets() : void /** * @group DBAL-204 */ - public function testFilterSchemaExpression() : void + public function testFilterSchemaExpression(): void { $testTable = new Table('dbal204_test_prefix'); $column = $testTable->addColumn('id', 'integer'); @@ -225,13 +226,13 @@ public function testFilterSchemaExpression() : void self::assertCount(1, $names); } - public function testListForeignKeys() : void + public function testListForeignKeys(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); } - $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION','CASCADE', 'RESTRICT']; + $fkOptions = ['SET NULL', 'SET DEFAULT', 'NO ACTION', 'CASCADE', 'RESTRICT']; $foreignKeys = []; $fkTable = $this->getTestTable('test_create_fk1'); for ($i = 0; $i < count($fkOptions); $i++) { @@ -269,7 +270,7 @@ public function testListForeignKeys() : void /** * @group DBAL-511 */ - public function testDefaultValueCharacterVarying() : void + public function testDefaultValueCharacterVarying(): void { $testTable = new Table('dbal511_default'); $testTable->addColumn('id', 'integer'); @@ -286,7 +287,7 @@ public function testDefaultValueCharacterVarying() : void /** * @group DDC-2843 */ - public function testBooleanDefault() : void + public function testBooleanDefault(): void { $table = new Table('ddc2843_bools'); $table->addColumn('id', 'integer'); @@ -302,7 +303,7 @@ public function testBooleanDefault() : void self::assertFalse($diff); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -323,7 +324,7 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testListQuotedTable() : void + public function testListQuotedTable(): void { $offlineTable = new Schema\Table('user'); $offlineTable->addColumn('id', 'integer'); @@ -341,7 +342,7 @@ public function testListQuotedTable() : void self::assertFalse($comparator->diffTable($offlineTable, $onlineTable)); } - public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void + public function testListTableDetailsWhenCurrentSchemaNameQuoted(): void { $this->connection->exec('CREATE SCHEMA "001_test"'); $this->connection->exec('SET search_path TO "001_test"'); @@ -353,7 +354,7 @@ public function testListTableDetailsWhenCurrentSchemaNameQuoted() : void } } - public function testListTablesExcludesViews() : void + public function testListTablesExcludesViews(): void { $this->createTestTable('list_tables_excludes_views'); @@ -382,7 +383,7 @@ public function testListTablesExcludesViews() : void /** * @group DBAL-1033 */ - public function testPartialIndexes() : void + public function testPartialIndexes(): void { $offlineTable = new Schema\Table('person'); $offlineTable->addColumn('id', 'integer'); @@ -405,7 +406,7 @@ public function testPartialIndexes() : void /** * @dataProvider jsonbColumnTypeProvider */ - public function testJsonbColumn(string $type) : void + public function testJsonbColumn(string $type): void { if (! $this->schemaManager->getDatabasePlatform() instanceof PostgreSQL94Platform) { $this->markTestSkipped('Requires PostgresSQL 9.4+'); @@ -426,7 +427,7 @@ public function testJsonbColumn(string $type) : void /** * @return mixed[][] */ - public function jsonbColumnTypeProvider() : array + public function jsonbColumnTypeProvider(): array { return [ [Types::JSON], @@ -437,7 +438,7 @@ public function jsonbColumnTypeProvider() : array /** * @group DBAL-2427 */ - public function testListNegativeColumnDefaultValue() : void + public function testListNegativeColumnDefaultValue(): void { $table = new Schema\Table('test_default_negative'); $table->addColumn('col_smallint', 'smallint', ['default' => -1]); @@ -462,7 +463,7 @@ public function testListNegativeColumnDefaultValue() : void /** * @return mixed[][] */ - public static function serialTypes() : iterable + public static function serialTypes(): iterable { return [ ['integer'], @@ -474,7 +475,7 @@ public static function serialTypes() : iterable * @dataProvider serialTypes * @group 2906 */ - public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(string $type) : void + public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(string $type): void { $tableName = 'test_serial_type_' . $type; @@ -492,7 +493,7 @@ public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValue(stri * @dataProvider serialTypes * @group 2906 */ - public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenWhenDefaultIsSet(string $type) : void + public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenWhenDefaultIsSet(string $type): void { $tableName = 'test_serial_type_with_default_' . $type; @@ -510,7 +511,7 @@ public function testAutoIncrementCreatesSerialDataTypesWithoutADefaultValueEvenW * @group 2916 * @dataProvider autoIncrementTypeMigrations */ - public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, string $expected) : void + public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, string $expected): void { $tableFrom = new Table('autoinc_type_modification'); $column = $tableFrom->addColumn('id', $from); @@ -536,7 +537,7 @@ public function testAlterTableAutoIncrementIntToBigInt(string $from, string $to, /** * @return mixed[][] */ - public static function autoIncrementTypeMigrations() : iterable + public static function autoIncrementTypeMigrations(): iterable { return [ 'int->bigint' => ['integer', 'bigint', 'BIGINT'], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php index ab5db98eff9..5a2bb2f42a4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php @@ -8,7 +8,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase { - public function testCreateAndListViews() : void + public function testCreateAndListViews(): void { $this->createTestTable('view_test_table'); @@ -27,7 +27,7 @@ public function testCreateAndListViews() : void self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql()); } - public function testDropAndCreateAdvancedIndex() : void + public function testDropAndCreateAdvancedIndex(): void { $table = $this->getTestTable('test_create_advanced_index'); $this->schemaManager->dropAndCreateTable($table); @@ -47,7 +47,7 @@ public function testDropAndCreateAdvancedIndex() : void self::assertTrue($tableIndexes['test']->hasFlag('for_olap_workload')); } - public function testListTableColumnsWithFixedStringTypeColumn() : void + public function testListTableColumnsWithFixedStringTypeColumn(): void { $table = new Table('list_table_columns_char'); $table->addColumn('id', 'integer', ['notnull' => true]); @@ -62,7 +62,7 @@ public function testListTableColumnsWithFixedStringTypeColumn() : void self::assertTrue($columns['test']->getFixed()); } - public function testCommentInTable() : void + public function testCommentInTable(): void { self::markTestSkipped('Table level comments are not supported on SQLAnywhere'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php index f8b3b66c15c..657fd9c392e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLServerSchemaManagerTest.php @@ -7,11 +7,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; + use function current; class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase { - protected function getPlatformName() : string + protected function getPlatformName(): string { return 'mssql'; } @@ -19,7 +20,7 @@ protected function getPlatformName() : string /** * @group DBAL-255 */ - public function testDropColumnConstraints() : void + public function testDropColumnConstraints(): void { $table = new Table('sqlsrv_drop_column'); $table->addColumn('id', 'integer'); @@ -34,7 +35,7 @@ public function testDropColumnConstraints() : void self::assertCount(1, $columns); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Table($tableName = 'test_collation'); $column = $table->addColumn($columnName = 'test', 'string'); @@ -52,7 +53,7 @@ public function testColumnCollation() : void self::assertEquals($collation, $columns[$columnName]->getPlatformOption('collation')); } - public function testDefaultConstraints() : void + public function testDefaultConstraints(): void { $table = new Table('sqlsrv_default_constraints'); $table->addColumn('no_default', 'string'); @@ -157,7 +158,7 @@ public function testDefaultConstraints() : void /** * @group DBAL-543 */ - public function testColumnComments() : void + public function testColumnComments(): void { $table = new Table('sqlsrv_column_comment'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -319,7 +320,7 @@ public function testColumnComments() : void self::assertEquals('666', $columns['added_commented_type_with_comment']->getComment()); } - public function testPkOrdering() : void + public function testPkOrdering(): void { // SQL Server stores index column information in a system table with two // columns that almost always have the same value: index_column_id and key_ordinal. diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index cf93304fae6..54d7df5abbb 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -31,6 +31,7 @@ use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function array_filter; use function array_keys; use function array_map; @@ -54,7 +55,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase /** @var AbstractSchemaManager */ protected $schemaManager; - protected function getPlatformName() : string + protected function getPlatformName(): string { $class = static::class; $e = explode('\\', $class); @@ -63,7 +64,7 @@ protected function getPlatformName() : string return strtolower(str_replace('SchemaManagerTest', '', $testClass)); } - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -76,7 +77,7 @@ protected function setUp() : void $this->schemaManager = $this->connection->getSchemaManager(); } - protected function tearDown() : void + protected function tearDown(): void { parent::tearDown(); @@ -94,7 +95,7 @@ protected function tearDown() : void /** * @group DBAL-1220 */ - public function testDropsDatabaseWithActiveConnections() : void + public function testDropsDatabaseWithActiveConnections(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) { $this->markTestSkipped('Cannot drop Database client side with this Driver.'); @@ -131,7 +132,7 @@ public function testDropsDatabaseWithActiveConnections() : void /** * @group DBAL-195 */ - public function testDropAndCreateSequence() : void + public function testDropAndCreateSequence(): void { $platform = $this->connection->getDatabasePlatform(); @@ -151,11 +152,11 @@ public function testDropAndCreateSequence() : void /** * @param AbstractAsset[] $items */ - private function hasElementWithName(array $items, string $name) : bool + private function hasElementWithName(array $items, string $name): bool { $filteredList = array_filter( $items, - static function (AbstractAsset $item) use ($name) : bool { + static function (AbstractAsset $item) use ($name): bool { return $item->getShortestName($item->getNamespaceName()) === $name; } ); @@ -163,7 +164,7 @@ static function (AbstractAsset $item) use ($name) : bool { return count($filteredList) === 1; } - public function testListSequences() : void + public function testListSequences(): void { $platform = $this->connection->getDatabasePlatform(); @@ -195,7 +196,7 @@ public function testListSequences() : void self::assertSame(10, $foundSequence->getInitialValue(), 'Initial Value is expected to be 10.'); } - public function testListDatabases() : void + public function testListDatabases(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsCreateDropDatabase()) { $this->markTestSkipped('Cannot drop Database client side with this Driver.'); @@ -212,7 +213,7 @@ public function testListDatabases() : void /** * @group DBAL-1058 */ - public function testListNamespaceNames() : void + public function testListNamespaceNames(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Platform does not support schemas.'); @@ -232,7 +233,7 @@ public function testListNamespaceNames() : void self::assertContains('test_create_schema', $namespaces); } - public function testListTables() : void + public function testListTables(): void { $this->createTestTable('list_tables_test'); $tables = $this->schemaManager->listTables(); @@ -257,7 +258,7 @@ public function testListTables() : void self::assertTrue($foundTable, "The 'list_tables_test' table has to be found."); } - public function createListTableColumns() : Table + public function createListTableColumns(): Table { $table = new Table('list_table_columns'); $table->addColumn('id', 'integer', ['notnull' => true]); @@ -272,7 +273,7 @@ public function createListTableColumns() : Table return $table; } - public function testListTableColumns() : void + public function testListTableColumns(): void { $table = $this->createListTableColumns(); @@ -346,7 +347,7 @@ public function testListTableColumns() : void /** * @group DBAL-1078 */ - public function testListTableColumnsWithFixedStringColumn() : void + public function testListTableColumnsWithFixedStringColumn(): void { $tableName = 'test_list_table_fixed_string'; @@ -363,7 +364,7 @@ public function testListTableColumnsWithFixedStringColumn() : void self::assertSame(2, $columns['column_char']->getLength()); } - public function testListTableColumnsDispatchEvent() : void + public function testListTableColumnsDispatchEvent(): void { $table = $this->createListTableColumns(); @@ -386,7 +387,7 @@ public function testListTableColumnsDispatchEvent() : void $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager); } - public function testListTableIndexesDispatchEvent() : void + public function testListTableIndexesDispatchEvent(): void { $table = $this->getTestTable('list_table_indexes_test'); $table->addUniqueIndex(['test'], 'test_index_name'); @@ -411,7 +412,7 @@ public function testListTableIndexesDispatchEvent() : void $this->schemaManager->getDatabasePlatform()->setEventManager($oldEventManager); } - public function testDiffListTableColumns() : void + public function testDiffListTableColumns(): void { if ($this->schemaManager->getDatabasePlatform()->getName() === 'oracle') { $this->markTestSkipped('Does not work with Oracle, since it cannot detect DateTime, Date and Time differenecs (at the moment).'); @@ -427,7 +428,7 @@ public function testDiffListTableColumns() : void self::assertFalse($diff, 'No differences should be detected with the offline vs online schema.'); } - public function testListTableIndexes() : void + public function testListTableIndexes(): void { $table = $this->getTestCompositeTable('list_table_indexes_test'); $table->addUniqueIndex(['test'], 'test_index_name'); @@ -455,7 +456,7 @@ public function testListTableIndexes() : void self::assertFalse($tableIndexes['test_composite_idx']->isPrimary()); } - public function testDropAndCreateIndex() : void + public function testDropAndCreateIndex(): void { $table = $this->getTestTable('test_create_index'); $table->addUniqueIndex(['test'], 'test'); @@ -471,7 +472,7 @@ public function testDropAndCreateIndex() : void self::assertFalse($tableIndexes['test']->isPrimary()); } - public function testCreateTableWithForeignKeys() : void + public function testCreateTableWithForeignKeys(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Platform does not support foreign keys.'); @@ -499,7 +500,7 @@ public function testCreateTableWithForeignKeys() : void self::assertTrue($fkTable->columnsAreIndexed($fkConstraint->getColumns()), 'The columns of a foreign key constraint should always be indexed.'); } - public function testListForeignKeys() : void + public function testListForeignKeys(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); @@ -534,12 +535,12 @@ public function testListForeignKeys() : void self::assertEquals('CASCADE', $fkeys[0]->getOption('onDelete')); } - protected function getCreateExampleViewSql() : void + protected function getCreateExampleViewSql(): void { $this->markTestSkipped('No Create Example View SQL was defined for this SchemaManager'); } - public function testCreateSchema() : void + public function testCreateSchema(): void { $this->createTestTable('test_table'); @@ -547,7 +548,7 @@ public function testCreateSchema() : void self::assertTrue($schema->hasTable('test_table')); } - public function testAlterTableScenario() : void + public function testAlterTableScenario(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsAlterTable()) { $this->markTestSkipped('Alter Table is not supported by this platform.'); @@ -636,7 +637,7 @@ public function testAlterTableScenario() : void self::assertEquals(['id'], array_map('strtolower', $foreignKey->getForeignColumns())); } - public function testTableInNamespace() : void + public function testTableInNamespace(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Schema definition is not supported by this platform.'); @@ -660,7 +661,7 @@ public function testTableInNamespace() : void self::assertContains('my_table_not_in_namespace', $this->schemaManager->listTableNames()); } - public function testCreateAndListViews() : void + public function testCreateAndListViews(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsViews()) { $this->markTestSkipped('Views is not supported by this platform.'); @@ -678,7 +679,7 @@ public function testCreateAndListViews() : void self::assertTrue($this->hasElementWithName($this->schemaManager->listViews(), $name)); } - public function testAutoincrementDetection() : void + public function testAutoincrementDetection(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); @@ -699,7 +700,7 @@ public function testAutoincrementDetection() : void /** * @group DBAL-792 */ - public function testAutoincrementDetectionMulticolumns() : void + public function testAutoincrementDetectionMulticolumns(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped('This test is only supported on platforms that have autoincrement'); @@ -721,7 +722,7 @@ public function testAutoincrementDetectionMulticolumns() : void /** * @group DDC-887 */ - public function testUpdateSchemaWithForeignKeyRenaming() : void + public function testUpdateSchemaWithForeignKeyRenaming(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -766,7 +767,7 @@ public function testUpdateSchemaWithForeignKeyRenaming() : void /** * @group DBAL-1062 */ - public function testRenameIndexUsedInForeignKeyConstraint() : void + public function testRenameIndexUsedInForeignKeyConstraint(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -807,11 +808,13 @@ public function testRenameIndexUsedInForeignKeyConstraint() : void /** * @group DBAL-42 */ - public function testGetColumnComment() : void + public function testGetColumnComment(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -851,11 +854,13 @@ public function testGetColumnComment() : void /** * @group DBAL-42 */ - public function testAutomaticallyAppendCommentOnMarkedColumns() : void + public function testAutomaticallyAppendCommentOnMarkedColumns(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -879,11 +884,13 @@ public function testAutomaticallyAppendCommentOnMarkedColumns() : void /** * @group DBAL-1228 */ - public function testCommentHintOnDateIntervalTypeColumn() : void + public function testCommentHintOnDateIntervalTypeColumn(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -904,7 +911,7 @@ public function testCommentHintOnDateIntervalTypeColumn() : void /** * @group DBAL-825 */ - public function testChangeColumnsTypeWithDefaultValue() : void + public function testChangeColumnsTypeWithDefaultValue(): void { $tableName = 'column_def_change_type'; $table = new Table($tableName); @@ -944,7 +951,7 @@ public function testChangeColumnsTypeWithDefaultValue() : void /** * @group DBAL-197 */ - public function testListTableWithBlob() : void + public function testListTableWithBlob(): void { $table = new Table('test_blob_table'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -963,7 +970,7 @@ public function testListTableWithBlob() : void /** * @param mixed[] $data */ - protected function createTestTable(string $name = 'test_table', array $data = []) : Table + protected function createTestTable(string $name = 'test_table', array $data = []): Table { $options = $data['options'] ?? []; @@ -977,7 +984,7 @@ protected function createTestTable(string $name = 'test_table', array $data = [] /** * @param mixed[] $options */ - protected function getTestTable(string $name, array $options = []) : Table + protected function getTestTable(string $name, array $options = []): Table { $table = new Table($name, [], [], [], false, $options); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -989,7 +996,7 @@ protected function getTestTable(string $name, array $options = []) : Table return $table; } - protected function getTestCompositeTable(string $name) : Table + protected function getTestCompositeTable(string $name): Table { $table = new Table($name, [], [], [], false, []); $table->setSchemaConfig($this->schemaManager->createSchemaConfig()); @@ -1004,7 +1011,7 @@ protected function getTestCompositeTable(string $name) : Table /** * @param Table[] $tables */ - protected function assertHasTable(array $tables) : void + protected function assertHasTable(array $tables): void { $foundTable = false; foreach ($tables as $table) { @@ -1019,7 +1026,7 @@ protected function assertHasTable(array $tables) : void self::assertTrue($foundTable, 'Could not find new table'); } - public function testListForeignKeysComposite() : void + public function testListForeignKeysComposite(): void { if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('Does not support foreign key constraints.'); @@ -1049,7 +1056,7 @@ public function testListForeignKeysComposite() : void /** * @group DBAL-44 */ - public function testColumnDefaultLifecycle() : void + public function testColumnDefaultLifecycle(): void { $table = new Table('col_def_lifecycle'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -1100,7 +1107,7 @@ public function testColumnDefaultLifecycle() : void self::assertNull($columns['column7']->getDefault()); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -1121,7 +1128,7 @@ public function testListTableWithBinary() : void self::assertTrue($table->getColumn('column_binary')->getFixed()); } - public function testListTableDetailsWithFullQualifiedTableName() : void + public function testListTableDetailsWithFullQualifiedTableName(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSchemas()) { $this->markTestSkipped('Test only works on platforms that support schemas.'); @@ -1161,11 +1168,13 @@ public function testListTableDetailsWithFullQualifiedTableName() : void ); } - public function testCommentStringsAreQuoted() : void + public function testCommentStringsAreQuoted(): void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -1179,7 +1188,7 @@ public function testCommentStringsAreQuoted() : void self::assertEquals("It's a comment with a quote", $columns['id']->getComment()); } - public function testCommentNotDuplicated() : void + public function testCommentNotDuplicated(): void { if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments()) { $this->markTestSkipped('Database does not support column comments.'); @@ -1210,10 +1219,12 @@ public function testAlterColumnComment( ?string $expectedComment1, ?string $comment2, ?string $expectedComment2 - ) : void { - if (! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && + ): void { + if ( + ! $this->connection->getDatabasePlatform()->supportsInlineColumnComments() && ! $this->connection->getDatabasePlatform()->supportsCommentOnStatement() && - $this->connection->getDatabasePlatform()->getName() !== 'mssql') { + $this->connection->getDatabasePlatform()->getName() !== 'mssql' + ) { $this->markTestSkipped('Database does not support column comments.'); } @@ -1255,7 +1266,7 @@ public function testAlterColumnComment( /** * @return mixed[][] */ - public static function getAlterColumnComment() : iterable + public static function getAlterColumnComment(): iterable { return [ [null, null, ' ', ' '], @@ -1276,7 +1287,7 @@ public static function getAlterColumnComment() : iterable /** * @group DBAL-1095 */ - public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() : void + public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsForeignKeyConstraints()) { $this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); @@ -1306,7 +1317,7 @@ public function testDoesNotListIndexesImplicitlyCreatedByForeignKeys() : void /** * @after */ - public function removeJsonArrayTable() : void + public function removeJsonArrayTable(): void { if (! $this->schemaManager->tablesExist(['json_array_test'])) { return; @@ -1319,7 +1330,7 @@ public function removeJsonArrayTable() : void * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment() : void + public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComment(): void { $table = new Table('json_array_test'); $table->addColumn('parameters', 'json_array'); @@ -1336,7 +1347,7 @@ public function testComparatorShouldReturnFalseWhenLegacyJsonArrayColumnHasComme * @group 2782 * @group 6654 */ - public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms() : void + public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArrayTypeOnLegacyPlatforms(): void { if ($this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that do not have native JSON type.'); @@ -1364,7 +1375,7 @@ public function testComparatorShouldModifyOnlyTheCommentWhenUpdatingFromJsonArra * @group 2782 * @group 6654 */ - public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt() : void + public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHaveIt(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1386,7 +1397,7 @@ public function testComparatorShouldAddCommentToLegacyJsonArrayTypeThatDoesNotHa * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType() : void + public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1408,7 +1419,7 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType * @group 2782 * @group 6654 */ - public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport() : void + public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayTypeEvenWhenPlatformHasJsonSupport(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1430,7 +1441,7 @@ public function testComparatorShouldReturnAllChangesWhenUsingLegacyJsonArrayType * @group 2782 * @group 6654 */ - public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNow() : void + public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNow(): void { if (! $this->schemaManager->getDatabasePlatform()->hasNativeJsonType()) { $this->markTestSkipped('This test is only supported on platforms that have native JSON type.'); @@ -1451,7 +1462,7 @@ public function testComparatorShouldNotAddCommentToJsonTypeSinceItIsTheDefaultNo * @dataProvider commentsProvider * @group 2596 */ - public function testExtractDoctrineTypeFromComment(string $comment, string $expected, string $currentType) : void + public function testExtractDoctrineTypeFromComment(string $comment, string $expected, string $currentType): void { $result = $this->schemaManager->extractDoctrineTypeFromComment($comment, $currentType); @@ -1461,7 +1472,7 @@ public function testExtractDoctrineTypeFromComment(string $comment, string $expe /** * @return string[][] */ - public function commentsProvider() : array + public function commentsProvider(): array { $currentType = 'current type'; @@ -1475,7 +1486,7 @@ public function commentsProvider() : array ]; } - public function testCreateAndListSequences() : void + public function testCreateAndListSequences(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) { self::markTestSkipped('This test is only supported on platforms that support sequences.'); @@ -1514,7 +1525,7 @@ public function testCreateAndListSequences() : void /** * @group #3086 */ - public function testComparisonWithAutoDetectedSequenceDefinition() : void + public function testComparisonWithAutoDetectedSequenceDefinition(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsSequences()) { self::markTestSkipped('This test is only supported on platforms that support sequences.'); @@ -1530,7 +1541,7 @@ public function testComparisonWithAutoDetectedSequenceDefinition() : void $createdSequence = array_values( array_filter( $this->schemaManager->listSequences(), - static function (Sequence $sequence) use ($sequenceName) : bool { + static function (Sequence $sequence) use ($sequenceName): bool { return strcasecmp($sequence->getName(), $sequenceName) === 0; } ) @@ -1547,7 +1558,7 @@ static function (Sequence $sequence) use ($sequenceName) : bool { /** * @group DBAL-2921 */ - public function testPrimaryKeyAutoIncrement() : void + public function testPrimaryKeyAutoIncrement(): void { $table = new Table('test_pk_auto_increment'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -1572,7 +1583,7 @@ public function testPrimaryKeyAutoIncrement() : void $this->assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete); } - public function testGenerateAnIndexWithPartialColumnLength() : void + public function testGenerateAnIndexWithPartialColumnLength(): void { if (! $this->schemaManager->getDatabasePlatform()->supportsColumnLengthIndexes()) { self::markTestSkipped('This test is only supported on platforms that support indexes with column length definitions.'); @@ -1592,7 +1603,7 @@ public function testGenerateAnIndexWithPartialColumnLength() : void self::assertEquals($expected, $onlineTable->getIndexes()); } - public function testCommentInTable() : void + public function testCommentInTable(): void { $table = new Table('table_with_comment'); $table->addColumn('id', 'integer'); @@ -1603,7 +1614,7 @@ public function testCommentInTable() : void self::assertSame('Foo with control characters \'\\', $table->getComment()); } - public function testSchemaDiffForeignKeys() : void + public function testSchemaDiffForeignKeys(): void { $schemaManager = $this->connection->getSchemaManager(); $platform = $this->connection->getDatabasePlatform(); @@ -1651,10 +1662,10 @@ public function testSchemaDiffForeignKeys() : void interface ListTableColumnsDispatchEventListener { - public function onSchemaColumnDefinition() : void; + public function onSchemaColumnDefinition(): void; } interface ListTableIndexesDispatchEventListener { - public function onSchemaIndexDefinition() : void; + public function onSchemaIndexDefinition(): void; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index b4008191230..dcfedbe4c61 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Types; use SQLite3; + use function array_map; use function dirname; use function extension_loaded; @@ -20,14 +21,14 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase /** * SQLITE does not support databases. */ - public function testListDatabases() : void + public function testListDatabases(): void { $this->expectException(DBALException::class); $this->schemaManager->listDatabases(); } - public function testCreateAndDropDatabase() : void + public function testCreateAndDropDatabase(): void { $path = dirname(__FILE__) . '/test_create_and_drop_sqlite_database.sqlite'; @@ -40,7 +41,7 @@ public function testCreateAndDropDatabase() : void /** * @group DBAL-1220 */ - public function testDropsDatabaseWithActiveConnections() : void + public function testDropsDatabaseWithActiveConnections(): void { $this->schemaManager->dropAndCreateDatabase('test_drop_database'); @@ -63,7 +64,7 @@ public function testDropsDatabaseWithActiveConnections() : void unset($connection); } - public function testRenameTable() : void + public function testRenameTable(): void { $this->createTestTable('oldname'); $this->schemaManager->renameTable('oldname', 'newname'); @@ -73,7 +74,7 @@ public function testRenameTable() : void self::assertNotContains('oldname', $tables); } - public function createListTableColumns() : Table + public function createListTableColumns(): Table { $table = parent::createListTableColumns(); $table->getColumn('id')->setAutoincrement(true); @@ -81,7 +82,7 @@ public function createListTableColumns() : Table return $table; } - public function testListForeignKeysFromExistingDatabase() : void + public function testListForeignKeysFromExistingDatabase(): void { $this->connection->exec(<<schemaManager->listTableForeignKeys('user')); } - public function testColumnCollation() : void + public function testColumnCollation(): void { $table = new Schema\Table('test_collation'); $table->addColumn('id', 'integer'); @@ -138,7 +139,7 @@ public function testColumnCollation() : void self::assertEquals('NOCASE', $columns['bar']->getPlatformOption('collation')); } - public function testListTableWithBinary() : void + public function testListTableWithBinary(): void { $tableName = 'test_binary_table'; @@ -159,7 +160,7 @@ public function testListTableWithBinary() : void self::assertFalse($table->getColumn('column_binary')->getFixed()); } - public function testNonDefaultPKOrder() : void + public function testNonDefaultPKOrder(): void { if (! extension_loaded('sqlite3')) { $this->markTestSkipped('This test requires the SQLite3 extension.'); @@ -190,7 +191,7 @@ public function testNonDefaultPKOrder() : void /** * @group DBAL-1779 */ - public function testListTableColumnsWithWhitespacesInTypeDeclarations() : void + public function testListTableColumnsWithWhitespacesInTypeDeclarations(): void { $sql = <<addColumn('id', 'integer'); @@ -280,7 +281,7 @@ public function testPrimaryKeyNoAutoIncrement() : void $this->assertEquals(1, $lastUsedIdAfterDelete); } - public function testOnlyOwnCommentIsParsed() : void + public function testOnlyOwnCommentIsParsed(): void { $table = new Table('own_column_comment'); $table->addColumn('col1', 'string', ['length' => 16]); diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index 392e6d756bc..bf3f4abab67 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -9,12 +9,13 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; + use function base64_decode; use function stream_get_contents; class StatementTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -24,7 +25,7 @@ protected function setUp() : void $this->connection->getSchemaManager()->dropAndCreateTable($table); } - public function testStatementIsReusableAfterClosingCursor() : void + public function testStatementIsReusableAfterClosingCursor(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); @@ -49,7 +50,7 @@ public function testStatementIsReusableAfterClosingCursor() : void self::assertEquals(2, $id); } - public function testReuseStatementWithLongerResults() : void + public function testReuseStatementWithLongerResults(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()'); @@ -86,7 +87,7 @@ public function testReuseStatementWithLongerResults() : void ], $stmt->fetchAll(FetchMode::NUMERIC)); } - public function testFetchLongBlob() : void + public function testFetchLongBlob(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported @@ -134,7 +135,7 @@ public function testFetchLongBlob() : void self::assertSame($contents, stream_get_contents($stream)); } - public function testIncompletelyFetchedStatementDoesNotBlockConnection() : void + public function testIncompletelyFetchedStatementDoesNotBlockConnection(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -151,7 +152,7 @@ public function testIncompletelyFetchedStatementDoesNotBlockConnection() : void self::assertEquals(1, $stmt2->fetchColumn()); } - public function testReuseStatementAfterClosingCursor() : void + public function testReuseStatementAfterClosingCursor(): void { if ($this->connection->getDriver() instanceof PDOOracleDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); @@ -173,7 +174,7 @@ public function testReuseStatementAfterClosingCursor() : void self::assertEquals(2, $id); } - public function testReuseStatementWithParameterBoundByReference() : void + public function testReuseStatementWithParameterBoundByReference(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -190,7 +191,7 @@ public function testReuseStatementWithParameterBoundByReference() : void self::assertEquals(2, $stmt->fetchColumn()); } - public function testReuseStatementWithReboundValue() : void + public function testReuseStatementWithReboundValue(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -206,7 +207,7 @@ public function testReuseStatementWithReboundValue() : void self::assertEquals(2, $stmt->fetchColumn()); } - public function testReuseStatementWithReboundParam() : void + public function testReuseStatementWithReboundParam(): void { $this->connection->insert('stmt_test', ['id' => 1]); $this->connection->insert('stmt_test', ['id' => 2]); @@ -229,14 +230,14 @@ public function testReuseStatementWithReboundParam() : void * * @dataProvider emptyFetchProvider */ - public function testFetchFromNonExecutedStatement(callable $fetch, $expected) : void + public function testFetchFromNonExecutedStatement(callable $fetch, $expected): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); self::assertSame($expected, $fetch($stmt)); } - public function testCloseCursorOnNonExecutedStatement() : void + public function testCloseCursorOnNonExecutedStatement(): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); self::assertTrue($stmt->closeCursor()); @@ -245,7 +246,7 @@ public function testCloseCursorOnNonExecutedStatement() : void /** * @group DBAL-2637 */ - public function testCloseCursorAfterCursorEnd() : void + public function testCloseCursorAfterCursorEnd(): void { $stmt = $this->connection->prepare('SELECT name FROM stmt_test'); @@ -260,7 +261,7 @@ public function testCloseCursorAfterCursorEnd() : void * * @dataProvider emptyFetchProvider */ - public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected) : void + public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected): void { $stmt = $this->connection->prepare('SELECT id FROM stmt_test'); $stmt->closeCursor(); @@ -273,7 +274,7 @@ public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetc * * @dataProvider emptyFetchProvider */ - public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected) : void + public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected): void { $this->connection->insert('stmt_test', ['id' => 1]); @@ -287,7 +288,7 @@ public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, /** * @return mixed[][] */ - public static function emptyFetchProvider() : iterable + public static function emptyFetchProvider(): iterable { return [ 'fetch' => [ @@ -311,7 +312,7 @@ static function (Statement $stmt) { ]; } - public function testFetchInColumnMode() : void + public function testFetchInColumnMode(): void { $platform = $this->connection->getDatabasePlatform(); $query = $platform->getDummySelectSQL(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php index 8a52c0503fe..083a7114996 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php @@ -16,7 +16,7 @@ class TableGeneratorTest extends DbalFunctionalTestCase /** @var TableGenerator */ private $generator; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -39,7 +39,7 @@ protected function setUp() : void $this->generator = new TableGenerator($this->connection); } - public function testNextVal() : void + public function testNextVal(): void { $id1 = $this->generator->nextValue('tbl1'); $id2 = $this->generator->nextValue('tbl1'); @@ -50,7 +50,7 @@ public function testNextVal() : void self::assertEquals($id1, $id3, 'First ids from different tables are equal.'); } - public function testNextValNotAffectedByOuterTransactions() : void + public function testNextValNotAffectedByOuterTransactions(): void { $this->connection->beginTransaction(); $id1 = $this->generator->nextValue('tbl1'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php index e96fd426b3a..7ee7fb23ff9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -9,7 +9,7 @@ class TemporaryTableTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); try { @@ -18,7 +18,7 @@ protected function setUp() : void } } - protected function tearDown() : void + protected function tearDown(): void { if ($this->connection) { try { @@ -34,10 +34,12 @@ protected function tearDown() : void /** * @group DDC-1337 */ - public function testDropTemporaryTableNotAutoCommitTransaction() : void + public function testDropTemporaryTableNotAutoCommitTransaction(): void { - if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->connection->getDatabasePlatform()->getName() === 'oracle') { + if ( + $this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || + $this->connection->getDatabasePlatform()->getName() === 'oracle' + ) { $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.'); } @@ -69,10 +71,12 @@ public function testDropTemporaryTableNotAutoCommitTransaction() : void /** * @group DDC-1337 */ - public function testCreateTemporaryTableNotAutoCommitTransaction() : void + public function testCreateTemporaryTableNotAutoCommitTransaction(): void { - if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || - $this->connection->getDatabasePlatform()->getName() === 'oracle') { + if ( + $this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' || + $this->connection->getDatabasePlatform()->getName() === 'oracle' + ) { $this->markTestSkipped('Test does not work on Oracle and SQL Anywhere.'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php index a3133635c0d..9a394ebcdc5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL168Test.php @@ -10,7 +10,7 @@ */ class DBAL168Test extends DbalFunctionalTestCase { - public function testDomainsTable() : void + public function testDomainsTable(): void { if ($this->connection->getDatabasePlatform()->getName() !== 'postgresql') { $this->markTestSkipped('PostgreSQL only test'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php index da1fbcbd2f1..99a841a9078 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php @@ -10,7 +10,7 @@ */ class DBAL202Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -29,7 +29,7 @@ protected function setUp() : void } } - public function testStatementRollback() : void + public function testStatementRollback(): void { $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)'); $this->connection->beginTransaction(); @@ -39,7 +39,7 @@ public function testStatementRollback() : void self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn()); } - public function testStatementCommit() : void + public function testStatementCommit(): void { $stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)'); $this->connection->beginTransaction(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php index 3ebd3a62f1f..86a061749f4 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL421Test.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; use function preg_match; @@ -11,7 +12,7 @@ */ class DBAL421Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -23,7 +24,7 @@ protected function setUp() : void $this->markTestSkipped('Currently restricted to MySQL and SQLite.'); } - public function testGuidShouldMatchPattern() : void + public function testGuidShouldMatchPattern(): void { $guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn(); $pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i'; @@ -34,7 +35,7 @@ public function testGuidShouldMatchPattern() : void * This test does (of course) not proof that all generated GUIDs are * random, it should however provide some basic confidence. */ - public function testGuidShouldBeRandom() : void + public function testGuidShouldBeRandom(): void { $statement = $this->connection->prepare($this->getSelectGuidSql()); $guids = []; @@ -49,7 +50,7 @@ public function testGuidShouldBeRandom() : void $statement->closeCursor(); } - private function getSelectGuidSql() : string + private function getSelectGuidSql(): string { return 'SELECT ' . $this->connection->getDatabasePlatform()->getGuidExpression(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php index e1c0927d852..96b10ebb2fe 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL461Test.php @@ -14,7 +14,7 @@ */ class DBAL461Test extends TestCase { - public function testIssue() : void + public function testIssue(): void { $conn = $this->createMock(Connection::class); $platform = $this->getMockForAbstractClass(AbstractPlatform::class); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php index 1b3008db65d..0b98eb3cb0c 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL510Test.php @@ -11,7 +11,7 @@ */ class DBAL510Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -22,7 +22,7 @@ protected function setUp() : void $this->markTestSkipped('PostgreSQL Only test'); } - public function testSearchPathSchemaChanges() : void + public function testSearchPathSchemaChanges(): void { $table = new Table('dbal510tbl'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index fc3657687a7..3a4cd20c3ed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; + use function in_array; /** @@ -16,7 +17,7 @@ class DBAL630Test extends DbalFunctionalTestCase /** @var bool */ private $running = false; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -35,7 +36,7 @@ protected function setUp() : void $this->running = true; } - protected function tearDown() : void + protected function tearDown(): void { if ($this->running) { $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); @@ -44,7 +45,7 @@ protected function tearDown() : void parent::tearDown(); } - public function testBooleanConversionSqlLiteral() : void + public function testBooleanConversionSqlLiteral(): void { $this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)'); $id = $this->connection->lastInsertId('dbal630_id_seq'); @@ -55,7 +56,7 @@ public function testBooleanConversionSqlLiteral() : void self::assertFalse($row['bool_col']); } - public function testBooleanConversionBoolParamRealPrepares() : void + public function testBooleanConversionBoolParamRealPrepares(): void { $this->connection->executeUpdate( 'INSERT INTO dbal630 (bool_col) VALUES(?)', @@ -70,7 +71,7 @@ public function testBooleanConversionBoolParamRealPrepares() : void self::assertFalse($row['bool_col']); } - public function testBooleanConversionBoolParamEmulatedPrepares() : void + public function testBooleanConversionBoolParamEmulatedPrepares(): void { $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); @@ -95,7 +96,7 @@ public function testBooleanConversionBoolParamEmulatedPrepares() : void public function testBooleanConversionNullParamEmulatedPrepares( ?bool $statementValue, ?bool $databaseConvertedValue - ) : void { + ): void { $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $platform = $this->connection->getDatabasePlatform(); @@ -119,7 +120,7 @@ public function testBooleanConversionNullParamEmulatedPrepares( public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInBindValue( ?bool $statementValue, bool $databaseConvertedValue - ) : void { + ): void { $this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $platform = $this->connection->getDatabasePlatform(); @@ -146,7 +147,7 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB * * @return mixed[][] */ - public static function booleanTypeConversionUsingBooleanTypeProvider() : iterable + public static function booleanTypeConversionUsingBooleanTypeProvider(): iterable { return [ // statement value, database converted value result @@ -161,7 +162,7 @@ public static function booleanTypeConversionUsingBooleanTypeProvider() : iterabl * * @return mixed[][] */ - public static function booleanTypeConversionWithoutPdoTypeProvider() : iterable + public static function booleanTypeConversionWithoutPdoTypeProvider(): iterable { return [ // statement value, database converted value result diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php index 47bc1c3e762..2998d83ec2d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL752Test.php @@ -3,6 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; use Doctrine\Tests\DbalFunctionalTestCase; + use function in_array; /** @@ -10,7 +11,7 @@ */ class DBAL752Test extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -23,7 +24,7 @@ protected function setUp() : void $this->markTestSkipped('Related to SQLite only'); } - public function testUnsignedIntegerDetection() : void + public function testUnsignedIntegerDetection(): void { $this->connection->exec(<<markTestSkipped('Restricted to MySQL.'); } - protected function tearDown() : void + protected function tearDown(): void { $this->resetSharedConn(); parent::tearDown(); } - public function testCommitFalse() : void + public function testCommitFalse(): void { $this->connection->query('SET SESSION wait_timeout=1'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php index 0d034edada2..b987905569e 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use stdClass; + use function str_repeat; class TypeConversionTest extends DbalFunctionalTestCase @@ -15,7 +16,7 @@ class TypeConversionTest extends DbalFunctionalTestCase /** @var int */ private static $typeCounter = 0; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -47,7 +48,7 @@ protected function setUp() : void * * @dataProvider booleanProvider */ - public function testIdempotentConversionToBoolean(string $type, $originalValue) : void + public function testIdempotentConversionToBoolean(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -58,7 +59,7 @@ public function testIdempotentConversionToBoolean(string $type, $originalValue) /** * @return mixed[][] */ - public static function booleanProvider() : iterable + public static function booleanProvider(): iterable { return [ 'true' => ['boolean', true], @@ -71,7 +72,7 @@ public static function booleanProvider() : iterable * * @dataProvider integerProvider */ - public function testIdempotentConversionToInteger(string $type, $originalValue) : void + public function testIdempotentConversionToInteger(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -82,7 +83,7 @@ public function testIdempotentConversionToInteger(string $type, $originalValue) /** * @return mixed[][] */ - public static function integerProvider() : iterable + public static function integerProvider(): iterable { return [ 'smallint' => ['smallint', 123], @@ -94,7 +95,7 @@ public static function integerProvider() : iterable * * @dataProvider floatProvider */ - public function testIdempotentConversionToFloat(string $type, $originalValue) : void + public function testIdempotentConversionToFloat(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -105,7 +106,7 @@ public function testIdempotentConversionToFloat(string $type, $originalValue) : /** * @return mixed[][] */ - public static function floatProvider() : iterable + public static function floatProvider(): iterable { return [ 'float' => ['float', 1.5], @@ -117,7 +118,7 @@ public static function floatProvider() : iterable * * @dataProvider toStringProvider */ - public function testIdempotentConversionToString(string $type, $originalValue) : void + public function testIdempotentConversionToString(string $type, $originalValue): void { if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported @@ -134,7 +135,7 @@ public function testIdempotentConversionToString(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toStringProvider() : iterable + public static function toStringProvider(): iterable { return [ 'string' => ['string', 'ABCDEFGabcdefg'], @@ -149,7 +150,7 @@ public static function toStringProvider() : iterable * * @dataProvider toArrayProvider */ - public function testIdempotentConversionToArray(string $type, $originalValue) : void + public function testIdempotentConversionToArray(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -160,7 +161,7 @@ public function testIdempotentConversionToArray(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toArrayProvider() : iterable + public static function toArrayProvider(): iterable { return [ 'array' => ['array', ['foo' => 'bar']], @@ -173,7 +174,7 @@ public static function toArrayProvider() : iterable * * @dataProvider toObjectProvider */ - public function testIdempotentConversionToObject(string $type, $originalValue) : void + public function testIdempotentConversionToObject(string $type, $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -184,7 +185,7 @@ public function testIdempotentConversionToObject(string $type, $originalValue) : /** * @return mixed[][] */ - public static function toObjectProvider() : iterable + public static function toObjectProvider(): iterable { $obj = new stdClass(); $obj->foo = 'bar'; @@ -198,7 +199,7 @@ public static function toObjectProvider() : iterable /** * @dataProvider toDateTimeProvider */ - public function testIdempotentConversionToDateTime(string $type, DateTime $originalValue) : void + public function testIdempotentConversionToDateTime(string $type, DateTime $originalValue): void { $dbValue = $this->processValue($type, $originalValue); @@ -218,7 +219,7 @@ public function testIdempotentConversionToDateTime(string $type, DateTime $origi /** * @return mixed[][] */ - public static function toDateTimeProvider() : iterable + public static function toDateTimeProvider(): iterable { return [ 'datetime' => ['datetime', new DateTime('2010-04-05 10:10:10')], diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index 76236acff0c..ff8a503b5a3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; + use function is_resource; use function random_bytes; use function str_replace; @@ -16,7 +17,7 @@ class BinaryTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -36,7 +37,7 @@ protected function setUp() : void $sm->dropAndCreateTable($table); } - public function testInsertAndSelect() : void + public function testInsertAndSelect(): void { $id1 = random_bytes(16); $id2 = random_bytes(16); @@ -57,7 +58,7 @@ public function testInsertAndSelect() : void $this->assertSame($value2, $this->select($id2)); } - private function insert(string $id, string $value) : void + private function insert(string $id, string $value): void { $result = $this->connection->insert('binary_table', [ 'id' => $id, diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index 2f8b19e9f97..5a39a71bef5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -11,12 +11,13 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use Throwable; + use function array_filter; use function strtolower; class WriteTest extends DbalFunctionalTestCase { - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -37,7 +38,7 @@ protected function setUp() : void /** * @group DBAL-80 */ - public function testExecuteUpdateFirstTypeIsNull() : void + public function testExecuteUpdateFirstTypeIsNull(): void { $sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)'; $this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]); @@ -46,7 +47,7 @@ public function testExecuteUpdateFirstTypeIsNull() : void self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111])); } - public function testExecuteUpdate() : void + public function testExecuteUpdate(): void { $sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')'; $affected = $this->connection->executeUpdate($sql); @@ -54,7 +55,7 @@ public function testExecuteUpdate() : void self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); } - public function testExecuteUpdateWithTypes() : void + public function testExecuteUpdateWithTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $affected = $this->connection->executeUpdate( @@ -66,7 +67,7 @@ public function testExecuteUpdateWithTypes() : void self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); } - public function testPrepareRowCountReturnsAffectedRows() : void + public function testPrepareRowCountReturnsAffectedRows(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -78,7 +79,7 @@ public function testPrepareRowCountReturnsAffectedRows() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithPdoTypes() : void + public function testPrepareWithPdoTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -90,7 +91,7 @@ public function testPrepareWithPdoTypes() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithDbalTypes() : void + public function testPrepareWithDbalTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -103,7 +104,7 @@ public function testPrepareWithDbalTypes() : void self::assertEquals(1, $stmt->rowCount()); } - public function testPrepareWithDbalTypeNames() : void + public function testPrepareWithDbalTypeNames(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; $stmt = $this->connection->prepare($sql); @@ -116,18 +117,18 @@ public function testPrepareWithDbalTypeNames() : void self::assertEquals(1, $stmt->rowCount()); } - public function insertRows() : void + public function insertRows(): void { self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 1, 'test_string' => 'foo'])); self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 2, 'test_string' => 'bar'])); } - public function testInsert() : void + public function testInsert(): void { $this->insertRows(); } - public function testDelete() : void + public function testDelete(): void { $this->insertRows(); @@ -138,7 +139,7 @@ public function testDelete() : void self::assertCount(0, $this->connection->fetchAll('SELECT * FROM write_table')); } - public function testUpdate() : void + public function testUpdate(): void { $this->insertRows(); @@ -147,7 +148,7 @@ public function testUpdate() : void self::assertEquals(0, $this->connection->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar'])); } - public function testLastInsertId() : void + public function testLastInsertId(): void { if (! $this->connection->getDatabasePlatform()->prefersIdentityColumns()) { $this->markTestSkipped('Test only works on platforms with identity columns.'); @@ -160,7 +161,7 @@ public function testLastInsertId() : void self::assertGreaterThan(0, $num, 'LastInsertId() should be non-negative number.'); } - public function testLastInsertIdSequence() : void + public function testLastInsertIdSequence(): void { if (! $this->connection->getDatabasePlatform()->supportsSequences()) { $this->markTestSkipped('Test only works on platforms with sequences.'); @@ -186,7 +187,7 @@ public function testLastInsertIdSequence() : void self::assertEquals($nextSequenceVal, $lastInsertId); } - public function testLastInsertIdNoSequenceGiven() : void + public function testLastInsertIdNoSequenceGiven(): void { if (! $this->connection->getDatabasePlatform()->supportsSequences() || $this->connection->getDatabasePlatform()->supportsIdentityColumns()) { $this->markTestSkipped("Test only works consistently on platforms that support sequences and don't support identity columns."); @@ -198,7 +199,7 @@ public function testLastInsertIdNoSequenceGiven() : void /** * @group DBAL-445 */ - public function testInsertWithKeyValueTypes() : void + public function testInsertWithKeyValueTypes(): void { $testString = new DateTime('2013-04-14 10:10:10'); @@ -216,7 +217,7 @@ public function testInsertWithKeyValueTypes() : void /** * @group DBAL-445 */ - public function testUpdateWithKeyValueTypes() : void + public function testUpdateWithKeyValueTypes(): void { $testString = new DateTime('2013-04-14 10:10:10'); @@ -243,7 +244,7 @@ public function testUpdateWithKeyValueTypes() : void /** * @group DBAL-445 */ - public function testDeleteWithKeyValueTypes() : void + public function testDeleteWithKeyValueTypes(): void { $val = new DateTime('2013-04-14 10:10:10'); $this->connection->insert( @@ -259,7 +260,7 @@ public function testDeleteWithKeyValueTypes() : void self::assertFalse($data); } - public function testEmptyIdentityInsert() : void + public function testEmptyIdentityInsert(): void { $platform = $this->connection->getDatabasePlatform(); @@ -302,7 +303,7 @@ public function testEmptyIdentityInsert() : void /** * @group DBAL-2688 */ - public function testUpdateWhereIsNull() : void + public function testUpdateWhereIsNull(): void { $this->connection->insert( 'write_table', @@ -321,7 +322,7 @@ public function testUpdateWhereIsNull() : void self::assertCount(0, $data); } - public function testDeleteWhereIsNull() : void + public function testDeleteWhereIsNull(): void { $this->connection->insert( 'write_table', diff --git a/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php b/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php index 254145f0d18..2c6227a0be6 100644 --- a/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Internal/DependencyOrderCalculatorTest.php @@ -18,12 +18,12 @@ class DependencyOrderCalculatorTest extends DbalTestCase /** @var DependencyOrderCalculator */ private $calculator; - protected function setUp() : void + protected function setUp(): void { $this->calculator = new DependencyOrderCalculator(); } - public function testCommitOrdering1() : void + public function testCommitOrdering1(): void { $table1 = new Table('table1'); $table2 = new Table('table2'); diff --git a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php index 26b5a959350..85f760fb83d 100644 --- a/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php +++ b/tests/Doctrine/Tests/DBAL/Logging/DebugStackTest.php @@ -10,17 +10,17 @@ class DebugStackTest extends DbalTestCase /** @var DebugStack */ private $logger; - protected function setUp() : void + protected function setUp(): void { $this->logger = new DebugStack(); } - protected function tearDown() : void + protected function tearDown(): void { unset($this->logger); } - public function testLoggedQuery() : void + public function testLoggedQuery(): void { $this->logger->startQuery('SELECT column FROM table'); self::assertEquals( @@ -39,7 +39,7 @@ public function testLoggedQuery() : void self::assertGreaterThan(0, $this->logger->queries[1]['executionMS']); } - public function testLoggedQueryDisabled() : void + public function testLoggedQueryDisabled(): void { $this->logger->enabled = false; $this->logger->startQuery('SELECT column FROM table'); diff --git a/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php b/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php index 60d9c669d13..8d956dff234 100644 --- a/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php +++ b/tests/Doctrine/Tests/DBAL/Logging/LoggerChainTest.php @@ -11,7 +11,7 @@ class LoggerChainTest extends TestCase { - public function testStartQuery() : void + public function testStartQuery(): void { $sql = 'SELECT ?'; $params = [1]; @@ -21,7 +21,7 @@ public function testStartQuery() : void $listener->startQuery($sql, $params, $types); } - public function testStopQuery() : void + public function testStopQuery(): void { $listener = $this->createChain('stopQuery'); $listener->stopQuery(); @@ -30,7 +30,7 @@ public function testStopQuery() : void /** * @param mixed ...$args */ - private function createChain(string $method, ...$args) : LoggerChain + private function createChain(string $method, ...$args): LoggerChain { $chain = new LoggerChain([ $this->createLogger($method, ...$args), @@ -44,7 +44,7 @@ private function createChain(string $method, ...$args) : LoggerChain /** * @param mixed ...$args */ - private function createLogger(string $method, ...$args) : SQLLogger + private function createLogger(string $method, ...$args): SQLLogger { $logger = $this->createMock(SQLLogger::class); $logger->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php index 109961f0368..92b30c595cf 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractMySQLPlatformTestCase.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; + use function array_shift; abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase @@ -17,13 +18,13 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase /** @var MySqlPlatform */ protected $platform; - public function testModifyLimitQueryWitoutLimit() : void + public function testModifyLimitQueryWitoutLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT n FROM Foo', null, 10); self::assertEquals('SELECT n FROM Foo LIMIT 18446744073709551615 OFFSET 10', $sql); } - public function testGenerateMixedCaseTableCreate() : void + public function testGenerateMixedCaseTableCreate(): void { $table = new Table('Foo'); $table->addColumn('Bar', 'integer'); @@ -32,7 +33,7 @@ public function testGenerateMixedCaseTableCreate() : void self::assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', array_shift($sql)); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT AUTO_INCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB'; } @@ -40,7 +41,7 @@ public function getGenerateTableSql() : string /** * @return string[] */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return ['CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL, UNIQUE INDEX UNIQ_D87F7E0C8C73652176FF8CAA (foo, bar)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -48,19 +49,19 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return ["ALTER TABLE mytable RENAME TO userlist, ADD quota INT DEFAULT NULL, DROP foo, CHANGE bar baz VARCHAR(255) DEFAULT 'def' NOT NULL, CHANGE bloo bloo TINYINT(1) DEFAULT '0' NOT NULL"]; } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('`', $this->platform->getIdentifierQuoteCharacter(), 'Quote character is not correct'); self::assertEquals('CONCAT(column1, column2, column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation function is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -81,7 +82,7 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('SHOW DATABASES', $this->platform->getListDatabasesSQL()); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); @@ -89,7 +90,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -107,7 +108,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -127,32 +128,32 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testDoesSupportSavePoints() : void + public function testDoesSupportSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } @@ -160,7 +161,7 @@ public function getGenerateForeignKeySql() : string /** * @group DBAL-126 */ - public function testUniquePrimaryKey() : void + public function testUniquePrimaryKey(): void { $keyTable = new Table('foo'); $keyTable->addColumn('bar', 'integer'); @@ -183,13 +184,13 @@ public function testUniquePrimaryKey() : void ], $sql); } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); @@ -198,7 +199,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void /** * @group DDC-118 */ - public function testGetDateTimeTypeDeclarationSql() : void + public function testGetDateTimeTypeDeclarationSql(): void { self::assertEquals('DATETIME', $this->platform->getDateTimeTypeDeclarationSQL(['version' => false])); self::assertEquals('TIMESTAMP', $this->platform->getDateTimeTypeDeclarationSQL(['version' => true])); @@ -208,7 +209,7 @@ public function testGetDateTimeTypeDeclarationSql() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return ["CREATE TABLE test (id INT NOT NULL COMMENT 'This is a comment', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; } @@ -216,7 +217,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return ["ALTER TABLE mytable ADD quota INT NOT NULL COMMENT 'A comment', CHANGE foo foo VARCHAR(255) NOT NULL, CHANGE bar baz VARCHAR(255) NOT NULL COMMENT 'B comment'"]; } @@ -224,7 +225,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return ["CREATE TABLE test (id INT NOT NULL, data LONGTEXT NOT NULL COMMENT '(DC2Type:array)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB"]; } @@ -232,7 +233,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * @group DBAL-237 */ - public function testChangeIndexWithForeignKeys() : void + public function testChangeIndexWithForeignKeys(): void { $index = new Index('idx', ['col'], false); $unique = new Index('uniq', ['col'], true); @@ -249,7 +250,7 @@ public function testChangeIndexWithForeignKeys() : void /** * @return string[] */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, PRIMARY KEY(`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -257,7 +258,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * @return string[] */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return ['CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, INDEX IDX_22660D028FD6E0FB (`create`)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -265,7 +266,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * @return string[] */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return ['CREATE TABLE test (column1 VARCHAR(255) NOT NULL, INDEX `key` (column1)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB']; } @@ -273,7 +274,7 @@ protected function getQuotedNameInIndexSQL() : array /** * @return string[] */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE `quoted` (`create` VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, `bar` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB', @@ -283,7 +284,7 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - public function testCreateTableWithFulltextIndex() : void + public function testCreateTableWithFulltextIndex(): void { $table = new Table('fulltext_table'); $table->addOption('engine', 'MyISAM'); @@ -297,7 +298,7 @@ public function testCreateTableWithFulltextIndex() : void self::assertEquals(['CREATE TABLE fulltext_table (text LONGTEXT NOT NULL, FULLTEXT INDEX fulltext_text (text)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); } - public function testCreateTableWithSpatialIndex() : void + public function testCreateTableWithSpatialIndex(): void { $table = new Table('spatial_table'); $table->addOption('engine', 'MyISAM'); @@ -311,7 +312,7 @@ public function testCreateTableWithSpatialIndex() : void self::assertEquals(['CREATE TABLE spatial_table (point LONGTEXT NOT NULL, SPATIAL INDEX spatial_text (point)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $sql); } - public function testClobTypeDeclarationSQL() : void + public function testClobTypeDeclarationSQL(): void { self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 1])); self::assertEquals('TINYTEXT', $this->platform->getClobTypeDeclarationSQL(['length' => 255])); @@ -323,7 +324,7 @@ public function testClobTypeDeclarationSQL() : void self::assertEquals('LONGTEXT', $this->platform->getClobTypeDeclarationSQL([])); } - public function testBlobTypeDeclarationSQL() : void + public function testBlobTypeDeclarationSQL(): void { self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 1])); self::assertEquals('TINYBLOB', $this->platform->getBlobTypeDeclarationSQL(['length' => 255])); @@ -338,7 +339,7 @@ public function testBlobTypeDeclarationSQL() : void /** * @group DBAL-400 */ - public function testAlterTableAddPrimaryKey() : void + public function testAlterTableAddPrimaryKey(): void { $table = new Table('alter_table_add_pk'); $table->addColumn('id', 'integer'); @@ -360,7 +361,7 @@ public function testAlterTableAddPrimaryKey() : void /** * @group DBAL-1132 */ - public function testAlterPrimaryKeyWithAutoincrementColumn() : void + public function testAlterPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('alter_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -386,7 +387,7 @@ public function testAlterPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-464 */ - public function testDropPrimaryKeyWithAutoincrementColumn() : void + public function testDropPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('drop_primary_key'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -411,7 +412,7 @@ public function testDropPrimaryKeyWithAutoincrementColumn() : void /** * @group DBAL-2302 */ - public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn() : void + public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -438,7 +439,7 @@ public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoinc /** * @group DBAL-2302 */ - public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn() : void + public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -465,7 +466,7 @@ public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn /** * @group DBAL-586 */ - public function testAddAutoIncrementPrimaryKey() : void + public function testAddAutoIncrementPrimaryKey(): void { $keyTable = new Table('foo'); $keyTable->addColumn('id', 'integer', ['autoincrement' => true]); @@ -483,7 +484,7 @@ public function testAddAutoIncrementPrimaryKey() : void self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql); } - public function testNamedPrimaryKey() : void + public function testNamedPrimaryKey(): void { $diff = new TableDiff('mytable'); $diff->changedIndexes['foo_index'] = new Index('foo_index', ['foo'], true, true); @@ -496,7 +497,7 @@ public function testNamedPrimaryKey() : void ], $sql); } - public function testAlterPrimaryKeyWithNewColumn() : void + public function testAlterPrimaryKeyWithNewColumn(): void { $table = new Table('yolo'); $table->addColumn('pkc1', 'integer'); @@ -520,7 +521,7 @@ public function testAlterPrimaryKeyWithNewColumn() : void ); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('binary')); self::assertSame('binary', $this->platform->getDoctrineTypeMapping('binary')); @@ -529,12 +530,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 65535; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -551,7 +552,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @expectedDeprecation Binary field length 16777215 is greater than supported by the platform (65535). Reduce the field length or use a BLOB field instead. * @expectedDeprecation Binary field length 16777216 is greater than supported by the platform (65535). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 65536])); self::assertSame('MEDIUMBLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 16777215])); @@ -562,7 +563,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void self::assertSame('LONGBLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 16777216])); } - public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() : void + public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines(): void { $table = new Table('foreign_table'); $table->addColumn('id', 'integer'); @@ -575,7 +576,7 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() ['CREATE TABLE foreign_table (id INT NOT NULL, fk_id INT NOT NULL, INDEX IDX_5690FFE2A57719D0 (fk_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = MyISAM'], $this->platform->getCreateTableSQL( $table, - AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS + AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS ) ); @@ -589,12 +590,12 @@ public function testDoesNotPropagateForeignKeyCreationForNonSupportingEngines() ], $this->platform->getCreateTableSQL( $table, - AbstractPlatform::CREATE_INDEXES|AbstractPlatform::CREATE_FOREIGNKEYS + AbstractPlatform::CREATE_INDEXES | AbstractPlatform::CREATE_FOREIGNKEYS ) ); } - public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines() : void + public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines(): void { $table = new Table('foreign_table'); $table->addColumn('id', 'integer'); @@ -639,7 +640,7 @@ public function testDoesNotPropagateForeignKeyAlterationForNonSupportingEngines( * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX idx_foo ON mytable', @@ -652,7 +653,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX `create` ON `table`', @@ -667,7 +668,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX idx_foo ON myschema.mytable', @@ -680,7 +681,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX `create` ON `schema`.`table`', @@ -690,17 +691,17 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE `table` DROP FOREIGN KEY `select`'; } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE `table` DROP CONSTRAINT `select`'; } - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { $table = new Table('text_blob_default_value'); $table->addColumn('def_text', 'text', ['default' => 'def']); @@ -727,7 +728,7 @@ public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : v /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return ['ALTER TABLE mytable ' . "CHANGE unquoted1 unquoted INT NOT NULL COMMENT 'Unquoted 1', " . @@ -745,7 +746,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return ['ALTER TABLE mytable ' . "CHANGE unquoted1 unquoted1 VARCHAR(255) NOT NULL COMMENT 'Unquoted 1', " . @@ -760,7 +761,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -768,7 +769,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ["ALTER TABLE foo CHANGE bar baz INT DEFAULT 666 NOT NULL COMMENT 'rename test'"]; } @@ -776,7 +777,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE `foo` DROP FOREIGN KEY fk1', @@ -791,7 +792,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ "COMMENT ON COLUMN foo.bar IS 'comment'", @@ -800,17 +801,17 @@ protected function getCommentOnColumnSQL() : array ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT `select` UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX `select` (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE `select`'; } @@ -818,7 +819,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable CHANGE name name CHAR(2) NOT NULL']; } @@ -826,7 +827,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return [ 'ALTER TABLE mytable DROP FOREIGN KEY fk_foo', @@ -839,7 +840,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * {@inheritdoc} */ - public static function getGeneratesDecimalTypeDeclarationSQL() : iterable + public static function getGeneratesDecimalTypeDeclarationSQL(): iterable { return [ [[], 'NUMERIC(10, 0)'], @@ -854,7 +855,7 @@ public static function getGeneratesDecimalTypeDeclarationSQL() : iterable /** * {@inheritdoc} */ - public static function getGeneratesFloatDeclarationSQL() : iterable + public static function getGeneratesFloatDeclarationSQL(): iterable { return [ [[], 'DOUBLE PRECISION'], @@ -869,7 +870,7 @@ public static function getGeneratesFloatDeclarationSQL() : iterable /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -880,7 +881,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableIndexesSQL() : void + public function testQuotesDatabaseNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -891,7 +892,7 @@ public function testQuotesDatabaseNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListViewsSQL() : void + public function testQuotesDatabaseNameInListViewsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -902,7 +903,7 @@ public function testQuotesDatabaseNameInListViewsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -913,7 +914,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableForeignKeysSQL() : void + public function testQuotesDatabaseNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -924,7 +925,7 @@ public function testQuotesDatabaseNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -935,7 +936,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableColumnsSQL() : void + public function testQuotesDatabaseNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\\\'", @@ -943,7 +944,7 @@ public function testQuotesDatabaseNameInListTableColumnsSQL() : void ); } - public function testListTableForeignKeysSQLEvaluatesDatabase() : void + public function testListTableForeignKeysSQLEvaluatesDatabase(): void { $sql = $this->platform->getListTableForeignKeysSQL('foo'); @@ -955,7 +956,7 @@ public function testListTableForeignKeysSQLEvaluatesDatabase() : void self::assertStringNotContainsString('DATABASE()', $sql); } - public function testColumnCharsetDeclarationSQL() : void + public function testColumnCharsetDeclarationSQL(): void { self::assertSame( 'CHARACTER SET ascii', @@ -963,12 +964,12 @@ public function testColumnCharsetDeclarationSQL() : void ); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE `ascii_general_ci`', @@ -976,7 +977,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index f90a8060608..ad4b1c7117e 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -17,6 +17,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\Types\CommentedType; + use function get_class; use function implode; use function sprintf; @@ -27,9 +28,9 @@ abstract class AbstractPlatformTestCase extends DbalTestCase /** @var AbstractPlatform */ protected $platform; - abstract public function createPlatform() : AbstractPlatform; + abstract public function createPlatform(): AbstractPlatform; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createPlatform(); } @@ -37,7 +38,7 @@ protected function setUp() : void /** * @group DDC-1360 */ - public function testQuoteIdentifier() : void + public function testQuoteIdentifier(): void { if ($this->platform->getName() === 'mssql') { $this->markTestSkipped('Not working this way on mssql.'); @@ -52,7 +53,7 @@ public function testQuoteIdentifier() : void /** * @group DDC-1360 */ - public function testQuoteSingleIdentifier() : void + public function testQuoteSingleIdentifier(): void { if ($this->platform->getName() === 'mssql') { $this->markTestSkipped('Not working this way on mssql.'); @@ -68,7 +69,7 @@ public function testQuoteSingleIdentifier() : void * @group DBAL-1029 * @dataProvider getReturnsForeignKeyReferentialActionSQL */ - public function testReturnsForeignKeyReferentialActionSQL(string $action, string $expectedSQL) : void + public function testReturnsForeignKeyReferentialActionSQL(string $action, string $expectedSQL): void { self::assertSame($expectedSQL, $this->platform->getForeignKeyReferentialActionSQL($action)); } @@ -76,7 +77,7 @@ public function testReturnsForeignKeyReferentialActionSQL(string $action, string /** * @return mixed[][] */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -88,25 +89,25 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - public function testGetInvalidForeignKeyReferentialActionSQL() : void + public function testGetInvalidForeignKeyReferentialActionSQL(): void { $this->expectException('InvalidArgumentException'); $this->platform->getForeignKeyReferentialActionSQL('unknown'); } - public function testGetUnknownDoctrineMappingType() : void + public function testGetUnknownDoctrineMappingType(): void { $this->expectException(DBALException::class); $this->platform->getDoctrineTypeMapping('foobar'); } - public function testRegisterDoctrineMappingType() : void + public function testRegisterDoctrineMappingType(): void { $this->platform->registerDoctrineTypeMapping('foo', 'integer'); self::assertEquals('integer', $this->platform->getDoctrineTypeMapping('foo')); } - public function testRegisterUnknownDoctrineMappingType() : void + public function testRegisterUnknownDoctrineMappingType(): void { $this->expectException(DBALException::class); $this->platform->registerDoctrineTypeMapping('foo', 'bar'); @@ -115,7 +116,7 @@ public function testRegisterUnknownDoctrineMappingType() : void /** * @group DBAL-2594 */ - public function testRegistersCommentedDoctrineMappingTypeImplicitly() : void + public function testRegistersCommentedDoctrineMappingTypeImplicitly(): void { if (! Type::hasType('my_commented')) { Type::addType('my_commented', CommentedType::class); @@ -131,7 +132,7 @@ public function testRegistersCommentedDoctrineMappingTypeImplicitly() : void * @group DBAL-939 * @dataProvider getIsCommentedDoctrineType */ - public function testIsCommentedDoctrineType(Type $type, bool $commented) : void + public function testIsCommentedDoctrineType(Type $type, bool $commented): void { self::assertSame($commented, $this->platform->isCommentedDoctrineType($type)); } @@ -139,7 +140,7 @@ public function testIsCommentedDoctrineType(Type $type, bool $commented) : void /** * @return mixed[] */ - public function getIsCommentedDoctrineType() : iterable + public function getIsCommentedDoctrineType(): iterable { $this->setUp(); @@ -157,7 +158,7 @@ public function getIsCommentedDoctrineType() : iterable return $data; } - public function testCreateWithNoColumns() : void + public function testCreateWithNoColumns(): void { $table = new Table('test'); @@ -165,7 +166,7 @@ public function testCreateWithNoColumns() : void $sql = $this->platform->getCreateTableSQL($table); } - public function testGeneratesTableCreationSql() : void + public function testGeneratesTableCreationSql(): void { $table = new Table('test'); $table->addColumn('id', 'integer', ['notnull' => true, 'autoincrement' => true]); @@ -176,9 +177,9 @@ public function testGeneratesTableCreationSql() : void self::assertEquals($this->getGenerateTableSql(), $sql[0]); } - abstract public function getGenerateTableSql() : string; + abstract public function getGenerateTableSql(): string; - public function testGenerateTableWithMultiColumnUniqueIndex() : void + public function testGenerateTableWithMultiColumnUniqueIndex(): void { $table = new Table('test'); $table->addColumn('foo', 'string', ['notnull' => false, 'length' => 255]); @@ -192,9 +193,9 @@ public function testGenerateTableWithMultiColumnUniqueIndex() : void /** * @return string[] */ - abstract public function getGenerateTableWithMultiColumnUniqueIndexSql() : array; + abstract public function getGenerateTableWithMultiColumnUniqueIndexSql(): array; - public function testGeneratesIndexCreationSql() : void + public function testGeneratesIndexCreationSql(): void { $indexDef = new Index('my_idx', ['user_name', 'last_login']); @@ -204,9 +205,9 @@ public function testGeneratesIndexCreationSql() : void ); } - abstract public function getGenerateIndexSql() : string; + abstract public function getGenerateIndexSql(): string; - public function testGeneratesUniqueIndexCreationSql() : void + public function testGeneratesUniqueIndexCreationSql(): void { $indexDef = new Index('index_name', ['test', 'test2'], true); @@ -214,9 +215,9 @@ public function testGeneratesUniqueIndexCreationSql() : void self::assertEquals($this->getGenerateUniqueIndexSql(), $sql); } - abstract public function getGenerateUniqueIndexSql() : string; + abstract public function getGenerateUniqueIndexSql(): string; - public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() : void + public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes(): void { $where = 'test IS NULL AND test2 IS NOT NULL'; $indexDef = new Index('name', ['test', 'test2'], false, false, [], ['where' => $where]); @@ -242,7 +243,7 @@ public function testGeneratesPartialIndexesSqlOnlyWhenSupportingPartialIndexes() } } - public function testGeneratesForeignKeyCreationSql() : void + public function testGeneratesForeignKeyCreationSql(): void { $fk = new ForeignKeyConstraint(['fk_name_id'], 'other_table', ['id'], ''); @@ -250,9 +251,9 @@ public function testGeneratesForeignKeyCreationSql() : void self::assertEquals($sql, $this->getGenerateForeignKeySql()); } - abstract public function getGenerateForeignKeySql() : string; + abstract public function getGenerateForeignKeySql(): string; - public function testGeneratesConstraintCreationSql() : void + public function testGeneratesConstraintCreationSql(): void { if (! $this->platform->supportsCreateDropForeignKeyConstraints()) { $this->markTestSkipped('Platform does not support creating or dropping foreign key constraints.'); @@ -271,7 +272,7 @@ public function testGeneratesConstraintCreationSql() : void self::assertEquals($this->getGenerateConstraintForeignKeySql($fk), $sql); } - protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . ' & ' . $value2 . ')'; } @@ -279,13 +280,13 @@ protected function getBitAndComparisonExpressionSql(string $value1, string $valu /** * @group DDC-1213 */ - public function testGeneratesBitAndComparisonExpressionSql() : void + public function testGeneratesBitAndComparisonExpressionSql(): void { $sql = $this->platform->getBitAndComparisonExpression(2, 4); self::assertEquals($this->getBitAndComparisonExpressionSql(2, 4), $sql); } - protected function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . ' | ' . $value2 . ')'; } @@ -293,23 +294,23 @@ protected function getBitOrComparisonExpressionSql(string $value1, string $value /** * @group DDC-1213 */ - public function testGeneratesBitOrComparisonExpressionSql() : void + public function testGeneratesBitOrComparisonExpressionSql(): void { $sql = $this->platform->getBitOrComparisonExpression(2, 4); self::assertEquals($this->getBitOrComparisonExpressionSql(2, 4), $sql); } - public function getGenerateConstraintUniqueIndexSql() : string + public function getGenerateConstraintUniqueIndexSql(): string { return 'ALTER TABLE test ADD CONSTRAINT constraint_name UNIQUE (test)'; } - public function getGenerateConstraintPrimaryIndexSql() : string + public function getGenerateConstraintPrimaryIndexSql(): string { return 'ALTER TABLE test ADD CONSTRAINT constraint_name PRIMARY KEY (test)'; } - public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk) : string + public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk): string { $quotedForeignTable = $fk->getQuotedForeignTableName($this->platform); @@ -322,9 +323,9 @@ public function getGenerateConstraintForeignKeySql(ForeignKeyConstraint $fk) : s /** * @return string[] */ - abstract public function getGenerateAlterTableSql() : array; + abstract public function getGenerateAlterTableSql(): array; - public function testGeneratesTableAlterationSql() : void + public function testGeneratesTableAlterationSql(): void { $expectedSql = $this->getGenerateAlterTableSql(); @@ -364,13 +365,13 @@ public function testGeneratesTableAlterationSql() : void self::assertEquals($expectedSql, $sql); } - public function testGetCustomColumnDeclarationSql() : void + public function testGetCustomColumnDeclarationSql(): void { $field = ['columnDefinition' => 'MEDIUMINT(6) UNSIGNED']; self::assertEquals('foo MEDIUMINT(6) UNSIGNED', $this->platform->getColumnDeclarationSQL('foo', $field)); } - public function testGetCreateTableSqlDispatchEvent() : void + public function testGetCreateTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetCreateTableSqlDispatchEventListener::class); $listenerMock @@ -392,7 +393,7 @@ public function testGetCreateTableSqlDispatchEvent() : void $this->platform->getCreateTableSQL($table); } - public function testGetDropTableSqlDispatchEvent() : void + public function testGetDropTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetDropTableSqlDispatchEventListener::class); $listenerMock @@ -407,7 +408,7 @@ public function testGetDropTableSqlDispatchEvent() : void $this->platform->getDropTableSQL('TABLE'); } - public function testGetAlterTableSqlDispatchEvent() : void + public function testGetAlterTableSqlDispatchEvent(): void { $listenerMock = $this->createMock(GetAlterTableSqlDispatchEventListener::class); $listenerMock @@ -464,7 +465,7 @@ public function testGetAlterTableSqlDispatchEvent() : void /** * @group DBAL-42 */ - public function testCreateTableColumnComments() : void + public function testCreateTableColumnComments(): void { $table = new Table('test'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -476,7 +477,7 @@ public function testCreateTableColumnComments() : void /** * @group DBAL-42 */ - public function testAlterTableColumnComments() : void + public function testAlterTableColumnComments(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['comment' => 'A comment']); @@ -501,7 +502,7 @@ public function testAlterTableColumnComments() : void self::assertEquals($this->getAlterTableColumnCommentsSQL(), $this->platform->getAlterTableSQL($tableDiff)); } - public function testCreateTableColumnTypeComments() : void + public function testCreateTableColumnTypeComments(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -514,7 +515,7 @@ public function testCreateTableColumnTypeComments() : void /** * @return string[] */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } @@ -522,7 +523,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * @return string[] */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } @@ -530,12 +531,12 @@ public function getAlterTableColumnCommentsSQL() : array /** * @return string[] */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { $this->markTestSkipped('Platform does not support Column comments.'); } - public function testGetDefaultValueDeclarationSQL() : void + public function testGetDefaultValueDeclarationSQL(): void { // non-timestamp value will get single quotes $field = [ @@ -549,7 +550,7 @@ public function testGetDefaultValueDeclarationSQL() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLDateTime() : void + public function testGetDefaultValueDeclarationSQLDateTime(): void { // timestamps on datetime types should not be quoted foreach (['datetime', 'datetimetz', 'datetime_immutable', 'datetimetz_immutable'] as $type) { @@ -565,7 +566,7 @@ public function testGetDefaultValueDeclarationSQLDateTime() : void } } - public function testGetDefaultValueDeclarationSQLForIntegerTypes() : void + public function testGetDefaultValueDeclarationSQLForIntegerTypes(): void { foreach (['bigint', 'integer', 'smallint'] as $type) { $field = [ @@ -583,7 +584,7 @@ public function testGetDefaultValueDeclarationSQLForIntegerTypes() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLForDateType() : void + public function testGetDefaultValueDeclarationSQLForDateType(): void { $currentDateSql = $this->platform->getCurrentDateSQL(); foreach (['date', 'date_immutable'] as $type) { @@ -602,7 +603,7 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void /** * @group DBAL-45 */ - public function testKeywordList() : void + public function testKeywordList(): void { $keywordList = $this->platform->getReservedKeywordsList(); self::assertInstanceOf(KeywordList::class, $keywordList); @@ -613,7 +614,7 @@ public function testKeywordList() : void /** * @group DBAL-374 */ - public function testQuotedColumnInPrimaryKeyPropagation() : void + public function testQuotedColumnInPrimaryKeyPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -626,27 +627,27 @@ public function testQuotedColumnInPrimaryKeyPropagation() : void /** * @return string[] */ - abstract protected function getQuotedColumnInPrimaryKeySQL() : array; + abstract protected function getQuotedColumnInPrimaryKeySQL(): array; /** * @return string[] */ - abstract protected function getQuotedColumnInIndexSQL() : array; + abstract protected function getQuotedColumnInIndexSQL(): array; /** * @return string[] */ - abstract protected function getQuotedNameInIndexSQL() : array; + abstract protected function getQuotedNameInIndexSQL(): array; /** * @return string[] */ - abstract protected function getQuotedColumnInForeignKeySQL() : array; + abstract protected function getQuotedColumnInForeignKeySQL(): array; /** * @group DBAL-374 */ - public function testQuotedColumnInIndexPropagation() : void + public function testQuotedColumnInIndexPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -656,7 +657,7 @@ public function testQuotedColumnInIndexPropagation() : void self::assertEquals($this->getQuotedColumnInIndexSQL(), $sql); } - public function testQuotedNameInIndexSQL() : void + public function testQuotedNameInIndexSQL(): void { $table = new Table('test'); $table->addColumn('column1', 'string'); @@ -669,7 +670,7 @@ public function testQuotedNameInIndexSQL() : void /** * @group DBAL-374 */ - public function testQuotedColumnInForeignKeyPropagation() : void + public function testQuotedColumnInForeignKeyPropagation(): void { $table = new Table('`quoted`'); $table->addColumn('create', 'string'); @@ -707,7 +708,7 @@ public function testQuotedColumnInForeignKeyPropagation() : void /** * @group DBAL-1051 */ - public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : void + public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): void { $index = new Index('select', ['foo'], true); @@ -717,12 +718,12 @@ public function testQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : vo ); } - abstract protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string; + abstract protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string; /** * @group DBAL-2270 */ - public function testQuotesReservedKeywordInTruncateTableSQL() : void + public function testQuotesReservedKeywordInTruncateTableSQL(): void { self::assertSame( $this->getQuotesReservedKeywordInTruncateTableSQL(), @@ -730,12 +731,12 @@ public function testQuotesReservedKeywordInTruncateTableSQL() : void ); } - abstract protected function getQuotesReservedKeywordInTruncateTableSQL() : string; + abstract protected function getQuotesReservedKeywordInTruncateTableSQL(): string; /** * @group DBAL-1051 */ - public function testQuotesReservedKeywordInIndexDeclarationSQL() : void + public function testQuotesReservedKeywordInIndexDeclarationSQL(): void { $index = new Index('select', ['foo']); @@ -749,24 +750,24 @@ public function testQuotesReservedKeywordInIndexDeclarationSQL() : void ); } - abstract protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string; + abstract protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string; - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return true; } - public function testSupportsCommentOnStatement() : void + public function testSupportsCommentOnStatement(): void { self::assertSame($this->supportsCommentOnStatement(), $this->platform->supportsCommentOnStatement()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return false; } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $this->expectException(DBALException::class); @@ -776,7 +777,7 @@ public function testGetCreateSchemaSQL() : void /** * @group DBAL-585 */ - public function testAlterTableChangeQuotedColumn() : void + public function testAlterTableChangeQuotedColumn(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->fromTable = new Table('mytable'); @@ -798,7 +799,7 @@ public function testAlterTableChangeQuotedColumn() : void /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertFalse($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -806,41 +807,41 @@ public function testUsesSequenceEmulatedIdentityColumns() : void /** * @group DBAL-563 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { $this->expectException(DBALException::class); $this->platform->getIdentitySequenceName('mytable', 'mycolumn'); } - public function testReturnsBinaryDefaultLength() : void + public function testReturnsBinaryDefaultLength(): void { self::assertSame($this->getBinaryDefaultLength(), $this->platform->getBinaryDefaultLength()); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 255; } - public function testReturnsBinaryMaxLength() : void + public function testReturnsBinaryMaxLength(): void { self::assertSame($this->getBinaryMaxLength(), $this->platform->getBinaryMaxLength()); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 4000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { $this->expectException(DBALException::class); $this->platform->getBinaryTypeDeclarationSQL([]); } - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { $this->markTestSkipped('Not applicable to the platform'); } @@ -848,7 +849,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void /** * @group DBAL-553 */ - public function hasNativeJsonType() : void + public function hasNativeJsonType(): void { self::assertFalse($this->platform->hasNativeJsonType()); } @@ -856,7 +857,7 @@ public function hasNativeJsonType() : void /** * @group DBAL-553 */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { $column = [ 'length' => 666, @@ -873,7 +874,7 @@ public function testReturnsJsonTypeDeclarationSQL() : void /** * @group DBAL-234 */ - public function testAlterTableRenameIndex() : void + public function testAlterTableRenameIndex(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->fromTable = new Table('mytable'); @@ -894,7 +895,7 @@ public function testAlterTableRenameIndex() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX idx_foo', @@ -905,7 +906,7 @@ protected function getAlterTableRenameIndexSQL() : array /** * @group DBAL-234 */ - public function testQuotesAlterTableRenameIndex() : void + public function testQuotesAlterTableRenameIndex(): void { $tableDiff = new TableDiff('table'); $tableDiff->fromTable = new Table('table'); @@ -927,7 +928,7 @@ public function testQuotesAlterTableRenameIndex() : void * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'DROP INDEX "create"', @@ -940,7 +941,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * @group DBAL-835 */ - public function testQuotesAlterTableRenameColumn() : void + public function testQuotesAlterTableRenameColumn(): void { $fromTable = new Table('mytable'); @@ -985,12 +986,12 @@ public function testQuotesAlterTableRenameColumn() : void * * @group DBAL-835 */ - abstract protected function getQuotedAlterTableRenameColumnSQL() : array; + abstract protected function getQuotedAlterTableRenameColumnSQL(): array; /** * @group DBAL-835 */ - public function testQuotesAlterTableChangeColumnLength() : void + public function testQuotesAlterTableChangeColumnLength(): void { $fromTable = new Table('mytable'); @@ -1027,12 +1028,12 @@ public function testQuotesAlterTableChangeColumnLength() : void * * @group DBAL-835 */ - abstract protected function getQuotedAlterTableChangeColumnLengthSQL() : array; + abstract protected function getQuotedAlterTableChangeColumnLengthSQL(): array; /** * @group DBAL-807 */ - public function testAlterTableRenameIndexInSchema() : void + public function testAlterTableRenameIndexInSchema(): void { $tableDiff = new TableDiff('myschema.mytable'); $tableDiff->fromTable = new Table('myschema.mytable'); @@ -1053,7 +1054,7 @@ public function testAlterTableRenameIndexInSchema() : void * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX idx_foo', @@ -1064,7 +1065,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-807 */ - public function testQuotesAlterTableRenameIndexInSchema() : void + public function testQuotesAlterTableRenameIndexInSchema(): void { $tableDiff = new TableDiff('`schema`.table'); $tableDiff->fromTable = new Table('`schema`.table'); @@ -1086,7 +1087,7 @@ public function testQuotesAlterTableRenameIndexInSchema() : void * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'DROP INDEX "schema"."create"', @@ -1099,7 +1100,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-1237 */ - public function testQuotesDropForeignKeySQL() : void + public function testQuotesDropForeignKeySQL(): void { if (! $this->platform->supportsCreateDropForeignKeyConstraints()) { $this->markTestSkipped( @@ -1117,7 +1118,7 @@ public function testQuotesDropForeignKeySQL() : void self::assertSame($expectedSql, $this->platform->getDropForeignKeySQL($foreignKey, $table)); } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP FOREIGN KEY "select"'; } @@ -1125,7 +1126,7 @@ protected function getQuotesDropForeignKeySQL() : string /** * @group DBAL-1237 */ - public function testQuotesDropConstraintSQL() : void + public function testQuotesDropConstraintSQL(): void { $tableName = 'table'; $table = new Table($tableName); @@ -1137,27 +1138,27 @@ public function testQuotesDropConstraintSQL() : void self::assertSame($expectedSql, $this->platform->getDropConstraintSQL($constraint, $table)); } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } - protected function getStringLiteralQuoteCharacter() : string + protected function getStringLiteralQuoteCharacter(): string { return "'"; } - public function testGetStringLiteralQuoteCharacter() : void + public function testGetStringLiteralQuoteCharacter(): void { self::assertSame($this->getStringLiteralQuoteCharacter(), $this->platform->getStringLiteralQuoteCharacter()); } - protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter() : string + protected function getQuotedCommentOnColumnSQLWithoutQuoteCharacter(): string { return "COMMENT ON COLUMN mytable.id IS 'This is a comment'"; } - public function testGetCommentOnColumnSQLWithoutQuoteCharacter() : void + public function testGetCommentOnColumnSQLWithoutQuoteCharacter(): void { self::assertEquals( $this->getQuotedCommentOnColumnSQLWithoutQuoteCharacter(), @@ -1165,12 +1166,12 @@ public function testGetCommentOnColumnSQLWithoutQuoteCharacter() : void ); } - protected function getQuotedCommentOnColumnSQLWithQuoteCharacter() : string + protected function getQuotedCommentOnColumnSQLWithQuoteCharacter(): string { return "COMMENT ON COLUMN mytable.id IS 'It''s a quote !'"; } - public function testGetCommentOnColumnSQLWithQuoteCharacter() : void + public function testGetCommentOnColumnSQLWithQuoteCharacter(): void { $c = $this->getStringLiteralQuoteCharacter(); @@ -1185,12 +1186,12 @@ public function testGetCommentOnColumnSQLWithQuoteCharacter() : void * * @return string[] */ - abstract protected function getCommentOnColumnSQL() : array; + abstract protected function getCommentOnColumnSQL(): array; /** * @group DBAL-1004 */ - public function testGetCommentOnColumnSQL() : void + public function testGetCommentOnColumnSQL(): void { self::assertSame( $this->getCommentOnColumnSQL(), @@ -1206,7 +1207,7 @@ public function testGetCommentOnColumnSQL() : void * @group DBAL-1176 * @dataProvider getGeneratesInlineColumnCommentSQL */ - public function testGeneratesInlineColumnCommentSQL(?string $comment, string $expectedSql) : void + public function testGeneratesInlineColumnCommentSQL(?string $comment, string $expectedSql): void { if (! $this->platform->supportsInlineColumnComments()) { $this->markTestSkipped(sprintf('%s does not support inline column comments.', get_class($this->platform))); @@ -1218,7 +1219,7 @@ public function testGeneratesInlineColumnCommentSQL(?string $comment, string $ex /** * @return mixed[][] */ - public static function getGeneratesInlineColumnCommentSQL() : iterable + public static function getGeneratesInlineColumnCommentSQL(): iterable { return [ 'regular comment' => ['Regular comment', static::getInlineColumnRegularCommentSQL()], @@ -1233,37 +1234,37 @@ public static function getGeneratesInlineColumnCommentSQL() : iterable ]; } - protected static function getInlineColumnCommentDelimiter() : string + protected static function getInlineColumnCommentDelimiter(): string { return "'"; } - protected static function getInlineColumnRegularCommentSQL() : string + protected static function getInlineColumnRegularCommentSQL(): string { return "COMMENT 'Regular comment'"; } - protected static function getInlineColumnCommentRequiringEscapingSQL() : string + protected static function getInlineColumnCommentRequiringEscapingSQL(): string { return "COMMENT 'Using inline comment delimiter '' works'"; } - protected static function getInlineColumnEmptyCommentSQL() : string + protected static function getInlineColumnEmptyCommentSQL(): string { return "COMMENT ''"; } - protected function getQuotedStringLiteralWithoutQuoteCharacter() : string + protected function getQuotedStringLiteralWithoutQuoteCharacter(): string { return "'No quote'"; } - protected function getQuotedStringLiteralWithQuoteCharacter() : string + protected function getQuotedStringLiteralWithQuoteCharacter(): string { return "'It''s a quote'"; } - protected function getQuotedStringLiteralQuoteCharacter() : string + protected function getQuotedStringLiteralQuoteCharacter(): string { return "''''"; } @@ -1271,7 +1272,7 @@ protected function getQuotedStringLiteralQuoteCharacter() : string /** * @group DBAL-1176 */ - public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupported() : void + public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupported(): void { if ($this->platform->supportsInlineColumnComments()) { $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->platform))); @@ -1284,7 +1285,7 @@ public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupport $this->platform->getInlineColumnCommentSQL('unsupported'); } - public function testQuoteStringLiteral() : void + public function testQuoteStringLiteral(): void { $c = $this->getStringLiteralQuoteCharacter(); @@ -1305,7 +1306,7 @@ public function testQuoteStringLiteral() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { $this->expectException(DBALException::class); @@ -1315,7 +1316,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * @group DBAL-1010 */ - public function testGeneratesAlterTableRenameColumnSQL() : void + public function testGeneratesAlterTableRenameColumnSQL(): void { $table = new Table('foo'); $table->addColumn( @@ -1338,12 +1339,12 @@ public function testGeneratesAlterTableRenameColumnSQL() : void /** * @return string[] */ - abstract public function getAlterTableRenameColumnSQL() : array; + abstract public function getAlterTableRenameColumnSQL(): array; /** * @group DBAL-1016 */ - public function testQuotesTableIdentifiersInAlterTableSQL() : void + public function testQuotesTableIdentifiersInAlterTableSQL(): void { $table = new Table('"foo"'); $table->addColumn('id', 'integer'); @@ -1380,12 +1381,12 @@ public function testQuotesTableIdentifiersInAlterTableSQL() : void /** * @return string[] */ - abstract protected function getQuotesTableIdentifiersInAlterTableSQL() : array; + abstract protected function getQuotesTableIdentifiersInAlterTableSQL(): array; /** * @group DBAL-1090 */ - public function testAlterStringToFixedString() : void + public function testAlterStringToFixedString(): void { $table = new Table('mytable'); $table->addColumn('name', 'string', ['length' => 2]); @@ -1413,12 +1414,12 @@ public function testAlterStringToFixedString() : void /** * @return string[] */ - abstract protected function getAlterStringToFixedStringSQL() : array; + abstract protected function getAlterStringToFixedStringSQL(): array; /** * @group DBAL-1062 */ - public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : void + public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): void { $foreignTable = new Table('foreign_table'); $foreignTable->addColumn('id', 'integer'); @@ -1446,7 +1447,7 @@ public function testGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : void /** * @return string[] */ - abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array; + abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array; /** * @param mixed[] $column @@ -1454,7 +1455,7 @@ abstract protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL * @group DBAL-1082 * @dataProvider getGeneratesDecimalTypeDeclarationSQL */ - public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $expectedSql) : void + public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDecimalTypeDeclarationSQL($column)); } @@ -1462,7 +1463,7 @@ public function testGeneratesDecimalTypeDeclarationSQL(array $column, string $ex /** * @return mixed[][] */ - public static function getGeneratesDecimalTypeDeclarationSQL() : iterable + public static function getGeneratesDecimalTypeDeclarationSQL(): iterable { return [ [[], 'NUMERIC(10, 0)'], @@ -1480,7 +1481,7 @@ public static function getGeneratesDecimalTypeDeclarationSQL() : iterable * @group DBAL-1082 * @dataProvider getGeneratesFloatDeclarationSQL */ - public function testGeneratesFloatDeclarationSQL(array $column, string $expectedSql) : void + public function testGeneratesFloatDeclarationSQL(array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getFloatDeclarationSQL($column)); } @@ -1488,7 +1489,7 @@ public function testGeneratesFloatDeclarationSQL(array $column, string $expected /** * @return mixed[][] */ - public static function getGeneratesFloatDeclarationSQL() : iterable + public static function getGeneratesFloatDeclarationSQL(): iterable { return [ [[], 'DOUBLE PRECISION'], @@ -1500,7 +1501,7 @@ public static function getGeneratesFloatDeclarationSQL() : iterable ]; } - public function testItEscapesStringsForLike() : void + public function testItEscapesStringsForLike(): void { self::assertSame( '\_25\% off\_ your next purchase \\\\o/', @@ -1508,7 +1509,7 @@ public function testItEscapesStringsForLike() : void ); } - public function testZeroOffsetWithoutLimitIsIgnored() : void + public function testZeroOffsetWithoutLimitIsIgnored(): void { $query = 'SELECT * FROM user'; @@ -1521,25 +1522,25 @@ public function testZeroOffsetWithoutLimitIsIgnored() : void interface GetCreateTableSqlDispatchEventListener { - public function onSchemaCreateTable() : void; + public function onSchemaCreateTable(): void; - public function onSchemaCreateTableColumn() : void; + public function onSchemaCreateTableColumn(): void; } interface GetAlterTableSqlDispatchEventListener { - public function onSchemaAlterTable() : void; + public function onSchemaAlterTable(): void; - public function onSchemaAlterTableAddColumn() : void; + public function onSchemaAlterTableAddColumn(): void; - public function onSchemaAlterTableRemoveColumn() : void; + public function onSchemaAlterTableRemoveColumn(): void; - public function onSchemaAlterTableChangeColumn() : void; + public function onSchemaAlterTableChangeColumn(): void; - public function onSchemaAlterTableRenameColumn() : void; + public function onSchemaAlterTableRenameColumn(): void; } interface GetDropTableSqlDispatchEventListener { - public function onSchemaDropTable() : void; + public function onSchemaDropTable(): void; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php index 10ccac9a046..c202066f68e 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPostgreSqlPlatformTestCase.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; use UnexpectedValueException; + use function sprintf; abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase @@ -24,9 +25,9 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa /** * @return PostgreSqlPlatform */ - abstract public function createPlatform() : AbstractPlatform; + abstract public function createPlatform(): AbstractPlatform; - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; } @@ -34,7 +35,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -45,7 +46,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD quota INT DEFAULT NULL', @@ -60,17 +61,17 @@ public function getGenerateAlterTableSql() : array ]; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id) NOT DEFERRABLE INITIALLY IMMEDIATE'; } - public function testGeneratesForeignKeySqlForNonStandardOptions() : void + public function testGeneratesForeignKeySqlForNonStandardOptions(): void { $foreignKey = new ForeignKeyConstraint( ['foreign_id'], @@ -145,7 +146,7 @@ public function testGeneratesForeignKeySqlForNonStandardOptions() : void ); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('SIMILAR TO', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); @@ -154,7 +155,7 @@ public function testGeneratesSqlSnippets() : void self::assertEquals('SUBSTRING(column FROM 1 FOR 5)', $this->platform->getSubstringExpression('column', 1, 5), 'Substring expression with length is not correct'); } - public function testGeneratesTransactionCommands() : void + public function testGeneratesTransactionCommands(): void { self::assertEquals( 'SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -174,14 +175,14 @@ public function testGeneratesTransactionCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar')); self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGenerateTableWithAutoincrement() : void + public function testGenerateTableWithAutoincrement(): void { $table = new Table('autoinc_table'); $column = $table->addColumn('id', 'integer'); @@ -193,7 +194,7 @@ public function testGenerateTableWithAutoincrement() : void /** * @return mixed[][] */ - public static function serialTypes() : iterable + public static function serialTypes(): iterable { return [ ['integer', 'SERIAL'], @@ -205,7 +206,7 @@ public static function serialTypes() : iterable * @dataProvider serialTypes * @group 2906 */ - public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type, string $definition) : void + public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type, string $definition): void { $table = new Table('autoinc_table_notnull'); $column = $table->addColumn('id', $type); @@ -221,7 +222,7 @@ public function testGenerateTableWithAutoincrementDoesNotSetDefault(string $type * @dataProvider serialTypes * @group 2906 */ - public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $type, string $definition) : void + public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string $type, string $definition): void { $table = new Table('autoinc_table_notnull_enabled'); $column = $table->addColumn('id', $type); @@ -237,7 +238,7 @@ public function testCreateTableWithAutoincrementAndNotNullAddsConstraint(string * @dataProvider serialTypes * @group 2906 */ - public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFieldIsSerial(string $type) : void + public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFieldIsSerial(string $type): void { $sql = $this->platform->getDefaultValueDeclarationSQL( [ @@ -250,7 +251,7 @@ public function testGetDefaultValueDeclarationSQLIgnoresTheDefaultKeyWhenTheFiel self::assertSame('', $sql); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -268,7 +269,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -288,12 +289,12 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -310,43 +311,43 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testDoesNotPreferIdentityColumns() : void + public function testDoesNotPreferIdentityColumns(): void { self::assertFalse($this->platform->prefersIdentityColumns()); } - public function testPrefersSequences() : void + public function testPrefersSequences(): void { self::assertTrue($this->platform->prefersSequences()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); @@ -355,7 +356,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY(id))', @@ -366,7 +367,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -379,7 +380,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY(id))', @@ -390,7 +391,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -398,7 +399,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -409,7 +410,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -420,7 +421,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)', @@ -441,7 +442,7 @@ public function testConvertBooleanAsLiteralStrings( string $preparedStatementValue, ?int $integerValue, ?bool $booleanValue - ) : void { + ): void { $platform = $this->createPlatform(); self::assertEquals($preparedStatementValue, $platform->convertBooleans($databaseValue)); @@ -450,7 +451,7 @@ public function testConvertBooleanAsLiteralStrings( /** * @group DBAL-457 */ - public function testConvertBooleanAsLiteralIntegers() : void + public function testConvertBooleanAsLiteralIntegers(): void { $platform = $this->createPlatform(); $platform->setUseBooleanTrueFalseStrings(false); @@ -473,7 +474,7 @@ public function testConvertBooleanAsDatabaseValueStrings( string $preparedStatementValue, ?int $integerValue, ?bool $booleanValue - ) : void { + ): void { $platform = $this->createPlatform(); self::assertSame($integerValue, $platform->convertBooleansToDatabaseValue($booleanValue)); @@ -482,7 +483,7 @@ public function testConvertBooleanAsDatabaseValueStrings( /** * @group DBAL-630 */ - public function testConvertBooleanAsDatabaseValueIntegers() : void + public function testConvertBooleanAsDatabaseValueIntegers(): void { $platform = $this->createPlatform(); $platform->setUseBooleanTrueFalseStrings(false); @@ -496,14 +497,14 @@ public function testConvertBooleanAsDatabaseValueIntegers() : void * * @dataProvider pgBooleanProvider */ - public function testConvertFromBoolean($databaseValue, string $prepareStatementValue, ?int $integerValue, ?bool $booleanValue) : void + public function testConvertFromBoolean($databaseValue, string $prepareStatementValue, ?int $integerValue, ?bool $booleanValue): void { $platform = $this->createPlatform(); self::assertSame($booleanValue, $platform->convertFromBoolean($databaseValue)); } - public function testThrowsExceptionWithInvalidBooleanLiteral() : void + public function testThrowsExceptionWithInvalidBooleanLiteral(): void { $platform = $this->createPlatform(); @@ -513,14 +514,14 @@ public function testThrowsExceptionWithInvalidBooleanLiteral() : void $platform->convertBooleansToDatabaseValue('my-bool'); } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $schemaName = 'schema'; $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } - public function testAlterDecimalPrecisionScale() : void + public function testAlterDecimalPrecisionScale(): void { $table = new Table('mytable'); $table->addColumn('dfoo1', 'decimal'); @@ -582,7 +583,7 @@ public function testAlterDecimalPrecisionScale() : void /** * @group DBAL-365 */ - public function testDroppingConstraintsBeforeColumns() : void + public function testDroppingConstraintsBeforeColumns(): void { $newTable = new Table('mytable'); $newTable->addColumn('id', 'integer'); @@ -609,7 +610,7 @@ public function testDroppingConstraintsBeforeColumns() : void /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -617,7 +618,7 @@ public function testUsesSequenceEmulatedIdentityColumns() : void /** * @group DBAL-563 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { self::assertSame('mytable_mycolumn_seq', $this->platform->getIdentitySequenceName('mytable', 'mycolumn')); } @@ -626,7 +627,7 @@ public function testReturnsIdentitySequenceName() : void * @dataProvider dataCreateSequenceWithCache * @group DBAL-139 */ - public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) : void + public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql): void { $sequence = new Sequence('foo', 1, 1, $cacheSize); self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); @@ -635,24 +636,24 @@ public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) /** * @return mixed[][] */ - public static function dataCreateSequenceWithCache() : iterable + public static function dataCreateSequenceWithCache(): iterable { return [ [3, 'CACHE 3'], ]; } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 0; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 0; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -663,7 +664,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void self::assertSame('BYTEA', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 9999999])); } - public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : void + public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): void { $table1 = new Table('mytable'); $table1->addColumn('column_varbinary', 'binary'); @@ -708,7 +709,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : v * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_bar']; } @@ -718,7 +719,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" RENAME TO "select"', @@ -731,7 +732,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @return mixed[][] */ - public static function pgBooleanProvider() : iterable + public static function pgBooleanProvider(): iterable { return [ // Database value, prepared statement value, boolean integer value, boolean value. @@ -758,7 +759,7 @@ public static function pgBooleanProvider() : iterable /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted', @@ -776,7 +777,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return [ 'ALTER TABLE mytable ALTER unquoted1 TYPE VARCHAR(255)', @@ -793,7 +794,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar']; } @@ -803,7 +804,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "schema"."create" RENAME TO "select"', @@ -811,12 +812,12 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } - public function testGetNullCommentOnColumnSQL() : void + public function testGetNullCommentOnColumnSQL(): void { self::assertEquals( 'COMMENT ON COLUMN mytable.id IS NULL', @@ -827,7 +828,7 @@ public function testGetNullCommentOnColumnSQL() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UUID', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -835,7 +836,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -843,7 +844,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP CONSTRAINT fk1', @@ -863,7 +864,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -875,7 +876,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -894,7 +895,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : /** * @group 3158 */ - public function testAltersTableColumnCommentIfRequiredByType() : void + public function testAltersTableColumnCommentIfRequiredByType(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('datetime'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('datetime_immutable'))]); @@ -914,17 +915,17 @@ public function testAltersTableColumnCommentIfRequiredByType() : void ); } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE "select"'; } @@ -932,7 +933,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER name TYPE CHAR(2)']; } @@ -940,7 +941,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed']; } @@ -948,7 +949,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-1142 */ - public function testInitializesTsvectorTypeMapping() : void + public function testInitializesTsvectorTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('tsvector')); self::assertEquals('text', $this->platform->getDoctrineTypeMapping('tsvector')); @@ -957,7 +958,7 @@ public function testInitializesTsvectorTypeMapping() : void /** * @group DBAL-1220 */ - public function testReturnsDisallowDatabaseConnectionsSQL() : void + public function testReturnsDisallowDatabaseConnectionsSQL(): void { self::assertSame( "UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'", @@ -968,7 +969,7 @@ public function testReturnsDisallowDatabaseConnectionsSQL() : void /** * @group DBAL-1220 */ - public function testReturnsCloseActiveDatabaseConnectionsSQL() : void + public function testReturnsCloseActiveDatabaseConnectionsSQL(): void { self::assertSame( "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'", @@ -979,7 +980,7 @@ public function testReturnsCloseActiveDatabaseConnectionsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -990,7 +991,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1001,7 +1002,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1012,7 +1013,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1023,7 +1024,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1034,7 +1035,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1045,7 +1046,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1056,7 +1057,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() : void + public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index e7f7c0d71c1..6887c62af10 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; + use function sprintf; abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase @@ -18,7 +19,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas /** @var SQLServerPlatform */ protected $platform; - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test NVARCHAR(255), PRIMARY KEY (id))'; } @@ -26,7 +27,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo NVARCHAR(255), bar NVARCHAR(255))', @@ -37,7 +38,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD quota INT', @@ -57,14 +58,14 @@ public function getGenerateAlterTableSql() : array ]; } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('CONVERT(date, GETDATE())', $this->platform->getCurrentDateSQL()); self::assertEquals('CONVERT(time, GETDATE())', $this->platform->getCurrentTimeSQL()); @@ -73,7 +74,7 @@ public function testGeneratesSqlSnippets() : void self::assertEquals('(column1 + column2 + column3)', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -93,7 +94,7 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { $dropDatabaseExpectation = 'DROP DATABASE foobar'; @@ -103,7 +104,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INT', @@ -121,7 +122,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationsForStrings() : void + public function testGeneratesTypeDeclarationsForStrings(): void { self::assertEquals( 'NCHAR(10)', @@ -146,47 +147,47 @@ public function testGeneratesTypeDeclarationsForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsCreateDropDatabase() : void + public function testSupportsCreateDropDatabase(): void { self::assertTrue($this->platform->supportsCreateDropDatabase()); } - public function testSupportsSchemas() : void + public function testSupportsSchemas(): void { self::assertTrue($this->platform->supportsSchemas()); } - public function testDoesNotSupportSavePoints() : void + public function testDoesNotSupportSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2) WHERE test IS NOT NULL AND test2 IS NOT NULL'; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $querySql = 'SELECT * FROM user'; $alteredSql = 'SELECT TOP 10 * FROM user'; @@ -194,7 +195,7 @@ public function testModifyLimitQuery() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $querySql = 'SELECT * FROM user'; $alteredSql = 'SELECT TOP 10 * FROM user'; @@ -202,7 +203,7 @@ public function testModifyLimitQueryWithEmptyOffset() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithOffset() : void + public function testModifyLimitQueryWithOffset(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -215,7 +216,7 @@ public function testModifyLimitQueryWithOffset() : void $this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username ASC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username ASC'; @@ -224,7 +225,7 @@ public function testModifyLimitQueryWithAscOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithLowercaseOrderBy() : void + public function testModifyLimitQueryWithLowercaseOrderBy(): void { $querySql = 'SELECT * FROM user order by username'; $alteredSql = 'SELECT TOP 10 * FROM user order by username'; @@ -232,7 +233,7 @@ public function testModifyLimitQueryWithLowercaseOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username DESC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC'; @@ -240,7 +241,7 @@ public function testModifyLimitQueryWithDescOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithMultipleOrderBy() : void + public function testModifyLimitQueryWithMultipleOrderBy(): void { $querySql = 'SELECT * FROM user ORDER BY username DESC, usereamil ASC'; $alteredSql = 'SELECT TOP 10 * FROM user ORDER BY username DESC, usereamil ASC'; @@ -248,7 +249,7 @@ public function testModifyLimitQueryWithMultipleOrderBy() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelect() : void + public function testModifyLimitQueryWithSubSelect(): void { $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; $alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; @@ -256,7 +257,7 @@ public function testModifyLimitQueryWithSubSelect() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelectAndOrder() : void + public function testModifyLimitQueryWithSubSelectAndOrder(): void { $querySql = 'SELECT * FROM (SELECT u.id as uid, u.name as uname ORDER BY u.name DESC) dctrn_result'; $alteredSql = 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname) dctrn_result'; @@ -269,7 +270,7 @@ public function testModifyLimitQueryWithSubSelectAndOrder() : void $this->expectCteWithMaxRowNum($alteredSql, 10, $sql); } - public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void + public function testModifyLimitQueryWithSubSelectAndMultipleOrder(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -291,7 +292,7 @@ public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void $this->expectCteWithMinAndMaxRowNums($alteredSql, 6, 15, $sql); } - public function testModifyLimitQueryWithFromColumnNames() : void + public function testModifyLimitQueryWithFromColumnNames(): void { $querySql = 'SELECT a.fromFoo, fromBar FROM foo'; $alteredSql = 'SELECT TOP 10 a.fromFoo, fromBar FROM foo'; @@ -302,7 +303,7 @@ public function testModifyLimitQueryWithFromColumnNames() : void /** * @group DBAL-927 */ - public function testModifyLimitQueryWithExtraLongQuery() : void + public function testModifyLimitQueryWithExtraLongQuery(): void { $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 '; $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) '; @@ -321,7 +322,7 @@ public function testModifyLimitQueryWithExtraLongQuery() : void /** * @group DDC-2470 */ - public function testModifyLimitQueryWithOrderByClause() : void + public function testModifyLimitQueryWithOrderByClause(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -337,7 +338,7 @@ public function testModifyLimitQueryWithOrderByClause() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectList() : void + public function testModifyLimitQueryWithSubSelectInSelectList(): void { $querySql = 'SELECT ' . 'u.id, ' . @@ -361,7 +362,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() : void + public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause(): void { if (! $this->platform->supportsLimitOffset()) { $this->markTestSkipped(sprintf('Platform "%s" does not support offsets in result limiting.', $this->platform->getName())); @@ -390,7 +391,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() /** * @group DBAL-834 */ - public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : void + public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void { $querySql = 'SELECT ' . 'MAX(heading_id) aliased, ' . @@ -411,7 +412,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : voi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -435,7 +436,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -459,7 +460,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' . 'FROM (' @@ -480,7 +481,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } - public function testModifyLimitSubquerySimple() : void + public function testModifyLimitSubquerySimple(): void { $querySql = 'SELECT DISTINCT id_0 FROM ' . '(SELECT k0_.id AS id_0, k0_.field AS field_1 ' @@ -494,7 +495,7 @@ public function testModifyLimitSubquerySimple() : void /** * @group DDC-1360 */ - public function testQuoteIdentifier() : void + public function testQuoteIdentifier(): void { self::assertEquals('[fo][o]', $this->platform->quoteIdentifier('fo]o')); self::assertEquals('[test]', $this->platform->quoteIdentifier('test')); @@ -504,7 +505,7 @@ public function testQuoteIdentifier() : void /** * @group DDC-1360 */ - public function testQuoteSingleIdentifier() : void + public function testQuoteSingleIdentifier(): void { self::assertEquals('[fo][o]', $this->platform->quoteSingleIdentifier('fo]o')); self::assertEquals('[test]', $this->platform->quoteSingleIdentifier('test')); @@ -514,7 +515,7 @@ public function testQuoteSingleIdentifier() : void /** * @group DBAL-220 */ - public function testCreateClusteredIndex() : void + public function testCreateClusteredIndex(): void { $idx = new Index('idx', ['id']); $idx->addFlag('clustered'); @@ -524,7 +525,7 @@ public function testCreateClusteredIndex() : void /** * @group DBAL-220 */ - public function testCreateNonClusteredPrimaryKeyInTable() : void + public function testCreateNonClusteredPrimaryKeyInTable(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer'); @@ -537,14 +538,14 @@ public function testCreateNonClusteredPrimaryKeyInTable() : void /** * @group DBAL-220 */ - public function testCreateNonClusteredPrimaryKey() : void + public function testCreateNonClusteredPrimaryKey(): void { $idx = new Index('idx', ['id'], false, true); $idx->addFlag('nonclustered'); self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY NONCLUSTERED (id)', $this->platform->getCreatePrimaryKeySQL($idx, 'tbl')); } - public function testAlterAddPrimaryKey() : void + public function testAlterAddPrimaryKey(): void { $idx = new Index('idx', ['id'], false, true); self::assertEquals('ALTER TABLE tbl ADD PRIMARY KEY (id)', $this->platform->getCreateIndexSQL($idx, 'tbl')); @@ -553,7 +554,7 @@ public function testAlterAddPrimaryKey() : void /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, PRIMARY KEY ([create]))']; } @@ -561,7 +562,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL)', @@ -572,7 +573,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 NVARCHAR(255) NOT NULL)', @@ -583,7 +584,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE [quoted] ([create] NVARCHAR(255) NOT NULL, foo NVARCHAR(255) NOT NULL, [bar] NVARCHAR(255) NOT NULL)', @@ -593,14 +594,14 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - public function testGetCreateSchemaSQL() : void + public function testGetCreateSchemaSQL(): void { $schemaName = 'schema'; $sql = $this->platform->getCreateSchemaSQL($schemaName); self::assertEquals('CREATE SCHEMA ' . $schemaName, $sql); } - public function testCreateTableWithSchemaColumnComments() : void + public function testCreateTableWithSchemaColumnComments(): void { $table = new Table('testschema.test'); $table->addColumn('id', 'integer', ['comment' => 'This is a comment']); @@ -614,7 +615,7 @@ public function testCreateTableWithSchemaColumnComments() : void self::assertEquals($expectedSql, $this->platform->getCreateTableSQL($table)); } - public function testAlterTableWithSchemaColumnComments() : void + public function testAlterTableWithSchemaColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->addedColumns['quota'] = new Column('quota', Type::getType('integer'), ['comment' => 'A comment']); @@ -627,7 +628,7 @@ public function testAlterTableWithSchemaColumnComments() : void self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } - public function testAlterTableWithSchemaDropColumnComments() : void + public function testAlterTableWithSchemaDropColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->changedColumns['quota'] = new ColumnDiff( @@ -642,7 +643,7 @@ public function testAlterTableWithSchemaDropColumnComments() : void self::assertEquals($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } - public function testAlterTableWithSchemaUpdateColumnComments() : void + public function testAlterTableWithSchemaUpdateColumnComments(): void { $tableDiff = new TableDiff('testschema.mytable'); $tableDiff->changedColumns['quota'] = new ColumnDiff( @@ -662,7 +663,7 @@ public function testAlterTableWithSchemaUpdateColumnComments() : void * * @group DBAL-543 */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))', @@ -675,7 +676,7 @@ public function getCreateTableColumnCommentsSQL() : array * * @group DBAL-543 */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -690,7 +691,7 @@ public function getAlterTableColumnCommentsSQL() : array * * @group DBAL-543 */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data VARCHAR(MAX) NOT NULL, PRIMARY KEY (id))', @@ -701,7 +702,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * @group DBAL-543 */ - public function testGeneratesCreateTableSQLWithColumnComments() : void + public function testGeneratesCreateTableSQLWithColumnComments(): void { $table = new Table('mytable'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -740,7 +741,7 @@ public function testGeneratesCreateTableSQLWithColumnComments() : void * @group DBAL-543 * @group DBAL-1011 */ - public function testGeneratesAlterTableSQLWithColumnComments() : void + public function testGeneratesAlterTableSQLWithColumnComments(): void { $table = new Table('mytable'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -922,7 +923,7 @@ public function testGeneratesAlterTableSQLWithColumnComments() : void /** * @group DBAL-122 */ - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('bigint')); self::assertSame('bigint', $this->platform->getDoctrineTypeMapping('bigint')); @@ -1000,12 +1001,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('guid', $this->platform->getDoctrineTypeMapping('uniqueidentifier')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 8000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(255)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -1020,7 +1021,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 8001 is greater than supported by the platform (8000). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 8001])); self::assertSame('VARBINARY(MAX)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 8001])); @@ -1031,7 +1032,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_bar', N'INDEX'"]; } @@ -1041,7 +1042,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ "EXEC sp_RENAME N'[table].[create]', N'[select]', N'INDEX'", @@ -1052,7 +1053,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * @group DBAL-825 */ - public function testChangeColumnsTypeWithDefaultValue() : void + public function testChangeColumnsTypeWithDefaultValue(): void { $tableName = 'column_def_change_type'; $table = new Table($tableName); @@ -1094,7 +1095,7 @@ public function testChangeColumnsTypeWithDefaultValue() : void /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ "sp_RENAME 'mytable.unquoted1', 'unquoted', 'COLUMN'", @@ -1112,7 +1113,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -1122,7 +1123,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ["EXEC sp_RENAME N'myschema.mytable.idx_foo', N'idx_bar', N'INDEX'"]; } @@ -1132,7 +1133,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ "EXEC sp_RENAME N'[schema].[table].[create]', N'[select]', N'INDEX'", @@ -1140,12 +1141,12 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE [table] DROP CONSTRAINT [select]'; } - protected function getQuotesDropConstraintSQL() : string + protected function getQuotesDropConstraintSQL(): string { return 'ALTER TABLE [table] DROP CONSTRAINT [select]'; } @@ -1156,7 +1157,7 @@ protected function getQuotesDropConstraintSQL() : string * @dataProvider getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(string $table, array $column, string $expectedSql) : void + public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(string $table, array $column, string $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDefaultConstraintDeclarationSQL($table, $column)); } @@ -1164,7 +1165,7 @@ public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(st /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL() : iterable + public static function getGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1184,7 +1185,7 @@ public static function getGeneratesIdentifierNamesInDefaultConstraintDeclaration * @dataProvider getGeneratesIdentifierNamesInCreateTableSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array $expectedSql) : void + public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getCreateTableSQL($table)); } @@ -1192,7 +1193,7 @@ public function testGeneratesIdentifierNamesInCreateTableSQL(Table $table, array /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInCreateTableSQL() : iterable + public static function getGeneratesIdentifierNamesInCreateTableSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1236,7 +1237,7 @@ public static function getGeneratesIdentifierNamesInCreateTableSQL() : iterable * @dataProvider getGeneratesIdentifierNamesInAlterTableSQL * @group DBAL-830 */ - public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff, array $expectedSql) : void + public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getAlterTableSQL($tableDiff)); } @@ -1244,7 +1245,7 @@ public function testGeneratesIdentifierNamesInAlterTableSQL(TableDiff $tableDiff /** * @return mixed[][] */ - public static function getGeneratesIdentifierNamesInAlterTableSQL() : iterable + public static function getGeneratesIdentifierNamesInAlterTableSQL(): iterable { return [ // Unquoted identifiers non-reserved keywords. @@ -1349,7 +1350,7 @@ public static function getGeneratesIdentifierNamesInAlterTableSQL() : iterable /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -1357,7 +1358,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return [ "sp_RENAME 'foo.bar', 'baz', 'COLUMN'", @@ -1369,7 +1370,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE [foo] DROP CONSTRAINT fk1', @@ -1391,7 +1392,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ "COMMENT ON COLUMN foo.bar IS 'comment'", @@ -1403,7 +1404,7 @@ protected function getCommentOnColumnSQL() : array /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -1415,17 +1416,17 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT [select] UNIQUE (foo) WHERE foo IS NOT NULL'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX [select] (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE [select]'; } @@ -1433,7 +1434,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER COLUMN name NCHAR(2) NOT NULL']; } @@ -1441,12 +1442,12 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ["EXEC sp_RENAME N'mytable.idx_foo', N'idx_foo_renamed', N'INDEX'"]; } - public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void + public function testModifyLimitQueryWithTopNSubQueryWithOrderBy(): void { $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; $alteredSql = 'SELECT TOP 10 * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; @@ -1462,7 +1463,7 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1473,7 +1474,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1484,7 +1485,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1495,7 +1496,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1506,7 +1507,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1517,7 +1518,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1528,7 +1529,7 @@ public function testQuotesSchemaNameInListTableIndexesSQL() : void /** * @group 2859 */ - public function testGetDefaultValueDeclarationSQLForDateType() : void + public function testGetDefaultValueDeclarationSQLForDateType(): void { $currentDateSql = $this->platform->getCurrentDateSQL(); foreach (['date', 'date_immutable'] as $type) { @@ -1544,12 +1545,12 @@ public function testGetDefaultValueDeclarationSQLForDateType() : void } } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE Latin1_General_CS_AS_KS_WS', @@ -1557,7 +1558,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); @@ -1570,13 +1571,13 @@ public function testGetCreateTableSQLWithColumnCollation() : void ); } - private function expectCteWithMaxRowNum(string $expectedSql, int $expectedMax, string $sql) : void + private function expectCteWithMaxRowNum(string $expectedSql, int $expectedMax, string $sql): void { $pattern = 'WITH dctrn_cte AS (%s) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum <= %d ORDER BY doctrine_rownum ASC'; self::assertEquals(sprintf($pattern, $expectedSql, $expectedMax), $sql); } - private function expectCteWithMinAndMaxRowNums(string $expectedSql, int $expectedMin, int $expectedMax, string $sql) : void + private function expectCteWithMinAndMaxRowNums(string $expectedSql, int $expectedMin, int $expectedMax, string $sql): void { $pattern = 'WITH dctrn_cte AS (%s) SELECT * FROM (SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT 0)) AS doctrine_rownum FROM dctrn_cte) AS doctrine_tbl WHERE doctrine_rownum >= %d AND doctrine_rownum <= %d ORDER BY doctrine_rownum ASC'; self::assertEquals(sprintf($pattern, $expectedSql, $expectedMin, $expectedMax), $sql); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php index e3bca1e9c47..09a75fcdd50 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/DB2PlatformTest.php @@ -17,7 +17,7 @@ class DB2PlatformTest extends AbstractPlatformTestCase /** @var DB2Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new DB2Platform(); } @@ -25,7 +25,7 @@ public function createPlatform() : AbstractPlatform /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ALTER COLUMN baz SET DATA TYPE VARCHAR(255)', @@ -42,17 +42,17 @@ public function getGenerateAlterTableSql() : array ]; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INTEGER GENERATED BY DEFAULT AS IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))'; } @@ -60,7 +60,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -68,7 +68,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } @@ -76,7 +76,7 @@ public function getGenerateUniqueIndexSql() : string /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL)', @@ -89,7 +89,7 @@ protected function getQuotedColumnInForeignKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -100,7 +100,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -111,17 +111,17 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } - protected function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return 'BITAND(' . $value1 . ', ' . $value2 . ')'; } - protected function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + protected function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return 'BITOR(' . $value1 . ', ' . $value2 . ')'; } @@ -129,7 +129,7 @@ protected function getBitOrComparisonExpressionSql(string $value1, string $value /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))', @@ -140,7 +140,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ' . @@ -155,7 +155,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INTEGER NOT NULL, "data" CLOB(1M) NOT NULL, PRIMARY KEY(id))', @@ -163,12 +163,12 @@ public function getCreateTableColumnTypeCommentsSQL() : array ]; } - public function testHasCorrectPlatformName() : void + public function testHasCorrectPlatformName(): void { self::assertEquals('db2', $this->platform->getName()); } - public function testGeneratesCreateTableSQLWithCommonIndexes() : void + public function testGeneratesCreateTableSQLWithCommonIndexes(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -187,7 +187,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() : void ); } - public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void + public function testGeneratesCreateTableSQLWithForeignKeyConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -213,7 +213,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void ); } - public function testGeneratesCreateTableSQLWithCheckConstraints() : void + public function testGeneratesCreateTableSQLWithCheckConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -227,7 +227,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() : void ); } - public function testGeneratesColumnTypesDeclarationSQL() : void + public function testGeneratesColumnTypesDeclarationSQL(): void { $fullColumnDef = [ 'length' => 10, @@ -259,7 +259,7 @@ public function testGeneratesColumnTypesDeclarationSQL() : void self::assertEquals('TIME', $this->platform->getTimeTypeDeclarationSQL($fullColumnDef)); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { $this->platform->initializeDoctrineTypeMappings(); @@ -306,7 +306,7 @@ public function testInitializesDoctrineTypeMappings() : void /** * {@inheritDoc} */ - public function getIsCommentedDoctrineType() : array + public function getIsCommentedDoctrineType(): array { $data = parent::getIsCommentedDoctrineType(); @@ -315,7 +315,7 @@ public function getIsCommentedDoctrineType() : array return $data; } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals('DROP DATABASE foobar', $this->platform->getDropDatabaseSQL('foobar')); @@ -328,7 +328,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview')); } - public function testGeneratesCreateUnnamedPrimaryKeySQL() : void + public function testGeneratesCreateUnnamedPrimaryKeySQL(): void { self::assertEquals( 'ALTER TABLE foo ADD PRIMARY KEY (a, b)', @@ -339,7 +339,7 @@ public function testGeneratesCreateUnnamedPrimaryKeySQL() : void ); } - public function testGeneratesSQLSnippets() : void + public function testGeneratesSQLSnippets(): void { self::assertEquals('CURRENT DATE', $this->platform->getCurrentDateSQL()); self::assertEquals('CURRENT TIME', $this->platform->getCurrentTimeSQL()); @@ -369,7 +369,7 @@ public function testGeneratesSQLSnippets() : void self::assertEquals('SUBSTR(column, 5, 2)', $this->platform->getSubstringExpression('column', 5, 2)); } - public function testModifiesLimitQuery() : void + public function testModifiesLimitQuery(): void { self::assertEquals( 'SELECT * FROM user', @@ -396,47 +396,47 @@ public function testModifiesLimitQuery() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testDoesNotSupportSavePoints() : void + public function testDoesNotSupportSavePoints(): void { self::assertFalse($this->platform->supportsSavepoints()); } - public function testDoesNotSupportReleasePoints() : void + public function testDoesNotSupportReleasePoints(): void { self::assertFalse($this->platform->supportsReleaseSavepoints()); } - public function testDoesNotSupportCreateDropDatabase() : void + public function testDoesNotSupportCreateDropDatabase(): void { self::assertFalse($this->platform->supportsCreateDropDatabase()); } - public function testReturnsSQLResultCasing() : void + public function testReturnsSQLResultCasing(): void { self::assertSame('COL', $this->platform->getSQLResultCasing('cOl')); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 1; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 32704; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARCHAR(1) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARCHAR(255) FOR BIT DATA', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -450,7 +450,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 32705 is greater than supported by the platform (32704). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32705])); self::assertSame('BLOB(1M)', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32705])); @@ -461,7 +461,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['RENAME INDEX idx_foo TO idx_bar']; } @@ -471,7 +471,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'RENAME INDEX "create" TO "select"', @@ -482,7 +482,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return ['ALTER TABLE mytable ' . 'RENAME COLUMN unquoted1 TO unquoted ' . @@ -500,7 +500,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -510,7 +510,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['RENAME INDEX myschema.idx_foo TO idx_bar']; } @@ -520,7 +520,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'RENAME INDEX "schema"."create" TO "select"', @@ -531,7 +531,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -539,7 +539,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -547,7 +547,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP FOREIGN KEY fk1', @@ -567,7 +567,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -580,7 +580,7 @@ protected function getCommentOnColumnSQL() : array * @group DBAL-944 * @dataProvider getGeneratesAlterColumnSQL */ - public function testGeneratesAlterColumnSQL(string $changedProperty, Column $column, ?string $expectedSQLClause = null) : void + public function testGeneratesAlterColumnSQL(string $changedProperty, Column $column, ?string $expectedSQLClause = null): void { $tableDiff = new TableDiff('foo'); $tableDiff->fromTable = new Table('foo'); @@ -600,7 +600,7 @@ public function testGeneratesAlterColumnSQL(string $changedProperty, Column $col /** * @return mixed[][] */ - public static function getGeneratesAlterColumnSQL() : iterable + public static function getGeneratesAlterColumnSQL(): iterable { return [ [ @@ -661,27 +661,27 @@ public static function getGeneratesAlterColumnSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return ''; // not supported by this platform } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE "select" IMMEDIATE'; } - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return false; } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } @@ -689,7 +689,7 @@ protected function supportsCommentOnStatement() : bool /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return [ 'ALTER TABLE mytable ALTER COLUMN name SET DATA TYPE CHAR(2)', @@ -700,7 +700,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['RENAME INDEX idx_foo TO idx_foo_renamed']; } @@ -708,7 +708,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -719,7 +719,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -730,7 +730,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php index f8bbbf70ac5..ecd036146d4 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MariaDb1027PlatformTest.php @@ -8,12 +8,12 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MariaDb1027Platform(); } - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertFalse($this->platform->hasNativeJsonType()); } @@ -23,12 +23,12 @@ public function testHasNativeJsonType() : void * * @link https://mariadb.com/kb/en/library/json-data-type/ */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('LONGTEXT', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertSame(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -40,7 +40,7 @@ public function testInitializesJsonTypeMapping() : void * * @see AbstractMySQLPlatformTestCase::testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() */ - public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void + public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes(): void { $this->markTestSkipped('MariaDB102Platform support propagation of default values for BLOB and TEXT columns'); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php index 0587f4cde6a..301387cfe09 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySQL57PlatformTest.php @@ -8,22 +8,22 @@ class MySQL57PlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MySQL57Platform(); } - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertTrue($this->platform->hasNativeJsonType()); } - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertSame(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -34,7 +34,7 @@ public function testInitializesJsonTypeMapping() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_bar']; } @@ -44,7 +44,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER TABLE `table` RENAME INDEX `create` TO `select`', @@ -57,7 +57,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER TABLE myschema.mytable RENAME INDEX idx_foo TO idx_bar']; } @@ -67,7 +67,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER TABLE `schema`.`table` RENAME INDEX `create` TO `select`', @@ -78,7 +78,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER TABLE mytable RENAME INDEX idx_foo TO idx_foo_renamed']; } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php index e8007baf55f..b5727547915 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/MySqlPlatformTest.php @@ -8,12 +8,12 @@ class MySqlPlatformTest extends AbstractMySQLPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new MySqlPlatform(); } - public function testHasCorrectDefaultTransactionIsolationLevel() : void + public function testHasCorrectDefaultTransactionIsolationLevel(): void { self::assertEquals( TransactionIsolationLevel::REPEATABLE_READ, diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 235db34e9e0..db5b1d942e8 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -14,6 +14,7 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; + use function array_walk; use function preg_replace; use function sprintf; @@ -28,7 +29,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase /** * @return mixed[][] */ - public static function dataValidIdentifiers() : iterable + public static function dataValidIdentifiers(): iterable { return [ ['a'], @@ -46,7 +47,7 @@ public static function dataValidIdentifiers() : iterable /** * @dataProvider dataValidIdentifiers */ - public function testValidIdentifiers(string $identifier) : void + public function testValidIdentifiers(string $identifier): void { $platform = $this->createPlatform(); $platform->assertValidIdentifier($identifier); @@ -57,7 +58,7 @@ public function testValidIdentifiers(string $identifier) : void /** * @return mixed[][] */ - public static function dataInvalidIdentifiers() : iterable + public static function dataInvalidIdentifiers(): iterable { return [ ['1'], @@ -71,7 +72,7 @@ public static function dataInvalidIdentifiers() : iterable /** * @dataProvider dataInvalidIdentifiers */ - public function testInvalidIdentifiers(string $identifier) : void + public function testInvalidIdentifiers(string $identifier): void { $this->expectException(DBALException::class); @@ -82,12 +83,12 @@ public function testInvalidIdentifiers(string $identifier) : void /** * @return OraclePlatform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new OraclePlatform(); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id NUMBER(10) NOT NULL, test VARCHAR2(255) DEFAULT NULL NULL, PRIMARY KEY(id))'; } @@ -95,7 +96,7 @@ public function getGenerateTableSql() : string /** * @return mixed[] */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR2(255) DEFAULT NULL NULL, bar VARCHAR2(255) DEFAULT NULL NULL)', @@ -106,7 +107,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'ALTER TABLE mytable ADD (quota NUMBER(10) DEFAULT NULL NULL)', @@ -116,20 +117,20 @@ public function getGenerateAlterTableSql() : array ]; } - public function testRLike() : void + public function testRLike(): void { $this->expectException(DBALException::class); self::assertEquals('RLIKE', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('"', $this->platform->getIdentifierQuoteCharacter(), 'Identifier quote character is not correct'); self::assertEquals('column1 || column2 || column3', $this->platform->getConcatExpression('column1', 'column2', 'column3'), 'Concatenation expression is not correct'); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', @@ -149,24 +150,24 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testCreateDatabaseThrowsException() : void + public function testCreateDatabaseThrowsException(): void { $this->expectException(DBALException::class); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); } - public function testDropDatabaseThrowsException() : void + public function testDropDatabaseThrowsException(): void { self::assertEquals('DROP USER foobar CASCADE', $this->platform->getDropDatabaseSQL('foobar')); } - public function testDropTable() : void + public function testDropTable(): void { self::assertEquals('DROP TABLE foobar', $this->platform->getDropTableSQL('foobar')); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'NUMBER(10)', @@ -184,7 +185,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void ); } - public function testGeneratesTypeDeclarationsForStrings() : void + public function testGeneratesTypeDeclarationsForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -204,37 +205,37 @@ public function testGeneratesTypeDeclarationsForStrings() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertFalse($this->platform->prefersIdentityColumns()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertFalse($this->platform->supportsIdentityColumns()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - protected function supportsCommentOnStatement() : bool + protected function supportsCommentOnStatement(): bool { return true; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } @@ -245,7 +246,7 @@ public function getGenerateForeignKeySql() : string * @group DBAL-1097 * @dataProvider getGeneratesAdvancedForeignKeyOptionsSQLData */ - public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string $expectedSql) : void + public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string $expectedSql): void { $foreignKey = new ForeignKeyConstraint(['foo'], 'foreign_table', ['bar'], null, $options); @@ -255,7 +256,7 @@ public function testGeneratesAdvancedForeignKeyOptionsSQL(array $options, string /** * @return mixed[][] */ - public static function getGeneratesAdvancedForeignKeyOptionsSQLData() : iterable + public static function getGeneratesAdvancedForeignKeyOptionsSQLData(): iterable { return [ [[], ''], @@ -270,7 +271,7 @@ public static function getGeneratesAdvancedForeignKeyOptionsSQLData() : iterable /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -281,43 +282,43 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithNonEmptyOffset() : void + public function testModifyLimitQueryWithNonEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 10); self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a WHERE ROWNUM <= 20) WHERE doctrine_rownum >= 11', $sql); } - public function testModifyLimitQueryWithEmptyLimit() : void + public function testModifyLimitQueryWithEmptyLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10); self::assertEquals('SELECT * FROM (SELECT a.*, ROWNUM AS doctrine_rownum FROM (SELECT * FROM user) a) WHERE doctrine_rownum >= 11', $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username ASC) a WHERE ROWNUM <= 10', $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); self::assertEquals('SELECT a.* FROM (SELECT * FROM user ORDER BY username DESC) a WHERE ROWNUM <= 10', $sql); } - public function testGenerateTableWithAutoincrement() : void + public function testGenerateTableWithAutoincrement(): void { $columnName = strtoupper('id' . uniqid()); $tableName = strtoupper('table' . uniqid()); @@ -351,7 +352,7 @@ public function testGenerateTableWithAutoincrement() : void ]; $statements = $this->platform->getCreateTableSQL($table); //strip all the whitespace from the statements - array_walk($statements, static function (&$value) : void { + array_walk($statements, static function (&$value): void { $value = preg_replace('/\s+/', ' ', $value); }); foreach ($targets as $key => $sql) { @@ -363,7 +364,7 @@ public function testGenerateTableWithAutoincrement() : void /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id NUMBER(10) NOT NULL, PRIMARY KEY(id))', @@ -374,7 +375,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id NUMBER(10) NOT NULL, data CLOB NOT NULL, PRIMARY KEY(id))', @@ -385,7 +386,7 @@ public function getCreateTableColumnTypeCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD (quota NUMBER(10) NOT NULL)', @@ -395,12 +396,12 @@ public function getAlterTableColumnCommentsSQL() : array ]; } - public function getBitAndComparisonExpressionSql(string $value1, string $value2) : string + public function getBitAndComparisonExpressionSql(string $value1, string $value2): string { return 'BITAND(' . $value1 . ', ' . $value2 . ')'; } - public function getBitOrComparisonExpressionSql(string $value1, string $value2) : string + public function getBitOrComparisonExpressionSql(string $value1, string $value2): string { return '(' . $value1 . '-' . $this->getBitAndComparisonExpressionSql($value1, $value2) @@ -410,7 +411,7 @@ public function getBitOrComparisonExpressionSql(string $value1, string $value2) /** * @return mixed[] */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -418,7 +419,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * @return mixed[] */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL)', @@ -429,7 +430,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * @return mixed[] */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR2(255) NOT NULL)', @@ -440,7 +441,7 @@ protected function getQuotedNameInIndexSQL() : array /** * @return mixed[] */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR2(255) NOT NULL, foo VARCHAR2(255) NOT NULL, "bar" VARCHAR2(255) NOT NULL)', @@ -454,7 +455,7 @@ protected function getQuotedColumnInForeignKeySQL() : array * @group DBAL-472 * @group DBAL-1001 */ - public function testAlterTableNotNULL() : void + public function testAlterTableNotNULL(): void { $tableDiff = new TableDiff('mytable'); $tableDiff->changedColumns['foo'] = new ColumnDiff( @@ -492,7 +493,7 @@ public function testAlterTableNotNULL() : void /** * @group DBAL-2555 */ - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('long raw')); self::assertSame('blob', $this->platform->getDoctrineTypeMapping('long raw')); @@ -504,12 +505,12 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('date', $this->platform->getDoctrineTypeMapping('date')); } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 2000; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('RAW(255)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('RAW(2000)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -524,13 +525,13 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 2001 is greater than supported by the platform (2000). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 2001])); self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 2001])); } - public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : void + public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType(): void { $table1 = new Table('mytable'); $table1->addColumn('column_varbinary', 'binary'); @@ -550,7 +551,7 @@ public function testDoesNotPropagateUnnecessaryTableAlterationOnBinaryType() : v /** * @group DBAL-563 */ - public function testUsesSequenceEmulatedIdentityColumns() : void + public function testUsesSequenceEmulatedIdentityColumns(): void { self::assertTrue($this->platform->usesSequenceEmulatedIdentityColumns()); } @@ -559,7 +560,7 @@ public function testUsesSequenceEmulatedIdentityColumns() : void * @group DBAL-563 * @group DBAL-831 */ - public function testReturnsIdentitySequenceName() : void + public function testReturnsIdentitySequenceName(): void { self::assertSame('MYTABLE_SEQ', $this->platform->getIdentitySequenceName('mytable', 'mycolumn')); self::assertSame('"mytable_SEQ"', $this->platform->getIdentitySequenceName('"mytable"', 'mycolumn')); @@ -571,7 +572,7 @@ public function testReturnsIdentitySequenceName() : void * @dataProvider dataCreateSequenceWithCache * @group DBAL-139 */ - public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) : void + public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql): void { $sequence = new Sequence('foo', 1, 1, $cacheSize); self::assertStringContainsString($expectedSql, $this->platform->getCreateSequenceSQL($sequence)); @@ -580,7 +581,7 @@ public function testCreateSequenceWithCache(int $cacheSize, string $expectedSql) /** * @return mixed[][] */ - public static function dataCreateSequenceWithCache() : iterable + public static function dataCreateSequenceWithCache(): iterable { return [ [1, 'NOCACHE'], @@ -594,7 +595,7 @@ public static function dataCreateSequenceWithCache() : iterable * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_bar']; } @@ -604,7 +605,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" RENAME TO "select"', @@ -615,7 +616,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME COLUMN unquoted1 TO unquoted', @@ -633,7 +634,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -643,7 +644,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX myschema.idx_foo RENAME TO idx_bar']; } @@ -653,7 +654,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "schema"."create" RENAME TO "select"', @@ -661,7 +662,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array ]; } - protected function getQuotesDropForeignKeySQL() : string + protected function getQuotesDropForeignKeySQL(): string { return 'ALTER TABLE "table" DROP CONSTRAINT "select"'; } @@ -669,7 +670,7 @@ protected function getQuotesDropForeignKeySQL() : string /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -677,7 +678,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME COLUMN bar TO baz']; } @@ -688,7 +689,7 @@ public function getAlterTableRenameColumnSQL() : array * @dataProvider getReturnsDropAutoincrementSQL * @group DBAL-831 */ - public function testReturnsDropAutoincrementSQL(string $table, array $expectedSql) : void + public function testReturnsDropAutoincrementSQL(string $table, array $expectedSql): void { self::assertSame($expectedSql, $this->platform->getDropAutoincrementSql($table)); } @@ -696,7 +697,7 @@ public function testReturnsDropAutoincrementSQL(string $table, array $expectedSq /** * @return mixed[][] */ - public static function getReturnsDropAutoincrementSQL() : iterable + public static function getReturnsDropAutoincrementSQL(): iterable { return [ [ @@ -729,7 +730,7 @@ public static function getReturnsDropAutoincrementSQL() : iterable /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP CONSTRAINT fk1', @@ -747,7 +748,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -759,7 +760,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -775,7 +776,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : ); } - public function testQuotedTableNames() : void + public function testQuotedTableNames(): void { $table = new Table('"test"'); $table->addColumn('"id"', 'integer', ['autoincrement' => true]); @@ -819,7 +820,7 @@ public function testQuotedTableNames() : void * @dataProvider getReturnsGetListTableColumnsSQL * @group DBAL-831 */ - public function testReturnsGetListTableColumnsSQL(?string $database, string $expectedSql) : void + public function testReturnsGetListTableColumnsSQL(?string $database, string $expectedSql): void { // note: this assertion is a bit strict, as it compares a full SQL string. // Should this break in future, then please try to reduce the matching to substring matching while reworking @@ -830,7 +831,7 @@ public function testReturnsGetListTableColumnsSQL(?string $database, string $exp /** * @return mixed[][] */ - public static function getReturnsGetListTableColumnsSQL() : iterable + public static function getReturnsGetListTableColumnsSQL(): iterable { return [ [ @@ -884,17 +885,17 @@ public static function getReturnsGetListTableColumnsSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE "select"'; } @@ -902,7 +903,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable MODIFY (name CHAR(2) DEFAULT NULL)']; } @@ -910,7 +911,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo RENAME TO idx_foo_renamed']; } @@ -918,7 +919,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListSequencesSQL() : void + public function testQuotesDatabaseNameInListSequencesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -929,7 +930,7 @@ public function testQuotesDatabaseNameInListSequencesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -940,7 +941,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -951,7 +952,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -962,7 +963,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -973,7 +974,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesDatabaseNameInListTableColumnsSQL() : void + public function testQuotesDatabaseNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php index 0734c603017..5b1d8593fb3 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL100PlatformTest.php @@ -9,12 +9,12 @@ class PostgreSQL100PlatformTest extends PostgreSQL94PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL100Platform(); } - public function testGetListSequencesSQL() : void + public function testGetListSequencesSQL(): void { self::assertSame( "SELECT sequence_name AS relname, diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php index 3ed82529e08..563a7cc2414 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL91PlatformTest.php @@ -8,17 +8,17 @@ class PostgreSQL91PlatformTest extends PostgreSqlPlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL91Platform(); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE "en_US.UTF-8"', @@ -26,7 +26,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php index 04e9d953480..2ae9c4c6f2d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL92PlatformTest.php @@ -16,7 +16,7 @@ class PostgreSQL92PlatformTest extends AbstractPostgreSqlPlatformTestCase * * @return PostgreSQL92Platform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL92Platform(); } @@ -24,7 +24,7 @@ public function createPlatform() : AbstractPlatform /** * @group DBAL-553 */ - public function testHasNativeJsonType() : void + public function testHasNativeJsonType(): void { self::assertTrue($this->platform->hasNativeJsonType()); } @@ -32,12 +32,12 @@ public function testHasNativeJsonType() : void /** * @group DBAL-553 */ - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL([])); } - public function testReturnsSmallIntTypeDeclarationSQL() : void + public function testReturnsSmallIntTypeDeclarationSQL(): void { self::assertSame( 'SMALLSERIAL', @@ -58,7 +58,7 @@ public function testReturnsSmallIntTypeDeclarationSQL() : void /** * @group DBAL-553 */ - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('json')); self::assertEquals(Types::JSON, $this->platform->getDoctrineTypeMapping('json')); @@ -67,7 +67,7 @@ public function testInitializesJsonTypeMapping() : void /** * @group DBAL-1220 */ - public function testReturnsCloseActiveDatabaseConnectionsSQL() : void + public function testReturnsCloseActiveDatabaseConnectionsSQL(): void { self::assertSame( "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php index 36e53491848..86e2a89c487 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSQL94PlatformTest.php @@ -8,19 +8,19 @@ class PostgreSQL94PlatformTest extends PostgreSQL92PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSQL94Platform(); } - public function testReturnsJsonTypeDeclarationSQL() : void + public function testReturnsJsonTypeDeclarationSQL(): void { parent::testReturnsJsonTypeDeclarationSQL(); self::assertSame('JSON', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => false])); self::assertSame('JSONB', $this->platform->getJsonTypeDeclarationSQL(['jsonb' => true])); } - public function testInitializesJsonTypeMapping() : void + public function testInitializesJsonTypeMapping(): void { parent::testInitializesJsonTypeMapping(); self::assertTrue($this->platform->hasDoctrineTypeMappingFor('jsonb')); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php index 0b029d3497d..b4ef3b8d3b2 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/PostgreSqlPlatformTest.php @@ -8,17 +8,17 @@ class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new PostgreSqlPlatform(); } - public function testSupportsPartialIndexes() : void + public function testSupportsPartialIndexes(): void { self::assertTrue($this->platform->supportsPartialIndexes()); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('id', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php index 8d07f62274d..36340db352d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/ReservedKeywordsValidatorTest.php @@ -12,12 +12,12 @@ class ReservedKeywordsValidatorTest extends DbalTestCase /** @var ReservedKeywordsValidator */ private $validator; - protected function setUp() : void + protected function setUp(): void { $this->validator = new ReservedKeywordsValidator([new MySQLKeywords()]); } - public function testReservedTableName() : void + public function testReservedTableName(): void { $table = new Table('TABLE'); $this->validator->acceptTable($table); @@ -28,7 +28,7 @@ public function testReservedTableName() : void ); } - public function testReservedColumnName() : void + public function testReservedColumnName(): void { $table = new Table('TABLE'); $column = $table->addColumn('table', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php index bf3f7372df3..d899b32d018 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere11PlatformTest.php @@ -10,17 +10,17 @@ class SQLAnywhere11PlatformTest extends SQLAnywherePlatformTest /** @var SQLAnywhere11Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere11Platform(); } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->markTestSkipped('This version of the platform now supports regular expressions.'); } - public function testGeneratesRegularExpressionSQLSnippet() : void + public function testGeneratesRegularExpressionSQLSnippet(): void { self::assertEquals('REGEXP', $this->platform->getRegexpExpression()); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php index 5e2882a9168..221fa82f612 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere12PlatformTest.php @@ -12,22 +12,22 @@ class SQLAnywhere12PlatformTest extends SQLAnywhere11PlatformTest /** @var SQLAnywhere12Platform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere12Platform(); } - public function testDoesNotSupportSequences() : void + public function testDoesNotSupportSequences(): void { $this->markTestSkipped('This version of the platform now supports sequences.'); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -56,7 +56,7 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() : void + public function testGeneratesDateTimeTzColumnTypeDeclarationSQL(): void { self::assertEquals( 'TIMESTAMP WITH TIME ZONE', @@ -69,18 +69,18 @@ public function testGeneratesDateTimeTzColumnTypeDeclarationSQL() : void ); } - public function testHasCorrectDateTimeTzFormatString() : void + public function testHasCorrectDateTimeTzFormatString(): void { self::assertEquals('Y-m-d H:i:s.uP', $this->platform->getDateTimeTzFormatString()); } - public function testInitializesDateTimeTzTypeMapping() : void + public function testInitializesDateTimeTzTypeMapping(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('timestamp with time zone')); self::assertEquals('datetime', $this->platform->getDoctrineTypeMapping('timestamp with time zone')); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) WITH NULLS NOT DISTINCT FOR OLAP WORKLOAD', diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php index a6a0018a06e..e0c4a24a21a 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywhere16PlatformTest.php @@ -8,12 +8,12 @@ class SQLAnywhere16PlatformTest extends SQLAnywhere12PlatformTest { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywhere16Platform(); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE UNIQUE INDEX fooindex ON footable (a, b) WITH NULLS DISTINCT', @@ -62,7 +62,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void parent::testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(); } - public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions() : void + public function testThrowsExceptionOnInvalidWithNullsNotDistinctIndexOptions(): void { $this->expectException('UnexpectedValueException'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index a1ce2134336..7f6c059a731 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -18,6 +18,7 @@ use Doctrine\DBAL\TransactionIsolationLevel; use Doctrine\DBAL\Types\Type; use InvalidArgumentException; + use function mt_rand; use function strlen; use function substr; @@ -27,7 +28,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase /** @var SQLAnywherePlatform */ protected $platform; - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLAnywherePlatform(); } @@ -35,7 +36,7 @@ public function createPlatform() : AbstractPlatform /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ "ALTER TABLE mytable ADD quota INT DEFAULT NULL, DROP foo, ALTER baz VARCHAR(1) DEFAULT 'def' NOT NULL, ALTER bloo BIT DEFAULT '0' NOT NULL", @@ -43,17 +44,17 @@ public function getGenerateAlterTableSql() : array ]; } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)'; } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INT IDENTITY NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY (id))'; } @@ -61,7 +62,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -69,7 +70,7 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } @@ -77,7 +78,7 @@ public function getGenerateUniqueIndexSql() : string /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, foo VARCHAR(255) NOT NULL, "bar" VARCHAR(255) NOT NULL, CONSTRAINT FK_WITH_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES "foreign" ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_NON_RESERVED_KEYWORD FOREIGN KEY ("create", foo, "bar") REFERENCES foo ("create", bar, "foo-bar"), CONSTRAINT FK_WITH_INTENDED_QUOTATION FOREIGN KEY ("create", foo, "bar") REFERENCES "foo-bar" ("create", bar, "foo-bar"))']; } @@ -85,7 +86,7 @@ protected function getQuotedColumnInForeignKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -96,7 +97,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -107,7 +108,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY ("create"))']; } @@ -115,7 +116,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnCommentsSQL() : array + public function getCreateTableColumnCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, PRIMARY KEY (id))', @@ -126,7 +127,7 @@ public function getCreateTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getAlterTableColumnCommentsSQL() : array + public function getAlterTableColumnCommentsSQL(): array { return [ 'ALTER TABLE mytable ADD quota INT NOT NULL', @@ -139,7 +140,7 @@ public function getAlterTableColumnCommentsSQL() : array /** * {@inheritDoc} */ - public function getCreateTableColumnTypeCommentsSQL() : array + public function getCreateTableColumnTypeCommentsSQL(): array { return [ 'CREATE TABLE test (id INT NOT NULL, data TEXT NOT NULL, PRIMARY KEY (id))', @@ -147,12 +148,12 @@ public function getCreateTableColumnTypeCommentsSQL() : array ]; } - public function testHasCorrectPlatformName() : void + public function testHasCorrectPlatformName(): void { self::assertEquals('sqlanywhere', $this->platform->getName()); } - public function testGeneratesCreateTableSQLWithCommonIndexes() : void + public function testGeneratesCreateTableSQLWithCommonIndexes(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -171,7 +172,7 @@ public function testGeneratesCreateTableSQLWithCommonIndexes() : void ); } - public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void + public function testGeneratesCreateTableSQLWithForeignKeyConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -196,7 +197,7 @@ public function testGeneratesCreateTableSQLWithForeignKeyConstraints() : void ); } - public function testGeneratesCreateTableSQLWithCheckConstraints() : void + public function testGeneratesCreateTableSQLWithCheckConstraints(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -210,7 +211,7 @@ public function testGeneratesCreateTableSQLWithCheckConstraints() : void ); } - public function testGeneratesTableAlterationWithRemovedColumnCommentSql() : void + public function testGeneratesTableAlterationWithRemovedColumnCommentSql(): void { $table = new Table('mytable'); $table->addColumn('foo', 'string', ['comment' => 'foo comment']); @@ -234,7 +235,7 @@ public function testGeneratesTableAlterationWithRemovedColumnCommentSql() : void * * @dataProvider getLockHints */ - public function testAppendsLockHint($lockMode, string $lockHint) : void + public function testAppendsLockHint($lockMode, string $lockHint): void { $fromClause = 'FROM users'; $expectedResult = $fromClause . $lockHint; @@ -245,7 +246,7 @@ public function testAppendsLockHint($lockMode, string $lockHint) : void /** * @return mixed[][] */ - public static function getLockHints() : iterable + public static function getLockHints(): iterable { return [ [null, ''], @@ -258,12 +259,12 @@ public static function getLockHints() : iterable ]; } - public function testHasCorrectMaxIdentifierLength() : void + public function testHasCorrectMaxIdentifierLength(): void { self::assertEquals(128, $this->platform->getMaxIdentifierLength()); } - public function testFixesSchemaElementNames() : void + public function testFixesSchemaElementNames(): void { $maxIdentifierLength = $this->platform->getMaxIdentifierLength(); $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; @@ -285,7 +286,7 @@ public function testFixesSchemaElementNames() : void ); } - public function testGeneratesColumnTypesDeclarationSQL() : void + public function testGeneratesColumnTypesDeclarationSQL(): void { $fullColumnDef = [ 'length' => 10, @@ -315,12 +316,12 @@ public function testGeneratesColumnTypesDeclarationSQL() : void self::assertEquals(32767, $this->platform->getVarcharMaxLength()); } - public function testHasNativeGuidType() : void + public function testHasNativeGuidType(): void { self::assertTrue($this->platform->hasNativeGuidType()); } - public function testGeneratesDDLSnippets() : void + public function testGeneratesDDLSnippets(): void { self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('foobar')); self::assertEquals("CREATE DATABASE 'foobar'", $this->platform->getCreateDatabaseSQL('"foobar"')); @@ -343,7 +344,7 @@ public function testGeneratesDDLSnippets() : void self::assertEquals('DROP VIEW fooview', $this->platform->getDropViewSQL('fooview')); } - public function testGeneratesPrimaryKeyDeclarationSQL() : void + public function testGeneratesPrimaryKeyDeclarationSQL(): void { self::assertEquals( 'CONSTRAINT pk PRIMARY KEY CLUSTERED (a, b)', @@ -360,14 +361,14 @@ public function testGeneratesPrimaryKeyDeclarationSQL() : void ); } - public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns() : void + public function testCannotGeneratePrimaryKeyDeclarationSQLWithEmptyColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getPrimaryKeyDeclarationSQL(new Index('pk', [], true, true)); } - public function testGeneratesCreateUnnamedPrimaryKeySQL() : void + public function testGeneratesCreateUnnamedPrimaryKeySQL(): void { self::assertEquals( 'ALTER TABLE foo ADD PRIMARY KEY CLUSTERED (a, b)', @@ -385,7 +386,7 @@ public function testGeneratesCreateUnnamedPrimaryKeySQL() : void ); } - public function testGeneratesUniqueConstraintDeclarationSQL() : void + public function testGeneratesUniqueConstraintDeclarationSQL(): void { self::assertEquals( 'CONSTRAINT unique_constraint UNIQUE CLUSTERED (a, b)', @@ -400,14 +401,14 @@ public function testGeneratesUniqueConstraintDeclarationSQL() : void ); } - public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns() : void + public function testCannotGenerateUniqueConstraintDeclarationSQLWithEmptyColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getUniqueConstraintDeclarationSQL('constr', new Index('constr', [], true)); } - public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CONSTRAINT fk ' . @@ -434,7 +435,7 @@ public function testGeneratesForeignKeyConstraintsWithAdvancedPlatformOptionsSQL ); } - public function testGeneratesForeignKeyMatchClausesSQL() : void + public function testGeneratesForeignKeyMatchClausesSQL(): void { self::assertEquals('SIMPLE', $this->platform->getForeignKeyMatchClauseSQL(1)); self::assertEquals('FULL', $this->platform->getForeignKeyMatchClauseSQL(2)); @@ -442,46 +443,46 @@ public function testGeneratesForeignKeyMatchClausesSQL() : void self::assertEquals('UNIQUE FULL', $this->platform->getForeignKeyMatchClauseSQL(130)); } - public function testCannotGenerateInvalidForeignKeyMatchClauseSQL() : void + public function testCannotGenerateInvalidForeignKeyMatchClauseSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyMatchCLauseSQL(3); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyLocalColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint([], 'foreign_tbl', ['c', 'd'])); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignColumns(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], 'foreign_tbl', [])); } - public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName() : void + public function testCannotGenerateForeignKeyConstraintSQLWithEmptyForeignTableName(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getForeignKeyDeclarationSQL(new ForeignKeyConstraint(['a', 'b'], '', ['c', 'd'])); } - public function testCannotGenerateCommonIndexWithCreateConstraintSQL() : void + public function testCannotGenerateCommonIndexWithCreateConstraintSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getCreateConstraintSQL(new Index('fooindex', []), new Table('footable')); } - public function testCannotGenerateCustomConstraintWithCreateConstraintSQL() : void + public function testCannotGenerateCustomConstraintWithCreateConstraintSQL(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getCreateConstraintSQL($this->createMock(Constraint::class), 'footable'); } - public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void + public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void { self::assertEquals( 'CREATE VIRTUAL UNIQUE CLUSTERED INDEX fooindex ON footable (a, b) FOR OLAP WORKLOAD', @@ -498,14 +499,14 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL() : void ); } - public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements() : void + public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements(): void { $this->expectException(DBALException::class); $this->platform->getIndexDeclarationSQL('index', new Index('index', [])); } - public function testGeneratesDropIndexSQL() : void + public function testGeneratesDropIndexSQL(): void { $index = new Index('fooindex', []); @@ -520,7 +521,7 @@ public function testGeneratesDropIndexSQL() : void /** * @psalm-suppress InvalidArgument */ - public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void + public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter(): void { $this->expectException(InvalidArgumentException::class); @@ -530,14 +531,14 @@ public function testCannotGenerateDropIndexSQLWithInvalidIndexParameter() : void /** * @psalm-suppress InvalidArgument */ - public function testCannotGenerateDropIndexSQLWithInvalidTableParameter() : void + public function testCannotGenerateDropIndexSQLWithInvalidTableParameter(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getDropIndexSQL('index', ['table']); } - public function testGeneratesSQLSnippets() : void + public function testGeneratesSQLSnippets(): void { self::assertEquals('STRING(column1, "string1", column2, "string2")', $this->platform->getConcatExpression( 'column1', @@ -611,14 +612,14 @@ public function testGeneratesSQLSnippets() : void ); } - public function testDoesNotSupportRegexp() : void + public function testDoesNotSupportRegexp(): void { $this->expectException(DBALException::class); $this->platform->getRegexpExpression(); } - public function testHasCorrectDateTimeTzFormatString() : void + public function testHasCorrectDateTimeTzFormatString(): void { // Date time type with timezone is not supported before version 12. // For versions before we have to ensure that the date time with timezone format @@ -626,7 +627,7 @@ public function testHasCorrectDateTimeTzFormatString() : void self::assertEquals($this->platform->getDateTimeFormatString(), $this->platform->getDateTimeTzFormatString()); } - public function testHasCorrectDefaultTransactionIsolationLevel() : void + public function testHasCorrectDefaultTransactionIsolationLevel(): void { self::assertEquals( TransactionIsolationLevel::READ_UNCOMMITTED, @@ -634,7 +635,7 @@ public function testHasCorrectDefaultTransactionIsolationLevel() : void ); } - public function testGeneratesTransactionsCommands() : void + public function testGeneratesTransactionsCommands(): void { self::assertEquals( 'SET TEMPORARY OPTION isolation_level = 0', @@ -654,14 +655,14 @@ public function testGeneratesTransactionsCommands() : void ); } - public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel() : void + public function testCannotGenerateTransactionCommandWithInvalidIsolationLevel(): void { $this->expectException(InvalidArgumentException::class); $this->platform->getSetTransactionIsolationSQL('invalid_transaction_isolation_level'); } - public function testModifiesLimitQuery() : void + public function testModifiesLimitQuery(): void { self::assertEquals( 'SELECT TOP 10 * FROM user', @@ -669,7 +670,7 @@ public function testModifiesLimitQuery() : void ); } - public function testModifiesLimitQueryWithEmptyOffset() : void + public function testModifiesLimitQueryWithEmptyOffset(): void { self::assertEquals( 'SELECT TOP 10 * FROM user', @@ -677,7 +678,7 @@ public function testModifiesLimitQueryWithEmptyOffset() : void ); } - public function testModifiesLimitQueryWithOffset() : void + public function testModifiesLimitQueryWithOffset(): void { self::assertEquals( 'SELECT TOP 10 START AT 6 * FROM user', @@ -689,7 +690,7 @@ public function testModifiesLimitQueryWithOffset() : void ); } - public function testModifiesLimitQueryWithSubSelect() : void + public function testModifiesLimitQueryWithSubSelect(): void { self::assertEquals( 'SELECT TOP 10 * FROM (SELECT u.id as uid, u.name as uname FROM user) AS doctrine_tbl', @@ -697,7 +698,7 @@ public function testModifiesLimitQueryWithSubSelect() : void ); } - public function testModifiesLimitQueryWithoutLimit() : void + public function testModifiesLimitQueryWithoutLimit(): void { self::assertEquals( 'SELECT TOP ALL START AT 11 n FROM Foo', @@ -705,97 +706,97 @@ public function testModifiesLimitQueryWithoutLimit() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testDoesNotPreferSequences() : void + public function testDoesNotPreferSequences(): void { self::assertFalse($this->platform->prefersSequences()); } - public function testSupportsIdentityColumns() : void + public function testSupportsIdentityColumns(): void { self::assertTrue($this->platform->supportsIdentityColumns()); } - public function testSupportsPrimaryConstraints() : void + public function testSupportsPrimaryConstraints(): void { self::assertTrue($this->platform->supportsPrimaryConstraints()); } - public function testSupportsForeignKeyConstraints() : void + public function testSupportsForeignKeyConstraints(): void { self::assertTrue($this->platform->supportsForeignKeyConstraints()); } - public function testSupportsForeignKeyOnUpdate() : void + public function testSupportsForeignKeyOnUpdate(): void { self::assertTrue($this->platform->supportsForeignKeyOnUpdate()); } - public function testSupportsAlterTable() : void + public function testSupportsAlterTable(): void { self::assertTrue($this->platform->supportsAlterTable()); } - public function testSupportsTransactions() : void + public function testSupportsTransactions(): void { self::assertTrue($this->platform->supportsTransactions()); } - public function testSupportsSchemas() : void + public function testSupportsSchemas(): void { self::assertFalse($this->platform->supportsSchemas()); } - public function testSupportsIndexes() : void + public function testSupportsIndexes(): void { self::assertTrue($this->platform->supportsIndexes()); } - public function testSupportsCommentOnStatement() : void + public function testSupportsCommentOnStatement(): void { self::assertTrue($this->platform->supportsCommentOnStatement()); } - public function testSupportsSavePoints() : void + public function testSupportsSavePoints(): void { self::assertTrue($this->platform->supportsSavepoints()); } - public function testSupportsReleasePoints() : void + public function testSupportsReleasePoints(): void { self::assertTrue($this->platform->supportsReleaseSavepoints()); } - public function testSupportsCreateDropDatabase() : void + public function testSupportsCreateDropDatabase(): void { self::assertTrue($this->platform->supportsCreateDropDatabase()); } - public function testSupportsGettingAffectedRows() : void + public function testSupportsGettingAffectedRows(): void { self::assertTrue($this->platform->supportsGettingAffectedRows()); } - public function testDoesNotSupportSequences() : void + public function testDoesNotSupportSequences(): void { self::assertFalse($this->platform->supportsSequences()); } - public function testDoesNotSupportInlineColumnComments() : void + public function testDoesNotSupportInlineColumnComments(): void { self::assertFalse($this->platform->supportsInlineColumnComments()); } - public function testCannotEmulateSchemas() : void + public function testCannotEmulateSchemas(): void { self::assertFalse($this->platform->canEmulateSchemas()); } - public function testInitializesDoctrineTypeMappings() : void + public function testInitializesDoctrineTypeMappings(): void { self::assertTrue($this->platform->hasDoctrineTypeMappingFor('integer')); self::assertSame('integer', $this->platform->getDoctrineTypeMapping('integer')); @@ -807,17 +808,17 @@ public function testInitializesDoctrineTypeMappings() : void self::assertSame('binary', $this->platform->getDoctrineTypeMapping('varbinary')); } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 1; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 32767; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('VARBINARY(1)', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -832,7 +833,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * @group legacy * @expectedDeprecation Binary field length 32768 is greater than supported by the platform (32767). Reduce the field length or use a BLOB field instead. */ - public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void + public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL(): void { self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['length' => 32768])); self::assertSame('LONG BINARY', $this->platform->getBinaryTypeDeclarationSQL(['fixed' => true, 'length' => 32768])); @@ -843,7 +844,7 @@ public function testReturnsBinaryTypeLongerThanMaxDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_bar']; } @@ -853,7 +854,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'ALTER INDEX "create" ON "table" RENAME TO "select"', @@ -864,7 +865,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'ALTER TABLE mytable RENAME unquoted1 TO unquoted', @@ -882,7 +883,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { $this->markTestIncomplete('Not implemented yet'); } @@ -892,7 +893,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array * * @group DBAL-807 */ - protected function getAlterTableRenameIndexInSchemaSQL() : array + protected function getAlterTableRenameIndexInSchemaSQL(): array { return ['ALTER INDEX idx_foo ON myschema.mytable RENAME TO idx_bar']; } @@ -902,7 +903,7 @@ protected function getAlterTableRenameIndexInSchemaSQL() : array * * @group DBAL-807 */ - protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array + protected function getQuotedAlterTableRenameIndexInSchemaSQL(): array { return [ 'ALTER INDEX "create" ON "schema"."table" RENAME TO "select"', @@ -913,7 +914,7 @@ protected function getQuotedAlterTableRenameIndexInSchemaSQL() : array /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('UNIQUEIDENTIFIER', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -921,7 +922,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return ['ALTER TABLE foo RENAME bar TO baz']; } @@ -929,7 +930,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'ALTER TABLE "foo" DROP FOREIGN KEY fk1', @@ -945,7 +946,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -957,7 +958,7 @@ protected function getCommentOnColumnSQL() : array /** * @group DBAL-1004 */ - public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : void + public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers(): void { $table1 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'))]); $table2 = new Table('"foo"', [new Column('"bar"', Type::getType('integer'), ['comment' => 'baz'])]); @@ -976,7 +977,7 @@ public function testAltersTableColumnCommentWithExplicitlyQuotedIdentifiers() : /** * {@inheritdoc} */ - public static function getReturnsForeignKeyReferentialActionSQL() : iterable + public static function getReturnsForeignKeyReferentialActionSQL(): iterable { return [ ['CASCADE', 'CASCADE'], @@ -988,22 +989,22 @@ public static function getReturnsForeignKeyReferentialActionSQL() : iterable ]; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return ''; // not supported by this platform } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'TRUNCATE TABLE "select"'; } - protected function supportsInlineIndexDeclaration() : bool + protected function supportsInlineIndexDeclaration(): bool { return false; } @@ -1011,7 +1012,7 @@ protected function supportsInlineIndexDeclaration() : bool /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return ['ALTER TABLE mytable ALTER name CHAR(2) NOT NULL']; } @@ -1019,7 +1020,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return ['ALTER INDEX idx_foo ON mytable RENAME TO idx_foo_renamed']; } @@ -1027,7 +1028,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableColumnsSQL() : void + public function testQuotesSchemaNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1038,7 +1039,7 @@ public function testQuotesSchemaNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true); } @@ -1046,7 +1047,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableConstraintsSQL() : void + public function testQuotesSchemaNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1057,7 +1058,7 @@ public function testQuotesSchemaNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1068,7 +1069,7 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableForeignKeysSQL() : void + public function testQuotesSchemaNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1079,7 +1080,7 @@ public function testQuotesSchemaNameInListTableForeignKeysSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -1090,7 +1091,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesSchemaNameInListTableIndexesSQL() : void + public function testQuotesSchemaNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php index 65b5e85f219..81c38139686 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAzurePlatformTest.php @@ -14,12 +14,12 @@ class SQLAzurePlatformTest extends DbalTestCase /** @var SQLAzurePlatform */ private $platform; - protected function setUp() : void + protected function setUp(): void { $this->platform = new SQLAzurePlatform(); } - public function testCreateFederatedOnTable() : void + public function testCreateFederatedOnTable(): void { $table = new Table('tbl'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php index 60abcad7c06..17477909061 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2008PlatformTest.php @@ -7,12 +7,12 @@ class SQLServer2008PlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServer2008Platform(); } - public function testGeneratesTypeDeclarationForDateTimeTz() : void + public function testGeneratesTypeDeclarationForDateTimeTz(): void { self::assertEquals('DATETIMEOFFSET(6)', $this->platform->getDateTimeTzTypeDeclarationSQL([])); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php index e6d4975daed..0004c65fdad 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -9,22 +9,22 @@ class SQLServer2012PlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServer2012Platform(); } - public function testSupportsSequences() : void + public function testSupportsSequences(): void { self::assertTrue($this->platform->supportsSequences()); } - public function testDoesNotPreferSequences() : void + public function testDoesNotPreferSequences(): void { self::assertFalse($this->platform->prefersSequences()); } - public function testGeneratesSequenceSqlCommands() : void + public function testGeneratesSequenceSqlCommands(): void { $sequence = new Sequence('myseq', 20, 1); self::assertEquals( @@ -45,55 +45,55 @@ public function testGeneratesSequenceSqlCommands() : void ); } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithOffset() : void + public function testModifyLimitQueryWithOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5); self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithAscOrderBy() : void + public function testModifyLimitQueryWithAscOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username ASC', 10); self::assertEquals('SELECT * FROM user ORDER BY username ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithLowercaseOrderBy() : void + public function testModifyLimitQueryWithLowercaseOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user order by username', 10); self::assertEquals('SELECT * FROM user order by username OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithDescOrderBy() : void + public function testModifyLimitQueryWithDescOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10); self::assertEquals('SELECT * FROM user ORDER BY username DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithMultipleOrderBy() : void + public function testModifyLimitQueryWithMultipleOrderBy(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC, usereamil ASC', 10); self::assertEquals('SELECT * FROM user ORDER BY username DESC, usereamil ASC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelect() : void + public function testModifyLimitQueryWithSubSelect(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result', 10); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelectAndOrder() : void + public function testModifyLimitQueryWithSubSelectAndOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC', 10); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -102,7 +102,7 @@ public function testModifyLimitQueryWithSubSelectAndOrder() : void self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void + public function testModifyLimitQueryWithSubSelectAndMultipleOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC', 10, 5); self::assertEquals('SELECT * FROM (SELECT u.id as uid, u.name as uname) dctrn_result ORDER BY uname DESC, uid ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -114,7 +114,7 @@ public function testModifyLimitQueryWithSubSelectAndMultipleOrder() : void self::assertEquals('SELECT * FROM (SELECT u.id, u.name) dctrn_result ORDER BY name DESC, id ASC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY', $sql); } - public function testModifyLimitQueryWithFromColumnNames() : void + public function testModifyLimitQueryWithFromColumnNames(): void { $sql = $this->platform->modifyLimitQuery('SELECT a.fromFoo, fromBar FROM foo', 10); self::assertEquals('SELECT a.fromFoo, fromBar FROM foo ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', $sql); @@ -123,7 +123,7 @@ public function testModifyLimitQueryWithFromColumnNames() : void /** * @group DBAL-927 */ - public function testModifyLimitQueryWithExtraLongQuery() : void + public function testModifyLimitQueryWithExtraLongQuery(): void { $query = 'SELECT table1.column1, table2.column2, table3.column3, table4.column4, table5.column5, table6.column6, table7.column7, table8.column8 FROM table1, table2, table3, table4, table5, table6, table7, table8 '; $query .= 'WHERE (table1.column1 = table2.column2) AND (table1.column1 = table3.column3) AND (table1.column1 = table4.column4) AND (table1.column1 = table5.column5) AND (table1.column1 = table6.column6) AND (table1.column1 = table7.column7) AND (table1.column1 = table8.column8) AND (table2.column2 = table3.column3) AND (table2.column2 = table4.column4) AND (table2.column2 = table5.column5) AND (table2.column2 = table6.column6) '; @@ -144,7 +144,7 @@ public function testModifyLimitQueryWithExtraLongQuery() : void /** * @group DDC-2470 */ - public function testModifyLimitQueryWithOrderByClause() : void + public function testModifyLimitQueryWithOrderByClause(): void { $sql = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC'; $expected = 'SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2 FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ? ORDER BY m0_.FECHAINICIO DESC OFFSET 5 ROWS FETCH NEXT 10 ROWS ONLY'; @@ -156,7 +156,7 @@ public function testModifyLimitQueryWithOrderByClause() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectList() : void + public function testModifyLimitQueryWithSubSelectInSelectList(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -185,7 +185,7 @@ public function testModifyLimitQueryWithSubSelectInSelectList() : void /** * @group DBAL-713 */ - public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() : void + public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -217,7 +217,7 @@ public function testModifyLimitQueryWithSubSelectInSelectListAndOrderByClause() /** * @group DBAL-834 */ - public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : void + public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void { $sql = $this->platform->modifyLimitQuery( 'SELECT ' . @@ -242,7 +242,7 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause() : voi ); } - public function testModifyLimitQueryWithFromSubquery() : void + public function testModifyLimitQueryWithFromSubquery(): void { $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0 FROM (SELECT k0_.id AS id_0 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result', 10); @@ -251,7 +251,7 @@ public function testModifyLimitQueryWithFromSubquery() : void self::assertEquals($sql, $expected); } - public function testModifyLimitQueryWithFromSubqueryAndOrder() : void + public function testModifyLimitQueryWithFromSubqueryAndOrder(): void { $sql = $this->platform->modifyLimitQuery('SELECT DISTINCT id_0, value_1 FROM (SELECT k0_.id AS id_0, k0_.value AS value_1 FROM key_measure k0_ WHERE (k0_.id_zone in(2))) dctrn_result ORDER BY value_1 DESC', 10); @@ -260,7 +260,7 @@ public function testModifyLimitQueryWithFromSubqueryAndOrder() : void self::assertEquals($sql, $expected); } - public function testModifyLimitQueryWithComplexOrderByExpression() : void + public function testModifyLimitQueryWithComplexOrderByExpression(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM table ORDER BY (table.x * table.y) DESC', 10); @@ -272,7 +272,7 @@ public function testModifyLimitQueryWithComplexOrderByExpression() : void /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -295,7 +295,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' . 'FROM (' @@ -318,7 +318,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi /** * @throws DBALException */ - public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables() : void + public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' . 'FROM (' @@ -338,7 +338,7 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBo self::assertEquals($alteredSql, $sql); } - public function testModifyLimitSubquerySimple() : void + public function testModifyLimitSubquerySimple(): void { $querySql = 'SELECT DISTINCT id_0 FROM ' . '(SELECT k0_.id AS id_0, k0_.field AS field_1 ' @@ -349,7 +349,7 @@ public function testModifyLimitSubquerySimple() : void self::assertEquals($alteredSql, $sql); } - public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void + public function testModifyLimitQueryWithTopNSubQueryWithOrderBy(): void { $querySql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC)'; $expectedSql = 'SELECT * FROM test t WHERE t.id = (SELECT TOP 1 t2.id FROM test t2 ORDER BY t2.data DESC) ORDER BY (SELECT 0) OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY'; @@ -362,7 +362,7 @@ public function testModifyLimitQueryWithTopNSubQueryWithOrderBy() : void self::assertEquals($expectedSql, $sql); } - public function testModifyLimitQueryWithNewlineBeforeOrderBy() : void + public function testModifyLimitQueryWithNewlineBeforeOrderBy(): void { $querySql = "SELECT * FROM test\nORDER BY col DESC"; $expectedSql = "SELECT * FROM test\nORDER BY col DESC OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY"; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php index 77cf7b17b41..0ff64ba7111 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServerPlatformTest.php @@ -8,7 +8,7 @@ class SQLServerPlatformTest extends AbstractSQLServerPlatformTestCase { - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SQLServerPlatform(); } @@ -19,7 +19,7 @@ public function createPlatform() : AbstractPlatform * @group DDC-2310 * @dataProvider getLockHints */ - public function testAppendsLockHint($lockMode, string $lockHint) : void + public function testAppendsLockHint($lockMode, string $lockHint): void { $fromClause = 'FROM users'; $expectedResult = $fromClause . $lockHint; @@ -31,7 +31,7 @@ public function testAppendsLockHint($lockMode, string $lockHint) : void * @group DBAL-2408 * @dataProvider getModifyLimitQueries */ - public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, string $expectedResult) : void + public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, string $expectedResult): void { self::assertSame($expectedResult, $this->platform->modifyLimitQuery($query, $limit, $offset)); } @@ -39,7 +39,7 @@ public function testScrubInnerOrderBy(string $query, int $limit, ?int $offset, s /** * @return mixed[][] */ - public static function getLockHints() : iterable + public static function getLockHints(): iterable { return [ [null, ''], @@ -55,7 +55,7 @@ public static function getLockHints() : iterable /** * @return mixed[][] */ - public static function getModifyLimitQueries() : iterable + public static function getModifyLimitQueries(): iterable { return [ // Test re-ordered query with correctly-scrubbed ORDER BY clause diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 74b87deabf0..86af15396bc 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -19,12 +19,12 @@ class SqlitePlatformTest extends AbstractPlatformTestCase /** * @return SqlitePlatform */ - public function createPlatform() : AbstractPlatform + public function createPlatform(): AbstractPlatform { return new SqlitePlatform(); } - public function getGenerateTableSql() : string + public function getGenerateTableSql(): string { return 'CREATE TABLE test (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, test VARCHAR(255) DEFAULT NULL)'; } @@ -32,7 +32,7 @@ public function getGenerateTableSql() : string /** * {@inheritDoc} */ - public function getGenerateTableWithMultiColumnUniqueIndexSql() : array + public function getGenerateTableWithMultiColumnUniqueIndexSql(): array { return [ 'CREATE TABLE test (foo VARCHAR(255) DEFAULT NULL, bar VARCHAR(255) DEFAULT NULL)', @@ -40,14 +40,14 @@ public function getGenerateTableWithMultiColumnUniqueIndexSql() : array ]; } - public function testGeneratesSqlSnippets() : void + public function testGeneratesSqlSnippets(): void { self::assertEquals('REGEXP', $this->platform->getRegexpExpression(), 'Regular expression operator is not correct'); self::assertEquals('SUBSTR(column, 5, LENGTH(column))', $this->platform->getSubstringExpression('column', 5), 'Substring expression without length is not correct'); self::assertEquals('SUBSTR(column, 0, 5)', $this->platform->getSubstringExpression('column', 0, 5), 'Substring expression with length is not correct'); } - public function testGeneratesTransactionCommands() : void + public function testGeneratesTransactionCommands(): void { self::assertEquals( 'PRAGMA read_uncommitted = 0', @@ -67,12 +67,12 @@ public function testGeneratesTransactionCommands() : void ); } - public function testPrefersIdentityColumns() : void + public function testPrefersIdentityColumns(): void { self::assertTrue($this->platform->prefersIdentityColumns()); } - public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers() : void + public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers(): void { self::assertSame( 'INTEGER PRIMARY KEY AUTOINCREMENT', @@ -84,7 +84,7 @@ public function testIgnoresUnsignedIntegerDeclarationForAutoIncrementalIntegers( * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForTinyIntegers() : void + public function testGeneratesTypeDeclarationForTinyIntegers(): void { self::assertEquals( 'TINYINT', @@ -114,7 +114,7 @@ public function testGeneratesTypeDeclarationForTinyIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForSmallIntegers() : void + public function testGeneratesTypeDeclarationForSmallIntegers(): void { self::assertEquals( 'SMALLINT', @@ -148,7 +148,7 @@ public function testGeneratesTypeDeclarationForSmallIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForMediumIntegers() : void + public function testGeneratesTypeDeclarationForMediumIntegers(): void { self::assertEquals( 'MEDIUMINT', @@ -178,7 +178,7 @@ public function testGeneratesTypeDeclarationForMediumIntegers() : void ); } - public function testGeneratesTypeDeclarationForIntegers() : void + public function testGeneratesTypeDeclarationForIntegers(): void { self::assertEquals( 'INTEGER', @@ -212,7 +212,7 @@ public function testGeneratesTypeDeclarationForIntegers() : void * @group DBAL-752 * @group DBAL-924 */ - public function testGeneratesTypeDeclarationForBigIntegers() : void + public function testGeneratesTypeDeclarationForBigIntegers(): void { self::assertEquals( 'BIGINT', @@ -242,7 +242,7 @@ public function testGeneratesTypeDeclarationForBigIntegers() : void ); } - public function testGeneratesTypeDeclarationForStrings() : void + public function testGeneratesTypeDeclarationForStrings(): void { self::assertEquals( 'CHAR(10)', @@ -262,48 +262,48 @@ public function testGeneratesTypeDeclarationForStrings() : void ); } - public function getGenerateIndexSql() : string + public function getGenerateIndexSql(): string { return 'CREATE INDEX my_idx ON mytable (user_name, last_login)'; } - public function getGenerateUniqueIndexSql() : string + public function getGenerateUniqueIndexSql(): string { return 'CREATE UNIQUE INDEX index_name ON test (test, test2)'; } - public function testGeneratesForeignKeyCreationSql() : void + public function testGeneratesForeignKeyCreationSql(): void { $this->expectException(DBALException::class); parent::testGeneratesForeignKeyCreationSql(); } - public function testGeneratesConstraintCreationSql() : void + public function testGeneratesConstraintCreationSql(): void { $this->expectException(DBALException::class); parent::testGeneratesConstraintCreationSql(); } - public function getGenerateForeignKeySql() : string + public function getGenerateForeignKeySql(): string { return null; } - public function testModifyLimitQuery() : void + public function testModifyLimitQuery(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10, 0); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithEmptyOffset() : void + public function testModifyLimitQueryWithEmptyOffset(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', 10); self::assertEquals('SELECT * FROM user LIMIT 10', $sql); } - public function testModifyLimitQueryWithOffsetAndEmptyLimit() : void + public function testModifyLimitQueryWithOffsetAndEmptyLimit(): void { $sql = $this->platform->modifyLimitQuery('SELECT * FROM user', null, 10); self::assertEquals('SELECT * FROM user LIMIT -1 OFFSET 10', $sql); @@ -312,7 +312,7 @@ public function testModifyLimitQueryWithOffsetAndEmptyLimit() : void /** * {@inheritDoc} */ - public function getGenerateAlterTableSql() : array + public function getGenerateAlterTableSql(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id, bar, bloo FROM mytable', @@ -327,7 +327,7 @@ public function getGenerateAlterTableSql() : array /** * @group DDC-1845 */ - public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() : void + public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey(): void { $table = new Table('test'); $table->addColumn('"like"', 'integer', ['notnull' => true, 'autoincrement' => true]); @@ -340,7 +340,7 @@ public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey() : void ); } - public function testAlterTableAddColumns() : void + public function testAlterTableAddColumns(): void { $diff = new TableDiff('user'); $diff->addedColumns['foo'] = new Column('foo', Type::getType('string')); @@ -357,7 +357,7 @@ public function testAlterTableAddColumns() : void /** * @dataProvider complexDiffProvider */ - public function testAlterTableAddComplexColumns(TableDiff $diff) : void + public function testAlterTableAddComplexColumns(TableDiff $diff): void { $this->expectException(DBALException::class); @@ -367,7 +367,7 @@ public function testAlterTableAddComplexColumns(TableDiff $diff) : void /** * @return mixed[][] */ - public static function complexDiffProvider() : iterable + public static function complexDiffProvider(): iterable { $date = new TableDiff('user'); $date->addedColumns['time'] = new Column('time', Type::getType('date'), ['default' => 'CURRENT_DATE']); @@ -381,7 +381,7 @@ public static function complexDiffProvider() : iterable ]; } - public function testCreateTableWithDeferredForeignKeys() : void + public function testCreateTableWithDeferredForeignKeys(): void { $table = new Table('user'); $table->addColumn('id', 'integer'); @@ -409,7 +409,7 @@ public function testCreateTableWithDeferredForeignKeys() : void self::assertEquals($sql, $this->platform->getCreateTableSQL($table)); } - public function testAlterTable() : void + public function testAlterTable(): void { $table = new Table('user'); $table->addColumn('id', 'integer'); @@ -456,7 +456,7 @@ public function testAlterTable() : void /** * {@inheritDoc} */ - protected function getQuotedColumnInPrimaryKeySQL() : array + protected function getQuotedColumnInPrimaryKeySQL(): array { return ['CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL, PRIMARY KEY("create"))']; } @@ -464,7 +464,7 @@ protected function getQuotedColumnInPrimaryKeySQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInIndexSQL() : array + protected function getQuotedColumnInIndexSQL(): array { return [ 'CREATE TABLE "quoted" ("create" VARCHAR(255) NOT NULL)', @@ -475,7 +475,7 @@ protected function getQuotedColumnInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedNameInIndexSQL() : array + protected function getQuotedNameInIndexSQL(): array { return [ 'CREATE TABLE test (column1 VARCHAR(255) NOT NULL)', @@ -486,7 +486,7 @@ protected function getQuotedNameInIndexSQL() : array /** * {@inheritDoc} */ - protected function getQuotedColumnInForeignKeySQL() : array + protected function getQuotedColumnInForeignKeySQL(): array { return [ 'CREATE TABLE "quoted" (' . @@ -497,17 +497,17 @@ protected function getQuotedColumnInForeignKeySQL() : array ]; } - protected function getBinaryDefaultLength() : int + protected function getBinaryDefaultLength(): int { return 0; } - protected function getBinaryMaxLength() : int + protected function getBinaryMaxLength(): int { return 0; } - public function testReturnsBinaryTypeDeclarationSQL() : void + public function testReturnsBinaryTypeDeclarationSQL(): void { self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL([])); self::assertSame('BLOB', $this->platform->getBinaryTypeDeclarationSQL(['length' => 0])); @@ -523,7 +523,7 @@ public function testReturnsBinaryTypeDeclarationSQL() : void * * @group DBAL-234 */ - protected function getAlterTableRenameIndexSQL() : array + protected function getAlterTableRenameIndexSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT id FROM mytable', @@ -540,7 +540,7 @@ protected function getAlterTableRenameIndexSQL() : array * * @group DBAL-234 */ - protected function getQuotedAlterTableRenameIndexSQL() : array + protected function getQuotedAlterTableRenameIndexSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__table AS SELECT id FROM "table"', @@ -556,7 +556,7 @@ protected function getQuotedAlterTableRenameIndexSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableRenameColumnSQL() : array + protected function getQuotedAlterTableRenameColumnSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select", "quoted1", "quoted2", "quoted3" FROM mytable', @@ -579,7 +579,7 @@ protected function getQuotedAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotedAlterTableChangeColumnLengthSQL() : array + protected function getQuotedAlterTableChangeColumnLengthSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT unquoted1, unquoted2, unquoted3, "create", "table", "select" FROM mytable', @@ -599,7 +599,7 @@ protected function getQuotedAlterTableChangeColumnLengthSQL() : array /** * @group DBAL-807 */ - public function testAlterTableRenameIndexInSchema() : void + public function testAlterTableRenameIndexInSchema(): void { $this->markTestIncomplete( 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . @@ -610,7 +610,7 @@ public function testAlterTableRenameIndexInSchema() : void /** * @group DBAL-807 */ - public function testQuotesAlterTableRenameIndexInSchema() : void + public function testQuotesAlterTableRenameIndexInSchema(): void { $this->markTestIncomplete( 'Test currently produces broken SQL due to SQLLitePlatform::getAlterTable being broken ' . @@ -621,7 +621,7 @@ public function testQuotesAlterTableRenameIndexInSchema() : void /** * @group DBAL-423 */ - public function testReturnsGuidTypeDeclarationSQL() : void + public function testReturnsGuidTypeDeclarationSQL(): void { self::assertSame('CHAR(36)', $this->platform->getGuidTypeDeclarationSQL([])); } @@ -629,7 +629,7 @@ public function testReturnsGuidTypeDeclarationSQL() : void /** * {@inheritdoc} */ - public function getAlterTableRenameColumnSQL() : array + public function getAlterTableRenameColumnSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__foo AS SELECT bar FROM foo', @@ -644,7 +644,7 @@ public function getAlterTableRenameColumnSQL() : array /** * {@inheritdoc} */ - protected function getQuotesTableIdentifiersInAlterTableSQL() : array + protected function getQuotesTableIdentifiersInAlterTableSQL(): array { return [ 'DROP INDEX IDX_8C736521A81E660E', @@ -666,7 +666,7 @@ protected function getQuotesTableIdentifiersInAlterTableSQL() : array /** * {@inheritdoc} */ - protected function getCommentOnColumnSQL() : array + protected function getCommentOnColumnSQL(): array { return [ 'COMMENT ON COLUMN foo.bar IS \'comment\'', @@ -675,37 +675,37 @@ protected function getCommentOnColumnSQL() : array ]; } - protected static function getInlineColumnCommentDelimiter() : string + protected static function getInlineColumnCommentDelimiter(): string { return "\n"; } - protected static function getInlineColumnRegularCommentSQL() : string + protected static function getInlineColumnRegularCommentSQL(): string { return "--Regular comment\n"; } - protected static function getInlineColumnCommentRequiringEscapingSQL() : string + protected static function getInlineColumnCommentRequiringEscapingSQL(): string { return "--Using inline comment delimiter \n-- works\n"; } - protected static function getInlineColumnEmptyCommentSQL() : string + protected static function getInlineColumnEmptyCommentSQL(): string { return "--\n"; } - protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL() : string + protected function getQuotesReservedKeywordInUniqueConstraintDeclarationSQL(): string { return 'CONSTRAINT "select" UNIQUE (foo)'; } - protected function getQuotesReservedKeywordInIndexDeclarationSQL() : string + protected function getQuotesReservedKeywordInIndexDeclarationSQL(): string { return 'INDEX "select" (foo)'; } - protected function getQuotesReservedKeywordInTruncateTableSQL() : string + protected function getQuotesReservedKeywordInTruncateTableSQL(): string { return 'DELETE FROM "select"'; } @@ -713,7 +713,7 @@ protected function getQuotesReservedKeywordInTruncateTableSQL() : string /** * {@inheritdoc} */ - protected function getAlterStringToFixedStringSQL() : array + protected function getAlterStringToFixedStringSQL(): array { return [ 'CREATE TEMPORARY TABLE __temp__mytable AS SELECT name FROM mytable', @@ -727,7 +727,7 @@ protected function getAlterStringToFixedStringSQL() : array /** * {@inheritdoc} */ - protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : array + protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL(): array { return [ 'DROP INDEX idx_foo', @@ -745,7 +745,7 @@ protected function getGeneratesAlterTableRenameIndexUsedByForeignKeySQL() : arra /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableConstraintsSQL() : void + public function testQuotesTableNameInListTableConstraintsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -756,7 +756,7 @@ public function testQuotesTableNameInListTableConstraintsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableColumnsSQL() : void + public function testQuotesTableNameInListTableColumnsSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -767,7 +767,7 @@ public function testQuotesTableNameInListTableColumnsSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableIndexesSQL() : void + public function testQuotesTableNameInListTableIndexesSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -778,7 +778,7 @@ public function testQuotesTableNameInListTableIndexesSQL() : void /** * @group DBAL-2436 */ - public function testQuotesTableNameInListTableForeignKeysSQL() : void + public function testQuotesTableNameInListTableForeignKeysSQL(): void { self::assertStringContainsStringIgnoringCase( "'Foo''Bar\\'", @@ -786,22 +786,22 @@ public function testQuotesTableNameInListTableForeignKeysSQL() : void ); } - public function testDateAddStaticNumberOfDays() : void + public function testDateAddStaticNumberOfDays(): void { self::assertSame("DATE(rentalBeginsOn,'+12 DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 12)); } - public function testDateAddNumberOfDaysFromColumn() : void + public function testDateAddNumberOfDaysFromColumn(): void { self::assertSame("DATE(rentalBeginsOn,'+' || duration || ' DAY')", $this->platform->getDateAddDaysExpression('rentalBeginsOn', 'duration')); } - public function testSupportsColumnCollation() : void + public function testSupportsColumnCollation(): void { self::assertTrue($this->platform->supportsColumnCollation()); } - public function testColumnCollationDeclarationSQL() : void + public function testColumnCollationDeclarationSQL(): void { self::assertSame( 'COLLATE NOCASE', @@ -809,7 +809,7 @@ public function testColumnCollationDeclarationSQL() : void ); } - public function testGetCreateTableSQLWithColumnCollation() : void + public function testGetCreateTableSQLWithColumnCollation(): void { $table = new Table('foo'); $table->addColumn('no_collation', 'string'); diff --git a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php index 00dbe37b0d0..067581e81ab 100644 --- a/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Portability/StatementTest.php @@ -10,6 +10,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use ReflectionProperty; + use function iterator_to_array; class StatementTest extends DbalTestCase @@ -23,7 +24,7 @@ class StatementTest extends DbalTestCase /** @var DriverStatement|MockObject */ protected $wrappedStmt; - protected function setUp() : void + protected function setUp(): void { $this->wrappedStmt = $this->createMock(DriverStatement::class); $this->conn = $this->createConnection(); @@ -33,7 +34,7 @@ protected function setUp() : void /** * @group DBAL-726 */ - public function testBindParam() : void + public function testBindParam(): void { $column = 'mycolumn'; $variable = 'myvalue'; @@ -48,7 +49,7 @@ public function testBindParam() : void self::assertTrue($this->stmt->bindParam($column, $variable, $type, $length)); } - public function testBindValue() : void + public function testBindValue(): void { $param = 'myparam'; $value = 'myvalue'; @@ -62,7 +63,7 @@ public function testBindValue() : void self::assertTrue($this->stmt->bindValue($param, $value, $type)); } - public function testCloseCursor() : void + public function testCloseCursor(): void { $this->wrappedStmt->expects($this->once()) ->method('closeCursor') @@ -71,7 +72,7 @@ public function testCloseCursor() : void self::assertTrue($this->stmt->closeCursor()); } - public function testColumnCount() : void + public function testColumnCount(): void { $columnCount = 666; @@ -82,7 +83,7 @@ public function testColumnCount() : void self::assertSame($columnCount, $this->stmt->columnCount()); } - public function testErrorCode() : void + public function testErrorCode(): void { $errorCode = '666'; @@ -93,7 +94,7 @@ public function testErrorCode() : void self::assertSame($errorCode, $this->stmt->errorCode()); } - public function testErrorInfo() : void + public function testErrorInfo(): void { $errorInfo = ['666', 'Evil error.']; @@ -104,7 +105,7 @@ public function testErrorInfo() : void self::assertSame($errorInfo, $this->stmt->errorInfo()); } - public function testExecute() : void + public function testExecute(): void { $params = [ 'foo', @@ -119,7 +120,7 @@ public function testExecute() : void self::assertTrue($this->stmt->execute($params)); } - public function testSetFetchMode() : void + public function testSetFetchMode(): void { $fetchMode = FetchMode::CUSTOM_OBJECT; $arg1 = 'MyClass'; @@ -138,7 +139,7 @@ public function testSetFetchMode() : void self::assertSame($fetchMode, $re->getValue($this->stmt)); } - public function testGetIterator() : void + public function testGetIterator(): void { $this->wrappedStmt->expects($this->exactly(3)) ->method('fetch') @@ -147,7 +148,7 @@ public function testGetIterator() : void self::assertSame(['foo', 'bar'], iterator_to_array($this->stmt->getIterator())); } - public function testRowCount() : void + public function testRowCount(): void { $rowCount = 666; @@ -168,7 +169,7 @@ protected function createConnection() ->getMock(); } - protected function createStatement(DriverStatement $wrappedStatement, Connection $connection) : Statement + protected function createStatement(DriverStatement $wrappedStatement, Connection $connection): Statement { return new Statement($wrappedStatement, $connection); } diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php index 1e9eee344d1..43530b10e02 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/CompositeExpressionTest.php @@ -10,7 +10,7 @@ */ class CompositeExpressionTest extends DbalTestCase { - public function testCount() : void + public function testCount(): void { $expr = CompositeExpression::or('u.group_id = 1'); @@ -21,7 +21,7 @@ public function testCount() : void self::assertCount(2, $expr); } - public function testAdd() : void + public function testAdd(): void { $expr = CompositeExpression::or('u.group_id = 1'); @@ -44,7 +44,7 @@ public function testAdd() : void self::assertCount(3, $expr); } - public function testWith() : void + public function testWith(): void { $expr = CompositeExpression::or('u.group_id = 1'); @@ -69,7 +69,7 @@ public function testWith() : void * * @dataProvider provideDataForConvertToString */ - public function testCompositeUsageAndGeneration(string $type, array $parts, string $expects) : void + public function testCompositeUsageAndGeneration(string $type, array $parts, string $expects): void { $expr = new CompositeExpression($type, $parts); @@ -79,7 +79,7 @@ public function testCompositeUsageAndGeneration(string $type, array $parts, stri /** * @return mixed[][] */ - public static function provideDataForConvertToString() : iterable + public static function provideDataForConvertToString(): iterable { return [ [ diff --git a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php index 1c1915d7cb3..484273663a1 100644 --- a/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/Expression/ExpressionBuilderTest.php @@ -15,7 +15,7 @@ class ExpressionBuilderTest extends DbalTestCase /** @var ExpressionBuilder */ protected $expr; - protected function setUp() : void + protected function setUp(): void { $conn = $this->createMock(Connection::class); @@ -31,7 +31,7 @@ protected function setUp() : void * * @dataProvider provideDataForAnd */ - public function testAnd(array $parts, string $expected) : void + public function testAnd(array $parts, string $expected): void { $composite = $this->expr->and(...$parts); @@ -43,7 +43,7 @@ public function testAnd(array $parts, string $expected) : void * * @dataProvider provideDataForAnd */ - public function testAndX(array $parts, string $expected) : void + public function testAndX(array $parts, string $expected): void { $composite = $this->expr->andX(); @@ -57,7 +57,7 @@ public function testAndX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForAnd() : iterable + public static function provideDataForAnd(): iterable { return [ [ @@ -104,7 +104,7 @@ public static function provideDataForAnd() : iterable * * @dataProvider provideDataForOr */ - public function testOr(array $parts, string $expected) : void + public function testOr(array $parts, string $expected): void { $composite = $this->expr->or(...$parts); @@ -116,7 +116,7 @@ public function testOr(array $parts, string $expected) : void * * @dataProvider provideDataForOr */ - public function testOrX(array $parts, string $expected) : void + public function testOrX(array $parts, string $expected): void { $composite = $this->expr->orX(); @@ -130,7 +130,7 @@ public function testOrX(array $parts, string $expected) : void /** * @return mixed[][] */ - public static function provideDataForOr() : iterable + public static function provideDataForOr(): iterable { return [ [ @@ -175,7 +175,7 @@ public static function provideDataForOr() : iterable /** * @dataProvider provideDataForComparison */ - public function testComparison(string $leftExpr, string $operator, string $rightExpr, string $expected) : void + public function testComparison(string $leftExpr, string $operator, string $rightExpr, string $expected): void { $part = $this->expr->comparison($leftExpr, $operator, $rightExpr); @@ -185,7 +185,7 @@ public function testComparison(string $leftExpr, string $operator, string $right /** * @return mixed[][] */ - public static function provideDataForComparison() : iterable + public static function provideDataForComparison(): iterable { return [ ['u.user_id', ExpressionBuilder::EQ, '1', 'u.user_id = 1'], @@ -197,72 +197,72 @@ public static function provideDataForComparison() : iterable ]; } - public function testEq() : void + public function testEq(): void { self::assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1')); } - public function testNeq() : void + public function testNeq(): void { self::assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1')); } - public function testLt() : void + public function testLt(): void { self::assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000')); } - public function testLte() : void + public function testLte(): void { self::assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000')); } - public function testGt() : void + public function testGt(): void { self::assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000')); } - public function testGte() : void + public function testGte(): void { self::assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000')); } - public function testIsNull() : void + public function testIsNull(): void { self::assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted')); } - public function testIsNotNull() : void + public function testIsNotNull(): void { self::assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated')); } - public function testIn() : void + public function testIn(): void { self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7])); } - public function testInWithPlaceholder() : void + public function testInWithPlaceholder(): void { self::assertEquals('u.groups IN (?)', $this->expr->in('u.groups', '?')); } - public function testNotIn() : void + public function testNotIn(): void { self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7])); } - public function testNotInWithPlaceholder() : void + public function testNotInWithPlaceholder(): void { self::assertEquals('u.groups NOT IN (:values)', $this->expr->notIn('u.groups', ':values')); } - public function testLikeWithoutEscape() : void + public function testLikeWithoutEscape(): void { self::assertEquals("a.song LIKE 'a virgin'", $this->expr->like('a.song', "'a virgin'")); } - public function testLikeWithEscape() : void + public function testLikeWithEscape(): void { self::assertEquals( "a.song LIKE 'a virgin' ESCAPE '💩'", @@ -270,7 +270,7 @@ public function testLikeWithEscape() : void ); } - public function testNotLikeWithoutEscape() : void + public function testNotLikeWithoutEscape(): void { self::assertEquals( "s.last_words NOT LIKE 'this'", @@ -278,7 +278,7 @@ public function testNotLikeWithoutEscape() : void ); } - public function testNotLikeWithEscape() : void + public function testNotLikeWithEscape(): void { self::assertEquals( "p.description NOT LIKE '20💩%' ESCAPE '💩'", diff --git a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php index 20dd21594e1..49042e96c91 100644 --- a/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php +++ b/tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php @@ -17,7 +17,7 @@ class QueryBuilderTest extends DbalTestCase /** @var Connection */ protected $conn; - protected function setUp() : void + protected function setUp(): void { $this->conn = $this->createMock(Connection::class); @@ -31,7 +31,7 @@ protected function setUp() : void /** * @group DBAL-2291 */ - public function testSimpleSelectWithoutFrom() : void + public function testSimpleSelectWithoutFrom(): void { $qb = new QueryBuilder($this->conn); @@ -40,7 +40,7 @@ public function testSimpleSelectWithoutFrom() : void self::assertEquals('SELECT some_function()', (string) $qb); } - public function testSimpleSelect() : void + public function testSimpleSelect(): void { $qb = new QueryBuilder($this->conn); @@ -50,7 +50,7 @@ public function testSimpleSelect() : void self::assertEquals('SELECT u.id FROM users u', (string) $qb); } - public function testSimpleSelectWithDistinct() : void + public function testSimpleSelectWithDistinct(): void { $qb = new QueryBuilder($this->conn); @@ -61,7 +61,7 @@ public function testSimpleSelectWithDistinct() : void self::assertEquals('SELECT DISTINCT u.id FROM users u', (string) $qb); } - public function testSelectWithSimpleWhere() : void + public function testSelectWithSimpleWhere(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -73,7 +73,7 @@ public function testSelectWithSimpleWhere() : void self::assertEquals('SELECT u.id FROM users u WHERE u.nickname = ?', (string) $qb); } - public function testSelectWithLeftJoin() : void + public function testSelectWithLeftJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -85,7 +85,7 @@ public function testSelectWithLeftJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithJoin() : void + public function testSelectWithJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -97,7 +97,7 @@ public function testSelectWithJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithJoinNoCondition() : void + public function testSelectWithJoinNoCondition(): void { $qb = new QueryBuilder($this->conn); @@ -108,7 +108,7 @@ public function testSelectWithJoinNoCondition() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p', (string) $qb); } - public function testSelectWithInnerJoin() : void + public function testSelectWithInnerJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -120,7 +120,7 @@ public function testSelectWithInnerJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithRightJoin() : void + public function testSelectWithRightJoin(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -132,7 +132,7 @@ public function testSelectWithRightJoin() : void self::assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb); } - public function testSelectWithAndWhereConditions() : void + public function testSelectWithAndWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -145,7 +145,7 @@ public function testSelectWithAndWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb); } - public function testSelectWithOrWhereConditions() : void + public function testSelectWithOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -158,7 +158,7 @@ public function testSelectWithOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); } - public function testSelectWithOrOrWhereConditions() : void + public function testSelectWithOrOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -171,7 +171,7 @@ public function testSelectWithOrOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb); } - public function testSelectWithAndOrWhereConditions() : void + public function testSelectWithAndOrWhereConditions(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -186,7 +186,7 @@ public function testSelectWithAndOrWhereConditions() : void self::assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb); } - public function testSelectGroupBy() : void + public function testSelectGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -198,7 +198,7 @@ public function testSelectGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb); } - public function testSelectEmptyGroupBy() : void + public function testSelectEmptyGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -210,7 +210,7 @@ public function testSelectEmptyGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testSelectEmptyAddGroupBy() : void + public function testSelectEmptyAddGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -222,7 +222,7 @@ public function testSelectEmptyAddGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testSelectAddGroupBy() : void + public function testSelectAddGroupBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -235,7 +235,7 @@ public function testSelectAddGroupBy() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb); } - public function testSelectAddGroupBys() : void + public function testSelectAddGroupBys(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -248,7 +248,7 @@ public function testSelectAddGroupBys() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb); } - public function testSelectHaving() : void + public function testSelectHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -261,7 +261,7 @@ public function testSelectHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); } - public function testSelectAndHaving() : void + public function testSelectAndHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -274,7 +274,7 @@ public function testSelectAndHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb); } - public function testSelectHavingAndHaving() : void + public function testSelectHavingAndHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -288,7 +288,7 @@ public function testSelectHavingAndHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb); } - public function testSelectHavingOrHaving() : void + public function testSelectHavingOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -302,7 +302,7 @@ public function testSelectHavingOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); } - public function testSelectOrHavingOrHaving() : void + public function testSelectOrHavingOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -316,7 +316,7 @@ public function testSelectOrHavingOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb); } - public function testSelectHavingAndOrHaving() : void + public function testSelectHavingAndOrHaving(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -331,7 +331,7 @@ public function testSelectHavingAndOrHaving() : void self::assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb); } - public function testSelectOrderBy() : void + public function testSelectOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -343,7 +343,7 @@ public function testSelectOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb); } - public function testSelectAddOrderBy() : void + public function testSelectAddOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -356,7 +356,7 @@ public function testSelectAddOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); } - public function testSelectAddAddOrderBy() : void + public function testSelectAddAddOrderBy(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -369,7 +369,7 @@ public function testSelectAddAddOrderBy() : void self::assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb); } - public function testEmptySelect() : void + public function testEmptySelect(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->select(); @@ -378,7 +378,7 @@ public function testEmptySelect() : void self::assertEquals(QueryBuilder::SELECT, $qb->getType()); } - public function testSelectAddSelect() : void + public function testSelectAddSelect(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -390,7 +390,7 @@ public function testSelectAddSelect() : void self::assertEquals('SELECT u.*, p.* FROM users u', (string) $qb); } - public function testEmptyAddSelect() : void + public function testEmptyAddSelect(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->addSelect(); @@ -399,7 +399,7 @@ public function testEmptyAddSelect() : void self::assertEquals(QueryBuilder::SELECT, $qb->getType()); } - public function testSelectMultipleFrom() : void + public function testSelectMultipleFrom(): void { $qb = new QueryBuilder($this->conn); $expr = $qb->expr(); @@ -412,7 +412,7 @@ public function testSelectMultipleFrom() : void self::assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb); } - public function testUpdate() : void + public function testUpdate(): void { $qb = new QueryBuilder($this->conn); $qb->update('users', 'u') @@ -423,7 +423,7 @@ public function testUpdate() : void self::assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb); } - public function testUpdateWithoutAlias() : void + public function testUpdateWithoutAlias(): void { $qb = new QueryBuilder($this->conn); $qb->update('users') @@ -433,7 +433,7 @@ public function testUpdateWithoutAlias() : void self::assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb); } - public function testUpdateWhere() : void + public function testUpdateWhere(): void { $qb = new QueryBuilder($this->conn); $qb->update('users', 'u') @@ -443,7 +443,7 @@ public function testUpdateWhere() : void self::assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb); } - public function testEmptyUpdate() : void + public function testEmptyUpdate(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->update(); @@ -452,7 +452,7 @@ public function testEmptyUpdate() : void self::assertSame($qb2, $qb); } - public function testDelete() : void + public function testDelete(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users', 'u'); @@ -461,7 +461,7 @@ public function testDelete() : void self::assertEquals('DELETE FROM users u', (string) $qb); } - public function testDeleteWithoutAlias() : void + public function testDeleteWithoutAlias(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users'); @@ -470,7 +470,7 @@ public function testDeleteWithoutAlias() : void self::assertEquals('DELETE FROM users', (string) $qb); } - public function testDeleteWhere() : void + public function testDeleteWhere(): void { $qb = new QueryBuilder($this->conn); $qb->delete('users', 'u') @@ -479,7 +479,7 @@ public function testDeleteWhere() : void self::assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb); } - public function testEmptyDelete() : void + public function testEmptyDelete(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->delete(); @@ -488,7 +488,7 @@ public function testEmptyDelete() : void self::assertSame($qb2, $qb); } - public function testInsertValues() : void + public function testInsertValues(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -503,7 +503,7 @@ public function testInsertValues() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testInsertReplaceValues() : void + public function testInsertReplaceValues(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -524,7 +524,7 @@ public function testInsertReplaceValues() : void self::assertEquals('INSERT INTO users (bar, foo) VALUES(?, ?)', (string) $qb); } - public function testInsertSetValue() : void + public function testInsertSetValue(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -536,7 +536,7 @@ public function testInsertSetValue() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testInsertValuesSetValue() : void + public function testInsertValuesSetValue(): void { $qb = new QueryBuilder($this->conn); $qb->insert('users') @@ -549,7 +549,7 @@ public function testInsertValuesSetValue() : void self::assertEquals('INSERT INTO users (foo, bar) VALUES(?, ?)', (string) $qb); } - public function testEmptyInsert() : void + public function testEmptyInsert(): void { $qb = new QueryBuilder($this->conn); $qb2 = $qb->insert(); @@ -558,13 +558,13 @@ public function testEmptyInsert() : void self::assertSame($qb2, $qb); } - public function testGetConnection() : void + public function testGetConnection(): void { $qb = new QueryBuilder($this->conn); self::assertSame($this->conn, $qb->getConnection()); } - public function testGetState() : void + public function testGetState(): void { $qb = new QueryBuilder($this->conn); @@ -583,7 +583,7 @@ public function testGetState() : void /** * @dataProvider maxResultsProvider */ - public function testSetMaxResults(?int $maxResults) : void + public function testSetMaxResults(?int $maxResults): void { $qb = new QueryBuilder($this->conn); $qb->setMaxResults($maxResults); @@ -595,7 +595,7 @@ public function testSetMaxResults(?int $maxResults) : void /** * @return mixed[][] */ - public static function maxResultsProvider() : iterable + public static function maxResultsProvider(): iterable { return [ 'non-null' => [10], @@ -603,7 +603,7 @@ public static function maxResultsProvider() : iterable ]; } - public function testSetFirstResult() : void + public function testSetFirstResult(): void { $qb = new QueryBuilder($this->conn); $qb->setFirstResult(10); @@ -612,7 +612,7 @@ public function testSetFirstResult() : void self::assertEquals(10, $qb->getFirstResult()); } - public function testResetQueryPart() : void + public function testResetQueryPart(): void { $qb = new QueryBuilder($this->conn); @@ -623,7 +623,7 @@ public function testResetQueryPart() : void self::assertEquals('SELECT u.* FROM users u', (string) $qb); } - public function testResetQueryParts() : void + public function testResetQueryParts(): void { $qb = new QueryBuilder($this->conn); @@ -634,7 +634,7 @@ public function testResetQueryParts() : void self::assertEquals('SELECT u.* FROM users u', (string) $qb); } - public function testCreateNamedParameter() : void + public function testCreateNamedParameter(): void { $qb = new QueryBuilder($this->conn); @@ -647,7 +647,7 @@ public function testCreateNamedParameter() : void self::assertEquals(ParameterType::INTEGER, $qb->getParameterType('dcValue1')); } - public function testCreateNamedParameterCustomPlaceholder() : void + public function testCreateNamedParameterCustomPlaceholder(): void { $qb = new QueryBuilder($this->conn); @@ -660,7 +660,7 @@ public function testCreateNamedParameterCustomPlaceholder() : void self::assertEquals(ParameterType::INTEGER, $qb->getParameterType('test')); } - public function testCreatePositionalParameter() : void + public function testCreatePositionalParameter(): void { $qb = new QueryBuilder($this->conn); @@ -676,7 +676,7 @@ public function testCreatePositionalParameter() : void /** * @group DBAL-172 */ - public function testReferenceJoinFromJoin() : void + public function testReferenceJoinFromJoin(): void { $qb = new QueryBuilder($this->conn); @@ -695,7 +695,7 @@ public function testReferenceJoinFromJoin() : void /** * @group DBAL-172 */ - public function testSelectFromMasterWithWhereOnJoinedTables() : void + public function testSelectFromMasterWithWhereOnJoinedTables(): void { $qb = new QueryBuilder($this->conn); @@ -713,7 +713,7 @@ public function testSelectFromMasterWithWhereOnJoinedTables() : void /** * @group DBAL-442 */ - public function testSelectWithMultipleFromAndJoins() : void + public function testSelectWithMultipleFromAndJoins(): void { $qb = new QueryBuilder($this->conn); @@ -731,7 +731,7 @@ public function testSelectWithMultipleFromAndJoins() : void /** * @group DBAL-774 */ - public function testSelectWithJoinsWithMultipleOnConditionsParseOrder() : void + public function testSelectWithJoinsWithMultipleOnConditionsParseOrder(): void { $qb = new QueryBuilder($this->conn); @@ -756,7 +756,7 @@ public function testSelectWithJoinsWithMultipleOnConditionsParseOrder() : void /** * @group DBAL-774 */ - public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParseOrder() : void + public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParseOrder(): void { $qb = new QueryBuilder($this->conn); @@ -782,7 +782,7 @@ public function testSelectWithMultipleFromsAndJoinsWithMultipleOnConditionsParse ); } - public function testClone() : void + public function testClone(): void { $qb = new QueryBuilder($this->conn); @@ -802,7 +802,7 @@ public function testClone() : void self::assertNotSame($qb->getParameters(), $qbClone->getParameters()); } - public function testSimpleSelectWithoutTableAlias() : void + public function testSimpleSelectWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -812,7 +812,7 @@ public function testSimpleSelectWithoutTableAlias() : void self::assertEquals('SELECT id FROM users', (string) $qb); } - public function testSelectWithSimpleWhereWithoutTableAlias() : void + public function testSelectWithSimpleWhereWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -823,7 +823,7 @@ public function testSelectWithSimpleWhereWithoutTableAlias() : void self::assertEquals('SELECT id, name FROM users WHERE awesome=9001', (string) $qb); } - public function testComplexSelectWithoutTableAliases() : void + public function testComplexSelectWithoutTableAliases(): void { $qb = new QueryBuilder($this->conn); @@ -838,7 +838,7 @@ public function testComplexSelectWithoutTableAliases() : void self::assertEquals('SELECT DISTINCT users.id FROM users INNER JOIN permissions p ON p.user_id = users.id, articles INNER JOIN comments c ON c.article_id = articles.id WHERE (users.id = articles.user_id) AND (p.read = 1)', $qb->getSQL()); } - public function testComplexSelectWithSomeTableAliases() : void + public function testComplexSelectWithSomeTableAliases(): void { $qb = new QueryBuilder($this->conn); @@ -851,7 +851,7 @@ public function testComplexSelectWithSomeTableAliases() : void self::assertEquals('SELECT u.id FROM users u INNER JOIN permissions p ON p.user_id = u.id, articles INNER JOIN comments c ON c.article_id = articles.id', $qb->getSQL()); } - public function testSelectAllFromTableWithoutTableAlias() : void + public function testSelectAllFromTableWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -861,7 +861,7 @@ public function testSelectAllFromTableWithoutTableAlias() : void self::assertEquals('SELECT users.* FROM users', (string) $qb); } - public function testSelectAllWithoutTableAlias() : void + public function testSelectAllWithoutTableAlias(): void { $qb = new QueryBuilder($this->conn); @@ -874,7 +874,7 @@ public function testSelectAllWithoutTableAlias() : void /** * @group DBAL-959 */ - public function testGetParameterType() : void + public function testGetParameterType(): void { $qb = new QueryBuilder($this->conn); @@ -895,7 +895,7 @@ public function testGetParameterType() : void /** * @group DBAL-959 */ - public function testGetParameterTypes() : void + public function testGetParameterTypes(): void { $qb = new QueryBuilder($this->conn); @@ -922,7 +922,7 @@ public function testGetParameterTypes() : void /** * @group DBAL-1137 */ - public function testJoinWithNonUniqueAliasThrowsException() : void + public function testJoinWithNonUniqueAliasThrowsException(): void { $qb = new QueryBuilder($this->conn); diff --git a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php index 621520029b1..bfa7a5fcc30 100644 --- a/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php +++ b/tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php @@ -17,7 +17,7 @@ class SQLParserUtilsTest extends DbalTestCase /** * @return mixed[][] */ - public static function dataGetPlaceholderPositions() : iterable + public static function dataGetPlaceholderPositions(): iterable { return [ // none @@ -98,7 +98,7 @@ public static function dataGetPlaceholderPositions() : iterable * * @dataProvider dataGetPlaceholderPositions */ - public function testGetPlaceholderPositions(string $query, bool $isPositional, array $expectedParamPos) : void + public function testGetPlaceholderPositions(string $query, bool $isPositional, array $expectedParamPos): void { $actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional); self::assertEquals($expectedParamPos, $actualParamPos); @@ -107,7 +107,7 @@ public function testGetPlaceholderPositions(string $query, bool $isPositional, a /** * @return mixed[][] */ - public static function dataExpandListParameters() : iterable + public static function dataExpandListParameters(): iterable { return [ 'Positional: Very simple with one needle' => [ @@ -439,7 +439,7 @@ public function testExpandListParameters( string $expectedQuery, array $expectedParams, array $expectedTypes - ) : void { + ): void { [$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types); self::assertEquals($expectedQuery, $query, 'Query was not rewritten correctly.'); @@ -450,7 +450,7 @@ public function testExpandListParameters( /** * @return mixed[][] */ - public static function dataQueryWithMissingParameters() : iterable + public static function dataQueryWithMissingParameters(): iterable { return [ [ @@ -492,7 +492,7 @@ public static function dataQueryWithMissingParameters() : iterable * * @dataProvider dataQueryWithMissingParameters */ - public function testExceptionIsThrownForMissingParam(string $query, array $params, array $types = []) : void + public function testExceptionIsThrownForMissingParam(string $query, array $params, array $types = []): void { $this->expectException(SQLParserUtilsException::class); $this->expectExceptionMessage('Value for :param not found in params array. Params array key should be "param"'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php index 0bdaa85ef6d..b37d24b2825 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnDiffTest.php @@ -13,7 +13,7 @@ class ColumnDiffTest extends TestCase /** * @group DBAL-1255 */ - public function testPreservesOldColumnNameQuotation() : void + public function testPreservesOldColumnNameQuotation(): void { $fromColumn = new Column('"foo"', Type::getType(Types::INTEGER)); $toColumn = new Column('bar', Type::getType(Types::INTEGER)); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php index 269df62de32..e2b10b51069 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ColumnTest.php @@ -12,7 +12,7 @@ class ColumnTest extends TestCase { - public function testGet() : void + public function testGet(): void { $column = $this->createColumn(); @@ -38,7 +38,7 @@ public function testGet() : void self::assertFalse($column->hasCustomSchemaOption('foo')); } - public function testToArray() : void + public function testToArray(): void { $expected = [ 'name' => 'foo', @@ -64,7 +64,7 @@ public function testToArray() : void * @group legacy * @expectedDeprecation The "unknown_option" column option is not supported, setting it is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testSettingUnknownOptionIsStillSupported() : void + public function testSettingUnknownOptionIsStillSupported(): void { $this->expectNotToPerformAssertions(); @@ -75,7 +75,7 @@ public function testSettingUnknownOptionIsStillSupported() : void * @group legacy * @expectedDeprecation The "unknown_option" column option is not supported, setting it is deprecated and will cause an error in Doctrine DBAL 3.0 */ - public function testOptionsShouldNotBeIgnored() : void + public function testOptionsShouldNotBeIgnored(): void { $col1 = new Column('bar', Type::getType(Types::INTEGER), ['unknown_option' => 'bar', 'notnull' => true]); self::assertTrue($col1->getNotnull()); @@ -84,7 +84,7 @@ public function testOptionsShouldNotBeIgnored() : void self::assertFalse($col2->getNotnull()); } - public function createColumn() : Column + public function createColumn(): Column { $options = [ 'length' => 200, @@ -107,7 +107,7 @@ public function createColumn() : Column * @group DBAL-64 * @group DBAL-830 */ - public function testQuotedColumnName() : void + public function testQuotedColumnName(): void { $string = Type::getType('string'); $column = new Column('`bar`', $string, []); @@ -131,7 +131,7 @@ public function testQuotedColumnName() : void * @dataProvider getIsQuoted * @group DBAL-830 */ - public function testIsQuoted(string $columnName, bool $isQuoted) : void + public function testIsQuoted(string $columnName, bool $isQuoted): void { $type = Type::getType('string'); $column = new Column($columnName, $type); @@ -142,7 +142,7 @@ public function testIsQuoted(string $columnName, bool $isQuoted) : void /** * @return mixed[][] */ - public static function getIsQuoted() : iterable + public static function getIsQuoted(): iterable { return [ ['bar', false], @@ -155,7 +155,7 @@ public static function getIsQuoted() : iterable /** * @group DBAL-42 */ - public function testColumnComment() : void + public function testColumnComment(): void { $column = new Column('bar', Type::getType('string')); self::assertNull($column->getComment()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php index cc77a153a4a..017cc5adcb5 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php @@ -15,12 +15,13 @@ use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; + use function array_keys; use function get_class; class ComparatorTest extends TestCase { - public function testCompareSame1() : void + public function testCompareSame1(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -44,7 +45,7 @@ public function testCompareSame1() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareSame2() : void + public function testCompareSame2(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -70,7 +71,7 @@ public function testCompareSame2() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareMissingTable() : void + public function testCompareMissingTable(): void { $schemaConfig = new SchemaConfig(); $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]); @@ -84,7 +85,7 @@ public function testCompareMissingTable() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewTable() : void + public function testCompareNewTable(): void { $schemaConfig = new SchemaConfig(); $table = new Table('bugdb', ['integerfield1' => new Column('integerfield1', Type::getType('integer'))]); @@ -98,7 +99,7 @@ public function testCompareNewTable() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareOnlyAutoincrementChanged() : void + public function testCompareOnlyAutoincrementChanged(): void { $column1 = new Column('foo', Type::getType('integer'), ['autoincrement' => true]); $column2 = new Column('foo', Type::getType('integer'), ['autoincrement' => false]); @@ -109,7 +110,7 @@ public function testCompareOnlyAutoincrementChanged() : void self::assertEquals(['autoincrement'], $changedProperties); } - public function testCompareMissingField() : void + public function testCompareMissingField(): void { $missingColumn = new Column('integerfield1', Type::getType('integer')); $schema1 = new Schema([ @@ -147,7 +148,7 @@ public function testCompareMissingField() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewField() : void + public function testCompareNewField(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -184,7 +185,7 @@ public function testCompareNewField() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedColumnsChangeType() : void + public function testCompareChangedColumnsChangeType(): void { $column1 = new Column('charfield1', Type::getType('string')); $column2 = new Column('charfield1', Type::getType('integer')); @@ -194,7 +195,7 @@ public function testCompareChangedColumnsChangeType() : void self::assertEquals([], $c->diffColumn($column1, $column1)); } - public function testCompareColumnsMultipleTypeInstances() : void + public function testCompareColumnsMultipleTypeInstances(): void { $integerType1 = Type::getType('integer'); Type::overrideType('integer', get_class($integerType1)); @@ -207,7 +208,7 @@ public function testCompareColumnsMultipleTypeInstances() : void self::assertEquals([], $c->diffColumn($column1, $column2)); } - public function testCompareColumnsOverriddenType() : void + public function testCompareColumnsOverriddenType(): void { $oldStringInstance = Type::getType('string'); $integerType = Type::getType('integer'); @@ -224,7 +225,7 @@ public function testCompareColumnsOverriddenType() : void self::assertEquals([], $c->diffColumn($column1, $column2)); } - public function testCompareChangedColumnsChangeCustomSchemaOption() : void + public function testCompareChangedColumnsChangeCustomSchemaOption(): void { $column1 = new Column('charfield1', Type::getType('string')); $column2 = new Column('charfield1', Type::getType('string')); @@ -240,7 +241,7 @@ public function testCompareChangedColumnsChangeCustomSchemaOption() : void self::assertEquals([], $c->diffColumn($column1, $column1)); } - public function testCompareChangeColumnsMultipleNewColumnsRename() : void + public function testCompareChangeColumnsMultipleNewColumnsRename(): void { $tableA = new Table('foo'); $tableA->addColumn('datefield1', 'datetime'); @@ -260,7 +261,7 @@ public function testCompareChangeColumnsMultipleNewColumnsRename() : void self::assertCount(0, $tableDiff->changedColumns, 'Nothing should be changed as all fields old & new have diff names.'); } - public function testCompareRemovedIndex() : void + public function testCompareRemovedIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -314,7 +315,7 @@ public function testCompareRemovedIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareNewIndex() : void + public function testCompareNewIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -366,7 +367,7 @@ public function testCompareNewIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedIndex() : void + public function testCompareChangedIndex(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -429,7 +430,7 @@ public function testCompareChangedIndex() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareChangedIndexFieldPositions() : void + public function testCompareChangedIndexFieldPositions(): void { $schema1 = new Schema([ 'bugdb' => new Table( @@ -477,7 +478,7 @@ public function testCompareChangedIndexFieldPositions() : void self::assertEquals($expected, Comparator::compareSchemas($schema1, $schema2)); } - public function testCompareSequences() : void + public function testCompareSequences(): void { $seq1 = new Sequence('foo', 1, 1); $seq2 = new Sequence('foo', 1, 2); @@ -491,7 +492,7 @@ public function testCompareSequences() : void self::assertFalse($c->diffSequence($seq1, $seq4)); } - public function testRemovedSequence() : void + public function testRemovedSequence(): void { $schema1 = new Schema(); $seq = $schema1->createSequence('foo'); @@ -505,7 +506,7 @@ public function testRemovedSequence() : void self::assertSame($seq, $diffSchema->removedSequences[0]); } - public function testAddedSequence() : void + public function testAddedSequence(): void { $schema1 = new Schema(); @@ -519,7 +520,7 @@ public function testAddedSequence() : void self::assertSame($seq, $diffSchema->newSequences[0]); } - public function testTableAddForeignKey() : void + public function testTableAddForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -538,7 +539,7 @@ public function testTableAddForeignKey() : void self::assertCount(1, $tableDiff->addedForeignKeys); } - public function testTableRemoveForeignKey() : void + public function testTableRemoveForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -557,7 +558,7 @@ public function testTableRemoveForeignKey() : void self::assertCount(1, $tableDiff->removedForeignKeys); } - public function testTableUpdateForeignKey() : void + public function testTableUpdateForeignKey(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -577,7 +578,7 @@ public function testTableUpdateForeignKey() : void self::assertCount(1, $tableDiff->changedForeignKeys); } - public function testMovedForeignKeyForeignTable() : void + public function testMovedForeignKeyForeignTable(): void { $tableForeign = new Table('bar'); $tableForeign->addColumn('id', 'integer'); @@ -600,7 +601,7 @@ public function testMovedForeignKeyForeignTable() : void self::assertCount(1, $tableDiff->changedForeignKeys); } - public function testTablesCaseInsensitive() : void + public function testTablesCaseInsensitive(): void { $schemaA = new Schema(); $schemaA->createTable('foo'); @@ -620,7 +621,7 @@ public function testTablesCaseInsensitive() : void $this->assertSchemaTableChangeCount($diff, 1, 0, 1); } - public function testSequencesCaseInsensitive() : void + public function testSequencesCaseInsensitive(): void { $schemaA = new Schema(); $schemaA->createSequence('foo'); @@ -640,7 +641,7 @@ public function testSequencesCaseInsensitive() : void $this->assertSchemaSequenceChangeCount($diff, 1, 0, 1); } - public function testCompareColumnCompareCaseInsensitive() : void + public function testCompareColumnCompareCaseInsensitive(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -654,7 +655,7 @@ public function testCompareColumnCompareCaseInsensitive() : void self::assertFalse($tableDiff); } - public function testCompareIndexBasedOnPropertiesNotName() : void + public function testCompareIndexBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -675,7 +676,7 @@ public function testCompareIndexBasedOnPropertiesNotName() : void ); } - public function testCompareForeignKeyBasedOnPropertiesNotName() : void + public function testCompareForeignKeyBasedOnPropertiesNotName(): void { $tableA = new Table('foo'); $tableA->addColumn('id', 'integer'); @@ -691,7 +692,7 @@ public function testCompareForeignKeyBasedOnPropertiesNotName() : void self::assertFalse($tableDiff); } - public function testCompareForeignKeyRestrictNoActionAreTheSame() : void + public function testCompareForeignKeyRestrictNoActionAreTheSame(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); $fk2 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'RESTRICT']); @@ -703,7 +704,7 @@ public function testCompareForeignKeyRestrictNoActionAreTheSame() : void /** * @group DBAL-492 */ - public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable() : void + public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvailable(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'foo.bar', ['baz'], 'fk1'); $fk2 = new ForeignKeyConstraint(['foo'], 'baz.bar', ['baz'], 'fk1'); @@ -712,7 +713,7 @@ public function testCompareForeignKeyNamesUnqualifiedAsNoSchemaInformationIsAvai self::assertFalse($c->diffForeignKey($fk1, $fk2)); } - public function testDetectRenameColumn() : void + public function testDetectRenameColumn(): void { $tableA = new Table('foo'); $tableA->addColumn('foo', 'integer'); @@ -736,7 +737,7 @@ public function testDetectRenameColumn() : void * * @group DBAL-24 */ - public function testDetectRenameColumnAmbiguous() : void + public function testDetectRenameColumnAmbiguous(): void { $tableA = new Table('foo'); $tableA->addColumn('foo', 'integer'); @@ -759,7 +760,7 @@ public function testDetectRenameColumnAmbiguous() : void /** * @group DBAL-1063 */ - public function testDetectRenameIndex() : void + public function testDetectRenameIndex(): void { $table1 = new Table('foo'); $table1->addColumn('foo', 'integer'); @@ -786,7 +787,7 @@ public function testDetectRenameIndex() : void * * @group DBAL-1063 */ - public function testDetectRenameIndexAmbiguous() : void + public function testDetectRenameIndexAmbiguous(): void { $table1 = new Table('foo'); $table1->addColumn('foo', 'integer'); @@ -809,7 +810,7 @@ public function testDetectRenameIndexAmbiguous() : void self::assertCount(0, $tableDiff->renamedIndexes); } - public function testDetectChangeIdentifierType() : void + public function testDetectChangeIdentifierType(): void { $this->markTestSkipped('DBAL-2 was reopened, this test cannot work anymore.'); @@ -829,7 +830,7 @@ public function testDetectChangeIdentifierType() : void /** * @group DBAL-105 */ - public function testDiff() : void + public function testDiff(): void { $table = new Table('twitter_users'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -856,7 +857,7 @@ public function testDiff() : void /** * @group DBAL-112 */ - public function testChangedSequence() : void + public function testChangedSequence(): void { $schema = new Schema(); $sequence = $schema->createSequence('baz'); @@ -874,7 +875,7 @@ public function testChangedSequence() : void * @group DBAL-106 * @psalm-suppress NullArgument */ - public function testDiffDecimalWithNullPrecision() : void + public function testDiffDecimalWithNullPrecision(): void { $column = new Column('foo', Type::getType('decimal')); $column->setPrecision(null); @@ -888,7 +889,7 @@ public function testDiffDecimalWithNullPrecision() : void /** * @group DBAL-204 */ - public function testFqnSchemaComparison() : void + public function testFqnSchemaComparison(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -908,7 +909,7 @@ public function testFqnSchemaComparison() : void /** * @group DBAL-669 */ - public function testNamespacesComparison() : void + public function testNamespacesComparison(): void { $config = new SchemaConfig(); $config->setName('schemaName'); @@ -935,7 +936,7 @@ public function testNamespacesComparison() : void /** * @group DBAL-204 */ - public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff() : void + public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -955,7 +956,7 @@ public function testFqnSchemaComparisonDifferentSchemaNameButSameTableNoDiff() : /** * @group DBAL-204 */ - public function testFqnSchemaComparisonNoSchemaSame() : void + public function testFqnSchemaComparisonNoSchemaSame(): void { $config = new SchemaConfig(); $config->setName('foo'); @@ -974,7 +975,7 @@ public function testFqnSchemaComparisonNoSchemaSame() : void /** * @group DDC-1657 */ - public function testAutoIncrementSequences() : void + public function testAutoIncrementSequences(): void { $oldSchema = new Schema(); $table = $oldSchema->createTable('foo'); @@ -998,7 +999,7 @@ public function testAutoIncrementSequences() : void * * @group DBAL-562 */ - public function testAutoIncrementNoSequences() : void + public function testAutoIncrementNoSequences(): void { $oldSchema = new Schema(); $table = $oldSchema->createTable('foo'); @@ -1023,7 +1024,7 @@ public function testAutoIncrementNoSequences() : void * array because of the dropped table, and once on changedTables array. We * now check that the key is present once. */ - public function testAvoidMultipleDropForeignKey() : void + public function testAvoidMultipleDropForeignKey(): void { $oldSchema = new Schema(); @@ -1056,7 +1057,7 @@ public function testAvoidMultipleDropForeignKey() : void self::assertCount(1, $schemaDiff->orphanedForeignKeys); } - public function testCompareChangedColumn() : void + public function testCompareChangedColumn(): void { $oldSchema = new Schema(); @@ -1078,7 +1079,7 @@ public function testCompareChangedColumn() : void self::assertEquals($expected, Comparator::compareSchemas($oldSchema, $newSchema)); } - public function testCompareChangedBinaryColumn() : void + public function testCompareChangedBinaryColumn(): void { $oldSchema = new Schema(); @@ -1103,7 +1104,7 @@ public function testCompareChangedBinaryColumn() : void /** * @group DBAL-617 */ - public function testCompareQuotedAndUnquotedForeignKeyColumns() : void + public function testCompareQuotedAndUnquotedForeignKeyColumns(): void { $fk1 = new ForeignKeyConstraint(['foo'], 'bar', ['baz'], 'fk1', ['onDelete' => 'NO ACTION']); $fk2 = new ForeignKeyConstraint(['`foo`'], 'bar', ['`baz`'], 'fk1', ['onDelete' => 'NO ACTION']); @@ -1114,7 +1115,7 @@ public function testCompareQuotedAndUnquotedForeignKeyColumns() : void self::assertFalse($diff); } - public function assertSchemaTableChangeCount(SchemaDiff $diff, int $newTableCount = 0, int $changeTableCount = 0, int $removeTableCount = 0) : void + public function assertSchemaTableChangeCount(SchemaDiff $diff, int $newTableCount = 0, int $changeTableCount = 0, int $removeTableCount = 0): void { self::assertCount($newTableCount, $diff->newTables); self::assertCount($changeTableCount, $diff->changedTables); @@ -1126,13 +1127,13 @@ public function assertSchemaSequenceChangeCount( int $newSequenceCount = 0, int $changeSequenceCount = 0, int $removeSequenceCount = 0 - ) : void { + ): void { self::assertCount($newSequenceCount, $diff->newSequences, 'Expected number of new sequences is wrong.'); self::assertCount($changeSequenceCount, $diff->changedSequences, 'Expected number of changed sequences is wrong.'); self::assertCount($removeSequenceCount, $diff->removedSequences, 'Expected number of removed sequences is wrong.'); } - public function testDiffColumnPlatformOptions() : void + public function testDiffColumnPlatformOptions(): void { $column1 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'bar' => 'bar']]); $column2 = new Column('foo', Type::getType('string'), ['platformOptions' => ['foo' => 'foo', 'foobar' => 'foobar']]); @@ -1149,7 +1150,7 @@ public function testDiffColumnPlatformOptions() : void self::assertEquals([], $comparator->diffColumn($column4, $column1)); } - public function testComplexDiffColumn() : void + public function testComplexDiffColumn(): void { $column1 = new Column('foo', Type::getType('string'), [ 'platformOptions' => ['foo' => 'foo'], @@ -1169,7 +1170,7 @@ public function testComplexDiffColumn() : void /** * @group DBAL-669 */ - public function testComparesNamespaces() : void + public function testComparesNamespaces(): void { $comparator = new Comparator(); $fromSchema = $this->getMockBuilder(Schema::class) @@ -1215,7 +1216,7 @@ public function testComparesNamespaces() : void self::assertEquals($expected, $comparator->compare($fromSchema, $toSchema)); } - public function testCompareGuidColumns() : void + public function testCompareGuidColumns(): void { $comparator = new Comparator(); @@ -1234,7 +1235,7 @@ public function testCompareGuidColumns() : void * @group DBAL-1009 * @dataProvider getCompareColumnComments */ - public function testCompareColumnComments(?string $comment1, ?string $comment2, bool $equals) : void + public function testCompareColumnComments(?string $comment1, ?string $comment2, bool $equals): void { $column1 = new Column('foo', Type::getType('integer'), ['comment' => $comment1]); $column2 = new Column('foo', Type::getType('integer'), ['comment' => $comment2]); @@ -1255,7 +1256,7 @@ public function testCompareColumnComments(?string $comment1, ?string $comment2, /** * @return mixed[][] */ - public static function getCompareColumnComments() : iterable + public static function getCompareColumnComments(): iterable { return [ [null, null, true], @@ -1280,7 +1281,7 @@ public static function getCompareColumnComments() : iterable ]; } - public function testForeignKeyRemovalWithRenamedLocalColumn() : void + public function testForeignKeyRemovalWithRenamedLocalColumn(): void { $fromSchema = new Schema([ 'table1' => new Table( diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index 86fe190c790..2ac7043abf4 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Schema\DB2SchemaManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function in_array; /** @@ -23,7 +24,7 @@ final class DB2SchemaManagerTest extends TestCase /** @var DB2SchemaManager */ private $manager; - protected function setUp() : void + protected function setUp(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -41,7 +42,7 @@ protected function setUp() : void * * @group DBAL-2701 */ - public function testListTableNamesFiltersAssetNamesCorrectly() : void + public function testListTableNamesFiltersAssetNamesCorrectly(): void { $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue([ @@ -63,7 +64,7 @@ public function testListTableNamesFiltersAssetNamesCorrectly() : void /** * @group DBAL-2701 */ - public function testAssetFilteringSetsACallable() : void + public function testAssetFilteringSetsACallable(): void { $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); @@ -89,7 +90,7 @@ public function testAssetFilteringSetsACallable() : void $this->assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); } - public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : void + public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable(): void { $accepted = ['T_FOO', 'T_BAR']; $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { @@ -114,7 +115,7 @@ public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : voi $this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); } - public function testSettingNullExpressionWillResetCallable() : void + public function testSettingNullExpressionWillResetCallable(): void { $accepted = ['T_FOO', 'T_BAR']; $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { @@ -151,7 +152,7 @@ public function testSettingNullExpressionWillResetCallable() : void $this->assertNull($this->conn->getConfiguration()->getSchemaAssetsFilter()); } - public function testSettingNullAsCallableClearsExpression() : void + public function testSettingNullAsCallableClearsExpression(): void { $filterExpression = '/^(?!T_)/'; $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); diff --git a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php index 5a59088e42a..763cd336b09 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ForeignKeyConstraintTest.php @@ -15,7 +15,7 @@ class ForeignKeyConstraintTest extends TestCase * @group DBAL-1062 * @dataProvider getIntersectsIndexColumnsData */ - public function testIntersectsIndexColumns(array $indexColumns, bool $expectedResult) : void + public function testIntersectsIndexColumns(array $indexColumns, bool $expectedResult): void { $foreignKey = new ForeignKeyConstraint(['foo', 'bar'], 'foreign_table', ['fk_foo', 'fk_bar']); @@ -32,7 +32,7 @@ public function testIntersectsIndexColumns(array $indexColumns, bool $expectedRe /** * @return mixed[][] */ - public static function getIntersectsIndexColumnsData() : iterable + public static function getIntersectsIndexColumnsData(): iterable { return [ [['baz'], false], @@ -64,7 +64,7 @@ public static function getIntersectsIndexColumnsData() : iterable * @group DBAL-1062 * @dataProvider getUnqualifiedForeignTableNameData */ - public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName) : void + public function testGetUnqualifiedForeignTableName($foreignTableName, string $expectedUnqualifiedTableName): void { $foreignKey = new ForeignKeyConstraint(['foo', 'bar'], $foreignTableName, ['fk_foo', 'fk_bar']); @@ -74,7 +74,7 @@ public function testGetUnqualifiedForeignTableName($foreignTableName, string $ex /** * @return mixed[][] */ - public static function getUnqualifiedForeignTableNameData() : iterable + public static function getUnqualifiedForeignTableNameData(): iterable { return [ ['schema.foreign_table', 'foreign_table'], diff --git a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php index d21e676b273..fa5e979e2a0 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/IndexTest.php @@ -10,12 +10,12 @@ class IndexTest extends TestCase /** * @param mixed[] $options */ - private function createIndex(bool $unique = false, bool $primary = false, array $options = []) : Index + private function createIndex(bool $unique = false, bool $primary = false, array $options = []): Index { return new Index('foo', ['bar', 'baz'], $unique, $primary, [], $options); } - public function testCreateIndex() : void + public function testCreateIndex(): void { $idx = $this->createIndex(); self::assertEquals('foo', $idx->getName()); @@ -26,14 +26,14 @@ public function testCreateIndex() : void self::assertFalse($idx->isPrimary()); } - public function testCreatePrimary() : void + public function testCreatePrimary(): void { $idx = $this->createIndex(false, true); self::assertTrue($idx->isUnique()); self::assertTrue($idx->isPrimary()); } - public function testCreateUnique() : void + public function testCreateUnique(): void { $idx = $this->createIndex(true, false); self::assertTrue($idx->isUnique()); @@ -43,7 +43,7 @@ public function testCreateUnique() : void /** * @group DBAL-50 */ - public function testFulfilledByUnique() : void + public function testFulfilledByUnique(): void { $idx1 = $this->createIndex(true, false); $idx2 = $this->createIndex(true, false); @@ -56,7 +56,7 @@ public function testFulfilledByUnique() : void /** * @group DBAL-50 */ - public function testFulfilledByPrimary() : void + public function testFulfilledByPrimary(): void { $idx1 = $this->createIndex(true, true); $idx2 = $this->createIndex(true, true); @@ -69,7 +69,7 @@ public function testFulfilledByPrimary() : void /** * @group DBAL-50 */ - public function testFulfilledByIndex() : void + public function testFulfilledByIndex(): void { $idx1 = $this->createIndex(); $idx2 = $this->createIndex(); @@ -81,7 +81,7 @@ public function testFulfilledByIndex() : void self::assertTrue($idx1->isFullfilledBy($uniq)); } - public function testFulfilledWithPartial() : void + public function testFulfilledWithPartial(): void { $without = new Index('without', ['col1', 'col2'], true, false, [], []); $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']); @@ -96,7 +96,7 @@ public function testFulfilledWithPartial() : void self::assertTrue($another->isFullfilledBy($partial)); } - public function testOverrulesWithPartial() : void + public function testOverrulesWithPartial(): void { $without = new Index('without', ['col1', 'col2'], true, false, [], []); $partial = new Index('partial', ['col1', 'col2'], true, false, [], ['where' => 'col1 IS NULL']); @@ -118,7 +118,7 @@ public function testOverrulesWithPartial() : void * * @dataProvider indexLengthProvider */ - public function testFulfilledWithLength(array $columns, array $lengths1, array $lengths2, bool $expected) : void + public function testFulfilledWithLength(array $columns, array $lengths1, array $lengths2, bool $expected): void { $index1 = new Index('index1', $columns, false, false, [], ['lengths' => $lengths1]); $index2 = new Index('index2', $columns, false, false, [], ['lengths' => $lengths2]); @@ -130,7 +130,7 @@ public function testFulfilledWithLength(array $columns, array $lengths1, array $ /** * @return mixed[][] */ - public static function indexLengthProvider() : iterable + public static function indexLengthProvider(): iterable { return [ 'empty' => [['column'], [], [], true], @@ -144,7 +144,7 @@ public static function indexLengthProvider() : iterable /** * @group DBAL-220 */ - public function testFlags() : void + public function testFlags(): void { $idx1 = $this->createIndex(); self::assertFalse($idx1->hasFlag('clustered')); @@ -163,7 +163,7 @@ public function testFlags() : void /** * @group DBAL-285 */ - public function testIndexQuotes() : void + public function testIndexQuotes(): void { $index = new Index('foo', ['`bar`', '`baz`']); @@ -175,7 +175,7 @@ public function testIndexQuotes() : void self::assertFalse($index->hasColumnAtPosition('baz', 0)); } - public function testOptions() : void + public function testOptions(): void { $idx1 = $this->createIndex(); self::assertFalse($idx1->hasOption('where')); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php index e65507b7826..bed295b67d5 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlInheritCharsetTest.php @@ -14,11 +14,12 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\TestCase; + use function array_merge; class MySqlInheritCharsetTest extends TestCase { - public function testInheritTableOptionsFromDatabase() : void + public function testInheritTableOptionsFromDatabase(): void { // default, no overrides $options = $this->getTableOptionsForOverride(); @@ -35,7 +36,7 @@ public function testInheritTableOptionsFromDatabase() : void self::assertSame($options['charset'], 'utf8mb4'); } - public function testTableOptions() : void + public function testTableOptions(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -70,7 +71,7 @@ public function testTableOptions() : void * * @return string[] */ - private function getTableOptionsForOverride(array $overrideOptions = []) : array + private function getTableOptionsForOverride(array $overrideOptions = []): array { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php index 02873cdeaeb..1ca7f0a825d 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\MySqlSchemaManager; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function array_map; class MySqlSchemaManagerTest extends TestCase @@ -22,7 +23,7 @@ class MySqlSchemaManagerTest extends TestCase /** @var Connection&MockObject */ private $conn; - protected function setUp() : void + protected function setUp(): void { $eventManager = new EventManager(); $driverMock = $this->createMock(Driver::class); @@ -38,7 +39,7 @@ protected function setUp() : void $this->manager = new MySqlSchemaManager($this->conn); } - public function testCompositeForeignKeys() : void + public function testCompositeForeignKeys(): void { $this->conn->expects($this->once())->method('fetchAllAssociative')->will($this->returnValue($this->getFKDefinition())); $fkeys = $this->manager->listTableForeignKeys('dummy'); @@ -52,7 +53,7 @@ public function testCompositeForeignKeys() : void /** * @return string[][] */ - public function getFKDefinition() : array + public function getFKDefinition(): array { return [ [ diff --git a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php index 4cf69f28f7c..7b494341e6d 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Platforms/MySQLSchemaTest.php @@ -16,13 +16,13 @@ class MySQLSchemaTest extends TestCase /** @var AbstractPlatform */ private $platform; - protected function setUp() : void + protected function setUp(): void { $this->comparator = new Comparator(); $this->platform = new MySqlPlatform(); } - public function testSwitchPrimaryKeyOrder() : void + public function testSwitchPrimaryKeyOrder(): void { $tableOld = new Table('test'); $tableOld->addColumn('foo_id', 'integer'); @@ -47,7 +47,7 @@ public function testSwitchPrimaryKeyOrder() : void /** * @group DBAL-132 */ - public function testGenerateForeignKeySQL() : void + public function testGenerateForeignKeySQL(): void { $tableOld = new Table('test'); $tableOld->addColumn('foo_id', 'integer'); @@ -64,7 +64,7 @@ public function testGenerateForeignKeySQL() : void /** * @group DDC-1737 */ - public function testClobNoAlterTable() : void + public function testClobNoAlterTable(): void { $tableOld = new Table('test'); $tableOld->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php index 92bc0c83dd6..141e1e4f1e3 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaDiffTest.php @@ -13,7 +13,7 @@ class SchemaDiffTest extends TestCase { - public function testSchemaDiffToSql() : void + public function testSchemaDiffToSql(): void { $diff = $this->createSchemaDiff(); $platform = $this->createPlatform(true); @@ -25,7 +25,7 @@ public function testSchemaDiffToSql() : void self::assertEquals($expected, $sql); } - public function testSchemaDiffToSaveSql() : void + public function testSchemaDiffToSaveSql(): void { $diff = $this->createSchemaDiff(); $platform = $this->createPlatform(false); @@ -108,7 +108,7 @@ private function createPlatform(bool $unsafe) return $platform; } - public function createSchemaDiff() : SchemaDiff + public function createSchemaDiff(): SchemaDiff { $diff = new SchemaDiff(); $diff->newNamespaces['foo_ns'] = 'foo_ns'; diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index 69796236235..cc665df5bd1 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -11,12 +11,13 @@ use Doctrine\DBAL\Schema\Visitor\Visitor; use PHPUnit\Framework\TestCase; use ReflectionProperty; + use function current; use function strlen; class SchemaTest extends TestCase { - public function testAddTable() : void + public function testAddTable(): void { $tableName = 'public.foo'; $table = new Table($tableName); @@ -32,7 +33,7 @@ public function testAddTable() : void self::assertTrue($schema->hasTable($tableName)); } - public function testTableMatchingCaseInsensitive() : void + public function testTableMatchingCaseInsensitive(): void { $table = new Table('Foo'); @@ -45,7 +46,7 @@ public function testTableMatchingCaseInsensitive() : void self::assertSame($table, $schema->getTable('Foo')); } - public function testGetUnknownTableThrowsException() : void + public function testGetUnknownTableThrowsException(): void { $this->expectException(SchemaException::class); @@ -53,7 +54,7 @@ public function testGetUnknownTableThrowsException() : void $schema->getTable('unknown'); } - public function testCreateTableTwiceThrowsException() : void + public function testCreateTableTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -64,7 +65,7 @@ public function testCreateTableTwiceThrowsException() : void $schema = new Schema($tables); } - public function testRenameTable() : void + public function testRenameTable(): void { $tableName = 'foo'; $table = new Table($tableName); @@ -77,7 +78,7 @@ public function testRenameTable() : void self::assertSame($table, $schema->getTable('bar')); } - public function testDropTable() : void + public function testDropTable(): void { $tableName = 'foo'; $table = new Table($tableName); @@ -90,7 +91,7 @@ public function testDropTable() : void self::assertFalse($schema->hasTable('foo')); } - public function testCreateTable() : void + public function testCreateTable(): void { $schema = new Schema(); @@ -103,7 +104,7 @@ public function testCreateTable() : void self::assertTrue($schema->hasTable('foo')); } - public function testAddSequences() : void + public function testAddSequences(): void { $sequence = new Sequence('a_seq', 1, 1); @@ -116,7 +117,7 @@ public function testAddSequences() : void self::assertArrayHasKey('public.a_seq', $sequences); } - public function testSequenceAccessCaseInsensitive() : void + public function testSequenceAccessCaseInsensitive(): void { $sequence = new Sequence('a_Seq'); @@ -130,7 +131,7 @@ public function testSequenceAccessCaseInsensitive() : void self::assertEquals($sequence, $schema->getSequence('A_SEQ')); } - public function testGetUnknownSequenceThrowsException() : void + public function testGetUnknownSequenceThrowsException(): void { $this->expectException(SchemaException::class); @@ -138,7 +139,7 @@ public function testGetUnknownSequenceThrowsException() : void $schema->getSequence('unknown'); } - public function testCreateSequence() : void + public function testCreateSequence(): void { $schema = new Schema(); $sequence = $schema->createSequence('a_seq', 10, 20); @@ -154,7 +155,7 @@ public function testCreateSequence() : void self::assertArrayHasKey('public.a_seq', $sequences); } - public function testDropSequence() : void + public function testDropSequence(): void { $sequence = new Sequence('a_seq', 1, 1); @@ -164,7 +165,7 @@ public function testDropSequence() : void self::assertFalse($schema->hasSequence('a_seq')); } - public function testAddSequenceTwiceThrowsException() : void + public function testAddSequenceTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -173,7 +174,7 @@ public function testAddSequenceTwiceThrowsException() : void $schema = new Schema([], [$sequence, $sequence]); } - public function testConfigMaxIdentifierLength() : void + public function testConfigMaxIdentifierLength(): void { $schemaConfig = new SchemaConfig(); $schemaConfig->setMaxIdentifierLength(5); @@ -187,7 +188,7 @@ public function testConfigMaxIdentifierLength() : void self::assertEquals(5, strlen($index->getName())); } - public function testDeepClone() : void + public function testDeepClone(): void { $schema = new Schema(); $sequence = $schema->createSequence('baz'); @@ -222,7 +223,7 @@ public function testDeepClone() : void /** * @group DBAL-219 */ - public function testHasTableForQuotedAsset() : void + public function testHasTableForQuotedAsset(): void { $schema = new Schema(); @@ -235,7 +236,7 @@ public function testHasTableForQuotedAsset() : void /** * @group DBAL-669 */ - public function testHasNamespace() : void + public function testHasNamespace(): void { $schema = new Schema(); @@ -259,7 +260,7 @@ public function testHasNamespace() : void /** * @group DBAL-669 */ - public function testCreatesNamespace() : void + public function testCreatesNamespace(): void { $schema = new Schema(); @@ -285,7 +286,7 @@ public function testCreatesNamespace() : void /** * @group DBAL-669 */ - public function testThrowsExceptionOnCreatingNamespaceTwice() : void + public function testThrowsExceptionOnCreatingNamespaceTwice(): void { $schema = new Schema(); @@ -299,7 +300,7 @@ public function testThrowsExceptionOnCreatingNamespaceTwice() : void /** * @group DBAL-669 */ - public function testCreatesNamespaceThroughAddingTableImplicitly() : void + public function testCreatesNamespaceThroughAddingTableImplicitly(): void { $schema = new Schema(); @@ -329,7 +330,7 @@ public function testCreatesNamespaceThroughAddingTableImplicitly() : void /** * @group DBAL-669 */ - public function testCreatesNamespaceThroughAddingSequenceImplicitly() : void + public function testCreatesNamespaceThroughAddingSequenceImplicitly(): void { $schema = new Schema(); @@ -359,7 +360,7 @@ public function testCreatesNamespaceThroughAddingSequenceImplicitly() : void /** * @group DBAL-669 */ - public function testVisitsVisitor() : void + public function testVisitsVisitor(): void { $schema = new Schema(); $visitor = $this->createMock(Visitor::class); @@ -405,7 +406,7 @@ public function testVisitsVisitor() : void /** * @group DBAL-669 */ - public function testVisitsNamespaceVisitor() : void + public function testVisitsNamespaceVisitor(): void { $schema = new Schema(); $visitor = $this->createMock(AbstractVisitor::class); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php index d13d0a908a6..a6314904c4e 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SequenceTest.php @@ -11,7 +11,7 @@ class SequenceTest extends DbalTestCase /** * @group DDC-1657 */ - public function testIsAutoincrementFor() : void + public function testIsAutoincrementFor(): void { $table = new Table('foo'); $table->addColumn('id', 'integer', ['autoincrement' => true]); @@ -26,7 +26,7 @@ public function testIsAutoincrementFor() : void self::assertFalse($sequence3->isAutoIncrementsFor($table)); } - public function testIsAutoincrementForCaseInsensitive() : void + public function testIsAutoincrementForCaseInsensitive(): void { $table = new Table('foo'); $table->addColumn('ID', 'integer', ['autoincrement' => true]); diff --git a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php index 3677212f240..5a473d13c92 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SqliteSchemaManagerTest.php @@ -14,7 +14,7 @@ class SqliteSchemaManagerTest extends TestCase * @dataProvider getDataColumnCollation * @group 2865 */ - public function testParseColumnCollation(?string $collation, string $column, string $sql) : void + public function testParseColumnCollation(?string $collation, string $column, string $sql): void { $conn = $this->createMock(Connection::class); $conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform()); @@ -29,7 +29,7 @@ public function testParseColumnCollation(?string $collation, string $column, str /** * @return mixed[][] */ - public static function getDataColumnCollation() : iterable + public static function getDataColumnCollation(): iterable { return [ ['RTRIM', 'a', 'CREATE TABLE "a" ("a" text DEFAULT "aa" COLLATE "RTRIM" NOT NULL)'], @@ -55,7 +55,7 @@ public static function getDataColumnCollation() : iterable * @dataProvider getDataColumnComment * @group 2865 */ - public function testParseColumnCommentFromSQL(?string $comment, string $column, string $sql) : void + public function testParseColumnCommentFromSQL(?string $comment, string $column, string $sql): void { $conn = $this->createMock(Connection::class); $conn->method('getDatabasePlatform')->willReturn(new SqlitePlatform()); @@ -70,7 +70,7 @@ public function testParseColumnCommentFromSQL(?string $comment, string $column, /** * @return mixed[][] */ - public static function getDataColumnComment() : iterable + public static function getDataColumnComment(): iterable { return [ 'Single column with no comment' => [ diff --git a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php index ad24ca599a6..c2dc73b3cb8 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizerTest.php @@ -19,7 +19,7 @@ class SingleDatabaseSynchronizerTest extends TestCase /** @var SingleDatabaseSynchronizer */ private $synchronizer; - protected function setUp() : void + protected function setUp(): void { $this->conn = DriverManager::getConnection([ 'driver' => 'pdo_sqlite', @@ -28,7 +28,7 @@ protected function setUp() : void $this->synchronizer = new SingleDatabaseSynchronizer($this->conn); } - public function testGetCreateSchema() : void + public function testGetCreateSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -39,7 +39,7 @@ public function testGetCreateSchema() : void self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql); } - public function testGetUpdateSchema() : void + public function testGetUpdateSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -50,7 +50,7 @@ public function testGetUpdateSchema() : void self::assertEquals(['CREATE TABLE test (id INTEGER NOT NULL, PRIMARY KEY(id))'], $sql); } - public function testGetDropSchema() : void + public function testGetDropSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); @@ -63,7 +63,7 @@ public function testGetDropSchema() : void self::assertEquals(['DROP TABLE test'], $sql); } - public function testGetDropAllSchema() : void + public function testGetDropAllSchema(): void { $schema = new Schema(); $table = $schema->createTable('test'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php index 7ae17019f83..2a5608608bb 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableDiffTest.php @@ -14,7 +14,7 @@ class TableDiffTest extends TestCase /** @var AbstractPlatform|MockObject */ private $platform; - public function setUp() : void + public function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); } @@ -22,7 +22,7 @@ public function setUp() : void /** * @group DBAL-1013 */ - public function testReturnsName() : void + public function testReturnsName(): void { $tableDiff = new TableDiff('foo'); @@ -32,7 +32,7 @@ public function testReturnsName() : void /** * @group DBAL-1016 */ - public function testPrefersNameFromTableObject() : void + public function testPrefersNameFromTableObject(): void { $tableMock = $this->getMockBuilder(Table::class) ->disableOriginalConstructor() @@ -52,7 +52,7 @@ public function testPrefersNameFromTableObject() : void /** * @group DBAL-1013 */ - public function testReturnsNewName() : void + public function testReturnsNewName(): void { $tableDiff = new TableDiff('foo'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index d330e758184..f98062b50b2 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -12,25 +12,26 @@ use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; + use function array_shift; use function current; class TableTest extends DbalTestCase { - public function testCreateWithInvalidTableName() : void + public function testCreateWithInvalidTableName(): void { $this->expectException(DBALException::class); new Table(''); } - public function testGetName() : void + public function testGetName(): void { $table = new Table('foo', [], [], []); self::assertEquals('foo', $table->getName()); } - public function testColumns() : void + public function testColumns(): void { $type = Type::getType('integer'); $columns = []; @@ -48,7 +49,7 @@ public function testColumns() : void self::assertCount(2, $table->getColumns()); } - public function testColumnsCaseInsensitive() : void + public function testColumnsCaseInsensitive(): void { $table = new Table('foo'); $column = $table->addColumn('Foo', 'integer'); @@ -62,7 +63,7 @@ public function testColumnsCaseInsensitive() : void self::assertSame($column, $table->getColumn('FOO')); } - public function testCreateColumn() : void + public function testCreateColumn(): void { $type = Type::getType('integer'); @@ -74,7 +75,7 @@ public function testCreateColumn() : void self::assertSame($type, $table->getColumn('bar')->getType()); } - public function testDropColumn() : void + public function testDropColumn(): void { $type = Type::getType('integer'); $columns = []; @@ -91,7 +92,7 @@ public function testDropColumn() : void self::assertFalse($table->hasColumn('bar')); } - public function testGetUnknownColumnThrowsException() : void + public function testGetUnknownColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -99,7 +100,7 @@ public function testGetUnknownColumnThrowsException() : void $table->getColumn('unknown'); } - public function testAddColumnTwiceThrowsException() : void + public function testAddColumnTwiceThrowsException(): void { $this->expectException(SchemaException::class); @@ -110,7 +111,7 @@ public function testAddColumnTwiceThrowsException() : void $table = new Table('foo', $columns, [], []); } - public function testCreateIndex() : void + public function testCreateIndex(): void { $type = Type::getType('integer'); $columns = [new Column('foo', $type), new Column('bar', $type), new Column('baz', $type)]; @@ -123,7 +124,7 @@ public function testCreateIndex() : void self::assertTrue($table->hasIndex('foo_bar_baz_uniq')); } - public function testIndexCaseInsensitive() : void + public function testIndexCaseInsensitive(): void { $type = Type::getType('integer'); $columns = [ @@ -140,7 +141,7 @@ public function testIndexCaseInsensitive() : void self::assertTrue($table->hasIndex('FOO_IDX')); } - public function testAddIndexes() : void + public function testAddIndexes(): void { $type = Type::getType('integer'); $columns = [ @@ -162,7 +163,7 @@ public function testAddIndexes() : void self::assertInstanceOf(Index::class, $table->getIndex('bar_idx')); } - public function testGetUnknownIndexThrowsException() : void + public function testGetUnknownIndexThrowsException(): void { $this->expectException(SchemaException::class); @@ -170,7 +171,7 @@ public function testGetUnknownIndexThrowsException() : void $table->getIndex('unknownIndex'); } - public function testAddTwoPrimaryThrowsException() : void + public function testAddTwoPrimaryThrowsException(): void { $this->expectException(SchemaException::class); @@ -183,7 +184,7 @@ public function testAddTwoPrimaryThrowsException() : void $table = new Table('foo', $columns, $indexes, []); } - public function testAddTwoIndexesWithSameNameThrowsException() : void + public function testAddTwoIndexesWithSameNameThrowsException(): void { $this->expectException(SchemaException::class); @@ -196,7 +197,7 @@ public function testAddTwoIndexesWithSameNameThrowsException() : void $table = new Table('foo', $columns, $indexes, []); } - public function testConstraints() : void + public function testConstraints(): void { $constraint = new ForeignKeyConstraint([], 'foo', []); @@ -207,7 +208,7 @@ public function testConstraints() : void self::assertSame($constraint, array_shift($constraints)); } - public function testOptions() : void + public function testOptions(): void { $table = new Table('foo', [], [], [], false, ['foo' => 'bar']); @@ -215,7 +216,7 @@ public function testOptions() : void self::assertEquals('bar', $table->getOption('foo')); } - public function testBuilderSetPrimaryKey() : void + public function testBuilderSetPrimaryKey(): void { $table = new Table('foo'); @@ -228,7 +229,7 @@ public function testBuilderSetPrimaryKey() : void self::assertTrue($table->getIndex('primary')->isPrimary()); } - public function testBuilderAddUniqueIndex() : void + public function testBuilderAddUniqueIndex(): void { $table = new Table('foo'); @@ -240,7 +241,7 @@ public function testBuilderAddUniqueIndex() : void self::assertFalse($table->getIndex('my_idx')->isPrimary()); } - public function testBuilderAddIndex() : void + public function testBuilderAddIndex(): void { $table = new Table('foo'); @@ -252,7 +253,7 @@ public function testBuilderAddIndex() : void self::assertFalse($table->getIndex('my_idx')->isPrimary()); } - public function testBuilderAddIndexWithInvalidNameThrowsException() : void + public function testBuilderAddIndexWithInvalidNameThrowsException(): void { $this->expectException(SchemaException::class); @@ -261,7 +262,7 @@ public function testBuilderAddIndexWithInvalidNameThrowsException() : void $table->addIndex(['bar'], 'invalid name %&/'); } - public function testBuilderAddIndexWithUnknownColumnThrowsException() : void + public function testBuilderAddIndexWithUnknownColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -269,7 +270,7 @@ public function testBuilderAddIndexWithUnknownColumnThrowsException() : void $table->addIndex(['bar'], 'invalidName'); } - public function testBuilderOptions() : void + public function testBuilderOptions(): void { $table = new Table('foo'); $table->addOption('foo', 'bar'); @@ -277,7 +278,7 @@ public function testBuilderOptions() : void self::assertEquals('bar', $table->getOption('foo')); } - public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException() : void + public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -290,7 +291,7 @@ public function testAddForeignKeyConstraintUnknownLocalColumnThrowsException() : $table->addForeignKeyConstraint($foreignTable, ['foo'], ['id']); } - public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException() : void + public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException(): void { $this->expectException(SchemaException::class); @@ -303,7 +304,7 @@ public function testAddForeignKeyConstraintUnknownForeignColumnThrowsException() $table->addForeignKeyConstraint($foreignTable, ['id'], ['foo']); } - public function testAddForeignKeyConstraint() : void + public function testAddForeignKeyConstraint(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -323,7 +324,7 @@ public function testAddForeignKeyConstraint() : void self::assertEquals('bar', $constraint->getOption('foo')); } - public function testAddIndexWithCaseSensitiveColumnProblem() : void + public function testAddIndexWithCaseSensitiveColumnProblem(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -335,7 +336,7 @@ public function testAddIndexWithCaseSensitiveColumnProblem() : void self::assertTrue($table->getIndex('my_idx')->spansColumns(['id'])); } - public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull() : void + public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull(): void { $table = new Table('foo'); $column = $table->addColumn('id', 'integer', ['notnull' => false]); @@ -350,7 +351,7 @@ public function testAddPrimaryKeyColumnsAreExplicitlySetToNotNull() : void /** * @group DDC-133 */ - public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() : void + public function testAllowImplicitSchemaTableInAutogeneratedIndexNames(): void { $table = new Table('foo.bar'); $table->addColumn('baz', 'integer', []); @@ -362,7 +363,7 @@ public function testAllowImplicitSchemaTableInAutogeneratedIndexNames() : void /** * @group DBAL-50 */ - public function testAddForeignKeyIndexImplicitly() : void + public function testAddForeignKeyIndexImplicitly(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -383,7 +384,7 @@ public function testAddForeignKeyIndexImplicitly() : void /** * @group DBAL-1063 */ - public function testAddForeignKeyDoesNotCreateDuplicateIndex() : void + public function testAddForeignKeyDoesNotCreateDuplicateIndex(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -402,7 +403,7 @@ public function testAddForeignKeyDoesNotCreateDuplicateIndex() : void /** * @group DBAL-1063 */ - public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan() : void + public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -430,7 +431,7 @@ public function testAddForeignKeyAddsImplicitIndexIfIndexColumnsDoNotSpan() : vo * @group DBAL-50 * @group DBAL-1063 */ - public function testOverrulingIndexDoesNotDropOverruledIndex() : void + public function testOverrulingIndexDoesNotDropOverruledIndex(): void { $table = new Table('bar'); $table->addColumn('baz', 'integer', []); @@ -448,7 +449,7 @@ public function testOverrulingIndexDoesNotDropOverruledIndex() : void /** * @group DBAL-1063 */ - public function testAllowsAddingDuplicateIndexesBasedOnColumns() : void + public function testAllowsAddingDuplicateIndexesBasedOnColumns(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -465,7 +466,7 @@ public function testAllowsAddingDuplicateIndexesBasedOnColumns() : void /** * @group DBAL-1063 */ - public function testAllowsAddingFulfillingIndexesBasedOnColumns() : void + public function testAllowsAddingFulfillingIndexesBasedOnColumns(): void { $table = new Table('foo'); $table->addColumn('bar', 'integer'); @@ -484,7 +485,7 @@ public function testAllowsAddingFulfillingIndexesBasedOnColumns() : void * @group DBAL-50 * @group DBAL-1063 */ - public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex() : void + public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex(): void { $table = new Table('bar'); $table->addColumn('baz', 'integer', []); @@ -499,7 +500,7 @@ public function testPrimaryKeyOverrulingUniqueIndexDoesNotDropUniqueIndex() : vo self::assertTrue($table->hasIndex('idx_unique')); } - public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -516,7 +517,7 @@ public function testAddingFulfillingRegularIndexOverridesImplicitForeignKeyConst self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -533,7 +534,7 @@ public function testAddingFulfillingUniqueIndexOverridesImplicitForeignKeyConstr self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex() : void + public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstraintIndex(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -550,7 +551,7 @@ public function testAddingFulfillingPrimaryKeyOverridesImplicitForeignKeyConstra self::assertTrue($localTable->hasIndex('explicit_idx')); } - public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException() : void + public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyConstraintIndexWithSameNameDoesNotThrowException(): void { $foreignTable = new Table('foreign'); $foreignTable->addColumn('id', 'integer'); @@ -574,7 +575,7 @@ public function testAddingFulfillingExplicitIndexOverridingImplicitForeignKeyCon /** * @group DBAL-64 */ - public function testQuotedTableName() : void + public function testQuotedTableName(): void { $table = new Table('`bar`'); @@ -589,7 +590,7 @@ public function testQuotedTableName() : void /** * @group DBAL-79 */ - public function testTableHasPrimaryKey() : void + public function testTableHasPrimaryKey(): void { $table = new Table('test'); @@ -604,7 +605,7 @@ public function testTableHasPrimaryKey() : void /** * @group DBAL-91 */ - public function testAddIndexWithQuotedColumns() : void + public function testAddIndexWithQuotedColumns(): void { $table = new Table('test'); $table->addColumn('"foo"', 'integer'); @@ -617,7 +618,7 @@ public function testAddIndexWithQuotedColumns() : void /** * @group DBAL-91 */ - public function testAddForeignKeyWithQuotedColumnsAndTable() : void + public function testAddForeignKeyWithQuotedColumnsAndTable(): void { $table = new Table('test'); $table->addColumn('"foo"', 'integer'); @@ -630,7 +631,7 @@ public function testAddForeignKeyWithQuotedColumnsAndTable() : void /** * @group DBAL-177 */ - public function testQuoteSchemaPrefixed() : void + public function testQuoteSchemaPrefixed(): void { $table = new Table('`test`.`test`'); self::assertEquals('test.test', $table->getName()); @@ -640,7 +641,7 @@ public function testQuoteSchemaPrefixed() : void /** * @group DBAL-204 */ - public function testFullQualifiedTableName() : void + public function testFullQualifiedTableName(): void { $table = new Table('`test`.`test`'); self::assertEquals('test.test', $table->getFullQualifiedName('test')); @@ -654,7 +655,7 @@ public function testFullQualifiedTableName() : void /** * @group DBAL-224 */ - public function testDropIndex() : void + public function testDropIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -669,7 +670,7 @@ public function testDropIndex() : void /** * @group DBAL-224 */ - public function testDropPrimaryKey() : void + public function testDropPrimaryKey(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -684,7 +685,7 @@ public function testDropPrimaryKey() : void /** * @group DBAL-234 */ - public function testRenameIndex() : void + public function testRenameIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -756,7 +757,7 @@ public function testRenameIndex() : void /** * @group DBAL-2508 */ - public function testKeepsIndexOptionsOnRenamingRegularIndex() : void + public function testKeepsIndexOptionsOnRenamingRegularIndex(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -770,7 +771,7 @@ public function testKeepsIndexOptionsOnRenamingRegularIndex() : void /** * @group DBAL-2508 */ - public function testKeepsIndexOptionsOnRenamingUniqueIndex() : void + public function testKeepsIndexOptionsOnRenamingUniqueIndex(): void { $table = new Table('foo'); $table->addColumn('id', 'integer'); @@ -784,7 +785,7 @@ public function testKeepsIndexOptionsOnRenamingUniqueIndex() : void /** * @group DBAL-234 */ - public function testThrowsExceptionOnRenamingNonExistingIndex() : void + public function testThrowsExceptionOnRenamingNonExistingIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -798,7 +799,7 @@ public function testThrowsExceptionOnRenamingNonExistingIndex() : void /** * @group DBAL-234 */ - public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() : void + public function testThrowsExceptionOnRenamingToAlreadyExistingIndex(): void { $table = new Table('test'); $table->addColumn('id', 'integer'); @@ -815,7 +816,7 @@ public function testThrowsExceptionOnRenamingToAlreadyExistingIndex() : void * @dataProvider getNormalizesAssetNames * @group DBAL-831 */ - public function testNormalizesColumnNames(string $assetName) : void + public function testNormalizesColumnNames(string $assetName): void { $table = new Table('test'); @@ -872,7 +873,7 @@ public function testNormalizesColumnNames(string $assetName) : void /** * @return mixed[][] */ - public static function getNormalizesAssetNames() : iterable + public static function getNormalizesAssetNames(): iterable { return [ ['foo'], @@ -886,7 +887,7 @@ public static function getNormalizesAssetNames() : iterable ]; } - public function testTableComment() : void + public function testTableComment(): void { $table = new Table('bar'); self::assertNull($table->getComment()); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index c60c2c41e71..ae7ba2a1efc 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -18,7 +18,7 @@ class CreateSchemaSqlCollectorTest extends TestCase /** @var CreateSchemaSqlCollector */ private $visitor; - protected function setUp() : void + protected function setUp(): void { parent::setUp(); @@ -45,7 +45,7 @@ protected function setUp() : void ->willReturn(['foo']); } - public function testAcceptsNamespace() : void + public function testAcceptsNamespace(): void { $this->platformMock->expects($this->at(0)) ->method('supportsSchemas') @@ -64,7 +64,7 @@ public function testAcceptsNamespace() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsTable() : void + public function testAcceptsTable(): void { $table = $this->createTableMock(); @@ -73,7 +73,7 @@ public function testAcceptsTable() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsForeignKey() : void + public function testAcceptsForeignKey(): void { $this->platformMock->expects($this->at(0)) ->method('supportsCreateDropForeignKeyConstraints') @@ -95,7 +95,7 @@ public function testAcceptsForeignKey() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsSequences() : void + public function testAcceptsSequences(): void { $sequence = $this->createSequenceMock(); @@ -104,7 +104,7 @@ public function testAcceptsSequences() : void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testResetsQueries() : void + public function testResetsQueries(): void { foreach (['supportsSchemas', 'supportsCreateDropForeignKeyConstraints'] as $method) { $this->platformMock->expects($this->any()) diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php index 12e3678cbf6..bd663dc93e6 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -14,7 +14,7 @@ */ class DropSchemaSqlCollectorTest extends TestCase { - public function testGetQueriesUsesAcceptedForeignKeys() : void + public function testGetQueriesUsesAcceptedForeignKeys(): void { $tableOne = $this->createMock(Table::class); $tableTwo = $this->createMock(Table::class); @@ -45,7 +45,7 @@ public function testGetQueriesUsesAcceptedForeignKeys() : void $collector->getQueries(); } - private function getStubKeyConstraint(string $name) : ForeignKeyConstraint + private function getStubKeyConstraint(string $name): ForeignKeyConstraint { $constraint = $this->createMock(ForeignKeyConstraint::class); @@ -64,7 +64,7 @@ private function getStubKeyConstraint(string $name) : ForeignKeyConstraint return $constraint; } - public function testGivenForeignKeyWithZeroLengthAcceptForeignKeyThrowsException() : void + public function testGivenForeignKeyWithZeroLengthAcceptForeignKeyThrowsException(): void { $collector = new DropSchemaSqlCollector( $this->getMockForAbstractClass(AbstractPlatform::class) diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php index 982da52ec44..bf4127e0143 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/RemoveNamespacedAssetsTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\SchemaConfig; use Doctrine\DBAL\Schema\Visitor\RemoveNamespacedAssets; use PHPUnit\Framework\TestCase; + use function array_keys; class RemoveNamespacedAssetsTest extends TestCase @@ -14,7 +15,7 @@ class RemoveNamespacedAssetsTest extends TestCase /** * @group DBAL-204 */ - public function testRemoveNamespacedAssets() : void + public function testRemoveNamespacedAssets(): void { $config = new SchemaConfig(); $config->setName('test'); @@ -33,7 +34,7 @@ public function testRemoveNamespacedAssets() : void /** * @group DBAL-204 */ - public function testCleanupForeignKeys() : void + public function testCleanupForeignKeys(): void { $config = new SchemaConfig(); $config->setName('test'); @@ -56,7 +57,7 @@ public function testCleanupForeignKeys() : void /** * @group DBAL-204 */ - public function testCleanupForeignKeysDifferentOrder() : void + public function testCleanupForeignKeysDifferentOrder(): void { $config = new SchemaConfig(); $config->setName('test'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php index 60c7f2a1f5b..93ccef355f9 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php @@ -8,7 +8,7 @@ class SchemaSqlCollectorTest extends TestCase { - public function testCreateSchema() : void + public function testCreateSchema(): void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->onlyMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) @@ -30,7 +30,7 @@ public function testCreateSchema() : void self::assertEquals(['foo', 'foo', 'bar', 'baz'], $sql); } - public function testDropSchema() : void + public function testDropSchema(): void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) ->onlyMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) @@ -52,7 +52,7 @@ public function testDropSchema() : void self::assertEquals(['fk', 'seq', 'tbl', 'tbl'], $sql); } - public function createFixtureSchema() : Schema + public function createFixtureSchema(): Schema { $schema = new Schema(); $tableA = $schema->createTable('foo'); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php index c782b06b919..ada144c9922 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardConnectionTest.php @@ -14,7 +14,7 @@ */ class PoolingShardConnectionTest extends TestCase { - public function testConnect() : void + public function testConnect(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -48,7 +48,7 @@ public function testConnect() : void self::assertFalse($conn->isConnected(2)); } - public function testNoGlobalServerException() : void + public function testNoGlobalServerException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); @@ -64,7 +64,7 @@ public function testNoGlobalServerException() : void ]); } - public function testNoShardsServersException() : void + public function testNoShardsServersException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Connection Parameters require 'global' and 'shards' configurations."); @@ -77,7 +77,7 @@ public function testNoShardsServersException() : void ]); } - public function testNoShardsChoserException() : void + public function testNoShardsChoserException(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Missing Shard Choser configuration 'shardChoser'"); @@ -93,7 +93,7 @@ public function testNoShardsChoserException() : void ]); } - public function testShardChoserWrongInstance() : void + public function testShardChoserWrongInstance(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("The 'shardChoser' configuration is not a valid instance of Doctrine\DBAL\Sharding\ShardChoser\ShardChoser"); @@ -110,7 +110,7 @@ public function testShardChoserWrongInstance() : void ]); } - public function testShardNonNumericId() : void + public function testShardNonNumericId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Shard Id has to be a non-negative number.'); @@ -126,7 +126,7 @@ public function testShardNonNumericId() : void ]); } - public function testShardMissingId() : void + public function testShardMissingId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Missing 'id' for one configured shard. Please specify a unique shard-id."); @@ -142,7 +142,7 @@ public function testShardMissingId() : void ]); } - public function testDuplicateShardId() : void + public function testDuplicateShardId(): void { $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Shard 1 is duplicated in the configuration.'); @@ -159,7 +159,7 @@ public function testDuplicateShardId() : void ]); } - public function testSwitchShardWithOpenTransactionException() : void + public function testSwitchShardWithOpenTransactionException(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -178,7 +178,7 @@ public function testSwitchShardWithOpenTransactionException() : void $conn->connect(1); } - public function testGetActiveShardId() : void + public function testGetActiveShardId(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -202,7 +202,7 @@ public function testGetActiveShardId() : void self::assertNull($conn->getActiveShardId()); } - public function testGetParamsOverride() : void + public function testGetParamsOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -241,7 +241,7 @@ public function testGetParamsOverride() : void ], $conn->getParams()); } - public function testGetHostOverride() : void + public function testGetHostOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -260,7 +260,7 @@ public function testGetHostOverride() : void self::assertEquals('foo', $conn->getHost()); } - public function testGetPortOverride() : void + public function testGetPortOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -279,7 +279,7 @@ public function testGetPortOverride() : void self::assertEquals(3307, $conn->getPort()); } - public function testGetUsernameOverride() : void + public function testGetUsernameOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, @@ -298,7 +298,7 @@ public function testGetUsernameOverride() : void self::assertEquals('bar', $conn->getUsername()); } - public function testGetPasswordOverride() : void + public function testGetPasswordOverride(): void { $conn = DriverManager::getConnection([ 'wrapperClass' => PoolingShardConnection::class, diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index 2143bb2be7f..3e723243ff7 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -13,7 +13,7 @@ class PoolingShardManagerTest extends TestCase /** * @return PoolingShardConnection|MockObject */ - private function createConnectionMock() : PoolingShardConnection + private function createConnectionMock(): PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) ->onlyMethods(['connect', 'getParams', 'fetchAllAssociative']) @@ -21,7 +21,7 @@ private function createConnectionMock() : PoolingShardConnection ->getMock(); } - private function createPassthroughShardChoser() : ShardChoser + private function createPassthroughShardChoser(): ShardChoser { $mock = $this->createMock(ShardChoser::class); $mock->expects($this->any()) @@ -33,7 +33,7 @@ private function createPassthroughShardChoser() : ShardChoser return $mock; } - private function createStaticShardChooser() : ShardChoser + private function createStaticShardChooser(): ShardChoser { $mock = $this->createMock(ShardChoser::class); $mock->expects($this->any()) @@ -43,7 +43,7 @@ private function createStaticShardChooser() : ShardChoser return $mock; } - public function testSelectGlobal() : void + public function testSelectGlobal(): void { $conn = $this->createConnectionMock(); $conn->expects($this->once())->method('connect')->with($this->equalTo(0)); @@ -58,7 +58,7 @@ public function testSelectGlobal() : void self::assertNull($shardManager->getCurrentDistributionValue()); } - public function testSelectShard() : void + public function testSelectShard(): void { $shardId = 10; $conn = $this->createConnectionMock(); @@ -71,12 +71,12 @@ public function testSelectShard() : void self::assertEquals($shardId, $shardManager->getCurrentDistributionValue()); } - public function testGetShards() : void + public function testGetShards(): void { $conn = $this->createConnectionMock(); $conn->expects($this->any())->method('getParams')->will( $this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] ) ); @@ -86,7 +86,7 @@ public function testGetShards() : void self::assertEquals([['id' => 1], ['id' => 2]], $shards); } - public function testQueryAll() : void + public function testQueryAll(): void { $sql = 'SELECT * FROM table'; $params = [1]; @@ -94,21 +94,21 @@ public function testQueryAll() : void $conn = $this->createConnectionMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] )); $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createPassthroughShardChoser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 1] ])); + ->will($this->returnValue([['id' => 1]])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 2] ])); + ->will($this->returnValue([['id' => 2]])); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); @@ -116,7 +116,7 @@ public function testQueryAll() : void self::assertEquals([['id' => 1], ['id' => 2]], $result); } - public function testQueryAllWithStaticShardChoser() : void + public function testQueryAllWithStaticShardChoser(): void { $sql = 'SELECT * FROM table'; $params = [1]; @@ -124,21 +124,21 @@ public function testQueryAllWithStaticShardChoser() : void $conn = $this->createConnectionMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] )); $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [ ['id' => 1], ['id' => 2] ], 'shardChoser' => $this->createStaticShardChooser()] + ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] )); $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); $conn->expects($this->at(3)) ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 1] ])); + ->will($this->returnValue([['id' => 1]])); $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); $conn->expects($this->at(5)) ->method('fetchAllAssociative') ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([ ['id' => 2] ])); + ->will($this->returnValue([['id' => 2]])); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php index b0439d5dfe2..146f81bf99b 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/AbstractTestCase.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager; use PHPUnit\Framework\TestCase; + use function strpos; abstract class AbstractTestCase extends TestCase @@ -17,7 +18,7 @@ abstract class AbstractTestCase extends TestCase /** @var SQLAzureShardManager */ protected $sm; - protected function setUp() : void + protected function setUp(): void { if (! isset($GLOBALS['db_type']) || strpos($GLOBALS['db_type'], 'sqlsrv') === false) { $this->markTestSkipped('No driver or sqlserver driver specified.'); @@ -52,7 +53,7 @@ protected function setUp() : void $this->sm = new SQLAzureShardManager($this->conn); } - protected function createShopSchema() : Schema + protected function createShopSchema(): Schema { $schema = new Schema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php index 6e31d8716ed..98ab482a7c6 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/FunctionalTest.php @@ -3,11 +3,12 @@ namespace Doctrine\Tests\DBAL\Sharding\SQLAzure; use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureFederationsSynchronizer; + use function count; class FunctionalTest extends AbstractTestCase { - public function testSharding() : void + public function testSharding(): void { $schema = $this->createShopSchema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php index 3549cf40b0e..f12379fafee 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/MultiTenantVisitorTest.php @@ -9,7 +9,7 @@ class MultiTenantVisitorTest extends TestCase { - public function testMultiTenantPrimaryKey() : void + public function testMultiTenantPrimaryKey(): void { $platform = new SQLAzurePlatform(); $visitor = new MultiTenantVisitor(); @@ -24,7 +24,7 @@ public function testMultiTenantPrimaryKey() : void self::assertTrue($foo->hasColumn('tenant_id')); } - public function testMultiTenantNonPrimaryKey() : void + public function testMultiTenantNonPrimaryKey(): void { $platform = new SQLAzurePlatform(); $visitor = new MultiTenantVisitor(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php index 2185a9fc8d1..6996df162e6 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureFederationsSynchronizerTest.php @@ -6,7 +6,7 @@ class SQLAzureFederationsSynchronizerTest extends AbstractTestCase { - public function testCreateSchema() : void + public function testCreateSchema(): void { $schema = $this->createShopSchema(); @@ -23,7 +23,7 @@ public function testCreateSchema() : void ], $sql); } - public function testUpdateSchema() : void + public function testUpdateSchema(): void { $schema = $this->createShopSchema(); @@ -35,7 +35,7 @@ public function testUpdateSchema() : void self::assertEquals([], $sql); } - public function testDropSchema() : void + public function testDropSchema(): void { $schema = $this->createShopSchema(); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php index 242c7a0fe52..950ae251a6c 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php @@ -10,7 +10,7 @@ class SQLAzureShardManagerTest extends TestCase { - public function testNoFederationName() : void + public function testNoFederationName(): void { $this->expectException(ShardingException::class); $this->expectExceptionMessage('SQLAzure requires a federation name to be set during sharding configuration.'); @@ -19,7 +19,7 @@ public function testNoFederationName() : void new SQLAzureShardManager($conn); } - public function testNoDistributionKey() : void + public function testNoDistributionKey(): void { $this->expectException(ShardingException::class); $this->expectExceptionMessage('SQLAzure requires a distribution key to be set during sharding configuration.'); @@ -28,7 +28,7 @@ public function testNoDistributionKey() : void new SQLAzureShardManager($conn); } - public function testNoDistributionType() : void + public function testNoDistributionType(): void { $this->expectException(ShardingException::class); @@ -36,7 +36,7 @@ public function testNoDistributionType() : void new SQLAzureShardManager($conn); } - public function testGetDefaultDistributionValue() : void + public function testGetDefaultDistributionValue(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); @@ -44,7 +44,7 @@ public function testGetDefaultDistributionValue() : void self::assertNull($sm->getCurrentDistributionValue()); } - public function testSelectGlobalTransactionActive() : void + public function testSelectGlobalTransactionActive(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); @@ -56,7 +56,7 @@ public function testSelectGlobalTransactionActive() : void $sm->selectGlobal(); } - public function testSelectGlobal() : void + public function testSelectGlobal(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); @@ -66,7 +66,7 @@ public function testSelectGlobal() : void $sm->selectGlobal(); } - public function testSelectShard() : void + public function testSelectShard(): void { $conn = $this->createConnection(['sharding' => ['federationName' => 'abc', 'distributionKey' => 'foo', 'distributionType' => 'integer']]); $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); @@ -85,7 +85,7 @@ public function testSelectShard() : void * * @return Connection&MockObject */ - private function createConnection(array $params) : Connection + private function createConnection(array $params): Connection { $conn = $this->getMockBuilder(Connection::class) ->onlyMethods(['getParams', 'exec', 'isTransactionActive']) diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php index 5b65deecc77..ea509cb98f4 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php @@ -8,7 +8,7 @@ class MultiTenantShardChoserTest extends TestCase { - public function testPickShard() : void + public function testPickShard(): void { $choser = new MultiTenantShardChoser(); $conn = $this->createConnectionMock(); @@ -17,7 +17,7 @@ public function testPickShard() : void self::assertEquals(2, $choser->pickShard(2, $conn)); } - private function createConnectionMock() : PoolingShardConnection + private function createConnectionMock(): PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) ->onlyMethods(['connect', 'getParams', 'fetchAll']) diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 728cc5ab58a..69cae985148 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -27,7 +27,7 @@ class StatementTest extends DbalTestCase /** @var PDOStatement&MockObject */ private $pdoStatement; - protected function setUp() : void + protected function setUp(): void { $this->pdoStatement = $this->getMockBuilder(PDOStatement::class) ->onlyMethods(['execute', 'bindParam', 'bindValue', 'fetchAll']) @@ -57,7 +57,7 @@ protected function setUp() : void ->will($this->returnValue($driver)); } - public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound() : void + public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound(): void { $name = 'foo'; $var = 'bar'; @@ -80,7 +80,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenValuesBound() $statement->execute(); } - public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute() : void + public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedToExecute(): void { $name = 'foo'; $var = 'bar'; @@ -101,7 +101,7 @@ public function testExecuteCallsLoggerStartQueryWithParametersWhenParamsPassedTo $statement->execute($values); } - public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam() : void + public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam(): void { $name = 'foo'; $var = 'bar'; @@ -123,7 +123,7 @@ public function testExecuteCallsStartQueryWithTheParametersBoundViaBindParam() : $statement->execute(); } - public function testExecuteCallsLoggerStopQueryOnException() : void + public function testExecuteCallsLoggerStopQueryOnException(): void { $logger = $this->createMock(SQLLogger::class); @@ -153,7 +153,7 @@ public function testExecuteCallsLoggerStopQueryOnException() : void $statement->execute(); } - public function testPDOCustomClassConstructorArgs() : void + public function testPDOCustomClassConstructorArgs(): void { $statement = new Statement('', $this->conn); diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index 65ccf2fe2ac..ef524e8ceca 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -22,7 +22,7 @@ class RunSqlCommandTest extends TestCase /** @var Connection&MockObject */ private $connectionMock; - protected function setUp() : void + protected function setUp(): void { $application = new Application(); $application->add(new RunSqlCommand()); @@ -40,7 +40,7 @@ protected function setUp() : void $this->command->setHelperSet($helperSet); } - public function testMissingSqlArgument() : void + public function testMissingSqlArgument(): void { try { $this->commandTester->execute([ @@ -53,7 +53,7 @@ public function testMissingSqlArgument() : void } } - public function testIncorrectDepthOption() : void + public function testIncorrectDepthOption(): void { try { $this->commandTester->execute([ @@ -67,7 +67,7 @@ public function testIncorrectDepthOption() : void } } - public function testSelectStatementsPrintsResult() : void + public function testSelectStatementsPrintsResult(): void { $this->expectConnectionFetchAllAssociative(); @@ -81,7 +81,7 @@ public function testSelectStatementsPrintsResult() : void self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay()); } - public function testUpdateStatementsPrintsAffectedLines() : void + public function testUpdateStatementsPrintsAffectedLines(): void { $this->expectConnectionExecuteUpdate(); @@ -94,7 +94,7 @@ public function testUpdateStatementsPrintsAffectedLines() : void self::assertNotRegExp('@array.*1.*@', $this->commandTester->getDisplay()); } - private function expectConnectionExecuteUpdate() : void + private function expectConnectionExecuteUpdate(): void { $this->connectionMock ->expects($this->exactly(1)) @@ -104,7 +104,7 @@ private function expectConnectionExecuteUpdate() : void ->method('fetchAllAssociative'); } - private function expectConnectionFetchAllAssociative() : void + private function expectConnectionFetchAllAssociative(): void { $this->connectionMock ->expects($this->exactly(0)) @@ -114,7 +114,7 @@ private function expectConnectionFetchAllAssociative() : void ->method('fetchAllAssociative'); } - public function testStatementsWithFetchResultPrintsResult() : void + public function testStatementsWithFetchResultPrintsResult(): void { $this->expectConnectionFetchAllAssociative(); diff --git a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php index ba99024231b..47d9e5ff12b 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/DumperTest.php @@ -10,13 +10,14 @@ use Doctrine\DBAL\Tools\Dumper; use Doctrine\Tests\DbalTestCase; use stdClass; + use function print_r; use function strpos; use function substr; class DumperTest extends DbalTestCase { - public function testExportObject() : void + public function testExportObject(): void { $obj = new stdClass(); $obj->foo = 'bar'; @@ -26,7 +27,7 @@ public function testExportObject() : void self::assertEquals('stdClass', $var->__CLASS__); } - public function testExportObjectWithReference() : void + public function testExportObjectWithReference(): void { $foo = 'bar'; $bar = ['foo' => & $foo]; @@ -39,7 +40,7 @@ public function testExportObjectWithReference() : void self::assertEquals('tab', $bar['foo']); } - public function testExportArray() : void + public function testExportArray(): void { $array = ['a' => 'b', 'b' => ['c', 'd' => ['e', 'f']]]; $var = Dumper::export($array, 2); @@ -48,7 +49,7 @@ public function testExportArray() : void self::assertEquals($expected, $var); } - public function testExportDateTime() : void + public function testExportDateTime(): void { $obj = new DateTime('2010-10-10 10:10:10', new DateTimeZone('UTC')); @@ -57,7 +58,7 @@ public function testExportDateTime() : void self::assertEquals('2010-10-10T10:10:10+00:00', $var->date); } - public function testExportDateTimeImmutable() : void + public function testExportDateTimeImmutable(): void { $obj = new DateTimeImmutable('2010-10-10 10:10:10', new DateTimeZone('UTC')); @@ -66,7 +67,7 @@ public function testExportDateTimeImmutable() : void self::assertEquals('2010-10-10T10:10:10+00:00', $var->date); } - public function testExportDateTimeZone() : void + public function testExportDateTimeZone(): void { $obj = new DateTimeImmutable('2010-10-10 12:34:56', new DateTimeZone('Europe/Rome')); @@ -75,7 +76,7 @@ public function testExportDateTimeZone() : void self::assertEquals('2010-10-10T12:34:56+02:00', $var->date); } - public function testExportArrayTraversable() : void + public function testExportArrayTraversable(): void { $obj = new ArrayObject(['foobar']); @@ -93,7 +94,7 @@ public function testExportArrayTraversable() : void * * @dataProvider provideAttributesCases */ - public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected) : void + public function testExportParentAttributes(TestAsset\ParentClass $class, array $expected): void { $print_r_class = print_r($class, true); $print_r_expected = print_r($expected, true); @@ -113,7 +114,7 @@ public function testExportParentAttributes(TestAsset\ParentClass $class, array $ /** * @return mixed[][] */ - public static function provideAttributesCases() : iterable + public static function provideAttributesCases(): iterable { return [ 'different-attributes' => [ diff --git a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php index bc6ab4d413f..00912413f5c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ArrayTest.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function serialize; class ArrayTest extends DbalTestCase @@ -18,30 +19,30 @@ class ArrayTest extends DbalTestCase /** @var ArrayType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('array'); } - public function testArrayConvertsToDatabaseValue() : void + public function testArrayConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue([], $this->platform)); } - public function testArrayConvertsToPHPValue() : void + public function testArrayConvertsToPHPValue(): void { self::assertIsArray($this->type->convertToPHPValue(serialize([]), $this->platform)); } - public function testConversionFailure() : void + public function testConversionFailure(): void { $this->expectException(ConversionException::class); $this->expectExceptionMessage("Could not convert database value to 'array' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'"); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } @@ -49,7 +50,7 @@ public function testNullConversion() : void /** * @group DBAL-73 */ - public function testFalseConversion() : void + public function testFalseConversion(): void { self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php index 062c77781f1..e033cd0f36b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php @@ -10,6 +10,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use stdClass; + use function date_default_timezone_get; use function date_default_timezone_set; @@ -24,7 +25,7 @@ abstract class BaseDateTypeTestCase extends TestCase /** @var string */ private $currentTimezone; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->currentTimezone = date_default_timezone_get(); @@ -32,12 +33,12 @@ protected function setUp() : void self::assertInstanceOf(Type::class, $this->type); } - protected function tearDown() : void + protected function tearDown(): void { date_default_timezone_set($this->currentTimezone); } - public function testDateConvertsToDatabaseValue() : void + public function testDateConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new DateTime(), $this->platform)); } @@ -47,19 +48,19 @@ public function testDateConvertsToDatabaseValue() : void * * @dataProvider invalidPHPValuesProvider */ - public function testInvalidTypeConversionToDatabaseValue($value) : void + public function testInvalidTypeConversionToDatabaseValue($value): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue($value, $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertDateTimeToPHPValue() : void + public function testConvertDateTimeToPHPValue(): void { $date = new DateTime('now'); @@ -73,7 +74,7 @@ public function testConvertDateTimeToPHPValue() : void * by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine. * This test is just in place to prevent further regressions, even if the type is being misused */ - public function testConvertDateTimeImmutableToPHPValue() : void + public function testConvertDateTimeImmutableToPHPValue(): void { $date = new DateTimeImmutable('now'); @@ -87,7 +88,7 @@ public function testConvertDateTimeImmutableToPHPValue() : void * by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine. * This test is just in place to prevent further regressions, even if the type is being misused */ - public function testDateTimeImmutableConvertsToDatabaseValue() : void + public function testDateTimeImmutableConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new DateTimeImmutable(), $this->platform)); } @@ -95,7 +96,7 @@ public function testDateTimeImmutableConvertsToDatabaseValue() : void /** * @return mixed[][] */ - public static function invalidPHPValuesProvider() : iterable + public static function invalidPHPValuesProvider(): iterable { return [ [0], diff --git a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php index d71512f3c01..23514f6160b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BinaryTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function stream_get_contents; @@ -22,23 +23,23 @@ class BinaryTest extends DbalTestCase /** @var BinaryType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('binary'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::BINARY, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::BINARY, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getBinaryTypeDeclarationSQL') @@ -47,12 +48,12 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_BINARY', $this->type->getSQLDeclaration([], $this->platform)); } - public function testBinaryNullConvertsToPHPValue() : void + public function testBinaryNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testBinaryStringConvertsToPHPValue() : void + public function testBinaryStringConvertsToPHPValue(): void { $databaseValue = 'binary string'; $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -61,7 +62,7 @@ public function testBinaryStringConvertsToPHPValue() : void self::assertEquals($databaseValue, stream_get_contents($phpValue)); } - public function testBinaryResourceConvertsToPHPValue() : void + public function testBinaryResourceConvertsToPHPValue(): void { $databaseValue = fopen('data://text/plain;base64,' . base64_encode('binary string'), 'r'); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -74,7 +75,7 @@ public function testBinaryResourceConvertsToPHPValue() : void * * @dataProvider getInvalidDatabaseValues */ - public function testThrowsConversionExceptionOnInvalidDatabaseValue($value) : void + public function testThrowsConversionExceptionOnInvalidDatabaseValue($value): void { $this->expectException(ConversionException::class); @@ -84,7 +85,7 @@ public function testThrowsConversionExceptionOnInvalidDatabaseValue($value) : vo /** * @return mixed[][] */ - public static function getInvalidDatabaseValues() : iterable + public static function getInvalidDatabaseValues(): iterable { return [ [false], diff --git a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php index d1a10a60bfa..23486819798 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BlobTest.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function chr; use function fopen; @@ -20,18 +21,18 @@ class BlobTest extends DbalTestCase /** @var BlobType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('blob'); } - public function testBlobNullConvertsToPHPValue() : void + public function testBlobNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testBinaryStringConvertsToPHPValue() : void + public function testBinaryStringConvertsToPHPValue(): void { $databaseValue = $this->getBinaryString(); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -40,7 +41,7 @@ public function testBinaryStringConvertsToPHPValue() : void self::assertSame($databaseValue, stream_get_contents($phpValue)); } - public function testBinaryResourceConvertsToPHPValue() : void + public function testBinaryResourceConvertsToPHPValue(): void { $databaseValue = fopen('data://text/plain;base64,' . base64_encode($this->getBinaryString()), 'r'); $phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform); @@ -51,7 +52,7 @@ public function testBinaryResourceConvertsToPHPValue() : void /** * Creates a binary string containing all possible byte values. */ - private function getBinaryString() : string + private function getBinaryString(): string { $string = ''; diff --git a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php index b5e25c2a77b..0fe4a2d5a5e 100644 --- a/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/BooleanTest.php @@ -16,23 +16,23 @@ class BooleanTest extends DbalTestCase /** @var BooleanType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); $this->type = Type::getType('boolean'); } - public function testBooleanConvertsToDatabaseValue() : void + public function testBooleanConvertsToDatabaseValue(): void { self::assertIsInt($this->type->convertToDatabaseValue(1, $this->platform)); } - public function testBooleanConvertsToPHPValue() : void + public function testBooleanConvertsToPHPValue(): void { self::assertIsBool($this->type->convertToPHPValue(0, $this->platform)); } - public function testBooleanNullConvertsToPHPValue() : void + public function testBooleanNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php index f8003c5c617..f2997ec5a92 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php @@ -6,11 +6,12 @@ use PHPUnit\Framework\TestCase; use stdClass; use Throwable; + use function tmpfile; class ConversionExceptionTest extends TestCase { - public function testConversionFailedPreviousException() : void + public function testConversionFailedPreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -25,7 +26,7 @@ public function testConversionFailedPreviousException() : void * * @dataProvider scalarsProvider */ - public function testConversionFailedInvalidTypeWithScalar($scalarValue) : void + public function testConversionFailedInvalidTypeWithScalar($scalarValue): void { $exception = ConversionException::conversionFailedInvalidType($scalarValue, 'foo', ['bar', 'baz']); @@ -42,7 +43,7 @@ public function testConversionFailedInvalidTypeWithScalar($scalarValue) : void * * @dataProvider nonScalarsProvider */ - public function testConversionFailedInvalidTypeWithNonScalar($nonScalar) : void + public function testConversionFailedInvalidTypeWithNonScalar($nonScalar): void { $exception = ConversionException::conversionFailedInvalidType($nonScalar, 'foo', ['bar', 'baz']); @@ -54,7 +55,7 @@ public function testConversionFailedInvalidTypeWithNonScalar($nonScalar) : void ); } - public function testConversionFailedInvalidTypePreviousException() : void + public function testConversionFailedInvalidTypePreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -64,7 +65,7 @@ public function testConversionFailedInvalidTypePreviousException() : void self::assertSame($previous, $exception->getPrevious()); } - public function testConversionFailedFormatPreservesPreviousException() : void + public function testConversionFailedFormatPreservesPreviousException(): void { $previous = $this->createMock(Throwable::class); @@ -77,7 +78,7 @@ public function testConversionFailedFormatPreservesPreviousException() : void /** * @return mixed[][] */ - public static function nonScalarsProvider() : iterable + public static function nonScalarsProvider(): iterable { return [ [[]], @@ -91,7 +92,7 @@ public static function nonScalarsProvider() : iterable /** * @return mixed[][] */ - public static function scalarsProvider() : iterable + public static function scalarsProvider(): iterable { return [ [''], diff --git a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php index d023e6bc1ba..e06e9b02f11 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateImmutableTypeTest extends TestCase /** @var DateImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('date_immutable'); $this->platform = $this->createMock(AbstractPlatform::class); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('date_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->createMock(DateTimeImmutable::class); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateStringToPHPValue() : void + public function testConvertsDateStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateFormatString') @@ -96,7 +97,7 @@ public function testConvertsDateStringToPHPValue() : void self::assertSame('2016-01-01', $date->format('Y-m-d')); } - public function testResetTimeFractionsWhenConvertingToPHPValue() : void + public function testResetTimeFractionsWhenConvertingToPHPValue(): void { $this->platform->expects($this->any()) ->method('getDateFormatString') @@ -107,14 +108,14 @@ public function testResetTimeFractionsWhenConvertingToPHPValue() : void self::assertSame('2016-01-01 00:00:00.000000', $date->format('Y-m-d H:i:s.u')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid date string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php index 15ee937e7d2..fa98a4f6eab 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateIntervalTest.php @@ -20,7 +20,7 @@ final class DateIntervalTest extends DbalTestCase /** @var DateIntervalType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('dateinterval'); @@ -28,7 +28,7 @@ protected function setUp() : void self::assertInstanceOf(DateIntervalType::class, $this->type); } - public function testDateIntervalConvertsToDatabaseValue() : void + public function testDateIntervalConvertsToDatabaseValue(): void { $interval = new DateInterval('P2Y1DT1H2M3S'); @@ -38,7 +38,7 @@ public function testDateIntervalConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateIntervalConvertsToPHPValue() : void + public function testDateIntervalConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('+P02Y00M01DT01H02M03S', $this->platform); @@ -46,7 +46,7 @@ public function testDateIntervalConvertsToPHPValue() : void self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testNegativeDateIntervalConvertsToDatabaseValue() : void + public function testNegativeDateIntervalConvertsToDatabaseValue(): void { $interval = new DateInterval('P2Y1DT1H2M3S'); $interval->invert = 1; @@ -56,7 +56,7 @@ public function testNegativeDateIntervalConvertsToDatabaseValue() : void self::assertEquals('-P02Y00M01DT01H02M03S', $actual); } - public function testNegativeDateIntervalConvertsToPHPValue() : void + public function testNegativeDateIntervalConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('-P02Y00M01DT01H02M03S', $this->platform); @@ -64,7 +64,7 @@ public function testNegativeDateIntervalConvertsToPHPValue() : void self::assertEquals('-P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testDateIntervalFormatWithoutSignConvertsToPHPValue() : void + public function testDateIntervalFormatWithoutSignConvertsToPHPValue(): void { $interval = $this->type->convertToPHPValue('P02Y00M01DT01H02M03S', $this->platform); @@ -72,19 +72,19 @@ public function testDateIntervalFormatWithoutSignConvertsToPHPValue() : void self::assertEquals('+P02Y00M01DT01H02M03S', $interval->format(DateIntervalType::FORMAT)); } - public function testInvalidDateIntervalFormatConversion() : void + public function testInvalidDateIntervalFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testDateIntervalNullConversion() : void + public function testDateIntervalNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testDateIntervalEmptyStringConversion() : void + public function testDateIntervalEmptyStringConversion(): void { $this->expectException(ConversionException::class); @@ -94,7 +94,7 @@ public function testDateIntervalEmptyStringConversion() : void /** * @group DBAL-1288 */ - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } @@ -104,7 +104,7 @@ public function testRequiresSQLCommentHint() : void * * @dataProvider invalidPHPValuesProvider */ - public function testInvalidTypeConversionToDatabaseValue($value) : void + public function testInvalidTypeConversionToDatabaseValue($value): void { $this->expectException(ConversionException::class); @@ -114,7 +114,7 @@ public function testInvalidTypeConversionToDatabaseValue($value) : void /** * @return mixed[][] */ - public static function invalidPHPValuesProvider() : iterable + public static function invalidPHPValuesProvider(): iterable { return [ [0], diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index 4bc2cda4556..1d97cceaa2c 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -5,18 +5,19 @@ use DateTime; use Doctrine\DBAL\Types\ConversionException; use Doctrine\DBAL\Types\Type; + use function date_default_timezone_set; class DateTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('date'); parent::setUp(); } - public function testDateConvertsToPHPValue() : void + public function testDateConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) self::assertInstanceOf( @@ -25,14 +26,14 @@ public function testDateConvertsToPHPValue() : void ); } - public function testDateResetsNonDatePartsToZeroUnixTimeValues() : void + public function testDateResetsNonDatePartsToZeroUnixTimeValues(): void { $date = $this->type->convertToPHPValue('1985-09-01', $this->platform); self::assertEquals('00:00:00', $date->format('H:i:s')); } - public function testDateRestsSummerTimeAffection() : void + public function testDateRestsSummerTimeAffection(): void { date_default_timezone_set('Europe/Berlin'); @@ -45,7 +46,7 @@ public function testDateRestsSummerTimeAffection() : void self::assertEquals('2009-11-01', $date->format('Y-m-d')); } - public function testInvalidDateFormatConversion() : void + public function testInvalidDateFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php index 6ace4b4c4e8..921d136d104 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateTimeImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateTimeImmutableTypeTest extends TestCase /** @var DateTimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetime_immutable'); $this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateTimeImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetime_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateTimeStringToPHPValue() : void + public function testConvertsDateTimeStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateTimeFormatString') @@ -99,7 +100,7 @@ public function testConvertsDateTimeStringToPHPValue() : void /** * @group DBAL-415 */ - public function testConvertsDateTimeStringWithMicrosecondsToPHPValue() : void + public function testConvertsDateTimeStringWithMicrosecondsToPHPValue(): void { $this->platform->expects($this->any()) ->method('getDateTimeFormatString') @@ -110,7 +111,7 @@ public function testConvertsDateTimeStringWithMicrosecondsToPHPValue() : void self::assertSame('2016-01-01 15:58:59', $date->format('Y-m-d H:i:s')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeString(): void { $this->platform->expects($this->atLeastOnce()) ->method('getDateTimeFormatString') @@ -121,7 +122,7 @@ public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTime $this->type->convertToPHPValue('invalid datetime string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php index 9d43cd9d7b3..72868f328a8 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php @@ -8,14 +8,14 @@ class DateTimeTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetime'); parent::setUp(); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -25,7 +25,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -33,13 +33,13 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); } - public function testInvalidDateTimeFormatConversion() : void + public function testInvalidDateTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testConvertsNonMatchingFormatToPhpValueWithParser() : void + public function testConvertsNonMatchingFormatToPhpValueWithParser(): void { $date = '1985/09/01 10:10:10.12345'; diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php index 808dfaf50ed..eafaedcb729 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class DateTimeTzImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class DateTimeTzImmutableTypeTest extends TestCase /** @var DateTimeTzImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetimetz_immutable'); $this->platform = $this->createMock(AbstractPlatform::class); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(DateTimeTzImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetimetz_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->createMock(DateTimeImmutable::class); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateTimeWithTimezoneStringToPHPValue() : void + public function testConvertsDateTimeWithTimezoneStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getDateTimeTzFormatString') @@ -96,7 +97,7 @@ public function testConvertsDateTimeWithTimezoneStringToPHPValue() : void self::assertSame('2016-01-01 15:58:59 UTC', $date->format('Y-m-d H:i:s T')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeWithTimezoneString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTimeWithTimezoneString(): void { $this->platform->expects($this->atLeastOnce()) ->method('getDateTimeTzFormatString') @@ -107,7 +108,7 @@ public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateTime $this->type->convertToPHPValue('invalid datetime with timezone string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php index adb75744d6e..f7367f283ec 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTimeTzTest.php @@ -8,14 +8,14 @@ class DateTimeTzTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('datetimetz'); parent::setUp(); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -25,7 +25,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -33,7 +33,7 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); } - public function testInvalidDateFormatConversion() : void + public function testInvalidDateFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php index 1528dfd86d9..bf05598ab32 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DecimalTest.php @@ -16,18 +16,18 @@ class DecimalTest extends DbalTestCase /** @var DecimalType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('decimal'); } - public function testDecimalConvertsToPHPValue() : void + public function testDecimalConvertsToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('5.5', $this->platform)); } - public function testDecimalNullConvertsToPHPValue() : void + public function testDecimalNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php index 4934f716c0f..44623c28b90 100644 --- a/tests/Doctrine/Tests/DBAL/Types/FloatTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/FloatTest.php @@ -16,28 +16,28 @@ class FloatTest extends DbalTestCase /** @var FloatType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('float'); } - public function testFloatConvertsToPHPValue() : void + public function testFloatConvertsToPHPValue(): void { self::assertIsFloat($this->type->convertToPHPValue('5.5', $this->platform)); } - public function testFloatNullConvertsToPHPValue() : void + public function testFloatNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testFloatConvertToDatabaseValue() : void + public function testFloatConvertToDatabaseValue(): void { self::assertIsFloat($this->type->convertToDatabaseValue(5.5, $this->platform)); } - public function testFloatNullConvertToDatabaseValue() : void + public function testFloatNullConvertToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php index df265d8541a..3615b687bd9 100644 --- a/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/GuidTypeTest.php @@ -16,24 +16,24 @@ class GuidTypeTest extends DbalTestCase /** @var GuidType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('guid'); } - public function testConvertToPHPValue() : void + public function testConvertToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testNativeGuidSupport() : void + public function testNativeGuidSupport(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php index e4ac718c4ea..7241a9237e1 100644 --- a/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/IntegerTest.php @@ -16,19 +16,19 @@ class IntegerTest extends DbalTestCase /** @var IntegerType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('integer'); } - public function testIntegerConvertsToPHPValue() : void + public function testIntegerConvertsToPHPValue(): void { self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } - public function testIntegerNullConvertsToPHPValue() : void + public function testIntegerNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php index 92cb6b6e17f..4603f3d6206 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonArrayTest.php @@ -9,6 +9,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function json_encode; @@ -21,23 +22,23 @@ class JsonArrayTest extends DbalTestCase /** @var JsonArrayType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('json_array'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::JSON_ARRAY, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getJsonTypeDeclarationSQL') @@ -46,17 +47,17 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_JSON', $this->type->getSQLDeclaration([], $this->platform)); } - public function testJsonNullConvertsToPHPValue() : void + public function testJsonNullConvertsToPHPValue(): void { self::assertSame([], $this->type->convertToPHPValue(null, $this->platform)); } - public function testJsonEmptyStringConvertsToPHPValue() : void + public function testJsonEmptyStringConvertsToPHPValue(): void { self::assertSame([], $this->type->convertToPHPValue('', $this->platform)); } - public function testJsonStringConvertsToPHPValue() : void + public function testJsonStringConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = json_encode($value); @@ -65,7 +66,7 @@ public function testJsonStringConvertsToPHPValue() : void self::assertEquals($value, $phpValue); } - public function testJsonResourceConvertsToPHPValue() : void + public function testJsonResourceConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r'); @@ -74,7 +75,7 @@ public function testJsonResourceConvertsToPHPValue() : void self::assertSame($value, $phpValue); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php index 034cc0361bb..0cf41b7f867 100644 --- a/tests/Doctrine/Tests/DBAL/Types/JsonTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/JsonTest.php @@ -10,6 +10,7 @@ use Doctrine\DBAL\Types\Types; use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; + use function base64_encode; use function fopen; use function json_encode; @@ -22,23 +23,23 @@ class JsonTest extends DbalTestCase /** @var JsonType */ protected $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('json'); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame(Types::JSON, $this->type->getName()); } - public function testReturnsSQLDeclaration() : void + public function testReturnsSQLDeclaration(): void { $this->platform->expects($this->once()) ->method('getJsonTypeDeclarationSQL') @@ -47,17 +48,17 @@ public function testReturnsSQLDeclaration() : void self::assertSame('TEST_JSON', $this->type->getSQLDeclaration([], $this->platform)); } - public function testJsonNullConvertsToPHPValue() : void + public function testJsonNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testJsonEmptyStringConvertsToPHPValue() : void + public function testJsonEmptyStringConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue('', $this->platform)); } - public function testJsonStringConvertsToPHPValue() : void + public function testJsonStringConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = json_encode($value); @@ -67,7 +68,7 @@ public function testJsonStringConvertsToPHPValue() : void } /** @dataProvider providerFailure */ - public function testConversionFailure(string $data) : void + public function testConversionFailure(string $data): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue($data, $this->platform); @@ -76,12 +77,12 @@ public function testConversionFailure(string $data) : void /** * @return mixed[][] */ - public static function providerFailure() : iterable + public static function providerFailure(): iterable { return [['a'], ['{']]; } - public function testJsonResourceConvertsToPHPValue() : void + public function testJsonResourceConvertsToPHPValue(): void { $value = ['foo' => 'bar', 'bar' => 'foo']; $databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r'); @@ -90,7 +91,7 @@ public function testJsonResourceConvertsToPHPValue() : void self::assertSame($value, $phpValue); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php index da9481d105a..df69e965d6b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ObjectTest.php @@ -9,6 +9,7 @@ use Doctrine\Tests\DbalTestCase; use PHPUnit\Framework\MockObject\MockObject; use stdClass; + use function serialize; class ObjectTest extends DbalTestCase @@ -19,30 +20,30 @@ class ObjectTest extends DbalTestCase /** @var ObjectType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('object'); } - public function testObjectConvertsToDatabaseValue() : void + public function testObjectConvertsToDatabaseValue(): void { self::assertIsString($this->type->convertToDatabaseValue(new stdClass(), $this->platform)); } - public function testObjectConvertsToPHPValue() : void + public function testObjectConvertsToPHPValue(): void { self::assertIsObject($this->type->convertToPHPValue(serialize(new stdClass()), $this->platform)); } - public function testConversionFailure() : void + public function testConversionFailure(): void { $this->expectException(ConversionException::class); $this->expectExceptionMessage("Could not convert database value to 'object' as an error was triggered by the unserialization: 'unserialize(): Error at offset 0 of 7 bytes'"); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } @@ -50,7 +51,7 @@ public function testNullConversion() : void /** * @group DBAL-73 */ - public function testFalseConversion() : void + public function testFalseConversion(): void { self::assertFalse($this->type->convertToPHPValue(serialize(false), $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php index b1731a99578..31ed1a310dd 100644 --- a/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/SmallIntTest.php @@ -16,19 +16,19 @@ class SmallIntTest extends DbalTestCase /** @var SmallIntType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('smallint'); } - public function testSmallIntConvertsToPHPValue() : void + public function testSmallIntConvertsToPHPValue(): void { self::assertIsInt($this->type->convertToPHPValue('1', $this->platform)); self::assertIsInt($this->type->convertToPHPValue('0', $this->platform)); } - public function testSmallIntNullConvertsToPHPValue() : void + public function testSmallIntNullConvertsToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/StringTest.php b/tests/Doctrine/Tests/DBAL/Types/StringTest.php index 4548ff60943..a5175f52f19 100644 --- a/tests/Doctrine/Tests/DBAL/Types/StringTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/StringTest.php @@ -16,13 +16,13 @@ class StringTest extends DbalTestCase /** @var StringType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); $this->type = Type::getType('string'); } - public function testReturnsSqlDeclarationFromPlatformVarchar() : void + public function testReturnsSqlDeclarationFromPlatformVarchar(): void { $this->platform->expects($this->once()) ->method('getVarcharTypeDeclarationSQL') @@ -31,7 +31,7 @@ public function testReturnsSqlDeclarationFromPlatformVarchar() : void self::assertEquals('TEST_VARCHAR', $this->type->getSqlDeclaration([], $this->platform)); } - public function testReturnsDefaultLengthFromPlatformVarchar() : void + public function testReturnsDefaultLengthFromPlatformVarchar(): void { $this->platform->expects($this->once()) ->method('getVarcharDefaultLength') @@ -40,18 +40,18 @@ public function testReturnsDefaultLengthFromPlatformVarchar() : void self::assertEquals(255, $this->type->getDefaultLength($this->platform)); } - public function testConvertToPHPValue() : void + public function testConvertToPHPValue(): void { self::assertIsString($this->type->convertToPHPValue('foo', $this->platform)); self::assertIsString($this->type->convertToPHPValue('', $this->platform)); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testSQLConversion() : void + public function testSQLConversion(): void { self::assertFalse($this->type->canRequireSQLConversion(), 'String type can never require SQL conversion to work.'); self::assertEquals('t.foo', $this->type->convertToDatabaseValueSQL('t.foo', $this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php index ba087f19f40..c9518fe6dbf 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeImmutableTypeTest.php @@ -11,6 +11,7 @@ use Doctrine\DBAL\Types\Type; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; + use function get_class; class TimeImmutableTypeTest extends TestCase @@ -21,28 +22,28 @@ class TimeImmutableTypeTest extends TestCase /** @var TimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('time_immutable'); $this->platform = $this->getMockBuilder(AbstractPlatform::class)->getMock(); } - public function testFactoryCreatesCorrectType() : void + public function testFactoryCreatesCorrectType(): void { self::assertSame(TimeImmutableType::class, get_class($this->type)); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('time_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -60,31 +61,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsTimeStringToPHPValue() : void + public function testConvertsTimeStringToPHPValue(): void { $this->platform->expects($this->once()) ->method('getTimeFormatString') @@ -96,7 +97,7 @@ public function testConvertsTimeStringToPHPValue() : void self::assertSame('15:58:59', $date->format('H:i:s')); } - public function testResetDateFractionsWhenConvertingToPHPValue() : void + public function testResetDateFractionsWhenConvertingToPHPValue(): void { $this->platform->expects($this->any()) ->method('getTimeFormatString') @@ -107,14 +108,14 @@ public function testResetDateFractionsWhenConvertingToPHPValue() : void self::assertSame('1970-01-01 15:58:59', $date->format('Y-m-d H:i:s')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidTimeString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidTimeString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid time string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php index c9b340c6325..8bec5c2ae37 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TimeTest.php @@ -7,19 +7,19 @@ class TimeTest extends BaseDateTypeTestCase { - protected function setUp() : void + protected function setUp(): void { $this->type = Type::getType('time'); parent::setUp(); } - public function testTimeConvertsToPHPValue() : void + public function testTimeConvertsToPHPValue(): void { self::assertInstanceOf('DateTime', $this->type->convertToPHPValue('5:30:55', $this->platform)); } - public function testDateFieldResetInPHPValue() : void + public function testDateFieldResetInPHPValue(): void { $time = $this->type->convertToPHPValue('01:23:34', $this->platform); @@ -27,7 +27,7 @@ public function testDateFieldResetInPHPValue() : void self::assertEquals('1970-01-01', $time->format('Y-m-d')); } - public function testInvalidTimeFormatConversion() : void + public function testInvalidTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index 14cd7497385..be4ba0dddfe 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -26,7 +26,7 @@ class TypeRegistryTest extends TestCase /** @var BinaryType */ private $otherTestType; - protected function setUp() : void + protected function setUp(): void { $this->testType = new BlobType(); $this->otherTestType = new BinaryType(); @@ -36,7 +36,7 @@ protected function setUp() : void $this->registry->register(self::OTHER_TEST_TYPE_NAME, $this->otherTestType); } - public function testGet() : void + public function testGet(): void { self::assertSame($this->testType, $this->registry->get(self::TEST_TYPE_NAME)); self::assertSame($this->otherTestType, $this->registry->get(self::OTHER_TEST_TYPE_NAME)); @@ -45,7 +45,7 @@ public function testGet() : void $this->registry->get('unknown'); } - public function testGetReturnsSameInstances() : void + public function testGetReturnsSameInstances(): void { self::assertSame( $this->registry->get(self::TEST_TYPE_NAME), @@ -53,7 +53,7 @@ public function testGetReturnsSameInstances() : void ); } - public function testLookupName() : void + public function testLookupName(): void { self::assertSame( self::TEST_TYPE_NAME, @@ -68,14 +68,14 @@ public function testLookupName() : void $this->registry->lookupName(new TextType()); } - public function testHas() : void + public function testHas(): void { self::assertTrue($this->registry->has(self::TEST_TYPE_NAME)); self::assertTrue($this->registry->has(self::OTHER_TEST_TYPE_NAME)); self::assertFalse($this->registry->has('unknown')); } - public function testRegister() : void + public function testRegister(): void { $newType = new TextType(); @@ -85,7 +85,7 @@ public function testRegister() : void self::assertSame($newType, $this->registry->get('some')); } - public function testRegisterWithAlradyRegisteredName() : void + public function testRegisterWithAlradyRegisteredName(): void { $this->registry->register('some', new TextType()); @@ -93,7 +93,7 @@ public function testRegisterWithAlradyRegisteredName() : void $this->registry->register('some', new TextType()); } - public function testRegisterWithAlreadyRegisteredInstance() : void + public function testRegisterWithAlreadyRegisteredInstance(): void { $newType = new TextType(); @@ -103,7 +103,7 @@ public function testRegisterWithAlreadyRegisteredInstance() : void $this->registry->register('other', $newType); } - public function testOverride() : void + public function testOverride(): void { $baseType = new TextType(); $overrideType = new StringType(); @@ -114,7 +114,7 @@ public function testOverride() : void self::assertSame($overrideType, $this->registry->get('some')); } - public function testOverrideAllowsExistingInstance() : void + public function testOverrideAllowsExistingInstance(): void { $type = new TextType(); @@ -124,7 +124,7 @@ public function testOverrideAllowsExistingInstance() : void self::assertSame($type, $this->registry->get('some')); } - public function testOverrideWithAlreadyRegisteredInstance() : void + public function testOverrideWithAlreadyRegisteredInstance(): void { $newType = new TextType(); @@ -135,13 +135,13 @@ public function testOverrideWithAlreadyRegisteredInstance() : void $this->registry->override('second', $newType); } - public function testOverrideWithUnknownType() : void + public function testOverrideWithUnknownType(): void { $this->expectException(DBALException::class); $this->registry->override('unknown', new TextType()); } - public function testGetMap() : void + public function testGetMap(): void { $registeredTypes = $this->registry->getMap(); diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeTest.php index 8dbca8b57f0..314ad868024 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeTest.php @@ -13,7 +13,7 @@ class TypeTest extends TestCase /** * @dataProvider defaultTypesProvider() */ - public function testDefaultTypesAreRegistered(string $name) : void + public function testDefaultTypesAreRegistered(string $name): void { self::assertTrue(Type::hasType($name)); } @@ -21,7 +21,7 @@ public function testDefaultTypesAreRegistered(string $name) : void /** * @return iterable */ - public function defaultTypesProvider() : iterable + public function defaultTypesProvider(): iterable { foreach ((new ReflectionClass(Type::class))->getReflectionConstants() as $constant) { if (! $constant->isPublic()) { diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php index d3609fe2bac..a8652a6115b 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeImmutableTypeTest.php @@ -20,7 +20,7 @@ class VarDateTimeImmutableTypeTest extends TestCase /** @var VarDateTimeImmutableType */ private $type; - protected function setUp() : void + protected function setUp(): void { if (! Type::hasType('vardatetime_immutable')) { Type::addType('vardatetime_immutable', VarDateTimeImmutableType::class); @@ -30,17 +30,17 @@ protected function setUp() : void $this->platform = $this->getMockForAbstractClass(AbstractPlatform::class); } - public function testReturnsName() : void + public function testReturnsName(): void { self::assertSame('datetime_immutable', $this->type->getName()); } - public function testReturnsBindingType() : void + public function testReturnsBindingType(): void { self::assertSame(ParameterType::STRING, $this->type->getBindingType()); } - public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void + public function testConvertsDateTimeImmutableInstanceToDatabaseValue(): void { $date = $this->getMockBuilder(DateTimeImmutable::class)->getMock(); @@ -55,31 +55,31 @@ public function testConvertsDateTimeImmutableInstanceToDatabaseValue() : void ); } - public function testConvertsNullToDatabaseValue() : void + public function testConvertsNullToDatabaseValue(): void { self::assertNull($this->type->convertToDatabaseValue(null, $this->platform)); } - public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion() : void + public function testDoesNotSupportMutableDateTimeToDatabaseValueConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToDatabaseValue(new DateTime(), $this->platform); } - public function testConvertsDateTimeImmutableInstanceToPHPValue() : void + public function testConvertsDateTimeImmutableInstanceToPHPValue(): void { $date = new DateTimeImmutable(); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); } - public function testConvertsNullToPHPValue() : void + public function testConvertsNullToPHPValue(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertsDateishStringToPHPValue() : void + public function testConvertsDateishStringToPHPValue(): void { $date = $this->type->convertToPHPValue('2016-01-01 15:58:59.123456 UTC', $this->platform); @@ -87,14 +87,14 @@ public function testConvertsDateishStringToPHPValue() : void self::assertSame('2016-01-01 15:58:59.123456 UTC', $date->format('Y-m-d H:i:s.u T')); } - public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateishString() : void + public function testThrowsExceptionDuringConversionToPHPValueWithInvalidDateishString(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('invalid date-ish string', $this->platform); } - public function testRequiresSQLCommentHint() : void + public function testRequiresSQLCommentHint(): void { self::assertTrue($this->type->requiresSQLCommentHint($this->platform)); } diff --git a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php index 4e24f53373d..586b36e89cd 100644 --- a/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/VarDateTimeTest.php @@ -18,7 +18,7 @@ class VarDateTimeTest extends DbalTestCase /** @var VarDateTimeType */ private $type; - protected function setUp() : void + protected function setUp(): void { $this->platform = $this->createMock(AbstractPlatform::class); if (! Type::hasType('vardatetime')) { @@ -28,7 +28,7 @@ protected function setUp() : void $this->type = Type::getType('vardatetime'); } - public function testDateTimeConvertsToDatabaseValue() : void + public function testDateTimeConvertsToDatabaseValue(): void { $date = new DateTime('1985-09-01 10:10:10'); @@ -38,7 +38,7 @@ public function testDateTimeConvertsToDatabaseValue() : void self::assertEquals($expected, $actual); } - public function testDateTimeConvertsToPHPValue() : void + public function testDateTimeConvertsToPHPValue(): void { // Birthday of jwage and also birthday of Doctrine. Send him a present ;) $date = $this->type->convertToPHPValue('1985-09-01 00:00:00', $this->platform); @@ -47,13 +47,13 @@ public function testDateTimeConvertsToPHPValue() : void self::assertEquals('000000', $date->format('u')); } - public function testInvalidDateTimeFormatConversion() : void + public function testInvalidDateTimeFormatConversion(): void { $this->expectException(ConversionException::class); $this->type->convertToPHPValue('abcdefg', $this->platform); } - public function testConversionWithMicroseconds() : void + public function testConversionWithMicroseconds(): void { $date = $this->type->convertToPHPValue('1985-09-01 00:00:00.123456', $this->platform); self::assertInstanceOf('DateTime', $date); @@ -61,12 +61,12 @@ public function testConversionWithMicroseconds() : void self::assertEquals('123456', $date->format('u')); } - public function testNullConversion() : void + public function testNullConversion(): void { self::assertNull($this->type->convertToPHPValue(null, $this->platform)); } - public function testConvertDateTimeToPHPValue() : void + public function testConvertDateTimeToPHPValue(): void { $date = new DateTime('now'); self::assertSame($date, $this->type->convertToPHPValue($date, $this->platform)); diff --git a/tests/Doctrine/Tests/DBAL/UtilTest.php b/tests/Doctrine/Tests/DBAL/UtilTest.php index 92f63872f15..13211764a27 100644 --- a/tests/Doctrine/Tests/DBAL/UtilTest.php +++ b/tests/Doctrine/Tests/DBAL/UtilTest.php @@ -10,7 +10,7 @@ class UtilTest extends DbalTestCase /** * @return mixed[][] */ - public static function dataConvertPositionalToNamedParameters() : iterable + public static function dataConvertPositionalToNamedParameters(): iterable { return [ [ @@ -71,7 +71,7 @@ public static function dataConvertPositionalToNamedParameters() : iterable * * @dataProvider dataConvertPositionalToNamedParameters */ - public function testConvertPositionalToNamedParameters(string $inputSQL, string $expectedOutputSQL, array $expectedOutputParamsMap) : void + public function testConvertPositionalToNamedParameters(string $inputSQL, string $expectedOutputSQL, array $expectedOutputParamsMap): void { [$statement, $params] = OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL); diff --git a/tests/Doctrine/Tests/DbalFunctionalTestCase.php b/tests/Doctrine/Tests/DbalFunctionalTestCase.php index 4546f60090e..dc7786c5208 100644 --- a/tests/Doctrine/Tests/DbalFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DbalFunctionalTestCase.php @@ -7,6 +7,7 @@ use Exception; use PHPUnit\Framework\AssertionFailedError; use Throwable; + use function array_map; use function array_reverse; use function count; @@ -16,6 +17,7 @@ use function is_scalar; use function strpos; use function var_export; + use const PHP_EOL; abstract class DbalFunctionalTestCase extends DbalTestCase @@ -33,7 +35,7 @@ abstract class DbalFunctionalTestCase extends DbalTestCase /** @var DebugStack */ protected $sqlLoggerStack; - protected function resetSharedConn() : void + protected function resetSharedConn(): void { if (! self::$sharedConnection) { return; @@ -43,7 +45,7 @@ protected function resetSharedConn() : void self::$sharedConnection = null; } - protected function setUp() : void + protected function setUp(): void { if (! isset(self::$sharedConnection)) { self::$sharedConnection = TestUtil::getConnection(); @@ -55,14 +57,14 @@ protected function setUp() : void $this->connection->getConfiguration()->setSQLLogger($this->sqlLoggerStack); } - protected function tearDown() : void + protected function tearDown(): void { while ($this->connection->isTransactionActive()) { $this->connection->rollBack(); } } - protected function onNotSuccessfulTest(Throwable $t) : void + protected function onNotSuccessfulTest(Throwable $t): void { if ($t instanceof AssertionFailedError) { throw $t; diff --git a/tests/Doctrine/Tests/TestUtil.php b/tests/Doctrine/Tests/TestUtil.php index ad070abf491..607d9b0bf14 100644 --- a/tests/Doctrine/Tests/TestUtil.php +++ b/tests/Doctrine/Tests/TestUtil.php @@ -6,6 +6,7 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\AbstractPlatform; use PHPUnit\Framework\Assert; + use function array_keys; use function array_map; use function array_values; @@ -44,7 +45,7 @@ class TestUtil * * @return Connection The database connection instance. */ - public static function getConnection() : Connection + public static function getConnection(): Connection { if (self::hasRequiredConnectionParams() && ! self::$initialized) { self::initializeDatabase(); @@ -61,7 +62,7 @@ public static function getConnection() : Connection /** * @return mixed[] */ - public static function getConnectionParams() : array + public static function getConnectionParams(): array { if (self::hasRequiredConnectionParams()) { return self::getParamsForMainConnection(); @@ -70,7 +71,7 @@ public static function getConnectionParams() : array return self::getFallbackConnectionParams(); } - private static function hasRequiredConnectionParams() : bool + private static function hasRequiredConnectionParams(): bool { return isset( $GLOBALS['db_type'], @@ -89,7 +90,7 @@ private static function hasRequiredConnectionParams() : bool ); } - private static function initializeDatabase() : void + private static function initializeDatabase(): void { $realDbParams = self::getParamsForMainConnection(); $tmpDbParams = self::getParamsForTemporaryConnection(); @@ -123,7 +124,7 @@ private static function initializeDatabase() : void /** * @return mixed[] */ - private static function getFallbackConnectionParams() : array + private static function getFallbackConnectionParams(): array { if (! extension_loaded('pdo_sqlite')) { Assert::markTestSkipped('PDO SQLite extension is not loaded'); @@ -142,7 +143,7 @@ private static function getFallbackConnectionParams() : array return $params; } - private static function addDbEventSubscribers(Connection $conn) : void + private static function addDbEventSubscribers(Connection $conn): void { if (! isset($GLOBALS['db_event_subscribers'])) { return; @@ -158,7 +159,7 @@ private static function addDbEventSubscribers(Connection $conn) : void /** * @return mixed[] */ - private static function getParamsForTemporaryConnection() : array + private static function getParamsForTemporaryConnection(): array { $connectionParams = [ 'driver' => $GLOBALS['tmpdb_type'], @@ -187,7 +188,7 @@ private static function getParamsForTemporaryConnection() : array /** * @return mixed[] */ - private static function getParamsForMainConnection() : array + private static function getParamsForMainConnection(): array { $connectionParams = [ 'driver' => $GLOBALS['db_type'], @@ -209,7 +210,7 @@ private static function getParamsForMainConnection() : array return $connectionParams; } - public static function getTempConnection() : Connection + public static function getTempConnection(): Connection { return DriverManager::getConnection(self::getParamsForTemporaryConnection()); } @@ -219,11 +220,11 @@ public static function getTempConnection() : Connection * * @param array> $rows */ - public static function generateResultSetQuery(array $rows, AbstractPlatform $platform) : string + public static function generateResultSetQuery(array $rows, AbstractPlatform $platform): string { - return implode(' UNION ALL ', array_map(static function (array $row) use ($platform) : string { + return implode(' UNION ALL ', array_map(static function (array $row) use ($platform): string { return $platform->getDummySelectSQL( - implode(', ', array_map(static function (string $column, $value) use ($platform) : string { + implode(', ', array_map(static function (string $column, $value) use ($platform): string { if (is_string($value)) { $value = $platform->quoteStringLiteral($value); } diff --git a/tests/Doctrine/Tests/Types/CommentedType.php b/tests/Doctrine/Tests/Types/CommentedType.php index cbe98b2324b..a589c9fbe22 100644 --- a/tests/Doctrine/Tests/Types/CommentedType.php +++ b/tests/Doctrine/Tests/Types/CommentedType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; + use function strtoupper; class CommentedType extends Type diff --git a/tests/Doctrine/Tests/Types/MySqlPointType.php b/tests/Doctrine/Tests/Types/MySqlPointType.php index f4740769b8b..951bd7f4916 100644 --- a/tests/Doctrine/Tests/Types/MySqlPointType.php +++ b/tests/Doctrine/Tests/Types/MySqlPointType.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; + use function strtoupper; class MySqlPointType extends Type diff --git a/tests/continuousphp/bootstrap.php b/tests/continuousphp/bootstrap.php index e24bea47112..899fd6d5e16 100644 --- a/tests/continuousphp/bootstrap.php +++ b/tests/continuousphp/bootstrap.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DriverManager; -(static function () : void { +(static function (): void { // workaround for https://bugs.php.net/bug.php?id=77120 DriverManager::getConnection([ 'driver' => 'oci8', From 4a04c867323e328bed9553f7ad6a6d19135c3384 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 18:28:44 -0700 Subject: [PATCH 26/93] Make caching layer not rely on closeCursor() --- docs/en/reference/caching.rst | 4 +- .../DBAL/Cache/ResultCacheStatement.php | 50 +++++++++---------- .../Tests/DBAL/Functional/ResultCacheTest.php | 13 ++--- 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/docs/en/reference/caching.rst b/docs/en/reference/caching.rst index 5e6885deae8..ee2ed635161 100644 --- a/docs/en/reference/caching.rst +++ b/docs/en/reference/caching.rst @@ -35,15 +35,13 @@ the default cache instance: new QueryCacheProfile(0, "some key", $cache); In order for the data to actually be cached its necessary to ensure that the entire -result set is read (the easiest way to ensure this is to use ``fetchAll``) and the statement -object is closed: +result set is read (the easiest way to ensure this is to use one of the ``fetchAll*()`` methods): :: executeCacheQuery($query, $params, $types, new QueryCacheProfile(0, "some key")); $data = $stmt->fetchAllAssociative(); - $stmt->closeCursor(); // at this point the result is cached .. warning:: diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index cb36ff9974b..dd8d62fde83 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -50,14 +50,7 @@ class ResultCacheStatement implements IteratorAggregate, ResultStatement, Forwar /** @var ResultStatement */ private $statement; - /** - * Did we reach the end of the statement? - * - * @var bool - */ - private $emptied = false; - - /** @var array> */ + /** @var array>|null */ private $data; /** @var int */ @@ -83,19 +76,8 @@ public function __construct(ResultStatement $stmt, Cache $resultCache, $cacheKey public function closeCursor() { $this->statement->closeCursor(); - if (! $this->emptied || $this->data === null) { - return true; - } - - $data = $this->resultCache->fetch($this->cacheKey); - if (! $data) { - $data = []; - } - $data[$this->realKey] = $this->data; - - $this->resultCache->save($this->cacheKey, $data, $this->lifetime); - unset($this->data); + $this->data = null; return true; } @@ -169,7 +151,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX throw new InvalidArgumentException('Invalid fetch-style given for caching result.'); } - $this->emptied = true; + $this->saveToCache(); return false; } @@ -183,8 +165,9 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n { $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE, $fetchArgument, $ctorArgs); - $this->data = $data; - $this->emptied = true; + $this->data = $data; + + $this->saveToCache(); if ($fetchMode === FetchMode::NUMERIC) { foreach ($data as $i => $row) { @@ -327,7 +310,7 @@ private function doFetch() return $row; } - $this->emptied = true; + $this->saveToCache(); return false; } @@ -337,7 +320,22 @@ private function doFetch() */ private function store(array $data): void { - $this->data = $data; - $this->emptied = true; + $this->data = $data; + } + + private function saveToCache(): void + { + if ($this->data === null) { + return; + } + + $data = $this->resultCache->fetch($this->cacheKey); + if (! $data) { + $data = []; + } + + $data[$this->realKey] = $this->data; + + $this->resultCache->save($this->cacheKey, $data, $this->lifetime); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index 21b30304677..dd4c8431685 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -135,7 +135,7 @@ private function assertStandardAndIteratorFetchAreEqual(int $fetchMode): void self::assertEquals($data, $dataIterator); } - public function testDontCloseNoCache(): void + public function testFetchAndFinishSavesCache(): void { $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); @@ -153,7 +153,7 @@ public function testDontCloseNoCache(): void $data[] = $row; } - self::assertCount(2, $this->sqlLogger->queries); + self::assertCount(1, $this->sqlLogger->queries); } public function testDontFinishNoCache(): void @@ -161,7 +161,6 @@ public function testDontFinishNoCache(): void $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); $stmt->fetch(FetchMode::ASSOCIATIVE); - $stmt->closeCursor(); $stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(0, 'testcachekey')); @@ -170,12 +169,11 @@ public function testDontFinishNoCache(): void self::assertCount(2, $this->sqlLogger->queries); } - public function testFetchAllAndFinishSavesCache(): void + public function testFetchAllSavesCache(): void { $layerCache = new ArrayCache(); $stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(0, 'testcachekey', $layerCache)); $stmt->fetchAll(); - $stmt->closeCursor(); self::assertCount(1, $layerCache->fetch('testcachekey')); } @@ -189,7 +187,6 @@ public function testFetchAllColumn(): void $stmt = $this->connection->executeCacheQuery($query, [], [], $qcp); $stmt->fetchAll(FetchMode::COLUMN); - $stmt->closeCursor(); $stmt = $this->connection->executeCacheQuery($query, [], [], $qcp); @@ -251,8 +248,6 @@ private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode:: $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; } - $stmt->closeCursor(); - return $data; } @@ -267,8 +262,6 @@ private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = Fet $data[] = is_array($row) ? array_change_key_case($row, CASE_LOWER) : $row; } - $stmt->closeCursor(); - return $data; } } From 0d9ea40ab628078d5635afc6287a04c1c7f10a65 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 17:54:05 -0700 Subject: [PATCH 27/93] Rename forward-compatible ResultStatement interfaces to Result --- UPGRADE.md | 12 ++++++---- .../Result.php} | 9 ++++---- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 4 ++-- .../DBAL/Cache/ResultCacheStatement.php | 10 ++++----- lib/Doctrine/DBAL/Connection.php | 20 ++++++++--------- lib/Doctrine/DBAL/Driver/FetchUtils.php | 18 +++++++-------- .../DBAL/Driver/IBMDB2/DB2Statement.php | 4 ++-- .../DBAL/Driver/Mysqli/MysqliStatement.php | 4 ++-- .../DBAL/Driver/OCI8/OCI8Statement.php | 4 ++-- .../DBAL/Driver/PDOSqlsrv/Connection.php | 4 ++-- lib/Doctrine/DBAL/Driver/PDOStatement.php | 3 +-- .../ResultStatement.php => Driver/Result.php} | 19 ++++++++-------- .../SQLAnywhere/SQLAnywhereConnection.php | 6 ++--- .../SQLAnywhere/SQLAnywhereStatement.php | 4 ++-- .../DBAL/Driver/SQLSrv/SQLSrvConnection.php | 4 ++-- .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 4 ++-- lib/Doctrine/DBAL/Portability/Statement.php | 16 +++++++------- lib/Doctrine/DBAL/Statement.php | 22 +++++++++---------- 18 files changed, 84 insertions(+), 83 deletions(-) rename lib/Doctrine/DBAL/{ForwardCompatibility/ResultStatement.php => Abstraction/Result.php} (75%) rename lib/Doctrine/DBAL/{ForwardCompatibility/Driver/ResultStatement.php => Driver/Result.php} (58%) diff --git a/UPGRADE.md b/UPGRADE.md index 15f11853f02..46e4666b21c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,13 +1,17 @@ # Upgrade to 2.11 +## Deprecated `ResultStatement` interface + +The `ResultStatement` interface is deprecated. Use the `Driver\Result` and `Abstraction\Result` interfaces instead. + ## Deprecated `FetchMode` and the corresponding methods 1. The `FetchMode` class and the `setFetchMode()` method of the `Connection` and `Statement` interfaces are deprecated. -2. The `Statement::fetch()` method is deprecated in favor of `fetchNumeric()`, `fetchAssociative()` and `fetchOne()`. -3. The `Statement::fetchAll()` method is deprecated in favor of `fetchAllNumeric()`, `fetchAllAssociative()` and `fetchFirstColumn()`. -4. The `Statement::fetchColumn()` method is deprecated in favor of `fetchOne()`. +2. The `Statement::fetch()` method is deprecated in favor of `Result::fetchNumeric()`, `::fetchAssociative()` and `::fetchOne()`. +3. The `Statement::fetchAll()` method is deprecated in favor of `Result::fetchAllNumeric()`, `::fetchAllAssociative()` and `::fetchFirstColumn()`. +4. The `Statement::fetchColumn()` method is deprecated in favor of `Result::fetchOne()`. 5. The `Connection::fetchArray()` and `fetchAssoc()` method are deprecated in favor of `fetchNumeric()` and `fetchAssociative()` respectively. -6. The `StatementIterator` class and the usage of a `Statement` object as `Traversable` is deprecated in favor of `iterateNumeric()`, `iterateAssociative()` and `iterateColumn()`. +6. The `StatementIterator` class and the usage of a `Statement` object as `Traversable` is deprecated in favor of `Result::iterateNumeric()`, `::iterateAssociative()` and `::iterateColumn()`. 7. Fetching data in mixed mode (`FetchMode::MIXED`) is deprecated. ## Deprecated `Connection::project()` diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php b/lib/Doctrine/DBAL/Abstraction/Result.php similarity index 75% rename from lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php rename to lib/Doctrine/DBAL/Abstraction/Result.php index 041c4098419..5e163785405 100644 --- a/lib/Doctrine/DBAL/ForwardCompatibility/ResultStatement.php +++ b/lib/Doctrine/DBAL/Abstraction/Result.php @@ -2,16 +2,17 @@ declare(strict_types=1); -namespace Doctrine\DBAL\ForwardCompatibility; +namespace Doctrine\DBAL\Abstraction; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as BaseResultStatement; +use Doctrine\DBAL\Driver\Result as DriverResult; use Traversable; /** - * Forward compatibility extension for the DBAL ResultStatement interface. + * Abstraction-level result statement execution result. Provides additional methods on top + * of the driver-level interface. */ -interface ResultStatement extends BaseResultStatement +interface Result extends DriverResult { /** * Returns an iterator over the result set rows represented as numeric arrays. diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 50c4edae861..f9bef8d73d7 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -4,9 +4,9 @@ use ArrayIterator; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use InvalidArgumentException; use IteratorAggregate; use PDO; @@ -16,7 +16,7 @@ use function count; use function reset; -class ArrayStatement implements IteratorAggregate, ResultStatement, ForwardCompatibleResultStatement +class ArrayStatement implements IteratorAggregate, ResultStatement, Result { /** @var mixed[] */ private $data; diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index dd8d62fde83..78d97d25cdf 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -6,10 +6,10 @@ use Doctrine\Common\Cache\Cache; use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use InvalidArgumentException; use IteratorAggregate; use PDO; @@ -33,7 +33,7 @@ * Also you have to realize that the cache will load the whole result into memory at once to ensure 2. * This means that the memory usage for cached results might increase by using this feature. */ -class ResultCacheStatement implements IteratorAggregate, ResultStatement, ForwardCompatibleResultStatement +class ResultCacheStatement implements IteratorAggregate, ResultStatement, Result { /** @var Cache */ private $resultCache; @@ -234,7 +234,7 @@ public function fetchOne() */ public function fetchAllNumeric(): array { - if ($this->statement instanceof ForwardCompatibleResultStatement) { + if ($this->statement instanceof Result) { $data = $this->statement->fetchAllAssociative(); } else { $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); @@ -250,7 +250,7 @@ public function fetchAllNumeric(): array */ public function fetchAllAssociative(): array { - if ($this->statement instanceof ForwardCompatibleResultStatement) { + if ($this->statement instanceof Result) { $data = $this->statement->fetchAllAssociative(); } else { $data = $this->statement->fetchAll(FetchMode::ASSOCIATIVE); @@ -298,7 +298,7 @@ private function doFetch() $this->data = []; } - if ($this->statement instanceof ForwardCompatibleResultStatement) { + if ($this->statement instanceof Result) { $row = $this->statement->fetchAssociative(); } else { $row = $this->statement->fetch(FetchMode::ASSOCIATIVE); diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 32a97d85809..0a0c8c40d99 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -4,6 +4,7 @@ use Closure; use Doctrine\Common\EventManager; +use Doctrine\DBAL\Abstraction\Result; use Doctrine\DBAL\Cache\ArrayStatement; use Doctrine\DBAL\Cache\CacheException; use Doctrine\DBAL\Cache\QueryCacheProfile; @@ -14,7 +15,6 @@ use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Exception\InvalidArgumentException; -use Doctrine\DBAL\ForwardCompatibility\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; use Doctrine\DBAL\Query\QueryBuilder; @@ -616,7 +616,7 @@ public function fetchAssociative(string $query, array $params = [], array $types try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchAssociative(); } @@ -643,7 +643,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [ try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchNumeric(); } @@ -670,7 +670,7 @@ public function fetchOne(string $query, array $params = [], array $types = []) try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchOne(); } @@ -956,7 +956,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchAllNumeric(); } @@ -982,7 +982,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchAllAssociative(); } @@ -1008,7 +1008,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchFirstColumn(); } @@ -1034,7 +1034,7 @@ public function iterateNumeric(string $query, array $params = [], array $types = try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { yield from $stmt->iterateNumeric(); } else { while (($row = $stmt->fetch(FetchMode::NUMERIC)) !== false) { @@ -1062,7 +1062,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { yield from $stmt->iterateAssociative(); } else { while (($row = $stmt->fetch(FetchMode::ASSOCIATIVE)) !== false) { @@ -1090,7 +1090,7 @@ public function iterateColumn(string $query, array $params = [], array $types = try { $stmt = $this->executeQuery($query, $params, $types); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { yield from $stmt->iterateColumn(); } else { while (($value = $stmt->fetch(FetchMode::COLUMN)) !== false) { diff --git a/lib/Doctrine/DBAL/Driver/FetchUtils.php b/lib/Doctrine/DBAL/Driver/FetchUtils.php index 428b8174397..a94793e1157 100644 --- a/lib/Doctrine/DBAL/Driver/FetchUtils.php +++ b/lib/Doctrine/DBAL/Driver/FetchUtils.php @@ -4,8 +4,6 @@ namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement; - /** * @internal */ @@ -16,9 +14,9 @@ final class FetchUtils * * @throws DriverException */ - public static function fetchOne(ResultStatement $stmt) + public static function fetchOne(Result $result) { - $row = $stmt->fetchNumeric(); + $row = $result->fetchNumeric(); if ($row === false) { return false; @@ -32,11 +30,11 @@ public static function fetchOne(ResultStatement $stmt) * * @throws DriverException */ - public static function fetchAllNumeric(ResultStatement $stmt): array + public static function fetchAllNumeric(Result $result): array { $rows = []; - while (($row = $stmt->fetchNumeric()) !== false) { + while (($row = $result->fetchNumeric()) !== false) { $rows[] = $row; } @@ -48,11 +46,11 @@ public static function fetchAllNumeric(ResultStatement $stmt): array * * @throws DriverException */ - public static function fetchAllAssociative(ResultStatement $stmt): array + public static function fetchAllAssociative(Result $result): array { $rows = []; - while (($row = $stmt->fetchAssociative()) !== false) { + while (($row = $result->fetchAssociative()) !== false) { $rows[] = $row; } @@ -64,11 +62,11 @@ public static function fetchAllAssociative(ResultStatement $stmt): array * * @throws DriverException */ - public static function fetchFirstColumn(ResultStatement $stmt): array + public static function fetchFirstColumn(Result $result): array { $rows = []; - while (($row = $stmt->fetchOne()) !== false) { + while (($row = $result->fetchOne()) !== false) { $rows[] = $row; } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 45959bdc35e..163accb5a70 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -3,10 +3,10 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -50,7 +50,7 @@ use const DB2_PARAM_FILE; use const DB2_PARAM_IN; -class DB2Statement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement +class DB2Statement implements IteratorAggregate, Statement, Result { /** @var resource */ private $stmt; diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 16a0cf767f1..4f912fa1f5b 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -3,11 +3,11 @@ namespace Doctrine\DBAL\Driver\Mysqli; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use mysqli; @@ -27,7 +27,7 @@ use function sprintf; use function str_repeat; -class MysqliStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement +class MysqliStatement implements IteratorAggregate, Statement, Result { /** @var string[] */ protected static $_paramTypeMap = [ diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 38a5a14bafe..e31f42d5f4c 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -3,10 +3,10 @@ namespace Doctrine\DBAL\Driver\OCI8; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use InvalidArgumentException; use IteratorAggregate; @@ -51,7 +51,7 @@ /** * The OCI8 implementation of the Statement interface. */ -class OCI8Statement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement +class OCI8Statement implements IteratorAggregate, Statement, Result { /** @var resource */ protected $_dbh; diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index ab4078e05a9..bc5ae131778 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\PDOConnection; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; use PDO; @@ -36,7 +36,7 @@ public function lastInsertId($name = null) $stmt = $this->prepare('SELECT CONVERT(VARCHAR(MAX), current_value) FROM sys.sequences WHERE name = ?'); $stmt->execute([$name]); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchOne(); } diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index c55a79925d7..4ff31dfc702 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -3,7 +3,6 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use PDO; @@ -20,7 +19,7 @@ * The PDO implementation of the Statement interface. * Used by all PDO-based drivers. */ -class PDOStatement extends \PDOStatement implements Statement, ForwardCompatibleResultStatement +class PDOStatement extends \PDOStatement implements Statement, Result { private const PARAM_TYPE_MAP = [ ParameterType::NULL => PDO::PARAM_NULL, diff --git a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/Result.php similarity index 58% rename from lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php rename to lib/Doctrine/DBAL/Driver/Result.php index c0c7dffc667..49487249914 100644 --- a/lib/Doctrine/DBAL/ForwardCompatibility/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/Driver/Result.php @@ -2,18 +2,17 @@ declare(strict_types=1); -namespace Doctrine\DBAL\ForwardCompatibility\Driver; +namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\ResultStatement as BaseResultStatement; /** - * Forward compatibility extension for the ResultStatement interface. + * Driver-level result statement execution result. */ -interface ResultStatement extends BaseResultStatement +interface Result extends BaseResultStatement { /** - * Returns the next row of a result set as a numeric array or FALSE if there are no more rows. + * Returns the next row of the result as a numeric array or FALSE if there are no more rows. * * @return array|false * @@ -22,7 +21,7 @@ interface ResultStatement extends BaseResultStatement public function fetchNumeric(); /** - * Returns the next row of a result set as an associative array or FALSE if there are no more rows. + * Returns the next row of the result as an associative array or FALSE if there are no more rows. * * @return array|false * @@ -31,7 +30,7 @@ public function fetchNumeric(); public function fetchAssociative(); /** - * Returns the first value of the next row of a result set or FALSE if there are no more rows. + * Returns the first value of the next row of the result or FALSE if there are no more rows. * * @return mixed|false * @@ -40,7 +39,7 @@ public function fetchAssociative(); public function fetchOne(); /** - * Returns an array containing all of the result set rows represented as numeric arrays. + * Returns an array containing all of the result rows represented as numeric arrays. * * @return array> * @@ -49,7 +48,7 @@ public function fetchOne(); public function fetchAllNumeric(): array; /** - * Returns an array containing all of the result set rows represented as associative arrays. + * Returns an array containing all of the result rows represented as associative arrays. * * @return array> * @@ -58,7 +57,7 @@ public function fetchAllNumeric(): array; public function fetchAllAssociative(): array; /** - * Returns an array containing the values of the first column of the result set. + * Returns an array containing the values of the first column of the result. * * @return array * diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index b3657e41350..b56fd61ff2d 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -3,8 +3,8 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use function assert; @@ -129,7 +129,7 @@ public function getServerVersion() { $stmt = $this->query("SELECT PROPERTY('ProductVersion')"); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { $version = $stmt->fetchOne(); } else { $version = $stmt->fetchColumn(); @@ -151,7 +151,7 @@ public function lastInsertId($name = null) $stmt = $this->query('SELECT ' . $name . '.CURRVAL'); - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchOne(); } diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index a8eddb7fdad..de8d60cd42c 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -4,10 +4,10 @@ use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -44,7 +44,7 @@ /** * SAP SQL Anywhere implementation of the Statement interface. */ -class SQLAnywhereStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement +class SQLAnywhereStatement implements IteratorAggregate, Statement, Result { /** @var resource The connection resource. */ private $conn; diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 912b63336a7..cb38400182f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -3,8 +3,8 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use function func_get_args; @@ -144,7 +144,7 @@ public function lastInsertId($name = null) $stmt = $this->query('SELECT @@IDENTITY'); } - if ($stmt instanceof ForwardCompatibleResultStatement) { + if ($stmt instanceof Result) { return $stmt->fetchOne(); } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 1042bb18cb5..3e059a1c85d 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -3,10 +3,10 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -42,7 +42,7 @@ /** * SQL Server Statement. */ -class SQLSrvStatement implements IteratorAggregate, Statement, ForwardCompatibleResultStatement +class SQLSrvStatement implements IteratorAggregate, Statement, Result { /** * The SQLSRV Resource. diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 02b598fc9ee..34d07343748 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -2,11 +2,11 @@ namespace Doctrine\DBAL\Portability; +use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; -use Doctrine\DBAL\ForwardCompatibility\Driver\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\ParameterType; use IteratorAggregate; use PDO; @@ -19,7 +19,7 @@ /** * Portability wrapper for a Statement. */ -class Statement implements IteratorAggregate, DriverStatement, ForwardCompatibleResultStatement +class Statement implements IteratorAggregate, DriverStatement, Result { /** @var int */ private $portability; @@ -185,7 +185,7 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n */ public function fetchNumeric() { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $row = $this->stmt->fetchNumeric(); } else { $row = $this->stmt->fetch(FetchMode::NUMERIC); @@ -199,7 +199,7 @@ public function fetchNumeric() */ public function fetchAssociative() { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $row = $this->stmt->fetchAssociative(); } else { $row = $this->stmt->fetch(FetchMode::ASSOCIATIVE); @@ -213,7 +213,7 @@ public function fetchAssociative() */ public function fetchOne() { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $value = $this->stmt->fetchOne(); } else { $value = $this->stmt->fetch(FetchMode::COLUMN); @@ -233,7 +233,7 @@ public function fetchOne() */ public function fetchAllNumeric(): array { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $data = $this->stmt->fetchAllNumeric(); } else { $data = $this->stmt->fetchAll(FetchMode::NUMERIC); @@ -247,7 +247,7 @@ public function fetchAllNumeric(): array */ public function fetchAllAssociative(): array { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $data = $this->stmt->fetchAllAssociative(); } else { $data = $this->stmt->fetchAll(FetchMode::ASSOCIATIVE); @@ -261,7 +261,7 @@ public function fetchAllAssociative(): array */ public function fetchFirstColumn(): array { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { $data = $this->stmt->fetchFirstColumn(); } else { $data = $this->stmt->fetchAll(FetchMode::COLUMN); diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 907e631d064..6f329048c81 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL; +use Doctrine\DBAL\Abstraction\Result; use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ForwardCompatibility\ResultStatement as ForwardCompatibleResultStatement; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; use IteratorAggregate; @@ -19,7 +19,7 @@ * A thin wrapper around a Doctrine\DBAL\Driver\Statement that adds support * for logging, DBAL mapping types, etc. */ -class Statement implements IteratorAggregate, DriverStatement, ForwardCompatibleResultStatement +class Statement implements IteratorAggregate, DriverStatement, Result { /** * The SQL statement. @@ -289,7 +289,7 @@ public function fetchColumn($columnIndex = 0) public function fetchNumeric() { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchNumeric(); } @@ -307,7 +307,7 @@ public function fetchNumeric() public function fetchAssociative() { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchAssociative(); } @@ -325,7 +325,7 @@ public function fetchAssociative() public function fetchOne() { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchOne(); } @@ -343,7 +343,7 @@ public function fetchOne() public function fetchAllNumeric(): array { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchAllNumeric(); } @@ -361,7 +361,7 @@ public function fetchAllNumeric(): array public function fetchAllAssociative(): array { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchAllAssociative(); } @@ -379,7 +379,7 @@ public function fetchAllAssociative(): array public function fetchFirstColumn(): array { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { return $this->stmt->fetchFirstColumn(); } @@ -399,7 +399,7 @@ public function fetchFirstColumn(): array public function iterateNumeric(): Traversable { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { while (($row = $this->stmt->fetchNumeric()) !== false) { yield $row; } @@ -423,7 +423,7 @@ public function iterateNumeric(): Traversable public function iterateAssociative(): Traversable { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { while (($row = $this->stmt->fetchAssociative()) !== false) { yield $row; } @@ -447,7 +447,7 @@ public function iterateAssociative(): Traversable public function iterateColumn(): Traversable { try { - if ($this->stmt instanceof ForwardCompatibleResultStatement) { + if ($this->stmt instanceof Result) { while (($value = $this->stmt->fetchOne()) !== false) { yield $value; } From cc5bbd015a45df9012eb69b7805d6ab16db6dd15 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 22:47:01 -0700 Subject: [PATCH 28/93] Do not extend ResultStetement by Result --- lib/Doctrine/DBAL/Driver/Result.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/Result.php b/lib/Doctrine/DBAL/Driver/Result.php index 49487249914..cb450c9cc7b 100644 --- a/lib/Doctrine/DBAL/Driver/Result.php +++ b/lib/Doctrine/DBAL/Driver/Result.php @@ -4,12 +4,10 @@ namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver\ResultStatement as BaseResultStatement; - /** * Driver-level result statement execution result. */ -interface Result extends BaseResultStatement +interface Result { /** * Returns the next row of the result as a numeric array or FALSE if there are no more rows. @@ -64,4 +62,19 @@ public function fetchAllAssociative(): array; * @throws DriverException */ public function fetchFirstColumn(): array; + + /** + * Returns the number of columns in the result + * + * @return int The number of columns in the result. If the columns cannot be counted, + * this method must return 0. + */ + public function columnCount(); + + /** + * Closes the cursor, enabling the statement to be executed again. + * + * @return bool TRUE on success or FALSE on failure. + */ + public function closeCursor(); } From 94d5321e7c1a7deaa5e5d189abbceee4bd5809aa Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 22:53:20 -0700 Subject: [PATCH 29/93] Add rowCount() to the Result interface --- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 10 +++++++++- lib/Doctrine/DBAL/Driver/Result.php | 11 +++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index f9bef8d73d7..b9e19036a84 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -48,11 +48,19 @@ public function __construct(array $data) */ public function closeCursor() { - unset($this->data); + $this->data = []; return true; } + /** + * {@inheritdoc} + */ + public function rowCount() + { + return count($this->data); + } + /** * {@inheritdoc} */ diff --git a/lib/Doctrine/DBAL/Driver/Result.php b/lib/Doctrine/DBAL/Driver/Result.php index cb450c9cc7b..ad23d693c40 100644 --- a/lib/Doctrine/DBAL/Driver/Result.php +++ b/lib/Doctrine/DBAL/Driver/Result.php @@ -63,6 +63,17 @@ public function fetchAllAssociative(): array; */ public function fetchFirstColumn(): array; + /** + * Returns the number of rows affected by the DELETE, INSERT, or UPDATE statement that produced the result. + * + * If the statement executed a SELECT query or a similar platform-specific SQL (e.g. DESCRIBE, SHOW, etc.), + * some database drivers may return the number of rows returned by that query. However, this behaviour + * is not guaranteed for all drivers and should not be relied on in portable applications. + * + * @return int The number of rows. + */ + public function rowCount(); + /** * Returns the number of columns in the result * From f8ae949ff9deb7f610c9ba211d9813f9b53189f5 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 23:01:47 -0700 Subject: [PATCH 30/93] Deprecate ResultStatement::closeCursor() in favor of Result::free() --- UPGRADE.md | 3 +- lib/Doctrine/DBAL/Cache/ArrayStatement.php | 9 ++++- .../DBAL/Cache/ResultCacheStatement.php | 11 +++++-- .../DBAL/Driver/IBMDB2/DB2Statement.php | 11 +++++++ .../DBAL/Driver/Mysqli/MysqliStatement.php | 11 +++++-- .../DBAL/Driver/OCI8/OCI8Statement.php | 23 ++++++++----- lib/Doctrine/DBAL/Driver/PDOStatement.php | 7 ++++ lib/Doctrine/DBAL/Driver/Result.php | 6 ++-- lib/Doctrine/DBAL/Driver/ResultStatement.php | 2 ++ .../SQLAnywhere/SQLAnywhereStatement.php | 7 ++++ .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 33 +++++++++++-------- lib/Doctrine/DBAL/Portability/Statement.php | 13 ++++++++ lib/Doctrine/DBAL/Statement.php | 13 ++++++++ 13 files changed, 117 insertions(+), 32 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 46e4666b21c..5485f61d2bc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,7 +2,8 @@ ## Deprecated `ResultStatement` interface -The `ResultStatement` interface is deprecated. Use the `Driver\Result` and `Abstraction\Result` interfaces instead. +1. The `ResultStatement` interface is deprecated. Use the `Driver\Result` and `Abstraction\Result` interfaces instead. +2. `ResultStatement::closeCursor()` is deprecated in favor of `Result::free()`. ## Deprecated `FetchMode` and the corresponding methods diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index b9e19036a84..98d545727f5 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -45,10 +45,12 @@ public function __construct(array $data) /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { - $this->data = []; + $this->free(); return true; } @@ -218,6 +220,11 @@ public function fetchFirstColumn(): array return FetchUtils::fetchFirstColumn($this); } + public function free(): void + { + $this->data = []; + } + /** * @return mixed|false */ diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 78d97d25cdf..79151279aad 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -72,12 +72,12 @@ public function __construct(ResultStatement $stmt, Cache $resultCache, $cacheKey /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { - $this->statement->closeCursor(); - - $this->data = null; + $this->free(); return true; } @@ -287,6 +287,11 @@ public function rowCount() return $this->statement->rowCount(); } + public function free(): void + { + $this->data = null; + } + /** * @return array|false * diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 163accb5a70..7c97017099d 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -147,6 +147,8 @@ private function bind($position, &$variable, int $parameterType, int $dataType): /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { @@ -426,6 +428,15 @@ public function rowCount() return @db2_num_rows($this->stmt) ? : 0; } + public function free(): void + { + $this->bindParam = []; + + db2_free_result($this->stmt); + + $this->result = false; + } + /** * Casts a stdClass object to the given class name mapping its' properties. * diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 4f912fa1f5b..c3f893fc127 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -498,11 +498,12 @@ public function errorInfo() /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { - $this->_stmt->free_result(); - $this->result = false; + $this->free(); return true; } @@ -527,6 +528,12 @@ public function columnCount() return $this->_stmt->field_count; } + public function free(): void + { + $this->_stmt->free_result(); + $this->result = false; + } + /** * {@inheritdoc} * diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index e31f42d5f4c..4f04a46a5cf 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -331,17 +331,12 @@ private function convertParameterType(int $type): int /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { - // not having the result means there's nothing to close - if (! $this->result) { - return true; - } - - oci_cancel($this->_sth); - - $this->result = false; + $this->free(); return true; } @@ -601,6 +596,18 @@ public function fetchFirstColumn(): array return $this->doFetchAll(OCI_NUM, OCI_FETCHSTATEMENT_BY_COLUMN)[0]; } + public function free(): void + { + // not having the result means there's nothing to close + if (! $this->result) { + return; + } + + oci_cancel($this->_sth); + + $this->result = false; + } + /** * @return mixed|false */ diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 4ff31dfc702..911f5d49665 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -110,6 +110,8 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { @@ -249,6 +251,11 @@ public function fetchFirstColumn(): array return $this->fetchAll(PDO::FETCH_COLUMN); } + public function free(): void + { + parent::closeCursor(); + } + /** * Converts DBAL parameter type to PDO parameter type * diff --git a/lib/Doctrine/DBAL/Driver/Result.php b/lib/Doctrine/DBAL/Driver/Result.php index ad23d693c40..65be0f03c49 100644 --- a/lib/Doctrine/DBAL/Driver/Result.php +++ b/lib/Doctrine/DBAL/Driver/Result.php @@ -83,9 +83,7 @@ public function rowCount(); public function columnCount(); /** - * Closes the cursor, enabling the statement to be executed again. - * - * @return bool TRUE on success or FALSE on failure. + * Discards the non-fetched portion of the result, enabling the originating statement to be executed again. */ - public function closeCursor(); + public function free(): void; } diff --git a/lib/Doctrine/DBAL/Driver/ResultStatement.php b/lib/Doctrine/DBAL/Driver/ResultStatement.php index 442552040cc..601e28dba41 100644 --- a/lib/Doctrine/DBAL/Driver/ResultStatement.php +++ b/lib/Doctrine/DBAL/Driver/ResultStatement.php @@ -13,6 +13,8 @@ interface ResultStatement extends Traversable /** * Closes the cursor, enabling the statement to be executed again. * + * @deprecated Use Result::free() instead. + * * @return bool TRUE on success or FALSE on failure. */ public function closeCursor(); diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index de8d60cd42c..6a67072e266 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -136,6 +136,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING) /** * {@inheritdoc} * + * @deprecated Use free() instead. + * * @throws SQLAnywhereException */ public function closeCursor() @@ -388,6 +390,11 @@ public function rowCount() return sasql_stmt_affected_rows($this->stmt); } + public function free(): void + { + sasql_stmt_reset($this->stmt); + } + /** * {@inheritdoc} * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 3e059a1c85d..886faf55bcc 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -186,22 +186,12 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { - // not having the result means there's nothing to close - if ($this->stmt === null || ! $this->result) { - return true; - } - - // emulate it by fetching and discarding rows, similarly to what PDO does in this case - // @link http://php.net/manual/en/pdostatement.closecursor.php - // @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075 - // deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them - while (sqlsrv_fetch($this->stmt)) { - } - - $this->result = false; + $this->free(); return true; } @@ -498,6 +488,23 @@ public function rowCount() return sqlsrv_rows_affected($this->stmt) ?: 0; } + public function free(): void + { + // not having the result means there's nothing to close + if ($this->stmt === null || ! $this->result) { + return; + } + + // emulate it by fetching and discarding rows, similarly to what PDO does in this case + // @link http://php.net/manual/en/pdostatement.closecursor.php + // @link https://github.com/php/php-src/blob/php-7.0.11/ext/pdo/pdo_stmt.c#L2075 + // deliberately do not consider multiple result sets, since doctrine/dbal doesn't support them + while (sqlsrv_fetch($this->stmt)) { + } + + $this->result = false; + } + /** * @return mixed|false */ diff --git a/lib/Doctrine/DBAL/Portability/Statement.php b/lib/Doctrine/DBAL/Portability/Statement.php index 34d07343748..cafee72b71f 100644 --- a/lib/Doctrine/DBAL/Portability/Statement.php +++ b/lib/Doctrine/DBAL/Portability/Statement.php @@ -67,6 +67,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING) /** * {@inheritdoc} + * + * @deprecated Use free() instead. */ public function closeCursor() { @@ -270,6 +272,17 @@ public function fetchFirstColumn(): array return $this->fixResultSet($data, true, false); } + public function free(): void + { + if ($this->stmt instanceof Result) { + $this->stmt->free(); + + return; + } + + $this->stmt->closeCursor(); + } + /** * @param mixed $result * diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 6f329048c81..3d6dfc27f26 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -182,6 +182,8 @@ public function execute($params = null) /** * Closes the cursor, freeing the database resources used by this statement. * + * @deprecated Use Result::free() instead. + * * @return bool TRUE on success, FALSE on failure. */ public function closeCursor() @@ -471,6 +473,17 @@ public function rowCount() return $this->stmt->rowCount(); } + public function free(): void + { + if ($this->stmt instanceof Result) { + $this->stmt->free(); + + return; + } + + $this->stmt->closeCursor(); + } + /** * Gets the wrapped driver statement. * From e7c7cb1788353d8d57f6e416819dc4461b7dd467 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 5 Jun 2020 17:54:05 -0700 Subject: [PATCH 31/93] Deprecate ArrayStatement and ResultCacheStatement --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Cache/ArrayStatement.php | 3 +++ lib/Doctrine/DBAL/Cache/ResultCacheStatement.php | 2 ++ 3 files changed, 9 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 5485f61d2bc..2d1f52303a6 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecated `ArrayStatement` and `ResultCacheStatement` classes. + +The `ArrayStatement` and `ResultCacheStatement` classes are deprecated. In a future major release they will be renamed and marked internal as implementation details of the caching layer. + ## Deprecated `ResultStatement` interface 1. The `ResultStatement` interface is deprecated. Use the `Driver\Result` and `Abstraction\Result` interfaces instead. diff --git a/lib/Doctrine/DBAL/Cache/ArrayStatement.php b/lib/Doctrine/DBAL/Cache/ArrayStatement.php index 98d545727f5..58d0a59e361 100644 --- a/lib/Doctrine/DBAL/Cache/ArrayStatement.php +++ b/lib/Doctrine/DBAL/Cache/ArrayStatement.php @@ -16,6 +16,9 @@ use function count; use function reset; +/** + * @deprecated + */ class ArrayStatement implements IteratorAggregate, ResultStatement, Result { /** @var mixed[] */ diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index 79151279aad..d990b15fefd 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -32,6 +32,8 @@ * * Also you have to realize that the cache will load the whole result into memory at once to ensure 2. * This means that the memory usage for cached results might increase by using this feature. + * + * @deprecated */ class ResultCacheStatement implements IteratorAggregate, ResultStatement, Result { From 071824e7242ef61196fc3cc5bbcdc6cb6c3eb55e Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sun, 7 Jun 2020 00:52:04 +0200 Subject: [PATCH 32/93] [GH-4052] Deprecate MasterSlaveConnection and rename to PrimaryReplicaConnection --- UPGRADE.md | 37 ++ .../Connections/MasterSlaveConnection.php | 369 ++-------------- .../PrimaryReadReplicaConnection.php | 413 ++++++++++++++++++ lib/Doctrine/DBAL/DriverManager.php | 14 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 20 +- .../PrimaryReadReplicaConnectionTest.php | 243 +++++++++++ 6 files changed, 759 insertions(+), 337 deletions(-) create mode 100644 lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php diff --git a/UPGRADE.md b/UPGRADE.md index 2d1f52303a6..e69c41e563f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,42 @@ # Upgrade to 2.11 +## Deprecated `MasterSlaveConnection` use `PrimaryReadReplicaConnection` + +The `Doctrine\DBAL\Connections\MasterSlaveConnection` class is renamed to `Doctrine\DBAL\Connections\PrimaryReadReplicaConnection`. +In addition its configuration parameters `master`, `slaves` and `keepSlave` are renamed to `primary`, `replica` and `keepReplica`. + +Before: + + $connection = DriverManager::getConnection( + 'wrapperClass' => 'Doctrine\DBAL\Connections\MasterSlaveConnection', + 'driver' => 'pdo_mysql', + 'master' => array('user' => '', 'password' => '', 'host' => '', 'dbname' => ''), + 'slaves' => array( + array('user' => 'replica1', 'password', 'host' => '', 'dbname' => ''), + array('user' => 'replica2', 'password', 'host' => '', 'dbname' => ''), + ), + 'keepSlave' => true, + )); + $connection->connect('slave'); + $connection->connect('master'); + $connection->isConnectedToMaster(); + +After: + + $connection = DriverManager::getConnection(array( + 'wrapperClass' => 'Doctrine\DBAL\Connections\PrimaryReadReplicaConnection', + 'driver' => 'pdo_mysql', + 'primary' => array('user' => '', 'password' => '', 'host' => '', 'dbname' => ''), + 'replica' => array( + array('user' => 'replica1', 'password', 'host' => '', 'dbname' => ''), + array('user' => 'replica2', 'password', 'host' => '', 'dbname' => ''), + ) + 'keepReplica' => true, + )); + $connection->ensureConnectedToReplica(); + $connection->ensureConnectedToPrimary(); + $connection->isConnectedToPrimary(); + ## Deprecated `ArrayStatement` and `ResultCacheStatement` classes. The `ArrayStatement` and `ResultCacheStatement` classes are deprecated. In a future major release they will be renamed and marked internal as implementation details of the caching layer. diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 9362bc0c636..39b0c6165d5 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -4,88 +4,21 @@ use Doctrine\Common\EventManager; use Doctrine\DBAL\Configuration; -use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver\Connection as DriverConnection; -use Doctrine\DBAL\Event\ConnectionEventArgs; -use Doctrine\DBAL\Events; use InvalidArgumentException; -use function array_rand; -use function assert; -use function count; -use function func_get_args; +use function sprintf; +use function trigger_error; + +use const E_USER_DEPRECATED; /** - * Master-Slave Connection - * - * Connection can be used with master-slave setups. - * - * Important for the understanding of this connection should be how and when - * it picks the slave or master. - * - * 1. Slave if master was never picked before and ONLY if 'getWrappedConnection' - * or 'executeQuery' is used. - * 2. Master picked when 'exec', 'executeUpdate', 'insert', 'delete', 'update', 'createSavepoint', - * 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or - * 'prepare' is called. - * 3. If master was picked once during the lifetime of the connection it will always get picked afterwards. - * 4. One slave connection is randomly picked ONCE during a request. - * - * ATTENTION: You can write to the slave with this connection if you execute a write query without - * opening up a transaction. For example: - * - * $conn = DriverManager::getConnection(...); - * $conn->executeQuery("DELETE FROM table"); - * - * Be aware that Connection#executeQuery is a method specifically for READ - * operations only. - * - * This connection is limited to slave operations using the - * Connection#executeQuery operation only, because it wouldn't be compatible - * with the ORM or SchemaManager code otherwise. Both use all the other - * operations in a context where writes could happen to a slave, which makes - * this restricted approach necessary. - * - * You can manually connect to the master at any time by calling: - * - * $conn->connect('master'); - * - * Instantiation through the DriverManager looks like: - * - * @example - * - * $conn = DriverManager::getConnection(array( - * 'wrapperClass' => 'Doctrine\DBAL\Connections\MasterSlaveConnection', - * 'driver' => 'pdo_mysql', - * 'master' => array('user' => '', 'password' => '', 'host' => '', 'dbname' => ''), - * 'slaves' => array( - * array('user' => 'slave1', 'password', 'host' => '', 'dbname' => ''), - * array('user' => 'slave2', 'password', 'host' => '', 'dbname' => ''), - * ) - * )); - * - * You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information. + * @deprecated Use PrimaryReadReplicaConnection instead */ -class MasterSlaveConnection extends Connection +class MasterSlaveConnection extends PrimaryReadReplicaConnection { /** - * Master and slave connection (one of the randomly picked slaves). - * - * @var DriverConnection[]|null[] - */ - protected $connections = ['master' => null, 'slave' => null]; - - /** - * You can keep the slave connection and then switch back to it - * during the request if you know what you are doing. - * - * @var bool - */ - protected $keepSlave = false; - - /** - * Creates Master Slave Connection. + * Creates Primary Replica Connection. * * @param mixed[] $params * @@ -93,289 +26,73 @@ class MasterSlaveConnection extends Connection */ public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) { - if (! isset($params['slaves'], $params['master'])) { - throw new InvalidArgumentException('master or slaves configuration missing'); - } - - if (count($params['slaves']) === 0) { - throw new InvalidArgumentException('You have to configure at least one slaves.'); - } - - $params['master']['driver'] = $params['driver']; - foreach ($params['slaves'] as $slaveKey => $slave) { - $params['slaves'][$slaveKey]['driver'] = $params['driver']; - } - - $this->keepSlave = (bool) ($params['keepSlave'] ?? false); - - parent::__construct($params, $driver, $config, $eventManager); - } - - /** - * Checks if the connection is currently towards the master or not. - * - * @return bool - */ - public function isConnectedToMaster() - { - return $this->_conn !== null && $this->_conn === $this->connections['master']; - } - - /** - * @param string|null $connectionName - * - * @return bool - */ - public function connect($connectionName = null) - { - $requestedConnectionChange = ($connectionName !== null); - $connectionName = $connectionName ?: 'slave'; - - if ($connectionName !== 'slave' && $connectionName !== 'master') { - throw new InvalidArgumentException('Invalid option to connect(), only master or slave allowed.'); - } + $this->deprecated(self::class, PrimaryReadReplicaConnection::class); - // If we have a connection open, and this is not an explicit connection - // change request, then abort right here, because we are already done. - // This prevents writes to the slave in case of "keepSlave" option enabled. - if ($this->_conn !== null && ! $requestedConnectionChange) { - return false; - } - - $forceMasterAsSlave = false; + if (isset($params['master'])) { + $this->deprecated('Params key "master"', '"primary"'); - if ($this->getTransactionNestingLevel() > 0) { - $connectionName = 'master'; - $forceMasterAsSlave = true; + $params['primary'] = $params['master']; + unset($params['master']); } - if (isset($this->connections[$connectionName])) { - $this->_conn = $this->connections[$connectionName]; - - if ($forceMasterAsSlave && ! $this->keepSlave) { - $this->connections['slave'] = $this->_conn; - } + if (isset($params['slaves'])) { + $this->deprecated('Params key "slaves"', '"replica"'); - return false; + $params['replica'] = $params['slaves']; + unset($params['slaves']); } - if ($connectionName === 'master') { - $this->connections['master'] = $this->_conn = $this->connectTo($connectionName); + if (isset($params['keepSlave'])) { + $this->deprecated('Params key "keepSlave"', '"keepReplica"'); - // Set slave connection to master to avoid invalid reads - if (! $this->keepSlave) { - $this->connections['slave'] = $this->connections['master']; - } - } else { - $this->connections['slave'] = $this->_conn = $this->connectTo($connectionName); + $params['keepReplica'] = $params['keepSlave']; + unset($params['keepSlave']); } - if ($this->_eventManager->hasListeners(Events::postConnect)) { - $eventArgs = new ConnectionEventArgs($this); - $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs); - } - - return true; + parent::__construct($params, $driver, $config, $eventManager); } /** - * Connects to a specific connection. - * - * @param string $connectionName - * - * @return DriverConnection + * Checks if the connection is currently towards the primary or not. */ - protected function connectTo($connectionName) + public function isConnectedToMaster(): bool { - $params = $this->getParams(); + $this->deprecated('isConnectedtoMaster()', 'isConnectedToPrimary()'); - $driverOptions = $params['driverOptions'] ?? []; - - $connectionParams = $this->chooseConnectionConfiguration($connectionName, $params); - - $user = $connectionParams['user'] ?? null; - $password = $connectionParams['password'] ?? null; - - return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); + return $this->isConnectedToPrimary(); } /** - * @param string $connectionName - * @param mixed[] $params + * @param string|null $connectionName * - * @return mixed + * @return bool */ - protected function chooseConnectionConfiguration($connectionName, $params) + public function connect($connectionName = null) { if ($connectionName === 'master') { - return $params['master']; - } - - $config = $params['slaves'][array_rand($params['slaves'])]; + $connectionName = 'primary'; - if (! isset($config['charset']) && isset($params['master']['charset'])) { - $config['charset'] = $params['master']['charset']; + $this->deprecated('connect("master")', 'ensureConnectedToPrimary()'); } - return $config; - } - - /** - * {@inheritDoc} - */ - public function executeUpdate($query, array $params = [], array $types = []) - { - $this->connect('master'); - - return parent::executeUpdate($query, $params, $types); - } - - /** - * {@inheritDoc} - */ - public function beginTransaction() - { - $this->connect('master'); - - return parent::beginTransaction(); - } - - /** - * {@inheritDoc} - */ - public function commit() - { - $this->connect('master'); + if ($connectionName === 'slave') { + $connectionName = 'replica'; - return parent::commit(); - } - - /** - * {@inheritDoc} - */ - public function rollBack() - { - $this->connect('master'); - - return parent::rollBack(); - } - - /** - * {@inheritDoc} - */ - public function delete($tableName, array $identifier, array $types = []) - { - $this->connect('master'); - - return parent::delete($tableName, $identifier, $types); - } - - /** - * {@inheritDoc} - */ - public function close() - { - unset($this->connections['master'], $this->connections['slave']); - - parent::close(); - - $this->_conn = null; - $this->connections = ['master' => null, 'slave' => null]; - } - - /** - * {@inheritDoc} - */ - public function update($tableName, array $data, array $identifier, array $types = []) - { - $this->connect('master'); - - return parent::update($tableName, $data, $identifier, $types); - } - - /** - * {@inheritDoc} - */ - public function insert($tableName, array $data, array $types = []) - { - $this->connect('master'); - - return parent::insert($tableName, $data, $types); - } - - /** - * {@inheritDoc} - */ - public function exec($statement) - { - $this->connect('master'); - - return parent::exec($statement); - } - - /** - * {@inheritDoc} - */ - public function createSavepoint($savepoint) - { - $this->connect('master'); - - parent::createSavepoint($savepoint); - } - - /** - * {@inheritDoc} - */ - public function releaseSavepoint($savepoint) - { - $this->connect('master'); - - parent::releaseSavepoint($savepoint); - } - - /** - * {@inheritDoc} - */ - public function rollbackSavepoint($savepoint) - { - $this->connect('master'); - - parent::rollbackSavepoint($savepoint); - } - - /** - * {@inheritDoc} - */ - public function query() - { - $this->connect('master'); - assert($this->_conn instanceof DriverConnection); - - $args = func_get_args(); - - $logger = $this->getConfiguration()->getSQLLogger(); - if ($logger) { - $logger->startQuery($args[0]); - } - - $statement = $this->_conn->query(...$args); - - $statement->setFetchMode($this->defaultFetchMode); - - if ($logger) { - $logger->stopQuery(); + $this->deprecated('connect("slave")', 'ensureConnectedToReplica()'); } - return $statement; + return $this->performConnect($connectionName); } - /** - * {@inheritDoc} - */ - public function prepare($statement) + private function deprecated(string $thing, string $instead): void { - $this->connect('master'); - - return parent::prepare($statement); + @trigger_error( + sprintf( + '%s is deprecated since doctrine/dbal 2.11 and will be removed in 3.0, use %s instead.', + $thing, + $instead + ), + E_USER_DEPRECATED + ); } } diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php new file mode 100644 index 00000000000..cb78b69c451 --- /dev/null +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -0,0 +1,413 @@ +executeQuery("DELETE FROM table"); + * + * Be aware that Connection#executeQuery is a method specifically for READ + * operations only. + * + * Use Connection#executeUpdate for any SQL statement that changes/updates + * state in the database (UPDATE, INSERT, DELETE or DDL statements). + * + * This connection is limited to replica operations using the + * Connection#executeQuery operation only, because it wouldn't be compatible + * with the ORM or SchemaManager code otherwise. Both use all the other + * operations in a context where writes could happen to a replica, which makes + * this restricted approach necessary. + * + * You can manually connect to the primary at any time by calling: + * + * $conn->ensureConnectedToPrimary(); + * + * Instantiation through the DriverManager looks like: + * + * @example + * + * $conn = DriverManager::getConnection(array( + * 'wrapperClass' => 'Doctrine\DBAL\Connections\PrimaryReadReplicaConnection', + * 'driver' => 'pdo_mysql', + * 'primary' => array('user' => '', 'password' => '', 'host' => '', 'dbname' => ''), + * 'replica' => array( + * array('user' => 'replica1', 'password', 'host' => '', 'dbname' => ''), + * array('user' => 'replica2', 'password', 'host' => '', 'dbname' => ''), + * ) + * )); + * + * You can also pass 'driverOptions' and any other documented option to each of this drivers to pass additional information. + */ +class PrimaryReadReplicaConnection extends Connection +{ + /** + * Primary and Replica connection (one of the randomly picked replicas). + * + * @var DriverConnection[]|null[] + */ + protected $connections = ['primary' => null, 'replica' => null]; + + /** + * You can keep the replica connection and then switch back to it + * during the request if you know what you are doing. + * + * @var bool + */ + protected $keepReplica = false; + + /** + * Creates Primary Replica Connection. + * + * @param mixed[] $params + * + * @throws InvalidArgumentException + */ + public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) + { + if (! isset($params['replica'], $params['primary'])) { + throw new InvalidArgumentException('primary or replica configuration missing'); + } + + if (count($params['replica']) === 0) { + throw new InvalidArgumentException('You have to configure at least one replica.'); + } + + $params['primary']['driver'] = $params['driver']; + foreach ($params['replica'] as $replicaKey => $replica) { + $params['replica'][$replicaKey]['driver'] = $params['driver']; + } + + $this->keepReplica = (bool) ($params['keepReplica'] ?? false); + + parent::__construct($params, $driver, $config, $eventManager); + } + + /** + * Checks if the connection is currently towards the primary or not. + */ + public function isConnectedToPrimary(): bool + { + return $this->_conn !== null && $this->_conn === $this->connections['primary']; + } + + /** + * @param string|null $connectionName + * + * @return bool + */ + public function connect($connectionName = null) + { + if ($connectionName !== null) { + throw new InvalidArgumentException('Passing a connection name as first argument is not supported anymore. Use ensureConnectedToPrimary()/ensureConnectedToReplica() instead.'); + } + + return $this->performConnect(); + } + + protected function performConnect(?string $connectionName = null): bool + { + $requestedConnectionChange = ($connectionName !== null); + $connectionName = $connectionName ?: 'replica'; + + if ($connectionName !== 'replica' && $connectionName !== 'primary') { + throw new InvalidArgumentException('Invalid option to connect(), only primary or replica allowed.'); + } + + // If we have a connection open, and this is not an explicit connection + // change request, then abort right here, because we are already done. + // This prevents writes to the replica in case of "keepReplica" option enabled. + if ($this->_conn !== null && ! $requestedConnectionChange) { + return false; + } + + $forcePrimaryAsReplica = false; + + if ($this->getTransactionNestingLevel() > 0) { + $connectionName = 'primary'; + $forcePrimaryAsReplica = true; + } + + if (isset($this->connections[$connectionName])) { + $this->_conn = $this->connections[$connectionName]; + + if ($forcePrimaryAsReplica && ! $this->keepReplica) { + $this->connections['replica'] = $this->_conn; + } + + return false; + } + + if ($connectionName === 'primary') { + $this->connections['primary'] = $this->_conn = $this->connectTo($connectionName); + + // Set replica connection to primary to avoid invalid reads + if (! $this->keepReplica) { + $this->connections['replica'] = $this->connections['primary']; + } + } else { + $this->connections['replica'] = $this->_conn = $this->connectTo($connectionName); + } + + if ($this->_eventManager->hasListeners(Events::postConnect)) { + $eventArgs = new ConnectionEventArgs($this); + $this->_eventManager->dispatchEvent(Events::postConnect, $eventArgs); + } + + return true; + } + + /** + * Connects to the primary node of the database cluster. + * + * All following statements after this will be executed against the primary node. + */ + public function ensureConnectedToPrimary(): bool + { + return $this->performConnect('primary'); + } + + /** + * Connects to a replica node of the database cluster. + * + * All following statements after this will be executed against the replica node, + * unless the keepReplica option is set to false and a primary connection + * was already opened. + */ + public function ensureConnectedToReplica(): bool + { + return $this->performConnect('replica'); + } + + /** + * Connects to a specific connection. + * + * @param string $connectionName + * + * @return DriverConnection + */ + protected function connectTo($connectionName) + { + $params = $this->getParams(); + + $driverOptions = $params['driverOptions'] ?? []; + + $connectionParams = $this->chooseConnectionConfiguration($connectionName, $params); + + $user = $connectionParams['user'] ?? null; + $password = $connectionParams['password'] ?? null; + + return $this->_driver->connect($connectionParams, $user, $password, $driverOptions); + } + + /** + * @param string $connectionName + * @param mixed[] $params + * + * @return mixed + */ + protected function chooseConnectionConfiguration($connectionName, $params) + { + if ($connectionName === 'primary') { + return $params['primary']; + } + + $config = $params['replica'][array_rand($params['replica'])]; + + if (! isset($config['charset']) && isset($params['primary']['charset'])) { + $config['charset'] = $params['primary']['charset']; + } + + return $config; + } + + /** + * {@inheritDoc} + */ + public function executeUpdate($query, array $params = [], array $types = []) + { + $this->ensureConnectedToPrimary(); + + return parent::executeUpdate($query, $params, $types); + } + + /** + * {@inheritDoc} + */ + public function beginTransaction() + { + $this->ensureConnectedToPrimary(); + + return parent::beginTransaction(); + } + + /** + * {@inheritDoc} + */ + public function commit() + { + $this->ensureConnectedToPrimary(); + + return parent::commit(); + } + + /** + * {@inheritDoc} + */ + public function rollBack() + { + $this->ensureConnectedToPrimary(); + + return parent::rollBack(); + } + + /** + * {@inheritDoc} + */ + public function delete($tableName, array $identifier, array $types = []) + { + $this->ensureConnectedToPrimary(); + + return parent::delete($tableName, $identifier, $types); + } + + /** + * {@inheritDoc} + */ + public function close() + { + unset($this->connections['primary'], $this->connections['replica']); + + parent::close(); + + $this->_conn = null; + $this->connections = ['primary' => null, 'replica' => null]; + } + + /** + * {@inheritDoc} + */ + public function update($tableName, array $data, array $identifier, array $types = []) + { + $this->ensureConnectedToPrimary(); + + return parent::update($tableName, $data, $identifier, $types); + } + + /** + * {@inheritDoc} + */ + public function insert($tableName, array $data, array $types = []) + { + $this->ensureConnectedToPrimary(); + + return parent::insert($tableName, $data, $types); + } + + /** + * {@inheritDoc} + */ + public function exec($statement) + { + $this->ensureConnectedToPrimary(); + + return parent::exec($statement); + } + + /** + * {@inheritDoc} + */ + public function createSavepoint($savepoint) + { + $this->ensureConnectedToPrimary(); + + parent::createSavepoint($savepoint); + } + + /** + * {@inheritDoc} + */ + public function releaseSavepoint($savepoint) + { + $this->ensureConnectedToPrimary(); + + parent::releaseSavepoint($savepoint); + } + + /** + * {@inheritDoc} + */ + public function rollbackSavepoint($savepoint) + { + $this->ensureConnectedToPrimary(); + + parent::rollbackSavepoint($savepoint); + } + + /** + * {@inheritDoc} + */ + public function query() + { + $this->ensureConnectedToPrimary(); + assert($this->_conn instanceof DriverConnection); + + $args = func_get_args(); + + $logger = $this->getConfiguration()->getSQLLogger(); + if ($logger) { + $logger->startQuery($args[0]); + } + + $statement = $this->_conn->query(...$args); + + $statement->setFetchMode($this->defaultFetchMode); + + if ($logger) { + $logger->stopQuery(); + } + + return $statement; + } + + /** + * {@inheritDoc} + */ + public function prepare($statement) + { + $this->ensureConnectedToPrimary(); + + return parent::prepare($statement); + } +} diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index f7462bbd462..b56ac7f9054 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -142,17 +142,29 @@ public static function getConnection( $params = self::parseDatabaseUrl($params); - // URL support for MasterSlaveConnection + // @todo: deprecated, notice thrown by connection constructor if (isset($params['master'])) { $params['master'] = self::parseDatabaseUrl($params['master']); } + // @todo: deprecated, notice thrown by connection constructor if (isset($params['slaves'])) { foreach ($params['slaves'] as $key => $slaveParams) { $params['slaves'][$key] = self::parseDatabaseUrl($slaveParams); } } + // URL support for PrimaryReplicaConnection + if (isset($params['primary'])) { + $params['primary'] = self::parseDatabaseUrl($params['primary']); + } + + if (isset($params['replica'])) { + foreach ($params['replica'] as $key => $replicaParams) { + $params['replica'][$key] = self::parseDatabaseUrl($replicaParams); + } + } + // URL support for PoolingShardConnection if (isset($params['global'])) { $params['global'] = self::parseDatabaseUrl($params['global']); diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index 524e03031c4..c88190f99f0 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Connections\MasterSlaveConnection; +use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver; @@ -139,15 +139,15 @@ public function testValidDriverClass(): void self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver()); } - public function testDatabaseUrlMasterSlave(): void + public function testDatabaseUrlPrimaryReplica(): void { $options = [ 'driver' => 'pdo_mysql', - 'master' => ['url' => 'mysql://foo:bar@localhost:11211/baz'], - 'slaves' => [ - 'slave1' => ['url' => 'mysql://foo:bar@localhost:11211/baz_slave'], + 'primary' => ['url' => 'mysql://foo:bar@localhost:11211/baz'], + 'replica' => [ + 'replica1' => ['url' => 'mysql://foo:bar@localhost:11211/baz_replica'], ], - 'wrapperClass' => MasterSlaveConnection::class, + 'wrapperClass' => PrimaryReadReplicaConnection::class, ]; $conn = DriverManager::getConnection($options); @@ -163,12 +163,12 @@ public function testDatabaseUrlMasterSlave(): void ]; foreach ($expected as $key => $value) { - self::assertEquals($value, $params['master'][$key]); - self::assertEquals($value, $params['slaves']['slave1'][$key]); + self::assertEquals($value, $params['primary'][$key]); + self::assertEquals($value, $params['replica']['replica1'][$key]); } - self::assertEquals('baz', $params['master']['dbname']); - self::assertEquals('baz_slave', $params['slaves']['slave1']['dbname']); + self::assertEquals('baz', $params['primary']['dbname']); + self::assertEquals('baz_replica', $params['replica']['replica1']['dbname']); } public function testDatabaseUrlShard(): void diff --git a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php new file mode 100644 index 00000000000..f2c714940a6 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php @@ -0,0 +1,243 @@ +connection->getDatabasePlatform()->getName(); + + // This is a MySQL specific test, skip other vendors. + if ($platformName !== 'mysql') { + $this->markTestSkipped(sprintf('Test does not work on %s.', $platformName)); + } + + try { + $table = new Table('primary_replica_table'); + $table->addColumn('test_int', 'integer'); + $table->setPrimaryKey(['test_int']); + + $sm = $this->connection->getSchemaManager(); + $sm->createTable($table); + } catch (Throwable $e) { + } + + $this->connection->executeUpdate('DELETE FROM primary_replica_table'); + $this->connection->insert('primary_replica_table', ['test_int' => 1]); + } + + private function createPrimaryReadReplicaConnection(bool $keepReplica = false): PrimaryReadReplicaConnection + { + return DriverManager::getConnection($this->createPrimaryReadReplicaConnectionParams($keepReplica)); + } + + /** + * @return mixed[] + */ + private function createPrimaryReadReplicaConnectionParams(bool $keepReplica = false): array + { + $params = $this->connection->getParams(); + $params['primary'] = $params; + $params['replica'] = [$params, $params]; + $params['keepReplica'] = $keepReplica; + $params['wrapperClass'] = PrimaryReadReplicaConnection::class; + + return $params; + } + + public function testInheritCharsetFromPrimary(): void + { + $charsets = [ + 'utf8', + 'latin1', + ]; + + foreach ($charsets as $charset) { + $params = $this->createPrimaryReadReplicaConnectionParams(); + $params['primary']['charset'] = $charset; + + foreach ($params['replica'] as $index => $replicaParams) { + if (! isset($replicaParams['charset'])) { + continue; + } + + unset($params['replica'][$index]['charset']); + } + + $conn = DriverManager::getConnection($params); + self::assertInstanceOf(PrimaryReadReplicaConnection::class, $conn); + $conn->ensureConnectedToReplica(); + + self::assertFalse($conn->isConnectedToPrimary()); + + $clientCharset = $conn->fetchColumn('select @@character_set_client as c'); + + self::assertSame( + $charset, + substr(strtolower($clientCharset), 0, strlen($charset)) + ); + } + } + + public function testPrimaryOnConnect(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + + self::assertFalse($conn->isConnectedToPrimary()); + $conn->ensureConnectedToReplica(); + self::assertFalse($conn->isConnectedToPrimary()); + $conn->ensureConnectedToPrimary(); + self::assertTrue($conn->isConnectedToPrimary()); + } + + public function testNoPrimaryrOnExecuteQuery(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + + $sql = 'SELECT count(*) as num FROM primary_replica_table'; + $data = $conn->fetchAll($sql); + $data[0] = array_change_key_case($data[0], CASE_LOWER); + + self::assertEquals(1, $data[0]['num']); + self::assertFalse($conn->isConnectedToPrimary()); + } + + public function testPrimaryOnWriteOperation(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + $conn->insert('primary_replica_table', ['test_int' => 30]); + + self::assertTrue($conn->isConnectedToPrimary()); + + $sql = 'SELECT count(*) as num FROM primary_replica_table'; + $data = $conn->fetchAll($sql); + $data[0] = array_change_key_case($data[0], CASE_LOWER); + + self::assertEquals(2, $data[0]['num']); + self::assertTrue($conn->isConnectedToPrimary()); + } + + /** + * @group DBAL-335 + */ + public function testKeepReplicaBeginTransactionStaysOnPrimary(): void + { + $conn = $this->createPrimaryReadReplicaConnection($keepReplica = true); + $conn->ensureConnectedToReplica(); + + $conn->beginTransaction(); + $conn->insert('primary_replica_table', ['test_int' => 30]); + $conn->commit(); + + self::assertTrue($conn->isConnectedToPrimary()); + + $conn->connect(); + self::assertTrue($conn->isConnectedToPrimary()); + + $conn->ensureConnectedToReplica(); + self::assertFalse($conn->isConnectedToPrimary()); + } + + /** + * @group DBAL-335 + */ + public function testKeepReplicaInsertStaysOnPrimary(): void + { + $conn = $this->createPrimaryReadReplicaConnection($keepReplica = true); + $conn->ensureConnectedToReplica(); + + $conn->insert('primary_replica_table', ['test_int' => 30]); + + self::assertTrue($conn->isConnectedToPrimary()); + + $conn->connect(); + self::assertTrue($conn->isConnectedToPrimary()); + + $conn->ensureConnectedToReplica(); + self::assertFalse($conn->isConnectedToPrimary()); + } + + public function testPrimaryReadReplicaConnectionCloseAndReconnect(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + $conn->ensureConnectedToPrimary(); + self::assertTrue($conn->isConnectedToPrimary()); + + $conn->close(); + self::assertFalse($conn->isConnectedToPrimary()); + + $conn->ensureConnectedToPrimary(); + self::assertTrue($conn->isConnectedToPrimary()); + } + + public function testQueryOnPrimary(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + + $query = 'SELECT count(*) as num FROM primary_replica_table'; + + $statement = $conn->query($query); + + self::assertInstanceOf(Statement::class, $statement); + + //Query must be executed only on Primary + self::assertTrue($conn->isConnectedToPrimary()); + + $data = $statement->fetchAll(); + + //Default fetchmode is FetchMode::ASSOCIATIVE + self::assertArrayHasKey(0, $data); + self::assertArrayHasKey('num', $data[0]); + + //Could be set in other fetchmodes + self::assertArrayNotHasKey(0, $data[0]); + self::assertEquals(1, $data[0]['num']); + } + + public function testQueryOnReplica(): void + { + $conn = $this->createPrimaryReadReplicaConnection(); + $conn->ensureConnectedToReplica(); + + $query = 'SELECT count(*) as num FROM primary_replica_table'; + + $statement = $conn->query($query); + + self::assertInstanceOf(Statement::class, $statement); + + //Query must be executed only on Primary, even when we connect to the replica + self::assertTrue($conn->isConnectedToPrimary()); + + $data = $statement->fetchAll(); + + //Default fetchmode is FetchMode::ASSOCIATIVE + self::assertArrayHasKey(0, $data); + self::assertArrayHasKey('num', $data[0]); + + //Could be set in other fetchmodes + self::assertArrayNotHasKey(0, $data[0]); + + self::assertEquals(1, $data[0]['num']); + } +} From f198104cc0c947b7ca85a67e61c376ab77b3e8ba Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 9 Jun 2020 17:19:32 -0700 Subject: [PATCH 33/93] Deprecated platform-specific portability mode constants --- UPGRADE.md | 5 +++ lib/Doctrine/DBAL/Portability/Connection.php | 28 ++++-------- .../DBAL/Portability/OptimizeFlags.php | 44 +++++++++++++++++++ .../DBAL/Portability/OptimizeFlagsTest.php | 36 +++++++++++++++ 4 files changed, 94 insertions(+), 19 deletions(-) create mode 100644 lib/Doctrine/DBAL/Portability/OptimizeFlags.php create mode 100644 tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php diff --git a/UPGRADE.md b/UPGRADE.md index e69c41e563f..916603a0e46 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 2.11 +## Deprecated `Portability\Connection::PORTABILITY_{PLATFORM}` constants` + +The platform-specific portability mode flags are meant to be used only by the portability layer internally to optimize +the user-provided mode for the current database platform. + ## Deprecated `MasterSlaveConnection` use `PrimaryReadReplicaConnection` The `Doctrine\DBAL\Connections\MasterSlaveConnection` class is renamed to `Doctrine\DBAL\Connections\PrimaryReadReplicaConnection`. diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php index 266b8ad095b..ad79f98e889 100644 --- a/lib/Doctrine/DBAL/Portability/Connection.php +++ b/lib/Doctrine/DBAL/Portability/Connection.php @@ -23,6 +23,10 @@ class Connection extends \Doctrine\DBAL\Connection public const PORTABILITY_EMPTY_TO_NULL = 4; public const PORTABILITY_FIX_CASE = 8; + /**#@+ + * + * @deprecated Will be removed as internal implementation details. + */ public const PORTABILITY_DB2 = 13; public const PORTABILITY_ORACLE = 9; public const PORTABILITY_POSTGRESQL = 13; @@ -31,6 +35,7 @@ class Connection extends \Doctrine\DBAL\Connection public const PORTABILITY_DRIZZLE = 13; public const PORTABILITY_SQLANYWHERE = 13; public const PORTABILITY_SQLSRV = 13; + /**#@-*/ /** @var int */ private $portability = self::PORTABILITY_NONE; @@ -47,25 +52,10 @@ public function connect() if ($ret) { $params = $this->getParams(); if (isset($params['portability'])) { - if ($this->getDatabasePlatform()->getName() === 'oracle') { - $params['portability'] &= self::PORTABILITY_ORACLE; - } elseif ($this->getDatabasePlatform()->getName() === 'postgresql') { - $params['portability'] &= self::PORTABILITY_POSTGRESQL; - } elseif ($this->getDatabasePlatform()->getName() === 'sqlite') { - $params['portability'] &= self::PORTABILITY_SQLITE; - } elseif ($this->getDatabasePlatform()->getName() === 'drizzle') { - $params['portability'] &= self::PORTABILITY_DRIZZLE; - } elseif ($this->getDatabasePlatform()->getName() === 'sqlanywhere') { - $params['portability'] &= self::PORTABILITY_SQLANYWHERE; - } elseif ($this->getDatabasePlatform()->getName() === 'db2') { - $params['portability'] &= self::PORTABILITY_DB2; - } elseif ($this->getDatabasePlatform()->getName() === 'mssql') { - $params['portability'] &= self::PORTABILITY_SQLSRV; - } else { - $params['portability'] &= self::PORTABILITY_OTHERVENDORS; - } - - $this->portability = $params['portability']; + $this->portability = $params['portability'] = (new OptimizeFlags())( + $this->getDatabasePlatform(), + $params['portability'] + ); } if (isset($params['fetch_case']) && $this->portability & self::PORTABILITY_FIX_CASE) { diff --git a/lib/Doctrine/DBAL/Portability/OptimizeFlags.php b/lib/Doctrine/DBAL/Portability/OptimizeFlags.php new file mode 100644 index 00000000000..7d8e55df457 --- /dev/null +++ b/lib/Doctrine/DBAL/Portability/OptimizeFlags.php @@ -0,0 +1,44 @@ + + */ + private static $platforms = [ + DB2Platform::class => 0, + OraclePlatform::class => Connection::PORTABILITY_EMPTY_TO_NULL, + PostgreSQL94Platform::class => 0, + SQLAnywhere16Platform::class => 0, + SqlitePlatform::class => 0, + SQLServer2012Platform::class => 0, + ]; + + public function __invoke(AbstractPlatform $platform, int $flags): int + { + foreach (self::$platforms as $class => $mask) { + if ($platform instanceof $class) { + $flags &= ~$mask; + + break; + } + } + + return $flags; + } +} diff --git a/tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php b/tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php new file mode 100644 index 00000000000..3d776de6e7b --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Portability/OptimizeFlagsTest.php @@ -0,0 +1,36 @@ +optimizeFlags = new OptimizeFlags(); + } + + public function testOracle(): void + { + $flags = ($this->optimizeFlags)(new OraclePlatform(), Connection::PORTABILITY_ALL); + + self::assertSame(0, $flags & Connection::PORTABILITY_EMPTY_TO_NULL); + } + + public function testAnotherPlatform(): void + { + $flags = ($this->optimizeFlags)(new SqlitePlatform(), Connection::PORTABILITY_ALL); + + self::assertSame(Connection::PORTABILITY_ALL, $flags); + } +} From c79064000962f77dce657654482cc1cf778f2c40 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 11 Jun 2020 19:34:05 -0700 Subject: [PATCH 34/93] Deprecate Driver::getDatabase() --- UPGRADE.md | 5 +++++ lib/Doctrine/DBAL/Driver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php | 2 ++ 9 files changed, 21 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 916603a0e46..8dbab7d54a3 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 2.11 +## Deprecated `Doctrine\DBAL\Driver::getDatabase()` + +- The usage of `Doctrine\DBAL\Driver::getDatabase()` is deprecated. Please use `Doctrine\DBAL\Connection::getDatabase()` instead. +- The behavior of the SQLite connection returning the database file path as the database is deprecated and shouldn't be relied upon. + ## Deprecated `Portability\Connection::PORTABILITY_{PLATFORM}` constants` The platform-specific portability mode flags are meant to be used only by the portability layer internally to optimize diff --git a/lib/Doctrine/DBAL/Driver.php b/lib/Doctrine/DBAL/Driver.php index 57493e633bb..6f8afbf3cf4 100644 --- a/lib/Doctrine/DBAL/Driver.php +++ b/lib/Doctrine/DBAL/Driver.php @@ -53,6 +53,8 @@ public function getName(); /** * Gets the name of the database connected to for this driver. * + * @deprecated Use Connection::getDatabase() instead. + * * @return string The name of the database. */ public function getDatabase(Connection $conn); diff --git a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php index c6e0565343a..cede8da7eb0 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php @@ -14,6 +14,8 @@ abstract class AbstractDB2Driver implements Driver { /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 87a16577100..ded2af9ae83 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -197,6 +197,8 @@ private function getMariaDbMysqlVersionNumber(string $versionString): string /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index dcbaaf097f7..bd1802f324e 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -59,6 +59,8 @@ public function convertException($message, DriverException $exception) /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 2b16c5822e1..dfc90fea1ea 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -115,6 +115,8 @@ public function createDatabasePlatformForVersion($version) /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index ff53552d379..456758c10e6 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -117,6 +117,8 @@ public function createDatabasePlatformForVersion($version) /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index b624acd2454..78da3a0853c 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -58,6 +58,8 @@ public function createDatabasePlatformForVersion($version) /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index 1c0def3a0f3..d0ec0b687bb 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -79,6 +79,8 @@ public function convertException($message, DriverException $exception) /** * {@inheritdoc} + * + * @deprecated Use Connection::getDatabase() instead. */ public function getDatabase(Connection $conn) { From ae4d25cbb119a55dca6bc06dc3cc7c4f79349c35 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 13 Jun 2020 21:59:34 -0700 Subject: [PATCH 35/93] Bump PHP requirement to 7.3 --- .travis.yml | 37 ------------------------------------- composer.json | 4 ++-- composer.lock | 24 +++++------------------- 3 files changed, 7 insertions(+), 58 deletions(-) diff --git a/.travis.yml b/.travis.yml index 341e475d264..f53074ceea3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,43 +33,6 @@ jobs: php: 7.3 env: DB=sqlite - - stage: Test - php: 7.2 - env: DB=mysql.docker IMAGE=mysql:8.0 - - stage: Test - php: 7.2 - env: DB=mysqli.docker IMAGE=mysql:8.0 - - stage: Test - php: 7.2 - env: DB=mariadb.docker IMAGE=mariadb:10.3 - - stage: Test - php: 7.2 - env: DB=mariadb.mysqli.docker IMAGE=mariadb:10.3 - - stage: Test - php: 7.2 - env: DB=pgsql POSTGRESQL_VERSION=11.0 - sudo: required - before_script: - - bash ./tests/travis/install-postgres-11.sh - - stage: Test - php: 7.2 - env: DB=sqlite - - stage: Test - php: 7.2 - env: DB=sqlsrv - sudo: required - before_script: - - bash ./tests/travis/install-sqlsrv-dependencies.sh - - bash ./tests/travis/install-mssql-sqlsrv.sh - - bash ./tests/travis/install-mssql.sh - - stage: Test - php: 7.2 - env: DB=pdo_sqlsrv - sudo: required - before_script: - - bash ./tests/travis/install-sqlsrv-dependencies.sh - - bash ./tests/travis/install-mssql-pdo_sqlsrv.sh - - bash ./tests/travis/install-mssql.sh - stage: Test php: 7.3 env: DB=mysql.docker IMAGE=mysql:5.7 diff --git a/composer.json b/composer.json index 2d1bc1cc6b2..57c2aec4e03 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ {"name": "Jonathan Wage", "email": "jonwage@gmail.com"} ], "require": { - "php": "^7.2", + "php": "^7.3", "ext-pdo": "*", "doctrine/cache": "^1.0", "doctrine/event-manager": "^1.0" @@ -54,7 +54,7 @@ "config": { "sort-packages": true, "platform": { - "php": "7.2.0" + "php": "7.3.0" } }, "autoload": { diff --git a/composer.lock b/composer.lock index 3f82ebef974..36c878b3b82 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a5c06fdb9d602a1498b1eba6aa45f1d4", + "content-hash": "84bb64fae33632b7c7f562447fda9b7d", "packages": [ { "name": "doctrine/cache", @@ -1364,20 +1364,6 @@ "MIT" ], "description": "PHPStan - PHP Static Analysis Tool", - "funding": [ - { - "url": "https://github.com/ondrejmirtes", - "type": "github" - }, - { - "url": "https://www.patreon.com/phpstan", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" - } - ], "time": "2020-03-22T16:51:47+00:00" }, { @@ -3007,8 +2993,8 @@ "authors": [ { "name": "Arne Blankerts", - "role": "Developer", - "email": "arne@blankerts.de" + "email": "arne@blankerts.de", + "role": "Developer" } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", @@ -3259,12 +3245,12 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": "^7.2", + "php": "^7.3", "ext-pdo": "*" }, "platform-dev": [], "platform-overrides": { - "php": "7.2.0" + "php": "7.3.0" }, "plugin-api-version": "1.1.0" } From 4375bd3b5552c58b154f4a312907805834934982 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 13 Jun 2020 22:37:23 -0700 Subject: [PATCH 36/93] Forward compatibility with PHPUnit 9.3 --- .../DBAL/Driver/OCI8/OCI8StatementTest.php | 2 +- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 37 +++++-------------- .../Visitor/DropSchemaSqlCollectorTest.php | 14 +++---- .../DBAL/Tools/Console/RunSqlCommandTest.php | 22 +++++------ 4 files changed, 27 insertions(+), 48 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index 6ab31682f37..77cb231f9a3 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -105,7 +105,7 @@ public static function executeDataProvider(): iterable public function testConvertNonTerminatedLiteral(string $sql, string $message): void { $this->expectException(OCI8Exception::class); - $this->expectExceptionMessageRegExp($message); + $this->expectExceptionMessageMatches($message); OCI8Statement::convertPositionalToNamedPlaceholders($sql); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index cc665df5bd1..29a61744b96 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -378,27 +378,19 @@ public function testVisitsVisitor(): void ->method('acceptSchema') ->with($schema); - $visitor->expects($this->at(1)) + $visitor->expects(self::exactly(2)) ->method('acceptTable') - ->with($schema->getTable('baz')); + ->withConsecutive( + [$schema->getTable('baz')], + [$schema->getTable('bla.bloo')] + ); - $visitor->expects($this->at(2)) - ->method('acceptTable') - ->with($schema->getTable('bla.bloo')); - - $visitor->expects($this->exactly(2)) - ->method('acceptTable'); - - $visitor->expects($this->at(3)) + $visitor->expects(self::exactly(2)) ->method('acceptSequence') - ->with($schema->getSequence('moo')); - - $visitor->expects($this->at(4)) - ->method('acceptSequence') - ->with($schema->getSequence('war')); - - $visitor->expects($this->exactly(2)) - ->method('acceptSequence'); + ->withConsecutive( + [$schema->getSequence('moo')], + [$schema->getSequence('war')] + ); self::assertNull($schema->visit($visitor)); } @@ -436,9 +428,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptNamespace') ->with('bla'); - $visitor->expects($this->exactly(3)) - ->method('acceptNamespace'); - $visitor->expects($this->at(4)) ->method('acceptTable') ->with($schema->getTable('baz')); @@ -447,9 +436,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptTable') ->with($schema->getTable('bla.bloo')); - $visitor->expects($this->exactly(2)) - ->method('acceptTable'); - $visitor->expects($this->at(6)) ->method('acceptSequence') ->with($schema->getSequence('moo')); @@ -458,9 +444,6 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptSequence') ->with($schema->getSequence('war')); - $visitor->expects($this->exactly(2)) - ->method('acceptSequence'); - self::assertNull($schema->visit($visitor)); } } diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php index bd663dc93e6..1adde346002 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -28,16 +28,12 @@ public function testGetQueriesUsesAcceptedForeignKeys(): void $collector = new DropSchemaSqlCollector($platform); - $platform->expects($this->exactly(2)) - ->method('getDropForeignKeySQL'); - - $platform->expects($this->at(0)) - ->method('getDropForeignKeySQL') - ->with($keyConstraintOne, $tableOne); - - $platform->expects($this->at(1)) + $platform->expects(self::exactly(2)) ->method('getDropForeignKeySQL') - ->with($keyConstraintTwo, $tableTwo); + ->withConsecutive( + [$keyConstraintOne, $tableOne], + [$keyConstraintTwo, $tableTwo] + ); $collector->acceptForeignKey($tableOne, $keyConstraintOne); $collector->acceptForeignKey($tableTwo, $keyConstraintTwo); diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index ef524e8ceca..15c8728dd87 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -31,10 +31,6 @@ protected function setUp(): void $this->commandTester = new CommandTester($this->command); $this->connectionMock = $this->createMock(Connection::class); - $this->connectionMock->method('fetchAllAssociative') - ->willReturn([[1]]); - $this->connectionMock->method('executeUpdate') - ->willReturn(42); $helperSet = ConsoleRunner::createHelperSet($this->connectionMock); $this->command->setHelperSet($helperSet); @@ -97,21 +93,25 @@ public function testUpdateStatementsPrintsAffectedLines(): void private function expectConnectionExecuteUpdate(): void { $this->connectionMock - ->expects($this->exactly(1)) - ->method('executeUpdate'); + ->expects($this->once()) + ->method('executeUpdate') + ->willReturn(42); + $this->connectionMock - ->expects($this->exactly(0)) + ->expects($this->never()) ->method('fetchAllAssociative'); } private function expectConnectionFetchAllAssociative(): void { $this->connectionMock - ->expects($this->exactly(0)) - ->method('executeUpdate'); + ->expects($this->once()) + ->method('fetchAllAssociative') + ->willReturn([[1]]); + $this->connectionMock - ->expects($this->exactly(1)) - ->method('fetchAllAssociative'); + ->expects($this->never()) + ->method('executeUpdate'); } public function testStatementsWithFetchResultPrintsResult(): void From 24056154365ee60bf45fb5465828ba36ac9b3664 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 16 Jun 2020 13:53:54 -0700 Subject: [PATCH 37/93] Update PHPUnit to 9.2 --- composer.json | 2 +- composer.lock | 610 ++++++++++++------ .../Driver/IBMDB2/DB2StatementTest.php | 3 +- .../Tests/DBAL/Functional/PortabilityTest.php | 6 +- .../Schema/SQLAnywhereSchemaManagerTest.php | 5 +- .../Schema/SqliteSchemaManagerTest.php | 4 +- .../DBAL/Tools/Console/RunSqlCommandTest.php | 12 +- .../DBAL/Types/ConversionExceptionTest.php | 4 +- 8 files changed, 442 insertions(+), 204 deletions(-) diff --git a/composer.json b/composer.json index 57c2aec4e03..31c5a4b104d 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12", - "phpunit/phpunit": "^8.5.5", + "phpunit/phpunit": "^9.2", "psalm/plugin-phpunit": "^0.10.0", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "vimeo/psalm": "^3.11.4" diff --git a/composer.lock b/composer.lock index 36c878b3b82..7ad34394620 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "84bb64fae33632b7c7f562447fda9b7d", + "content-hash": "38de60ad471a30b78483684323846e79", "packages": [ { "name": "doctrine/cache", @@ -534,20 +534,20 @@ }, { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f350df0268e904597e3bd9c4685c53e0e333feea", + "reference": "f350df0268e904597e3bd9c4685c53e0e333feea", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { "doctrine/coding-standard": "^6.0", @@ -586,7 +586,21 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2020-05-29T17:27:14+00:00" }, { "name": "felixfbecker/advanced-json-rpc", @@ -1368,40 +1382,41 @@ }, { "name": "phpunit/php-code-coverage", - "version": "7.0.10", + "version": "8.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf" + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f1884187926fbb755a9aaf0b3836ad3165b478bf", - "reference": "f1884187926fbb755a9aaf0b3836ad3165b478bf", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca6647ffddd2add025ab3f21644a441d7c146cdc", + "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc", "shasum": "" }, "require": { "ext-dom": "*", "ext-xmlwriter": "*", - "php": "^7.2", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-token-stream": "^3.1.1", - "sebastian/code-unit-reverse-lookup": "^1.0.1", - "sebastian/environment": "^4.2.2", - "sebastian/version": "^2.0.1", + "php": "^7.3", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-token-stream": "^4.0", + "sebastian/code-unit-reverse-lookup": "^2.0", + "sebastian/environment": "^5.0", + "sebastian/version": "^3.0", "theseer/tokenizer": "^1.1.3" }, "require-dev": { - "phpunit/phpunit": "^8.2.2" + "phpunit/phpunit": "^9.0" }, "suggest": { - "ext-xdebug": "^2.7.2" + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "7.0-dev" + "dev-master": "8.0-dev" } }, "autoload": { @@ -1427,32 +1442,38 @@ "testing", "xunit" ], - "time": "2019-11-20T13:55:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-05-23T08:02:54+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "2.0.2", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "050bedf145a257b1ff02746c31894800e5122946" + "reference": "eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/050bedf145a257b1ff02746c31894800e5122946", - "reference": "050bedf145a257b1ff02746c31894800e5122946", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2", + "reference": "eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1477,26 +1498,99 @@ "filesystem", "iterator" ], - "time": "2018-09-13T20:33:42+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T12:54:35+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "62f696ad0d140e0e513e69eaafdebb674d622b4c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/62f696ad0d140e0e513e69eaafdebb674d622b4c", + "reference": "62f696ad0d140e0e513e69eaafdebb674d622b4c", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:10:07+00:00" }, { "name": "phpunit/php-text-template", - "version": "1.2.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "reference": "0c69cbf965d5317ba33f24a352539f354a25db09" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c69cbf965d5317ba33f24a352539f354a25db09", + "reference": "0c69cbf965d5317ba33f24a352539f354a25db09", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1518,32 +1612,38 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T12:52:43+00:00" }, { "name": "phpunit/php-timer", - "version": "2.1.2", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e" + "reference": "b0d089de001ba60ffa3be36b23e1b8150d072238" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/1038454804406b0b5f5f520358e78c1c2f71501e", - "reference": "1038454804406b0b5f5f520358e78c1c2f71501e", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/b0d089de001ba60ffa3be36b23e1b8150d072238", + "reference": "b0d089de001ba60ffa3be36b23e1b8150d072238", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1567,33 +1667,39 @@ "keywords": [ "timer" ], - "time": "2019-06-07T04:22:29+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-07T12:05:53+00:00" }, { "name": "phpunit/php-token-stream", - "version": "3.1.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff" + "reference": "e61c593e9734b47ef462340c24fca8d6a57da14e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/995192df77f63a59e47f025390d2d1fdf8f425ff", - "reference": "995192df77f63a59e47f025390d2d1fdf8f425ff", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e61c593e9734b47ef462340c24fca8d6a57da14e", + "reference": "e61c593e9734b47ef462340c24fca8d6a57da14e", "shasum": "" }, "require": { "ext-tokenizer": "*", - "php": "^7.1" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1616,20 +1722,26 @@ "keywords": [ "tokenizer" ], - "time": "2019-09-17T06:23:10+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-16T07:00:44+00:00" }, { "name": "phpunit/phpunit", - "version": "8.5.5", + "version": "9.2.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "63dda3b212a0025d380a745f91bdb4d8c985adb7" + "reference": "c1b1d62095ef78427f112a7a1c1502d4607e3c00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/63dda3b212a0025d380a745f91bdb4d8c985adb7", - "reference": "63dda3b212a0025d380a745f91bdb4d8c985adb7", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1b1d62095ef78427f112a7a1c1502d4607e3c00", + "reference": "c1b1d62095ef78427f112a7a1c1502d4607e3c00", "shasum": "" }, "require": { @@ -1643,29 +1755,31 @@ "myclabs/deep-copy": "^1.9.1", "phar-io/manifest": "^1.0.3", "phar-io/version": "^2.0.1", - "php": "^7.2", + "php": "^7.3", "phpspec/prophecy": "^1.8.1", - "phpunit/php-code-coverage": "^7.0.7", - "phpunit/php-file-iterator": "^2.0.2", - "phpunit/php-text-template": "^1.2.1", - "phpunit/php-timer": "^2.1.2", - "sebastian/comparator": "^3.0.2", - "sebastian/diff": "^3.0.2", - "sebastian/environment": "^4.2.2", - "sebastian/exporter": "^3.1.1", - "sebastian/global-state": "^3.0.0", - "sebastian/object-enumerator": "^3.0.3", - "sebastian/resource-operations": "^2.0.1", - "sebastian/type": "^1.1.3", - "sebastian/version": "^2.0.1" + "phpunit/php-code-coverage": "^8.0.1", + "phpunit/php-file-iterator": "^3.0", + "phpunit/php-invoker": "^3.0", + "phpunit/php-text-template": "^2.0", + "phpunit/php-timer": "^5.0", + "sebastian/code-unit": "^1.0.2", + "sebastian/comparator": "^4.0", + "sebastian/diff": "^4.0", + "sebastian/environment": "^5.0.1", + "sebastian/exporter": "^4.0", + "sebastian/global-state": "^4.0", + "sebastian/object-enumerator": "^4.0", + "sebastian/resource-operations": "^3.0", + "sebastian/type": "^2.1", + "sebastian/version": "^3.0" }, "require-dev": { - "ext-pdo": "*" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0" }, "suggest": { "ext-soap": "*", - "ext-xdebug": "*", - "phpunit/php-invoker": "^2.0.0" + "ext-xdebug": "*" }, "bin": [ "phpunit" @@ -1673,12 +1787,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "8.5-dev" + "dev-master": "9.2-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1709,7 +1826,7 @@ "type": "github" } ], - "time": "2020-05-22T13:51:52+00:00" + "time": "2020-06-15T10:51:34+00:00" }, { "name": "psalm/plugin-phpunit", @@ -1858,30 +1975,82 @@ ], "time": "2020-03-23T09:12:05+00:00" }, + { + "name": "sebastian/code-unit", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "d650ef9b1fece15ed4d6eaed6e6b469b7b81183a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/d650ef9b1fece15ed4d6eaed6e6b469b7b81183a", + "reference": "d650ef9b1fece15ed4d6eaed6e6b469b7b81183a", + "shasum": "" + }, + "require": { + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:11:26+00:00" + }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "1.0.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + "reference": "c771130f0e8669104a4320b7101a81c2cc2963ef" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", - "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c771130f0e8669104a4320b7101a81c2cc2963ef", + "reference": "c771130f0e8669104a4320b7101a81c2cc2963ef", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1901,34 +2070,40 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", - "time": "2017-03-04T06:30:41+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T12:56:39+00:00" }, { "name": "sebastian/comparator", - "version": "3.0.2", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da" + "reference": "266d85ef789da8c41f06af4093c43e9798af2784" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5de4fc177adf9bce8df98d8d141a7559d7ccf6da", - "reference": "5de4fc177adf9bce8df98d8d141a7559d7ccf6da", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/266d85ef789da8c41f06af4093c43e9798af2784", + "reference": "266d85ef789da8c41f06af4093c43e9798af2784", "shasum": "" }, "require": { - "php": "^7.1", - "sebastian/diff": "^3.0", - "sebastian/exporter": "^3.1" + "php": "^7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^7.1" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1941,6 +2116,10 @@ "BSD-3-Clause" ], "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, { "name": "Jeff Welch", "email": "whatthejeff@gmail.com" @@ -1952,10 +2131,6 @@ { "name": "Bernhard Schussek", "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" } ], "description": "Provides the functionality to compare PHP values for equality", @@ -1965,33 +2140,39 @@ "compare", "equality" ], - "time": "2018-07-12T15:12:46+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T15:04:48+00:00" }, { "name": "sebastian/diff", - "version": "3.0.2", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29" + "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29", - "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3e523c576f29dacecff309f35e4cc5a5c168e78a", + "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.0", - "symfony/process": "^2 || ^3.3 || ^4" + "phpunit/phpunit": "^9.0", + "symfony/process": "^4.2 || ^5" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2004,13 +2185,13 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" } ], "description": "Diff implementation", @@ -2021,27 +2202,33 @@ "unidiff", "unified diff" ], - "time": "2019-02-04T06:01:07+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-05-08T05:01:12+00:00" }, { "name": "sebastian/environment", - "version": "4.2.3", + "version": "5.1.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368" + "reference": "16eb0fa43e29c33d7f2117ed23072e26fc5ab34e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/464c90d7bdf5ad4e8a6aea15c091fec0603d4368", - "reference": "464c90d7bdf5ad4e8a6aea15c091fec0603d4368", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/16eb0fa43e29c33d7f2117ed23072e26fc5ab34e", + "reference": "16eb0fa43e29c33d7f2117ed23072e26fc5ab34e", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^7.5" + "phpunit/phpunit": "^9.0" }, "suggest": { "ext-posix": "*" @@ -2049,7 +2236,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2074,34 +2261,40 @@ "environment", "hhvm" ], - "time": "2019-11-20T08:46:58+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:00:01+00:00" }, { "name": "sebastian/exporter", - "version": "3.1.2", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e" + "reference": "d12fbca85da932d01d941b59e4b71a0d559db091" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/68609e1261d215ea5b21b7987539cbfbe156ec3e", - "reference": "68609e1261d215ea5b21b7987539cbfbe156ec3e", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d12fbca85da932d01d941b59e4b71a0d559db091", + "reference": "d12fbca85da932d01d941b59e4b71a0d559db091", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/recursion-context": "^3.0" + "php": "^7.3", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.1.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2141,30 +2334,36 @@ "export", "exporter" ], - "time": "2019-09-14T09:02:43+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:12:44+00:00" }, { "name": "sebastian/global-state", - "version": "3.0.0", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4" + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", - "reference": "edf8a461cf1d4005f19fb0b6b8b95a9f7fa0adc4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", "shasum": "" }, "require": { - "php": "^7.2", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^8.0" + "phpunit/phpunit": "^9.0" }, "suggest": { "ext-uopz": "*" @@ -2172,7 +2371,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2195,34 +2394,34 @@ "keywords": [ "global state" ], - "time": "2019-02-01T05:30:01+00:00" + "time": "2020-02-07T06:11:37+00:00" }, { "name": "sebastian/object-enumerator", - "version": "3.0.3", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + "reference": "15f319d67c49fc55ebcdbffb3377433125588455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", - "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/15f319d67c49fc55ebcdbffb3377433125588455", + "reference": "15f319d67c49fc55ebcdbffb3377433125588455", "shasum": "" }, "require": { - "php": "^7.0", - "sebastian/object-reflector": "^1.1.1", - "sebastian/recursion-context": "^3.0" + "php": "^7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2242,32 +2441,38 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2017-08-03T12:35:26+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:15:25+00:00" }, { "name": "sebastian/object-reflector", - "version": "1.1.1", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "773f97c67f28de00d397be301821b06708fca0be" + "reference": "14e04b3c25b821cc0702d4837803fe497680b062" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", - "reference": "773f97c67f28de00d397be301821b06708fca0be", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/14e04b3c25b821cc0702d4837803fe497680b062", + "reference": "14e04b3c25b821cc0702d4837803fe497680b062", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -2287,32 +2492,38 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", - "time": "2017-03-29T09:07:27+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:08:02+00:00" }, { "name": "sebastian/recursion-context", - "version": "3.0.0", + "version": "4.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + "reference": "a32789e5f0157c10cf216ce6c5136db12a12b847" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", - "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/a32789e5f0157c10cf216ce6c5136db12a12b847", + "reference": "a32789e5f0157c10cf216ce6c5136db12a12b847", "shasum": "" }, "require": { - "php": "^7.0" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -2325,14 +2536,14 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", "email": "sebastian@phpunit.de" }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "name": "Adam Harvey", "email": "aharvey@php.net" @@ -2340,29 +2551,38 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2017-03-03T06:23:57+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:06:44+00:00" }, { "name": "sebastian/resource-operations", - "version": "2.0.1", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9" + "reference": "71421c1745788de4facae1b79af923650bd3ec15" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/4d7a795d35b889bf80a0cc04e08d77cedfa917a9", - "reference": "4d7a795d35b889bf80a0cc04e08d77cedfa917a9", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/71421c1745788de4facae1b79af923650bd3ec15", + "reference": "71421c1745788de4facae1b79af923650bd3ec15", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2382,32 +2602,38 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", - "time": "2018-10-04T04:07:39+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-15T13:17:14+00:00" }, { "name": "sebastian/type", - "version": "1.1.3", + "version": "2.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3" + "reference": "bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/3aaaa15fa71d27650d62a948be022fe3b48541a3", - "reference": "3aaaa15fa71d27650d62a948be022fe3b48541a3", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8", + "reference": "bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8", "shasum": "" }, "require": { - "php": "^7.2" + "php": "^7.3" }, "require-dev": { - "phpunit/phpunit": "^8.2" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1-dev" + "dev-master": "2.1-dev" } }, "autoload": { @@ -2428,29 +2654,35 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", - "time": "2019-07-02T08:10:15+00:00" + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-01T12:21:09+00:00" }, { "name": "sebastian/version", - "version": "2.0.1", + "version": "3.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + "reference": "0411bde656dce64202b39c2f4473993a9081d39e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", - "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/0411bde656dce64202b39c2f4473993a9081d39e", + "reference": "0411bde656dce64202b39c2f4473993a9081d39e", "shasum": "" }, "require": { - "php": ">=5.6" + "php": "^7.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -2471,7 +2703,7 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2016-10-03T07:35:21+00:00" + "time": "2020-01-21T06:36:37+00:00" }, { "name": "slevomat/coding-standard", diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index 927b85356da..ab25cfbf252 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -6,7 +6,6 @@ use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\Tests\DbalFunctionalTestCase; -use PHPUnit\Framework\Error\Notice; use function extension_loaded; @@ -34,7 +33,7 @@ public function testExecutionErrorsAreNotSuppressed(): void // unwrap the statement to prevent the wrapper from handling the PHPUnit-originated exception $wrappedStmt = $stmt->getWrappedStatement(); - $this->expectException(Notice::class); + $this->expectNotice(); $wrappedStmt->execute([[]]); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php index 981120a8d24..ce17f913f53 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php @@ -129,7 +129,11 @@ private function assertFetchResultRows(array $rows): void */ public function assertFetchResultRow(array $row): void { - self::assertContains($row['test_int'], [1, 2], 'Primary key test_int should either be 1 or 2.'); + self::assertThat($row['test_int'], self::logicalOr( + self::equalTo(1), + self::equalTo(2) + )); + self::assertArrayHasKey('test_string', $row, 'Case should be lowered.'); self::assertEquals(3, strlen($row['test_string']), 'test_string should be rtrimed to length of three for CHAR(32) column.'); self::assertNull($row['test_null']); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php index 5a2bb2f42a4..dbce7bba895 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SQLAnywhereSchemaManagerTest.php @@ -24,7 +24,10 @@ public function testCreateAndListViews(): void self::assertCount(1, $views, 'Database has to have one view.'); self::assertInstanceOf(View::class, $views[$name]); self::assertEquals($name, $views[$name]->getName()); - self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql()); + self::assertMatchesRegularExpression( + '/^SELECT \* from "?DBA"?\."?view_test_table"?$/', + $views[$name]->getSql() + ); } public function testDropAndCreateAdvancedIndex(): void diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index dcfedbe4c61..8818d101706 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -35,7 +35,7 @@ public function testCreateAndDropDatabase(): void $this->schemaManager->createDatabase($path); self::assertFileExists($path); $this->schemaManager->dropDatabase($path); - self::assertFileNotExists($path); + self::assertFileDoesNotExist($path); } /** @@ -59,7 +59,7 @@ public function testDropsDatabaseWithActiveConnections(): void $this->schemaManager->dropDatabase('test_drop_database'); - self::assertFileNotExists('test_drop_database'); + self::assertFileDoesNotExist('test_drop_database'); unset($connection); } diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index 15c8728dd87..3c9013a0ca7 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -73,8 +73,8 @@ public function testSelectStatementsPrintsResult(): void ]); $this->assertSame(0, $exitCode); - self::assertRegExp('@int.*1.*@', $this->commandTester->getDisplay()); - self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay()); + self::assertMatchesRegularExpression('@int.*1.*@', $this->commandTester->getDisplay()); + self::assertMatchesRegularExpression('@array.*1.*@', $this->commandTester->getDisplay()); } public function testUpdateStatementsPrintsAffectedLines(): void @@ -86,8 +86,8 @@ public function testUpdateStatementsPrintsAffectedLines(): void 'sql' => 'UPDATE foo SET bar = 42', ]); - self::assertRegExp('@int.*42.*@', $this->commandTester->getDisplay()); - self::assertNotRegExp('@array.*1.*@', $this->commandTester->getDisplay()); + self::assertMatchesRegularExpression('@int.*42.*@', $this->commandTester->getDisplay()); + self::assertDoesNotMatchRegularExpression('@array.*1.*@', $this->commandTester->getDisplay()); } private function expectConnectionExecuteUpdate(): void @@ -124,7 +124,7 @@ public function testStatementsWithFetchResultPrintsResult(): void '--force-fetch' => true, ]); - self::assertRegExp('@int.*1.*@', $this->commandTester->getDisplay()); - self::assertRegExp('@array.*1.*@', $this->commandTester->getDisplay()); + self::assertMatchesRegularExpression('@int.*1.*@', $this->commandTester->getDisplay()); + self::assertMatchesRegularExpression('@array.*1.*@', $this->commandTester->getDisplay()); } } diff --git a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php index f2997ec5a92..226987b8561 100644 --- a/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/ConversionExceptionTest.php @@ -31,7 +31,7 @@ public function testConversionFailedInvalidTypeWithScalar($scalarValue): void $exception = ConversionException::conversionFailedInvalidType($scalarValue, 'foo', ['bar', 'baz']); self::assertInstanceOf(ConversionException::class, $exception); - self::assertRegExp( + self::assertMatchesRegularExpression( '/^Could not convert PHP value \'.*\' of type \'(string|boolean|float|double|integer)\' to type \'foo\'. ' . 'Expected one of the following types: bar, baz$/', $exception->getMessage() @@ -48,7 +48,7 @@ public function testConversionFailedInvalidTypeWithNonScalar($nonScalar): void $exception = ConversionException::conversionFailedInvalidType($nonScalar, 'foo', ['bar', 'baz']); self::assertInstanceOf(ConversionException::class, $exception); - self::assertRegExp( + self::assertMatchesRegularExpression( '/^Could not convert PHP value of type \'(.*)\' to type \'foo\'. ' . 'Expected one of the following types: bar, baz$/', $exception->getMessage() From e676583f26fdb96e58ff207c81920adf8dfdc7ff Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 12 Jun 2020 14:54:18 -0700 Subject: [PATCH 38/93] The IBM DB2 driver Exception class must implement the DriverException interface --- .../DBAL/Driver/IBMDB2/DB2Connection.php | 18 ++-- .../DBAL/Driver/IBMDB2/DB2Exception.php | 4 +- .../DBAL/Driver/IBMDB2/DB2Statement.php | 5 +- .../IBMDB2/Exception/ConnectionError.php | 24 +++++ .../IBMDB2/Exception/ConnectionFailed.php | 21 ++++ .../Driver/IBMDB2/Exception/PrepareFailed.php | 18 ++++ .../IBMDB2/Exception/StatementError.php | 24 +++++ phpcs.xml.dist | 5 + .../Tests/DBAL/Functional/DataAccessTest.php | 98 ++++++++----------- .../Driver/IBMDB2/ConnectionTest.php | 55 +++++++++++ .../Driver/IBMDB2/DB2StatementTest.php | 17 +++- 11 files changed, 217 insertions(+), 72 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionFailed.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/PrepareFailed.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/StatementError.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 60dbe59f58d..d74f9db795c 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -3,6 +3,9 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionError; +use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed; +use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use stdClass; @@ -21,7 +24,7 @@ use function db2_prepare; use function db2_rollback; use function db2_server_info; -use function db2_stmt_errormsg; +use function error_get_last; use function func_get_args; use function is_bool; @@ -52,7 +55,7 @@ public function __construct(array $params, $username, $password, $driverOptions } if ($conn === false) { - throw new DB2Exception(db2_conn_errormsg()); + throw ConnectionFailed::new(); } $this->conn = $conn; @@ -83,8 +86,9 @@ public function requiresQueryForServerVersion() public function prepare($sql) { $stmt = @db2_prepare($this->conn, $sql); - if (! $stmt) { - throw new DB2Exception(db2_stmt_errormsg()); + + if ($stmt === false) { + throw PrepareFailed::new(error_get_last()['message']); } return new DB2Statement($stmt); @@ -125,7 +129,7 @@ public function exec($statement) $stmt = @db2_exec($this->conn, $statement); if ($stmt === false) { - throw new DB2Exception(db2_stmt_errormsg()); + throw ConnectionError::new($this->conn); } return db2_num_rows($stmt); @@ -156,7 +160,7 @@ public function beginTransaction() public function commit() { if (! db2_commit($this->conn)) { - throw new DB2Exception(db2_conn_errormsg($this->conn)); + throw ConnectionError::new($this->conn); } $result = db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON); @@ -171,7 +175,7 @@ public function commit() public function rollBack() { if (! db2_rollback($this->conn)) { - throw new DB2Exception(db2_conn_errormsg($this->conn)); + throw ConnectionError::new($this->conn); } $result = db2_autocommit($this->conn, DB2_AUTOCOMMIT_ON); diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php index 662d8533a8e..f66d0e533f9 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php @@ -2,11 +2,11 @@ namespace Doctrine\DBAL\Driver\IBMDB2; -use Exception; +use Doctrine\DBAL\Driver\AbstractDriverException; /** * @psalm-immutable */ -class DB2Exception extends Exception +class DB2Exception extends AbstractDriverException { } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 7c97017099d..5113a60da35 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\StatementIterator; @@ -141,7 +142,7 @@ private function bind($position, &$variable, int $parameterType, int $dataType): $this->bindParam[$position] =& $variable; if (! db2_bind_param($this->stmt, $position, 'variable', $parameterType, $dataType)) { - throw new DB2Exception(db2_stmt_errormsg()); + throw StatementError::new($this->stmt); } } @@ -228,7 +229,7 @@ public function execute($params = null) $this->lobs = []; if ($retval === false) { - throw new DB2Exception(db2_stmt_errormsg()); + throw StatementError::new($this->stmt); } $this->result = true; diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php new file mode 100644 index 00000000000..7293f87eb6f --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/ConnectionError.php @@ -0,0 +1,24 @@ +lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php + + + tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php + + lib/Doctrine/DBAL/Schema/Comparator.php diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 1fe74ad4075..b3330b7c093 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -5,6 +5,7 @@ use DateTime; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDOConnection; @@ -245,8 +246,9 @@ public function testFetchAllWithTypes(): void /** * @group DBAL-209 + * @dataProvider fetchProvider */ - public function testFetchAllWithMissingTypes(): void + public function testFetchAllWithMissingTypes(callable $fetch): void { if ( $this->connection->getDriver() instanceof MySQLiDriver || @@ -255,13 +257,51 @@ public function testFetchAllWithMissingTypes(): void $this->markTestSkipped('mysqli and sqlsrv actually supports this'); } + if ( + $this->connection->getDriver() instanceof DB2Driver + ) { + $this->markTestSkipped( + 'ibm_ibm2 may or may not report the error depending on the PHP version and the connection state' + ); + } + $datetimeString = '2010-01-01 10:10:10'; $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; $this->expectException(DBALException::class); - $this->connection->fetchAll($sql, [1, $datetime]); + $fetch($this->connection, $sql, [1, $datetime]); + } + + /** + * @return iterable + */ + public static function fetchProvider(): iterable + { + yield 'fetch-all-associative' => [ + static function (Connection $connection, string $query, array $params): void { + $connection->fetchAll($query, $params); + }, + ]; + + yield 'fetch-numeric' => [ + static function (Connection $connection, string $query, array $params): void { + $connection->fetchArray($query, $params); + }, + ]; + + yield 'fetch-associative' => [ + static function (Connection $connection, string $query, array $params): void { + $connection->fetchAssoc($query, $params); + }, + ]; + + yield 'fetch-one' => [ + static function (Connection $connection, string $query, array $params): void { + $connection->fetchColumn($query, $params); + }, + ]; } public function testFetchBoth(): void @@ -319,24 +359,6 @@ public function testFetchAssocWithTypes(): void self::assertStringStartsWith($datetimeString, $row['test_datetime']); } - public function testFetchAssocWithMissingTypes(): void - { - if ( - $this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver - ) { - $this->markTestSkipped('mysqli and sqlsrv actually supports this'); - } - - $datetimeString = '2010-01-01 10:10:10'; - $datetime = new DateTime($datetimeString); - $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - - $this->expectException(DBALException::class); - - $this->connection->fetchAssoc($sql, [1, $datetime]); - } - public function testFetchArray(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; @@ -366,24 +388,6 @@ public function testFetchArrayWithTypes(): void self::assertStringStartsWith($datetimeString, $row[1]); } - public function testFetchArrayWithMissingTypes(): void - { - if ( - $this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver - ) { - $this->markTestSkipped('mysqli and sqlsrv actually supports this'); - } - - $datetimeString = '2010-01-01 10:10:10'; - $datetime = new DateTime($datetimeString); - $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - - $this->expectException(DBALException::class); - - $this->connection->fetchArray($sql, [1, $datetime]); - } - public function testFetchColumn(): void { $sql = 'SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?'; @@ -415,24 +419,6 @@ public function testFetchColumnWithTypes(): void self::assertStringStartsWith($datetimeString, $column); } - public function testFetchColumnWithMissingTypes(): void - { - if ( - $this->connection->getDriver() instanceof MySQLiDriver || - $this->connection->getDriver() instanceof SQLSrvDriver - ) { - $this->markTestSkipped('mysqli and sqlsrv actually supports this'); - } - - $datetimeString = '2010-01-01 10:10:10'; - $datetime = new DateTime($datetimeString); - $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - - $this->expectException(DBALException::class); - - $this->connection->fetchColumn($sql, [1, $datetime], 1); - } - /** * @group DDC-697 */ diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php new file mode 100644 index 00000000000..1ffc5a7b9bb --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php @@ -0,0 +1,55 @@ +markTestSkipped('ibm_db2 is not installed.'); + } + + parent::setUp(); + + if ($this->connection->getDriver() instanceof DB2Driver) { + return; + } + + $this->markTestSkipped('ibm_db2 only test.'); + } + + protected function tearDown(): void + { + $this->resetSharedConn(); + } + + public function testConnectionFailure(): void + { + $this->expectException(ConnectionFailed::class); + new DB2Connection(['dbname' => 'garbage'], '', ''); + } + + public function testPrepareFailure(): void + { + $driverConnection = $this->connection->getWrappedConnection(); + + $re = new ReflectionProperty($driverConnection, 'conn'); + $re->setAccessible(true); + $conn = $re->getValue($driverConnection); + db2_close($conn); + + $this->expectException(PrepareFailed::class); + $driverConnection->prepare('SELECT 1'); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php index ab25cfbf252..2d504933060 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php @@ -5,10 +5,15 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2; use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\Tests\DbalFunctionalTestCase; use function extension_loaded; +use const E_ALL; +use const E_NOTICE; +use const E_WARNING; + class DB2StatementTest extends DbalFunctionalTestCase { protected function setUp(): void @@ -28,12 +33,14 @@ protected function setUp(): void public function testExecutionErrorsAreNotSuppressed(): void { - $stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?'); + $driverConnection = $this->connection->getWrappedConnection(); + + $stmt = $driverConnection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?'); - // unwrap the statement to prevent the wrapper from handling the PHPUnit-originated exception - $wrappedStmt = $stmt->getWrappedStatement(); + // prevent the PHPUnit error handler from handling the errors that db2_execute() may trigger + $this->iniSet('error_reporting', (string) (E_ALL & ~E_WARNING & ~E_NOTICE)); - $this->expectNotice(); - $wrappedStmt->execute([[]]); + $this->expectException(StatementError::class); + $stmt->execute([[]]); } } From d57340dc8993fbdca4266a3b9b09cd3d909c9c59 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 10 Jun 2019 07:16:15 -0700 Subject: [PATCH 39/93] Mark Connection::getParams() internal --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Connection.php | 4 +++- lib/Doctrine/DBAL/Id/TableGenerator.php | 11 ++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 8dbab7d54a3..3e2192c8d31 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `Connection::getParams()` has been marked internal + +Consumers of the Connection class should not rely on connection parameters stored in the connection object. If needed, they should be obtained from a different source, e.g. application configuration. + ## Deprecated `Doctrine\DBAL\Driver::getDatabase()` - The usage of `Doctrine\DBAL\Driver::getDatabase()` is deprecated. Please use `Doctrine\DBAL\Connection::getDatabase()` instead. diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 0a0c8c40d99..55ee3412eda 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -225,6 +225,8 @@ public function __construct( /** * Gets the parameters used during instantiation. * + * @internal + * * @return mixed[] */ public function getParams() @@ -1199,7 +1201,7 @@ public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qc throw CacheException::noResultDriverConfigured(); } - $connectionParams = $this->getParams(); + $connectionParams = $this->params; unset($connectionParams['platform']); [$cacheKey, $realKey] = $qcp->generateCacheKeys($query, $params, $types, $connectionParams); diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 35cda11431b..6b5a62353a4 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -4,6 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Driver; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\LockMode; use Throwable; @@ -69,12 +70,16 @@ class TableGenerator */ public function __construct(Connection $conn, $generatorTableName = 'sequences') { - $params = $conn->getParams(); - if ($params['driver'] === 'pdo_sqlite') { + if ($conn->getDriver() instanceof Driver\PDOSqlite\Driver) { throw new DBALException('Cannot use TableGenerator with SQLite.'); } - $this->conn = DriverManager::getConnection($params, $conn->getConfiguration(), $conn->getEventManager()); + $this->conn = DriverManager::getConnection( + $conn->getParams(), + $conn->getConfiguration(), + $conn->getEventManager() + ); + $this->generatorTableName = $generatorTableName; } From 2cedd229f3a2473cd5ae2b6d0ed4ddbe98e3cb24 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 18 Jun 2020 22:17:21 -0700 Subject: [PATCH 40/93] Remove Connection::$isConnected --- lib/Doctrine/DBAL/Connection.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 55ee3412eda..f487ce0cfbd 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -98,13 +98,6 @@ class Connection implements DriverConnection /** @var ExpressionBuilder */ protected $_expr; - /** - * Whether or not a connection has been established. - * - * @var bool - */ - private $isConnected = false; - /** * The current auto-commit mode of this connection. * @@ -192,8 +185,7 @@ public function __construct( $this->params = $params; if (isset($params['pdo'])) { - $this->_conn = $params['pdo']; - $this->isConnected = true; + $this->_conn = $params['pdo']; unset($this->params['pdo']); } @@ -356,7 +348,7 @@ public function getExpressionBuilder() */ public function connect() { - if ($this->isConnected) { + if ($this->_conn !== null) { return false; } @@ -364,8 +356,7 @@ public function connect() $user = $this->params['user'] ?? null; $password = $this->params['password'] ?? null; - $this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); - $this->isConnected = true; + $this->_conn = $this->_driver->connect($this->params, $user, $password, $driverOptions); $this->transactionNestingLevel = 0; @@ -524,7 +515,7 @@ public function setAutoCommit($autoCommit) $this->autoCommit = $autoCommit; // Commit all currently active transactions if any when switching auto-commit mode. - if ($this->isConnected !== true || $this->transactionNestingLevel === 0) { + if ($this->_conn === null || $this->transactionNestingLevel === 0) { return; } @@ -689,7 +680,7 @@ public function fetchOne(string $query, array $params = [], array $types = []) */ public function isConnected() { - return $this->isConnected; + return $this->_conn !== null; } /** @@ -771,8 +762,6 @@ public function delete($tableExpression, array $identifier, array $types = []) public function close() { $this->_conn = null; - - $this->isConnected = false; } /** From 10ebb4c1b4fd664470a4105cea5be8c832f1f7ed Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 20 Jun 2020 10:32:08 -0700 Subject: [PATCH 41/93] Return the non-null $data instead of the nullable $this->data --- lib/Doctrine/DBAL/Cache/ResultCacheStatement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index d990b15fefd..a3697529e75 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -260,7 +260,7 @@ public function fetchAllAssociative(): array $this->store($data); - return $this->data; + return $data; } /** From 932df0811d44fc8ad53ee638096fcb892847d390 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 20 Jun 2020 10:33:29 -0700 Subject: [PATCH 42/93] The test forward-incompatible statement must be a wrapper statement, not just implement the driver-level interface --- .../Connection/BackwardCompatibility/Statement.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php index 16e28595b84..fc935fc9569 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php @@ -6,7 +6,7 @@ use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\ParameterType; -use IteratorAggregate; +use Doctrine\DBAL\Statement as BaseStatement; use PDO; use function assert; @@ -14,10 +14,10 @@ /** * A wrapper that does not implement the forward-compatible statement interface. */ -class Statement implements IteratorAggregate, DriverStatement +class Statement extends BaseStatement { /** @var DriverStatement|ResultStatement */ - private $stmt; + protected $stmt; /** * @param DriverStatement|ResultStatement $stmt From a7374a24d7d51500e2567499f53509666ee36247 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 22 Jun 2020 22:12:47 -0700 Subject: [PATCH 43/93] Deprecate inconsistently and ambiguously named driver-level classes --- UPGRADE.md | 32 ++++++++++ .../DBAL/Cache/ResultCacheStatement.php | 4 +- lib/Doctrine/DBAL/DBALException.php | 4 +- .../DBAL/Driver/AbstractDriverException.php | 48 +-------------- .../DBAL/Driver/AbstractException.php | 60 +++++++++++++++++++ .../DBAL/Driver/AbstractMySQLDriver.php | 42 ++++++++----- .../DBAL/Driver/AbstractOracleDriver.php | 36 +++++++---- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 41 ++++++++----- .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 42 ++++++++----- .../{ => Exception}/PortWithoutHost.php | 6 +- .../DBAL/Driver/AbstractSQLiteDriver.php | 40 ++++++++----- lib/Doctrine/DBAL/Driver/DriverException.php | 27 +-------- lib/Doctrine/DBAL/Driver/Exception.php | 32 ++++++++++ .../DBAL/Driver/ExceptionConverterDriver.php | 13 ++-- lib/Doctrine/DBAL/Driver/FetchUtils.php | 8 +-- .../DBAL/Driver/IBMDB2/Connection.php | 9 +++ .../DBAL/Driver/IBMDB2/DB2Connection.php | 9 ++- lib/Doctrine/DBAL/Driver/IBMDB2/DB2Driver.php | 4 +- .../DBAL/Driver/IBMDB2/DB2Exception.php | 2 + .../DBAL/Driver/IBMDB2/DB2Statement.php | 7 ++- lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php | 9 +++ .../IBMDB2/Exception/ConnectionError.php | 6 +- .../IBMDB2/Exception/ConnectionFailed.php | 6 +- .../Driver/IBMDB2/Exception/PrepareFailed.php | 6 +- .../IBMDB2/Exception/StatementError.php | 6 +- lib/Doctrine/DBAL/Driver/IBMDB2/Statement.php | 9 +++ .../DBAL/Driver/Mysqli/Connection.php | 9 +++ lib/Doctrine/DBAL/Driver/Mysqli/Driver.php | 2 +- .../DBAL/Driver/Mysqli/MysqliConnection.php | 9 ++- .../DBAL/Driver/Mysqli/MysqliException.php | 2 +- .../DBAL/Driver/Mysqli/MysqliStatement.php | 7 ++- lib/Doctrine/DBAL/Driver/Mysqli/Statement.php | 9 +++ lib/Doctrine/DBAL/Driver/OCI8/Connection.php | 9 +++ lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 2 +- .../DBAL/Driver/OCI8/OCI8Connection.php | 8 ++- .../DBAL/Driver/OCI8/OCI8Exception.php | 2 + .../DBAL/Driver/OCI8/OCI8Statement.php | 6 +- lib/Doctrine/DBAL/Driver/OCI8/Statement.php | 9 +++ lib/Doctrine/DBAL/Driver/PDO/Connection.php | 11 ++++ lib/Doctrine/DBAL/Driver/PDO/Exception.php | 20 +++++++ lib/Doctrine/DBAL/Driver/PDO/Statement.php | 11 ++++ lib/Doctrine/DBAL/Driver/PDOConnection.php | 39 +++++++----- lib/Doctrine/DBAL/Driver/PDOException.php | 2 +- lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 4 +- .../DBAL/Driver/PDOSqlsrv/Connection.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 2 +- .../DBAL/Driver/PDOSqlsrv/Statement.php | 4 +- lib/Doctrine/DBAL/Driver/PDOStatement.php | 37 +++++++----- lib/Doctrine/DBAL/Driver/Result.php | 12 ++-- .../SQLAnywhere/SQLAnywhereStatement.php | 10 ++-- .../DBAL/Driver/SQLSrv/Connection.php | 9 +++ lib/Doctrine/DBAL/Driver/SQLSrv/Driver.php | 4 +- .../DBAL/Driver/SQLSrv/Exception/Error.php | 47 +++++++++++++++ .../DBAL/Driver/SQLSrv/SQLSrvConnection.php | 23 +++---- .../DBAL/Driver/SQLSrv/SQLSrvException.php | 32 ++-------- .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 11 ++-- lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php | 9 +++ lib/Doctrine/DBAL/DriverManager.php | 4 +- .../DBAL/Exception/DriverException.php | 9 +-- lib/Doctrine/DBAL/Portability/Connection.php | 5 +- .../DBAL/Schema/OracleSchemaManager.php | 4 +- .../DBAL/Schema/SQLServerSchemaManager.php | 4 +- lib/Doctrine/DBAL/Statement.php | 20 +++---- .../Tools/Console/Command/ImportCommand.php | 4 +- phpcs.xml.dist | 2 +- .../Driver/AbstractSQLServerDriverTest.php | 2 +- .../DBAL/Driver/IBMDB2/DB2DriverTest.php | 4 +- .../ExceptionTest.php} | 15 ++--- .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 4 +- .../Tests/DBAL/Functional/DataAccessTest.php | 6 +- .../Driver/IBMDB2/ConnectionTest.php | 11 ++-- .../{DB2DriverTest.php => DriverTest.php} | 12 ++-- ...DB2StatementTest.php => StatementTest.php} | 6 +- .../Driver/Mysqli/ConnectionTest.php | 8 +-- ...8ConnectionTest.php => ConnectionTest.php} | 6 +- .../ConnectionTest.php} | 22 +++---- .../ConnectionTest.php} | 4 +- .../Driver/PDOSqlsrv/DriverTest.php | 4 +- .../DBAL/Functional/PDOStatementTest.php | 4 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 6 +- .../DBAL/Functional/Types/BinaryTest.php | 4 +- .../Tests/DBAL/Functional/WriteTest.php | 6 +- tests/Doctrine/Tests/DBAL/UtilTest.php | 4 +- 87 files changed, 692 insertions(+), 377 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/AbstractException.php rename lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/{ => Exception}/PortWithoutHost.php (55%) create mode 100644 lib/Doctrine/DBAL/Driver/Exception.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/OCI8/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/OCI8/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/Exception.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/SQLSrv/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/SQLSrv/Exception/Error.php create mode 100644 lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php rename tests/Doctrine/Tests/DBAL/Driver/{PDOExceptionTest.php => PDO/ExceptionTest.php} (79%) rename tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/{DB2DriverTest.php => DriverTest.php} (74%) rename tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/{DB2StatementTest.php => StatementTest.php} (86%) rename tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/{OCI8ConnectionTest.php => ConnectionTest.php} (91%) rename tests/Doctrine/Tests/DBAL/Functional/Driver/{PDOConnectionTest.php => PDO/ConnectionTest.php} (83%) rename tests/Doctrine/Tests/DBAL/Functional/Driver/{PDOPgsqlConnectionTest.php => PDOPgSql/ConnectionTest.php} (92%) diff --git a/UPGRADE.md b/UPGRADE.md index 3e2192c8d31..0fedf7f1218 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,37 @@ # Upgrade to 2.11 +## Inconsistently and ambiguously named driver-level classes are deprecated + +The following classes under the `Driver` namespace have been deprecated in favor of their consistently named counterparts: + +- `DriverException` → `Exception` +- `AbstractDriverException` → `AbstractException` +- `IBMDB2\DB2Driver` → `IBMDB2\Driver` +- `IBMDB2\DB2Connection` → `IBMDB2\Connection` +- `IBMDB2\DB2Statement` → `IBMDB2\Statement` +- `Mysqli\MysqliConnection` → `Mysqli\Connection` +- `Mysqli\MysqliStatement` → `Mysqli\Statement` +- `OCI8\OCI8Connection` → `OCI8\Connection` +- `OCI8\OCI8Statement` → `OCI8\Statement` +- `SQLSrv\SQLSrvConnection` → `SQLSrv\Connection` +- `SQLSrv\SQLSrvStatement` → `SQLSrv\Statement` +- `PDOConnection` → `PDO\Connection` +- `PDOStatement` → `PDO\Statement` + +All driver-specific exception classes have been deprecated: + +- `IBMDB2\DB2Exception` +- `Mysqli\MysqliException` +- `OCI8\OCI8Exception` +- `PDOException` +- `SQLSrv\SQLSrvException` + +A driver-level exception should be only identified as a subtype of `Driver\Exception`. +Internal driver-level exception implementations may use `Driver\AbstractException` as the base class. +Driver-specific exception handling has to be implemented either in the driver or based on the type of the `Driver` implementation. + +The `Driver\AbstractException` class has been marked internal. + ## `Connection::getParams()` has been marked internal Consumers of the Connection class should not rely on connection parameters stored in the connection object. If needed, they should be obtained from a different source, e.g. application configuration. diff --git a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php index a3697529e75..34381e23b1c 100644 --- a/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php +++ b/lib/Doctrine/DBAL/Cache/ResultCacheStatement.php @@ -4,7 +4,7 @@ use ArrayIterator; use Doctrine\Common\Cache\Cache; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\ResultStatement; @@ -297,7 +297,7 @@ public function free(): void /** * @return array|false * - * @throws DriverException + * @throws Exception */ private function doFetch() { diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index dda63310675..9a85c110bb8 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL; -use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Driver\ExceptionConverterDriver; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -168,7 +168,7 @@ private static function wrapException(Driver $driver, Throwable $driverEx, strin return $driverEx; } - if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DriverExceptionInterface) { + if ($driver instanceof ExceptionConverterDriver && $driverEx instanceof DeprecatedDriverException) { return $driver->convertException($msg, $driverEx); } diff --git a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php index f57de38f09c..bf104545e41 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDriverException.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDriverException.php @@ -2,55 +2,11 @@ namespace Doctrine\DBAL\Driver; -use Exception; - /** - * Abstract base implementation of the {@link DriverException} interface. + * @deprecated * * @psalm-immutable */ -abstract class AbstractDriverException extends Exception implements DriverException +class AbstractDriverException extends AbstractException { - /** - * The driver specific error code. - * - * @var int|string|null - */ - private $errorCode; - - /** - * The SQLSTATE of the driver. - * - * @var string|null - */ - private $sqlState; - - /** - * @param string $message The driver error message. - * @param string|null $sqlState The SQLSTATE the driver is in at the time the error occurred, if any. - * @param int|string|null $errorCode The driver specific error code if any. - */ - public function __construct($message, $sqlState = null, $errorCode = null) - { - parent::__construct($message); - - $this->errorCode = $errorCode; - $this->sqlState = $sqlState; - } - - /** - * {@inheritdoc} - */ - public function getErrorCode() - { - return $this->errorCode; - } - - /** - * {@inheritdoc} - */ - public function getSQLState() - { - return $this->sqlState; - } } diff --git a/lib/Doctrine/DBAL/Driver/AbstractException.php b/lib/Doctrine/DBAL/Driver/AbstractException.php new file mode 100644 index 00000000000..65a9708ad65 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/AbstractException.php @@ -0,0 +1,60 @@ +errorCode = $errorCode; + $this->sqlState = $sqlState; + } + + /** + * {@inheritdoc} + */ + public function getErrorCode() + { + return $this->errorCode; + } + + /** + * {@inheritdoc} + */ + public function getSQLState() + { + return $this->sqlState; + } +} diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 276322e28cd..565d055353d 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -5,7 +5,19 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\DeadlockException; +use Doctrine\DBAL\Exception\DriverException; +use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; +use Doctrine\DBAL\Exception\InvalidFieldNameException; +use Doctrine\DBAL\Exception\LockWaitTimeoutException; +use Doctrine\DBAL\Exception\NonUniqueFieldNameException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\SyntaxErrorException; +use Doctrine\DBAL\Exception\TableExistsException; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Platforms\MariaDb1027Platform; use Doctrine\DBAL\Platforms\MySQL57Platform; use Doctrine\DBAL\Platforms\MySQL80Platform; @@ -19,7 +31,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for MySQL based drivers. + * Abstract base implementation of the {@link Driver} interface for MySQL based drivers. */ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { @@ -29,44 +41,44 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, * @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html * @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html */ - public function convertException($message, DriverException $exception) + public function convertException($message, DeprecatedDriverException $exception) { switch ($exception->getErrorCode()) { case '1213': - return new Exception\DeadlockException($message, $exception); + return new DeadlockException($message, $exception); case '1205': - return new Exception\LockWaitTimeoutException($message, $exception); + return new LockWaitTimeoutException($message, $exception); case '1050': - return new Exception\TableExistsException($message, $exception); + return new TableExistsException($message, $exception); case '1051': case '1146': - return new Exception\TableNotFoundException($message, $exception); + return new TableNotFoundException($message, $exception); case '1216': case '1217': case '1451': case '1452': case '1701': - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); case '1062': case '1557': case '1569': case '1586': - return new Exception\UniqueConstraintViolationException($message, $exception); + return new UniqueConstraintViolationException($message, $exception); case '1054': case '1166': case '1611': - return new Exception\InvalidFieldNameException($message, $exception); + return new InvalidFieldNameException($message, $exception); case '1052': case '1060': case '1110': - return new Exception\NonUniqueFieldNameException($message, $exception); + return new NonUniqueFieldNameException($message, $exception); case '1064': case '1149': @@ -80,7 +92,7 @@ public function convertException($message, DriverException $exception) case '1541': case '1554': case '1626': - return new Exception\SyntaxErrorException($message, $exception); + return new SyntaxErrorException($message, $exception); case '1044': case '1045': @@ -94,7 +106,7 @@ public function convertException($message, DriverException $exception) case '1429': case '2002': case '2005': - return new Exception\ConnectionException($message, $exception); + return new ConnectionException($message, $exception); case '1048': case '1121': @@ -104,10 +116,10 @@ public function convertException($message, DriverException $exception) case '1263': case '1364': case '1566': - return new Exception\NotNullConstraintViolationException($message, $exception); + return new NotNullConstraintViolationException($message, $exception); } - return new Exception\DriverException($message, $exception); + return new DriverException($message, $exception); } /** diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index bd1802f324e..b3b58e58db6 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -5,56 +5,66 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\DriverException; +use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; +use Doctrine\DBAL\Exception\InvalidFieldNameException; +use Doctrine\DBAL\Exception\NonUniqueFieldNameException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\SyntaxErrorException; +use Doctrine\DBAL\Exception\TableExistsException; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Schema\OracleSchemaManager; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for Oracle based drivers. + * Abstract base implementation of the {@link Driver} interface for Oracle based drivers. */ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver { /** * {@inheritdoc} */ - public function convertException($message, DriverException $exception) + public function convertException($message, DeprecatedDriverException $exception) { switch ($exception->getErrorCode()) { case '1': case '2299': case '38911': - return new Exception\UniqueConstraintViolationException($message, $exception); + return new UniqueConstraintViolationException($message, $exception); case '904': - return new Exception\InvalidFieldNameException($message, $exception); + return new InvalidFieldNameException($message, $exception); case '918': case '960': - return new Exception\NonUniqueFieldNameException($message, $exception); + return new NonUniqueFieldNameException($message, $exception); case '923': - return new Exception\SyntaxErrorException($message, $exception); + return new SyntaxErrorException($message, $exception); case '942': - return new Exception\TableNotFoundException($message, $exception); + return new TableNotFoundException($message, $exception); case '955': - return new Exception\TableExistsException($message, $exception); + return new TableExistsException($message, $exception); case '1017': case '12545': - return new Exception\ConnectionException($message, $exception); + return new ConnectionException($message, $exception); case '1400': - return new Exception\NotNullConstraintViolationException($message, $exception); + return new NotNullConstraintViolationException($message, $exception); case '2266': case '2291': case '2292': - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); } - return new Exception\DriverException($message, $exception); + return new DriverException($message, $exception); } /** diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 5aabb977f17..bf0ac0d2a5f 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -5,7 +5,18 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\DeadlockException; +use Doctrine\DBAL\Exception\DriverException; +use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; +use Doctrine\DBAL\Exception\InvalidFieldNameException; +use Doctrine\DBAL\Exception\NonUniqueFieldNameException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\SyntaxErrorException; +use Doctrine\DBAL\Exception\TableExistsException; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Platforms\PostgreSQL100Platform; use Doctrine\DBAL\Platforms\PostgreSQL91Platform; use Doctrine\DBAL\Platforms\PostgreSQL92Platform; @@ -20,7 +31,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for PostgreSQL based drivers. + * Abstract base implementation of the {@link Driver} interface for PostgreSQL based drivers. */ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { @@ -29,58 +40,58 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri * * @link http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html */ - public function convertException($message, DriverException $exception) + public function convertException($message, DeprecatedDriverException $exception) { switch ($exception->getSQLState()) { case '40001': case '40P01': - return new Exception\DeadlockException($message, $exception); + return new DeadlockException($message, $exception); case '0A000': // Foreign key constraint violations during a TRUNCATE operation // are considered "feature not supported" in PostgreSQL. if (strpos($exception->getMessage(), 'truncate') !== false) { - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); } break; case '23502': - return new Exception\NotNullConstraintViolationException($message, $exception); + return new NotNullConstraintViolationException($message, $exception); case '23503': - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); case '23505': - return new Exception\UniqueConstraintViolationException($message, $exception); + return new UniqueConstraintViolationException($message, $exception); case '42601': - return new Exception\SyntaxErrorException($message, $exception); + return new SyntaxErrorException($message, $exception); case '42702': - return new Exception\NonUniqueFieldNameException($message, $exception); + return new NonUniqueFieldNameException($message, $exception); case '42703': - return new Exception\InvalidFieldNameException($message, $exception); + return new InvalidFieldNameException($message, $exception); case '42P01': - return new Exception\TableNotFoundException($message, $exception); + return new TableNotFoundException($message, $exception); case '42P07': - return new Exception\TableExistsException($message, $exception); + return new TableExistsException($message, $exception); case '7': // In some case (mainly connection errors) the PDO exception does not provide a SQLSTATE via its code. // The exception code is always set to 7 here. // We have to match against the SQLSTATE in the error message in these cases. if (strpos($exception->getMessage(), 'SQLSTATE[08006]') !== false) { - return new Exception\ConnectionException($message, $exception); + return new ConnectionException($message, $exception); } break; } - return new Exception\DriverException($message, $exception); + return new DriverException($message, $exception); } /** diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 12296ab9603..52ecd4bcef2 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -5,7 +5,19 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\DeadlockException; +use Doctrine\DBAL\Exception\DriverException; +use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; +use Doctrine\DBAL\Exception\InvalidFieldNameException; +use Doctrine\DBAL\Exception\LockWaitTimeoutException; +use Doctrine\DBAL\Exception\NonUniqueFieldNameException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\SyntaxErrorException; +use Doctrine\DBAL\Exception\TableExistsException; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Platforms\SQLAnywhere11Platform; use Doctrine\DBAL\Platforms\SQLAnywhere12Platform; use Doctrine\DBAL\Platforms\SQLAnywhere16Platform; @@ -18,7 +30,7 @@ use function version_compare; /** - * Abstract base implementation of the {@link Doctrine\DBAL\Driver} interface for SAP Sybase SQL Anywhere based drivers. + * Abstract base implementation of the {@link Driver} interface for SAP Sybase SQL Anywhere based drivers. */ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDriver, VersionAwarePlatformDriver { @@ -27,54 +39,54 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr * * @link http://dcx.sybase.com/index.html#sa160/en/saerrors/sqlerror.html */ - public function convertException($message, DriverException $exception) + public function convertException($message, DeprecatedDriverException $exception) { switch ($exception->getErrorCode()) { case '-306': case '-307': case '-684': - return new Exception\DeadlockException($message, $exception); + return new DeadlockException($message, $exception); case '-210': case '-1175': case '-1281': - return new Exception\LockWaitTimeoutException($message, $exception); + return new LockWaitTimeoutException($message, $exception); case '-100': case '-103': case '-832': - return new Exception\ConnectionException($message, $exception); + return new ConnectionException($message, $exception); case '-143': - return new Exception\InvalidFieldNameException($message, $exception); + return new InvalidFieldNameException($message, $exception); case '-193': case '-196': - return new Exception\UniqueConstraintViolationException($message, $exception); + return new UniqueConstraintViolationException($message, $exception); case '-194': case '-198': - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); case '-144': - return new Exception\NonUniqueFieldNameException($message, $exception); + return new NonUniqueFieldNameException($message, $exception); case '-184': case '-195': - return new Exception\NotNullConstraintViolationException($message, $exception); + return new NotNullConstraintViolationException($message, $exception); case '-131': - return new Exception\SyntaxErrorException($message, $exception); + return new SyntaxErrorException($message, $exception); case '-110': - return new Exception\TableExistsException($message, $exception); + return new TableExistsException($message, $exception); case '-141': case '-1041': - return new Exception\TableNotFoundException($message, $exception); + return new TableNotFoundException($message, $exception); } - return new Exception\DriverException($message, $exception); + return new DriverException($message, $exception); } /** diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php similarity index 55% rename from lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php rename to lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php index e968421fe7a..ea8dcc461e5 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/PortWithoutHost.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Doctrine\DBAL\Driver\AbstractSQLServerDriver; +namespace Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception; -use Doctrine\DBAL\Driver\AbstractDriverException; +use Doctrine\DBAL\Driver\AbstractException; /** * @internal * * @psalm-immutable */ -final class PortWithoutHost extends AbstractDriverException +final class PortWithoutHost extends AbstractException { public static function new(): self { diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index d0ec0b687bb..f0cf8433e3d 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -4,7 +4,19 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Exception; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\DriverException; +use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; +use Doctrine\DBAL\Exception\InvalidFieldNameException; +use Doctrine\DBAL\Exception\LockWaitTimeoutException; +use Doctrine\DBAL\Exception\NonUniqueFieldNameException; +use Doctrine\DBAL\Exception\NotNullConstraintViolationException; +use Doctrine\DBAL\Exception\ReadOnlyException; +use Doctrine\DBAL\Exception\SyntaxErrorException; +use Doctrine\DBAL\Exception\TableExistsException; +use Doctrine\DBAL\Exception\TableNotFoundException; +use Doctrine\DBAL\Exception\UniqueConstraintViolationException; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\SqliteSchemaManager; @@ -20,10 +32,10 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver * * @link http://www.sqlite.org/c3ref/c_abort.html */ - public function convertException($message, DriverException $exception) + public function convertException($message, DeprecatedDriverException $exception) { if (strpos($exception->getMessage(), 'database is locked') !== false) { - return new Exception\LockWaitTimeoutException($message, $exception); + return new LockWaitTimeoutException($message, $exception); } if ( @@ -32,49 +44,49 @@ public function convertException($message, DriverException $exception) strpos($exception->getMessage(), 'are not unique') !== false || strpos($exception->getMessage(), 'UNIQUE constraint failed') !== false ) { - return new Exception\UniqueConstraintViolationException($message, $exception); + return new UniqueConstraintViolationException($message, $exception); } if ( strpos($exception->getMessage(), 'may not be NULL') !== false || strpos($exception->getMessage(), 'NOT NULL constraint failed') !== false ) { - return new Exception\NotNullConstraintViolationException($message, $exception); + return new NotNullConstraintViolationException($message, $exception); } if (strpos($exception->getMessage(), 'no such table:') !== false) { - return new Exception\TableNotFoundException($message, $exception); + return new TableNotFoundException($message, $exception); } if (strpos($exception->getMessage(), 'already exists') !== false) { - return new Exception\TableExistsException($message, $exception); + return new TableExistsException($message, $exception); } if (strpos($exception->getMessage(), 'has no column named') !== false) { - return new Exception\InvalidFieldNameException($message, $exception); + return new InvalidFieldNameException($message, $exception); } if (strpos($exception->getMessage(), 'ambiguous column name') !== false) { - return new Exception\NonUniqueFieldNameException($message, $exception); + return new NonUniqueFieldNameException($message, $exception); } if (strpos($exception->getMessage(), 'syntax error') !== false) { - return new Exception\SyntaxErrorException($message, $exception); + return new SyntaxErrorException($message, $exception); } if (strpos($exception->getMessage(), 'attempt to write a readonly database') !== false) { - return new Exception\ReadOnlyException($message, $exception); + return new ReadOnlyException($message, $exception); } if (strpos($exception->getMessage(), 'unable to open database file') !== false) { - return new Exception\ConnectionException($message, $exception); + return new ConnectionException($message, $exception); } if (strpos($exception->getMessage(), 'FOREIGN KEY constraint failed') !== false) { - return new Exception\ForeignKeyConstraintViolationException($message, $exception); + return new ForeignKeyConstraintViolationException($message, $exception); } - return new Exception\DriverException($message, $exception); + return new DriverException($message, $exception); } /** diff --git a/lib/Doctrine/DBAL/Driver/DriverException.php b/lib/Doctrine/DBAL/Driver/DriverException.php index a7f4008e1b7..2e83e82bee1 100644 --- a/lib/Doctrine/DBAL/Driver/DriverException.php +++ b/lib/Doctrine/DBAL/Driver/DriverException.php @@ -2,34 +2,11 @@ namespace Doctrine\DBAL\Driver; -use Throwable; - /** - * Contract for a driver exception. - * - * Driver exceptions provide the SQLSTATE of the driver - * and the driver specific error code at the time the error occurred. + * @deprecated Use {@link Exception} instead * * @psalm-immutable */ -interface DriverException extends Throwable +interface DriverException extends Exception { - /** - * Returns the driver specific error code if available. - * - * Returns null if no driver specific error code is available - * for the error raised by the driver. - * - * @return int|string|null - */ - public function getErrorCode(); - - /** - * Returns the SQLSTATE the driver was in at the time the error occurred. - * - * Returns null if the driver does not provide a SQLSTATE for the error occurred. - * - * @return string|null - */ - public function getSQLState(); } diff --git a/lib/Doctrine/DBAL/Driver/Exception.php b/lib/Doctrine/DBAL/Driver/Exception.php new file mode 100644 index 00000000000..f65591f90ca --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Exception.php @@ -0,0 +1,32 @@ +> * - * @throws DriverException + * @throws Exception */ public static function fetchAllNumeric(Result $result): array { @@ -44,7 +44,7 @@ public static function fetchAllNumeric(Result $result): array /** * @return array> * - * @throws DriverException + * @throws Exception */ public static function fetchAllAssociative(Result $result): array { @@ -60,7 +60,7 @@ public static function fetchAllAssociative(Result $result): array /** * @return array * - * @throws DriverException + * @throws Exception */ public static function fetchFirstColumn(Result $result): array { diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php new file mode 100644 index 00000000000..66d77c10406 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php @@ -0,0 +1,9 @@ +toString(); - return new DB2Connection( + return new Connection( $params, (string) $username, (string) $password, diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php index f66d0e533f9..aa9ee29c056 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Exception.php @@ -5,6 +5,8 @@ use Doctrine\DBAL\Driver\AbstractDriverException; /** + * @deprecated Use {@link Exception} instead + * * @psalm-immutable */ class DB2Exception extends AbstractDriverException diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 4f74c2a1f7f..d65e04c91e0 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -5,7 +5,7 @@ use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -53,7 +53,10 @@ use const DB2_PARAM_FILE; use const DB2_PARAM_IN; -class DB2Statement implements IteratorAggregate, Statement, Result +/** + * @deprecated Use {@link Statement} instead + */ +class DB2Statement implements IteratorAggregate, StatementInterface, Result { /** @var resource */ private $stmt; diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php new file mode 100644 index 00000000000..dcc84b32d05 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Driver.php @@ -0,0 +1,9 @@ +conn, $prepareString); + return new Statement($this->conn, $prepareString); } /** diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php index 8e8e697c4a3..6fbff4291d1 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliException.php @@ -5,7 +5,7 @@ use Doctrine\DBAL\Driver\AbstractDriverException; /** - * Exception thrown in case the mysqli driver errors. + * @deprecated Use {@link Exception} instead * * @psalm-immutable */ diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index c3f893fc127..2e267ce6d6c 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\FetchMode; @@ -27,7 +27,10 @@ use function sprintf; use function str_repeat; -class MysqliStatement implements IteratorAggregate, Statement, Result +/** + * @deprecated Use {@link Statement} instead + */ +class MysqliStatement implements IteratorAggregate, StatementInterface, Result { /** @var string[] */ protected static $_paramTypeMap = [ diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Statement.php b/lib/Doctrine/DBAL/Driver/Mysqli/Statement.php new file mode 100644 index 00000000000..308dd14dbff --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Statement.php @@ -0,0 +1,9 @@ +_constructDsn($params), diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index abf26957f40..c147d168c60 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Driver\OCI8; -use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\Driver\Connection as ConnectionInterface; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\ParameterType; use UnexpectedValueException; @@ -26,8 +26,10 @@ /** * OCI8 implementation of the Connection interface. + * + * @deprecated Use {@link Connection} instead */ -class OCI8Connection implements Connection, ServerInfoAwareConnection +class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection { /** @var resource */ protected $dbh; @@ -106,7 +108,7 @@ public function requiresQueryForServerVersion() */ public function prepare($prepareString) { - return new OCI8Statement($this->dbh, $prepareString, $this); + return new Statement($this->dbh, $prepareString, $this); } /** diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php index 83b078097a4..ab1449f3b56 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Exception.php @@ -5,6 +5,8 @@ use Doctrine\DBAL\Driver\AbstractDriverException; /** + * @deprecated Use {@link Exception} instead + * * @psalm-immutable */ class OCI8Exception extends AbstractDriverException diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 4f04a46a5cf..bf8272bccb4 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -50,8 +50,10 @@ /** * The OCI8 implementation of the Statement interface. + * + * @deprecated Use {@link Statement} instead */ -class OCI8Statement implements IteratorAggregate, Statement, Result +class OCI8Statement implements IteratorAggregate, StatementInterface, Result { /** @var resource */ protected $_dbh; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/Statement.php new file mode 100644 index 00000000000..706b402e3df --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/OCI8/Statement.php @@ -0,0 +1,9 @@ +setAttribute(PDO::ATTR_STATEMENT_CLASS, [PDOStatement::class, []]); + $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -43,8 +50,8 @@ public function exec($statement) assert($result !== false); return $result; - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -60,24 +67,24 @@ public function getServerVersion() * @param string $prepareString * @param array $driverOptions * - * @return \PDOStatement + * @return PDOStatement */ public function prepare($prepareString, $driverOptions = []) { try { $statement = parent::prepare($prepareString, $driverOptions); - assert($statement instanceof \PDOStatement); + assert($statement instanceof PDOStatement); return $statement; - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } /** * {@inheritdoc} * - * @return \PDOStatement + * @return PDOStatement */ public function query() { @@ -85,11 +92,11 @@ public function query() try { $stmt = parent::query(...$args); - assert($stmt instanceof \PDOStatement); + assert($stmt instanceof PDOStatement); return $stmt; - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -112,8 +119,8 @@ public function lastInsertId($name = null) } return parent::lastInsertId($name); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php index c2571032b80..e82bcbcfc6b 100644 --- a/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/lib/Doctrine/DBAL/Driver/PDOException.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Driver; /** - * Tiny wrapper for PDOException instances to implement the {@link DriverException} interface. + * @deprecated Use {@link Exception} instead * * @psalm-immutable */ diff --git a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php index 20332adbd16..0543d8786e7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOIbm/Driver.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOIbm; use Doctrine\DBAL\Driver\AbstractDB2Driver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; /** * Driver for the PDO IBM extension. @@ -17,7 +17,7 @@ class Driver extends AbstractDB2Driver */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { - return new PDOConnection( + return new Connection( $this->_constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index 3058febd05a..e6df0bbad21 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractMySQLDriver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use PDOException; /** @@ -18,7 +18,7 @@ class Driver extends AbstractMySQLDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - $conn = new PDOConnection( + $conn = new Connection( $this->constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index f1239eafbd4..88aa01a5434 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use PDOException; /** @@ -23,7 +23,7 @@ class Driver extends AbstractOracleDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - return new PDOConnection( + return new Connection( $this->constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index 43f06cb7b7f..e3f15ab610f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use PDO; use PDOException; @@ -21,7 +21,7 @@ class Driver extends AbstractPostgreSQLDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - $pdo = new PDOConnection( + $pdo = new Connection( $this->_constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index 4566f649578..304043b9cdd 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLiteDriver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; @@ -36,7 +36,7 @@ public function connect(array $params, $username = null, $password = null, array } try { - $pdo = new PDOConnection( + $pdo = new Connection( $this->_constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 5847669456c..a05f5898b22 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection as BaseStatement; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; use PDO; @@ -14,7 +14,7 @@ /** * Sqlsrv Connection implementation. */ -class Connection extends PDOConnection +class Connection extends BaseStatement { /** * {@inheritdoc} diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index 880f1263da0..bd0fd6a665c 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver\AbstractSQLServerDriver; -use Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost; +use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; use function is_int; use function sprintf; diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 8d6521ff56c..7091eb375a3 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -2,14 +2,14 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDOStatement; +use Doctrine\DBAL\Driver\PDO\Statement as BaseStatement; use Doctrine\DBAL\ParameterType; use PDO; /** * PDO SQL Server Statement */ -class Statement extends PDOStatement +class Statement extends BaseStatement { /** * {@inheritdoc} diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 911f5d49665..97b0407b556 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -2,9 +2,12 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\PDO\Exception; +use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use PDO; +use PDOException; use function array_slice; use function assert; @@ -18,8 +21,10 @@ /** * The PDO implementation of the Statement interface. * Used by all PDO-based drivers. + * + * @deprecated Use {@link Statement} instead */ -class PDOStatement extends \PDOStatement implements Statement, Result +class PDOStatement extends \PDOStatement implements StatementInterface, Result { private const PARAM_TYPE_MAP = [ ParameterType::NULL => PDO::PARAM_NULL, @@ -69,8 +74,8 @@ public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) } return parent::setFetchMode($fetchMode, $arg2, $arg3); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -83,8 +88,8 @@ public function bindValue($param, $value, $type = ParameterType::STRING) try { return parent::bindValue($param, $value, $type); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -103,8 +108,8 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l try { return parent::bindParam($column, $variable, $type, ...array_slice(func_get_args(), 3)); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -117,7 +122,7 @@ public function closeCursor() { try { return parent::closeCursor(); - } catch (\PDOException $exception) { + } catch (PDOException $exception) { // Exceptions not allowed by the interface. // In case driver implementations do not adhere to the interface, silence exceptions here. return true; @@ -131,8 +136,8 @@ public function execute($params = null) { try { return parent::execute($params); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -151,8 +156,8 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX try { return parent::fetch(...$args); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -184,8 +189,8 @@ public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = n assert(is_array($data)); return $data; - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } @@ -198,8 +203,8 @@ public function fetchColumn($columnIndex = 0) { try { return parent::fetchColumn($columnIndex); - } catch (\PDOException $exception) { - throw new PDOException($exception); + } catch (PDOException $exception) { + throw Exception::new($exception); } } diff --git a/lib/Doctrine/DBAL/Driver/Result.php b/lib/Doctrine/DBAL/Driver/Result.php index 65be0f03c49..a52f0563e4b 100644 --- a/lib/Doctrine/DBAL/Driver/Result.php +++ b/lib/Doctrine/DBAL/Driver/Result.php @@ -14,7 +14,7 @@ interface Result * * @return array|false * - * @throws DriverException + * @throws Exception */ public function fetchNumeric(); @@ -23,7 +23,7 @@ public function fetchNumeric(); * * @return array|false * - * @throws DriverException + * @throws Exception */ public function fetchAssociative(); @@ -32,7 +32,7 @@ public function fetchAssociative(); * * @return mixed|false * - * @throws DriverException + * @throws Exception */ public function fetchOne(); @@ -41,7 +41,7 @@ public function fetchOne(); * * @return array> * - * @throws DriverException + * @throws Exception */ public function fetchAllNumeric(): array; @@ -50,7 +50,7 @@ public function fetchAllNumeric(): array; * * @return array> * - * @throws DriverException + * @throws Exception */ public function fetchAllAssociative(): array; @@ -59,7 +59,7 @@ public function fetchAllAssociative(): array; * * @return array * - * @throws DriverException + * @throws Exception */ public function fetchFirstColumn(): array; diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index c9c3a6f2ef7..25e28e9a0e8 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement; @@ -350,7 +350,7 @@ public function fetchAssociative() /** * {@inheritdoc} * - * @throws DriverException + * @throws Exception */ public function fetchOne() { @@ -360,7 +360,7 @@ public function fetchOne() /** * @return array> * - * @throws DriverException + * @throws Exception */ public function fetchAllNumeric(): array { @@ -370,7 +370,7 @@ public function fetchAllNumeric(): array /** * @return array> * - * @throws DriverException + * @throws Exception */ public function fetchAllAssociative(): array { @@ -380,7 +380,7 @@ public function fetchAllAssociative(): array /** * @return array * - * @throws DriverException + * @throws Exception */ public function fetchFirstColumn(): array { diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Connection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Connection.php new file mode 100644 index 00000000000..646842c37d0 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Connection.php @@ -0,0 +1,9 @@ +conn = $conn; @@ -80,7 +83,7 @@ public function requiresQueryForServerVersion() */ public function prepare($sql) { - return new SQLSrvStatement($this->conn, $sql, $this->lastInsertId); + return new Statement($this->conn, $sql, $this->lastInsertId); } /** @@ -120,13 +123,13 @@ public function exec($statement) $stmt = sqlsrv_query($this->conn, $statement); if ($stmt === false) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } $rowsAffected = sqlsrv_rows_affected($stmt); if ($rowsAffected === false) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } return $rowsAffected; @@ -157,7 +160,7 @@ public function lastInsertId($name = null) public function beginTransaction() { if (! sqlsrv_begin_transaction($this->conn)) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } return true; @@ -169,7 +172,7 @@ public function beginTransaction() public function commit() { if (! sqlsrv_commit($this->conn)) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } return true; @@ -181,7 +184,7 @@ public function commit() public function rollBack() { if (! sqlsrv_rollback($this->conn)) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } return true; diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php index af70c6852ff..03300800e83 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvException.php @@ -3,13 +3,11 @@ namespace Doctrine\DBAL\Driver\SQLSrv; use Doctrine\DBAL\Driver\AbstractDriverException; - -use function rtrim; -use function sqlsrv_errors; - -use const SQLSRV_ERR_ERRORS; +use Doctrine\DBAL\Driver\SQLSrv\Exception\Error; /** + * @deprecated Use {@link Exception} instead + * * @psalm-immutable */ class SQLSrvException extends AbstractDriverException @@ -21,28 +19,6 @@ class SQLSrvException extends AbstractDriverException */ public static function fromSqlSrvErrors() { - $message = ''; - $sqlState = null; - $errorCode = null; - - foreach ((array) sqlsrv_errors(SQLSRV_ERR_ERRORS) as $error) { - $message .= 'SQLSTATE [' . $error['SQLSTATE'] . ', ' . $error['code'] . ']: ' . $error['message'] . "\n"; - - if ($sqlState === null) { - $sqlState = $error['SQLSTATE']; - } - - if ($errorCode !== null) { - continue; - } - - $errorCode = $error['code']; - } - - if (! $message) { - $message = 'SQL Server error occurred but no error message was retrieved from driver.'; - } - - return new self(rtrim($message), $sqlState, $errorCode); + return Error::new(); } } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 886faf55bcc..0a0dd78df27 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -4,7 +4,8 @@ use Doctrine\DBAL\Driver\FetchUtils; use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Driver\SQLSrv\Exception\Error; +use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -41,8 +42,10 @@ /** * SQL Server Statement. + * + * @deprecated Use {@link Statement} instead */ -class SQLSrvStatement implements IteratorAggregate, Statement, Result +class SQLSrvStatement implements IteratorAggregate, StatementInterface, Result { /** * The SQLSRV Resource. @@ -255,7 +258,7 @@ public function execute($params = null) } if (! sqlsrv_execute($this->stmt)) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } if ($this->lastInsertId) { @@ -308,7 +311,7 @@ private function prepare() $stmt = sqlsrv_prepare($this->conn, $this->sql, $params); if (! $stmt) { - throw SQLSrvException::fromSqlSrvErrors(); + throw Error::new(); } return $stmt; diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php new file mode 100644 index 00000000000..e0958f687d8 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php @@ -0,0 +1,9 @@ + PDOPgSQLDriver::class, 'pdo_oci' => PDOOCIDriver::class, 'oci8' => OCI8Driver::class, - 'ibm_db2' => DB2Driver::class, + 'ibm_db2' => IBMDB2Driver::class, 'pdo_sqlsrv' => PDOSQLSrvDriver::class, 'mysqli' => MySQLiDriver::class, 'drizzle_pdo_mysql' => DrizzlePDOMySQLDriver::class, diff --git a/lib/Doctrine/DBAL/Exception/DriverException.php b/lib/Doctrine/DBAL/Exception/DriverException.php index 2a3338733db..c0dd5d89d8a 100644 --- a/lib/Doctrine/DBAL/Exception/DriverException.php +++ b/lib/Doctrine/DBAL/Exception/DriverException.php @@ -3,6 +3,7 @@ namespace Doctrine\DBAL\Exception; use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Exception; /** @@ -15,15 +16,15 @@ class DriverException extends DBALException /** * The previous DBAL driver exception. * - * @var \Doctrine\DBAL\Driver\DriverException + * @var DeprecatedDriverException */ private $driverException; /** - * @param string $message The exception message. - * @param \Doctrine\DBAL\Driver\DriverException $driverException The DBAL driver exception to chain. + * @param string $message The exception message. + * @param DeprecatedDriverException $driverException The DBAL driver exception to chain. */ - public function __construct($message, \Doctrine\DBAL\Driver\DriverException $driverException) + public function __construct($message, DeprecatedDriverException $driverException) { $exception = null; diff --git a/lib/Doctrine/DBAL/Portability/Connection.php b/lib/Doctrine/DBAL/Portability/Connection.php index ad79f98e889..9fb001fcf14 100644 --- a/lib/Doctrine/DBAL/Portability/Connection.php +++ b/lib/Doctrine/DBAL/Portability/Connection.php @@ -4,7 +4,8 @@ use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\ColumnCase; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Connection as BaseConnection; +use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; use PDO; use function func_get_args; @@ -15,7 +16,7 @@ /** * Portability wrapper for a Connection. */ -class Connection extends \Doctrine\DBAL\Connection +class Connection extends BaseConnection { public const PORTABILITY_ALL = 255; public const PORTABILITY_NONE = 0; diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 4f463c0ad3a..301b7ae0184 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Types\Type; use Throwable; @@ -37,7 +37,7 @@ public function dropDatabase($database) $exception = $exception->getPrevious(); assert($exception instanceof Throwable); - if (! $exception instanceof DriverException) { + if (! $exception instanceof Exception) { throw $exception; } diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index 3fac92d70a6..a04ff08c430 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL\Schema; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Types\Type; use PDOException; @@ -35,7 +35,7 @@ public function dropDatabase($database) $exception = $exception->getPrevious(); assert($exception instanceof Throwable); - if (! $exception instanceof DriverException) { + if (! $exception instanceof Exception) { throw $exception; } diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 3d6dfc27f26..bc39b077687 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -3,7 +3,7 @@ namespace Doctrine\DBAL; use Doctrine\DBAL\Abstraction\Result; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\Statement as DriverStatement; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; @@ -296,7 +296,7 @@ public function fetchNumeric() } return $this->stmt->fetch(FetchMode::NUMERIC); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -314,7 +314,7 @@ public function fetchAssociative() } return $this->stmt->fetch(FetchMode::ASSOCIATIVE); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -332,7 +332,7 @@ public function fetchOne() } return $this->stmt->fetch(FetchMode::COLUMN); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -350,7 +350,7 @@ public function fetchAllNumeric(): array } return $this->stmt->fetchAll(FetchMode::NUMERIC); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -368,7 +368,7 @@ public function fetchAllAssociative(): array } return $this->stmt->fetchAll(FetchMode::ASSOCIATIVE); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -386,7 +386,7 @@ public function fetchFirstColumn(): array } return $this->stmt->fetchAll(FetchMode::COLUMN); - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -410,7 +410,7 @@ public function iterateNumeric(): Traversable yield $row; } } - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -434,7 +434,7 @@ public function iterateAssociative(): Traversable yield $row; } } - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } @@ -458,7 +458,7 @@ public function iterateColumn(): Traversable yield $value; } } - } catch (DriverException $e) { + } catch (Exception $e) { throw DBALException::driverException($this->conn->getDriver(), $e); } } diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php index c53c9ccf172..3d53f342968 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/ImportCommand.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Tools\Console\Command; -use Doctrine\DBAL\Driver\PDOConnection; -use Doctrine\DBAL\Driver\PDOStatement; +use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; +use Doctrine\DBAL\Driver\PDO\Statement as PDOStatement; use InvalidArgumentException; use PDOException; use RuntimeException; diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 20aa33d134b..d2a97194098 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -101,7 +101,7 @@ - tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php + tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php index bd9b8b6b11e..c55fba56fa8 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractSQLServerDriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\AbstractSQLServerDriver\PortWithoutHost; +use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform; diff --git a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php index e48d3c40b66..33e76c5e53d 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/IBMDB2/DB2DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest; class DB2DriverTest extends AbstractDB2DriverTest @@ -15,6 +15,6 @@ public function testReturnsName(): void protected function createDriver(): DriverInterface { - return new DB2Driver(); + return new Driver(); } } diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php similarity index 79% rename from tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php rename to tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php index 6cd2396e679..53f3e16710c 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDO/ExceptionTest.php @@ -1,14 +1,15 @@ wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE); + $this->wrappedException = new PDOException(self::MESSAGE, self::SQLSTATE); $this->wrappedException->errorInfo = [self::SQLSTATE, self::ERROR_CODE]; - $this->exception = new PDOException($this->wrappedException); + $this->exception = new Exception($this->wrappedException); } public function testReturnsCode(): void diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 5e3d24583f7..1607207cc47 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOPgSql; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\Driver\PDOPgSql\Driver; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use Doctrine\Tests\TestUtil; @@ -89,7 +89,7 @@ private function skipWhenNotUsingPdoPgsql(): void /** * @param array $driverOptions */ - private function connect(array $driverOptions): PDOConnection + private function connect(array $driverOptions): Connection { $params = TestUtil::getConnectionParams(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index b3330b7c093..785d0ac33d2 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -5,10 +5,10 @@ use DateTime; use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Driver as IBMDB2Driver; use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\FetchMode; @@ -258,7 +258,7 @@ public function testFetchAllWithMissingTypes(callable $fetch): void } if ( - $this->connection->getDriver() instanceof DB2Driver + $this->connection->getDriver() instanceof IBMDB2Driver ) { $this->markTestSkipped( 'ibm_ibm2 may or may not report the error depending on the PHP version and the connection state' diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php index 1ffc5a7b9bb..d042ec55020 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/ConnectionTest.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2; -use Doctrine\DBAL\Driver\IBMDB2\DB2Connection; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Connection; +use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\DBAL\Driver\IBMDB2\Exception\ConnectionFailed; use Doctrine\DBAL\Driver\IBMDB2\Exception\PrepareFailed; use Doctrine\Tests\DbalFunctionalTestCase; @@ -11,6 +11,7 @@ use function db2_close; use function extension_loaded; +use function get_parent_class; class ConnectionTest extends DbalFunctionalTestCase { @@ -22,7 +23,7 @@ protected function setUp(): void parent::setUp(); - if ($this->connection->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -37,14 +38,14 @@ protected function tearDown(): void public function testConnectionFailure(): void { $this->expectException(ConnectionFailed::class); - new DB2Connection(['dbname' => 'garbage'], '', ''); + new Connection(['dbname' => 'garbage'], '', ''); } public function testPrepareFailure(): void { $driverConnection = $this->connection->getWrappedConnection(); - $re = new ReflectionProperty($driverConnection, 'conn'); + $re = new ReflectionProperty(get_parent_class($driverConnection), 'conn'); $re->setAccessible(true); $conn = $re->getValue($driverConnection); db2_close($conn); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DriverTest.php similarity index 74% rename from tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php rename to tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DriverTest.php index 214251b76ee..daf31b4d2ed 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DriverTest.php @@ -2,13 +2,13 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2; -use Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver as DriverInterface; +use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; -class DB2DriverTest extends AbstractDriverTest +class DriverTest extends AbstractDriverTest { protected function setUp(): void { @@ -18,7 +18,7 @@ protected function setUp(): void parent::setUp(); - if ($this->connection->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } @@ -35,8 +35,8 @@ public function testReturnsDatabaseNameWithoutDatabaseNameParameter(): void $this->markTestSkipped('IBM DB2 does not support connecting without database name.'); } - protected function createDriver(): Driver + protected function createDriver(): DriverInterface { - return new DB2Driver(); + return new Driver(); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php similarity index 86% rename from tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php rename to tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php index 2d504933060..eb235185003 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/DB2StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\Tests\DbalFunctionalTestCase; @@ -14,7 +14,7 @@ use const E_NOTICE; use const E_WARNING; -class DB2StatementTest extends DbalFunctionalTestCase +class StatementTest extends DbalFunctionalTestCase { protected function setUp(): void { @@ -24,7 +24,7 @@ protected function setUp(): void parent::setUp(); - if ($this->connection->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof Driver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php index fc7e5e9d389..baba579d76f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/Mysqli/ConnectionTest.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\Mysqli; +use Doctrine\DBAL\Driver\Mysqli\Connection; use Doctrine\DBAL\Driver\Mysqli\Driver; -use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\TestUtil; @@ -39,7 +39,7 @@ public function testDriverOptions(): void $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1]; $connection = $this->getConnection($driverOptions); - self::assertInstanceOf(MysqliConnection::class, $connection); + self::assertInstanceOf(Connection::class, $connection); } public function testUnsupportedDriverOption(): void @@ -58,11 +58,11 @@ public function testPing(): void /** * @param mixed[] $driverOptions */ - private function getConnection(array $driverOptions): MysqliConnection + private function getConnection(array $driverOptions): Connection { $params = TestUtil::getConnectionParams(); - return new MysqliConnection( + return new Connection( $params, $params['user'] ?? '', $params['password'] ?? '', diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php similarity index 91% rename from tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php rename to tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php index eb6b767dd88..cd551e41b12 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/OCI8ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php @@ -2,16 +2,16 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8; +use Doctrine\DBAL\Driver\OCI8\Connection; use Doctrine\DBAL\Driver\OCI8\Driver; -use Doctrine\DBAL\Driver\OCI8\OCI8Connection; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; use function extension_loaded; -class OCI8ConnectionTest extends DbalFunctionalTestCase +class ConnectionTest extends DbalFunctionalTestCase { - /** @var OCI8Connection */ + /** @var Connection */ protected $driverConnection; protected function setUp(): void diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php similarity index 83% rename from tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php rename to tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php index f0104e5abd6..602e4b541ce 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php @@ -1,9 +1,9 @@ driverConnection = $this->connection->getWrappedConnection(); - if ($this->driverConnection instanceof PDOConnection) { + if ($this->driverConnection instanceof Connection) { return; } @@ -54,9 +54,9 @@ public function testDoesNotRequireQueryForServerVersion(): void public function testThrowsWrappedExceptionOnConstruct(): void { - $this->expectException(PDOException::class); + $this->expectException(Exception::class); - new PDOConnection('foo'); + new Connection('foo'); } /** @@ -64,7 +64,7 @@ public function testThrowsWrappedExceptionOnConstruct(): void */ public function testThrowsWrappedExceptionOnExec(): void { - $this->expectException(PDOException::class); + $this->expectException(Exception::class); $this->driverConnection->exec('foo'); } @@ -94,14 +94,14 @@ public function testThrowsWrappedExceptionOnPrepare(): void // so that PDO actually communicates with the database server to check the query. $this->driverConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); - $this->expectException(PDOException::class); + $this->expectException(Exception::class); $this->driverConnection->prepare('foo'); } public function testThrowsWrappedExceptionOnQuery(): void { - $this->expectException(PDOException::class); + $this->expectException(Exception::class); $this->driverConnection->query('foo'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/ConnectionTest.php similarity index 92% rename from tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php rename to tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/ConnectionTest.php index 3dbeb6edee1..6259c4c5a29 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgsqlConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/ConnectionTest.php @@ -1,6 +1,6 @@ connection->getWrappedConnection() instanceof PDOConnection) { + if (! $this->connection->getWrappedConnection() instanceof Connection) { $this->markTestSkipped('PDO-only test'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 83e50b16165..ca63bc0dc6d 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\Driver\PDOConnection; +use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; @@ -173,10 +173,10 @@ public static function booleanTypeConversionWithoutPdoTypeProvider(): iterable ]; } - private function getWrappedConnection(): PDOConnection + private function getWrappedConnection(): Connection { $connection = $this->connection->getWrappedConnection(); - self::assertInstanceOf(PDOConnection::class, $connection); + self::assertInstanceOf(Connection::class, $connection); return $connection; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index ff8a503b5a3..70217b09ede 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\DBAL\Functional\Types; -use Doctrine\DBAL\Driver\IBMDB2\DB2Driver; +use Doctrine\DBAL\Driver\IBMDB2\Driver; use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; @@ -46,7 +46,7 @@ public function testInsertAndSelect(): void $value2 = random_bytes(64); /** @see https://bugs.php.net/bug.php?id=76322 */ - if ($this->connection->getDriver() instanceof DB2Driver) { + if ($this->connection->getDriver() instanceof Driver) { $value1 = str_replace("\x00", "\xFF", $value1); $value2 = str_replace("\x00", "\xFF", $value2); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index 5a39a71bef5..aac223c39ff 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use DateTime; -use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Sequence; use Doctrine\DBAL\Schema\Table; @@ -347,13 +347,13 @@ public function testDeleteWhereIsNull(): void * * @return string|false * - * @throws DriverException + * @throws Exception */ private function lastInsertId(?string $name = null) { try { return $this->connection->lastInsertId($name); - } catch (DriverException $e) { + } catch (Exception $e) { if ($e->getCode() === 'IM001') { $this->markTestSkipped($e->getMessage()); } diff --git a/tests/Doctrine/Tests/DBAL/UtilTest.php b/tests/Doctrine/Tests/DBAL/UtilTest.php index 13211764a27..d07b9ec5068 100644 --- a/tests/Doctrine/Tests/DBAL/UtilTest.php +++ b/tests/Doctrine/Tests/DBAL/UtilTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL; -use Doctrine\DBAL\Driver\OCI8\OCI8Statement; +use Doctrine\DBAL\Driver\OCI8\Statement; use Doctrine\Tests\DbalTestCase; class UtilTest extends DbalTestCase @@ -73,7 +73,7 @@ public static function dataConvertPositionalToNamedParameters(): iterable */ public function testConvertPositionalToNamedParameters(string $inputSQL, string $expectedOutputSQL, array $expectedOutputParamsMap): void { - [$statement, $params] = OCI8Statement::convertPositionalToNamedPlaceholders($inputSQL); + [$statement, $params] = Statement::convertPositionalToNamedPlaceholders($inputSQL); self::assertEquals($expectedOutputSQL, $statement); self::assertEquals($expectedOutputParamsMap, $params); From b7ee1fbc879a5c6a205162cf1f180770e5faf532 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 23 Jun 2020 18:11:21 -0700 Subject: [PATCH 44/93] Rework deprecated MySQLi exceptions --- .../Mysqli/Exception/ConnectionError.php | 21 ++++++++++++++ .../Mysqli/Exception/ConnectionFailed.php | 21 ++++++++++++++ .../Exception/FailedReadingStreamOffset.php | 22 +++++++++++++++ .../Driver/Mysqli/Exception/InvalidOption.php | 28 +++++++++++++++++++ .../Mysqli/Exception/StatementError.php | 21 ++++++++++++++ .../Driver/Mysqli/Exception/UnknownType.php | 25 +++++++++++++++++ .../DBAL/Driver/Mysqli/MysqliConnection.php | 11 ++++---- .../DBAL/Driver/Mysqli/MysqliStatement.php | 26 +++++++++-------- phpcs.xml.dist | 1 + 9 files changed, 160 insertions(+), 16 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionError.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionFailed.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/FailedReadingStreamOffset.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/InvalidOption.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/StatementError.php create mode 100644 lib/Doctrine/DBAL/Driver/Mysqli/Exception/UnknownType.php diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionError.php b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionError.php new file mode 100644 index 00000000000..96a05facc87 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionError.php @@ -0,0 +1,21 @@ +error, $connection->sqlstate, $connection->errno); + } +} diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionFailed.php b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionFailed.php new file mode 100644 index 00000000000..f73e07c32fa --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionFailed.php @@ -0,0 +1,21 @@ +connect_error, 'HY000', $connection->connect_errno); + } +} diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Exception/FailedReadingStreamOffset.php b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/FailedReadingStreamOffset.php new file mode 100644 index 00000000000..d3aaf8fbed4 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/FailedReadingStreamOffset.php @@ -0,0 +1,22 @@ +error, $statement->sqlstate, $statement->errno); + } +} diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Exception/UnknownType.php b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/UnknownType.php new file mode 100644 index 00000000000..0282b4d1b32 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Exception/UnknownType.php @@ -0,0 +1,25 @@ +conn->real_connect($params['host'], $username, $password, $dbname, $port, $socket, $flags)) { - throw new MysqliException($this->conn->connect_error, $this->conn->sqlstate ?? 'HY000', $this->conn->connect_errno); + throw ConnectionFailed::new($this->conn); } } finally { restore_error_handler(); @@ -163,7 +166,7 @@ public function quote($input, $type = ParameterType::STRING) public function exec($statement) { if ($this->conn->query($statement) === false) { - throw new MysqliException($this->conn->error, $this->conn->sqlstate, $this->conn->errno); + throw ConnectionError::new($this->conn); } return $this->conn->affected_rows; @@ -257,9 +260,7 @@ private function setDriverOptions(array $driverOptions = []): void } if (! in_array($option, $supportedDriverOptions, true)) { - throw new MysqliException( - sprintf($exceptionMsg, 'Unsupported', $option, $value) - ); + throw InvalidOption::fromOption($option, $value); } if (@mysqli_options($this->conn, $option, $value)) { diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 2e267ce6d6c..0b07f87761a 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -3,6 +3,10 @@ namespace Doctrine\DBAL\Driver\Mysqli; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError; +use Doctrine\DBAL\Driver\Mysqli\Exception\FailedReadingStreamOffset; +use Doctrine\DBAL\Driver\Mysqli\Exception\StatementError; +use Doctrine\DBAL\Driver\Mysqli\Exception\UnknownType; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; @@ -89,7 +93,7 @@ public function __construct(mysqli $conn, $prepareString) $stmt = $conn->prepare($prepareString); if ($stmt === false) { - throw new MysqliException($this->_conn->error, $this->_conn->sqlstate, $this->_conn->errno); + throw ConnectionError::new($this->_conn); } $this->_stmt = $stmt; @@ -111,7 +115,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l assert(is_int($column)); if (! isset(self::$_paramTypeMap[$type])) { - throw new MysqliException(sprintf("Unknown type: '%s'", $type)); + throw UnknownType::new($type); } $this->_bindedValues[$column] =& $variable; @@ -128,7 +132,7 @@ public function bindValue($param, $value, $type = ParameterType::STRING) assert(is_int($param)); if (! isset(self::$_paramTypeMap[$type])) { - throw new MysqliException(sprintf("Unknown type: '%s'", $type)); + throw UnknownType::new($type); } $this->_values[$param] = $value; @@ -146,7 +150,7 @@ public function execute($params = null) if ($this->_bindedValues !== null) { if ($params !== null) { if (! $this->bindUntypedValues($params)) { - throw new MysqliException($this->_stmt->error, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } } else { $this->bindTypedParameters(); @@ -154,7 +158,7 @@ public function execute($params = null) } if (! $this->_stmt->execute()) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } if ($this->_columnNames === null) { @@ -201,7 +205,7 @@ public function execute($params = null) } if (! $this->_stmt->bind_result(...$refs)) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } } @@ -243,7 +247,7 @@ private function bindTypedParameters(): void } if (! $this->_stmt->bind_param($types, ...$values)) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } $this->sendLongData($streams); @@ -263,11 +267,11 @@ private function sendLongData(array $streams): void $chunk = fread($stream, 8192); if ($chunk === false) { - throw new MysqliException("Failed reading the stream resource for parameter offset ${paramNr}."); + throw FailedReadingStreamOffset::new($paramNr); } if (! $this->_stmt->send_long_data($paramNr - 1, $chunk)) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } } } @@ -337,7 +341,7 @@ public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEX } if ($values === false) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } if ($fetchMode === FetchMode::NUMERIC) { @@ -423,7 +427,7 @@ public function fetchNumeric() } if ($values === false) { - throw new MysqliException($this->_stmt->error, $this->_stmt->sqlstate, $this->_stmt->errno); + throw StatementError::new($this->_stmt); } return $values; diff --git a/phpcs.xml.dist b/phpcs.xml.dist index d2a97194098..3001de2f6bd 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -87,6 +87,7 @@ https://github.com/squizlabs/PHP_CodeSniffer/issues/2950 --> lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php + lib/Doctrine/DBAL/Driver/Mysqli/Exception/ConnectionFailed.php lib/Doctrine/DBAL/SQLParserUtils.php lib/Doctrine/DBAL/Tools/Dumper.php From 2eab0857aa69499f4ebc47565da66b92b0881638 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 23 Jun 2020 18:11:46 -0700 Subject: [PATCH 45/93] Rework deprecated OCI8 exceptions --- .../Exception/NonTerminatedStringLiteral.php | 27 +++++++++++++++++++ .../OCI8/Exception/SequenceDoesNotExist.php | 20 ++++++++++++++ .../OCI8/Exception/UnknownParameterIndex.php | 24 +++++++++++++++++ .../DBAL/Driver/OCI8/OCI8Connection.php | 3 ++- .../DBAL/Driver/OCI8/OCI8Statement.php | 10 +++---- 5 files changed, 77 insertions(+), 7 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/OCI8/Exception/NonTerminatedStringLiteral.php create mode 100644 lib/Doctrine/DBAL/Driver/OCI8/Exception/SequenceDoesNotExist.php create mode 100644 lib/Doctrine/DBAL/Driver/OCI8/Exception/UnknownParameterIndex.php diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Exception/NonTerminatedStringLiteral.php b/lib/Doctrine/DBAL/Driver/OCI8/Exception/NonTerminatedStringLiteral.php new file mode 100644 index 00000000000..870e4136970 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/OCI8/Exception/NonTerminatedStringLiteral.php @@ -0,0 +1,27 @@ +fetchColumn(); if ($result === false) { - throw new OCI8Exception('lastInsertId failed: Query was executed but no result was returned.'); + throw SequenceDoesNotExist::new(); } return (int) $result; diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index bf8272bccb4..e023532d405 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -3,6 +3,8 @@ namespace Doctrine\DBAL\Driver\OCI8; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\OCI8\Exception\NonTerminatedStringLiteral; +use Doctrine\DBAL\Driver\OCI8\Exception\UnknownParameterIndex; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement as StatementInterface; use Doctrine\DBAL\Driver\StatementIterator; @@ -31,7 +33,6 @@ use function oci_parse; use function preg_match; use function preg_quote; -use function sprintf; use function substr; use const OCI_ASSOC; @@ -163,10 +164,7 @@ public static function convertPositionalToNamedPlaceholders($statement) } while ($result); if ($currentLiteralDelimiter) { - throw new OCI8Exception(sprintf( - 'The statement contains non-terminated string literal starting at offset %d', - $tokenOffset - 1 - )); + throw NonTerminatedStringLiteral::new($tokenOffset - 1); } $fragments[] = substr($statement, $fragmentOffset); @@ -286,7 +284,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le { if (is_int($param)) { if (! isset($this->_paramMap[$param])) { - throw new OCI8Exception(sprintf('Could not find variable mapping with index %d, in the SQL statement', $param)); + throw UnknownParameterIndex::new($param); } $param = $this->_paramMap[$param]; From 569ca3956a773d814de10f72a9c1f7b487ba8e0a Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 23 Jun 2020 18:12:58 -0700 Subject: [PATCH 46/93] Rework deprecated IBMDB2 exceptions --- .../DBAL/Driver/IBMDB2/DB2Statement.php | 9 ++++++--- .../Exception/CannotCopyStreamToStream.php | 20 +++++++++++++++++++ .../Exception/CannotCreateTemporaryFile.php | 20 +++++++++++++++++++ .../Exception/CannotWriteToTemporaryFile.php | 20 +++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCreateTemporaryFile.php create mode 100644 lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotWriteToTemporaryFile.php diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index d65e04c91e0..71954994e53 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -3,6 +3,9 @@ namespace Doctrine\DBAL\Driver\IBMDB2; use Doctrine\DBAL\Driver\FetchUtils; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCopyStreamToStream; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotCreateTemporaryFile; +use Doctrine\DBAL\Driver\IBMDB2\Exception\CannotWriteToTemporaryFile; use Doctrine\DBAL\Driver\IBMDB2\Exception\StatementError; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Driver\Statement as StatementInterface; @@ -522,7 +525,7 @@ private function createTemporaryFile() $handle = @tmpfile(); if ($handle === false) { - throw new DB2Exception('Could not create temporary file: ' . error_get_last()['message']); + throw CannotCreateTemporaryFile::new(error_get_last()['message']); } return $handle; @@ -537,7 +540,7 @@ private function createTemporaryFile() private function copyStreamToStream($source, $target): void { if (@stream_copy_to_stream($source, $target) === false) { - throw new DB2Exception('Could not copy source stream to temporary file: ' . error_get_last()['message']); + throw CannotCopyStreamToStream::new(error_get_last()['message']); } } @@ -549,7 +552,7 @@ private function copyStreamToStream($source, $target): void private function writeStringToStream(string $string, $target): void { if (@fwrite($target, $string) === false) { - throw new DB2Exception('Could not write string to temporary file: ' . error_get_last()['message']); + throw CannotWriteToTemporaryFile::new(error_get_last()['message']); } } } diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php new file mode 100644 index 00000000000..8223a92d660 --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Exception/CannotCopyStreamToStream.php @@ -0,0 +1,20 @@ + Date: Thu, 25 Jun 2020 23:45:26 +0300 Subject: [PATCH 47/93] UPGRADE: Fix misplaced backtick --- UPGRADE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 0fedf7f1218..3fbd21bc7fc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -41,7 +41,7 @@ Consumers of the Connection class should not rely on connection parameters store - The usage of `Doctrine\DBAL\Driver::getDatabase()` is deprecated. Please use `Doctrine\DBAL\Connection::getDatabase()` instead. - The behavior of the SQLite connection returning the database file path as the database is deprecated and shouldn't be relied upon. -## Deprecated `Portability\Connection::PORTABILITY_{PLATFORM}` constants` +## Deprecated `Portability\Connection::PORTABILITY_{PLATFORM}` constants The platform-specific portability mode flags are meant to be used only by the portability layer internally to optimize the user-provided mode for the current database platform. From 085a955bf458be62f81d4d32b6fdf71389f6f51c Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 25 Jun 2020 14:55:42 -0700 Subject: [PATCH 48/93] Mark OCI8Statement::convertPositionalToNamedPlaceholders() internal --- UPGRADE.md | 6 ++++++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | 2 ++ 2 files changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 0fedf7f1218..98e5d78aad1 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 2.11 +## Non-interface driver methods have been marked internal + +The non-interface methods of driver-level classes have been marked internal: + +- `OCI8Statement::convertPositionalToNamedPlaceholders()` + ## Inconsistently and ambiguously named driver-level classes are deprecated The following classes under the `Driver` namespace have been deprecated in favor of their consistently named counterparts: diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index e023532d405..255b665b63a 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -133,6 +133,8 @@ public function __construct($dbh, $query, OCI8Connection $conn) * Question marks inside literal strings are therefore handled correctly by this method. * This comes at a cost, the whole sql statement has to be looped over. * + * @internal + * * @param string $statement The SQL statement to convert. * * @return mixed[] [0] => the statement value (string), [1] => the paramMap value (array). From a35819db586487754e75851046d96d85c70f5649 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 25 Jun 2020 16:03:31 -0700 Subject: [PATCH 49/93] Mark OCI8Connection::getExecuteMode() internal --- UPGRADE.md | 1 + lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 98e5d78aad1..a25fefa5575 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -4,6 +4,7 @@ The non-interface methods of driver-level classes have been marked internal: +- `OCI8Connection::getExecuteMode()` - `OCI8Statement::convertPositionalToNamedPlaceholders()` ## Inconsistently and ambiguously named driver-level classes are deprecated diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index b636b362cf2..2ee1e365fc3 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -176,6 +176,8 @@ public function lastInsertId($name = null) /** * Returns the current execution mode. * + * @internal + * * @return int */ public function getExecuteMode() From f01c923dfb29879025fcbed373efaa5a78ea22d4 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 13:19:35 -0700 Subject: [PATCH 50/93] Deprecate DriverException::getErrorCode() --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Driver/Exception.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 09e7ac5f941..34448db1a80 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `DriverException::getErrorCode()` is deprecated + +The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. + ## Non-interface driver methods have been marked internal The non-interface methods of driver-level classes have been marked internal: diff --git a/lib/Doctrine/DBAL/Driver/Exception.php b/lib/Doctrine/DBAL/Driver/Exception.php index f65591f90ca..a16db4f8adc 100644 --- a/lib/Doctrine/DBAL/Driver/Exception.php +++ b/lib/Doctrine/DBAL/Driver/Exception.php @@ -14,6 +14,8 @@ interface Exception extends Throwable /** * Returns the driver specific error code if available. * + * @deprecated Use {@link getCode()} or {@link getSQLState()} instead + * * Returns null if no driver specific error code is available * for the error raised by the driver. * From 2a88ff9012ec5b38c98f5fdc34467f1cf11f49d7 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 19:18:20 -0700 Subject: [PATCH 51/93] Revert declare(strict_types=1); from new driver classes --- lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php | 2 -- lib/Doctrine/DBAL/Driver/IBMDB2/Statement.php | 2 -- lib/Doctrine/DBAL/Driver/Mysqli/Connection.php | 2 -- lib/Doctrine/DBAL/Driver/Mysqli/Statement.php | 2 -- lib/Doctrine/DBAL/Driver/OCI8/Connection.php | 2 -- lib/Doctrine/DBAL/Driver/OCI8/Statement.php | 2 -- lib/Doctrine/DBAL/Driver/PDO/Connection.php | 2 -- lib/Doctrine/DBAL/Driver/PDO/Statement.php | 2 -- lib/Doctrine/DBAL/Driver/SQLSrv/Connection.php | 2 -- lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php | 2 -- 10 files changed, 20 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php index 66d77c10406..b05475780fd 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/Connection.php @@ -1,7 +1,5 @@ Date: Fri, 26 Jun 2020 19:21:04 -0700 Subject: [PATCH 52/93] Mark SQLSrv\Statement final --- lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php index fc5be4c8baa..6a96b87c939 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/Statement.php @@ -2,6 +2,6 @@ namespace Doctrine\DBAL\Driver\SQLSrv; -class Statement extends SQLSrvStatement +final class Statement extends SQLSrvStatement { } From 4b445ae71d9c0d4ab82641e79a3cd28d55186c1e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 20:02:38 -0700 Subject: [PATCH 53/93] Deprecate ExceptionConverterDriver --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php | 12 ++++++++++++ lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php | 12 ++++++++++++ .../DBAL/Driver/ExceptionConverterDriver.php | 3 +++ phpcs.xml.dist | 5 +++++ 5 files changed, 36 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 34448db1a80..20c6fedd97f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## The `ExceptionConverterDriver` interface is deprecated + +All drivers will have to implement the exception conversion API. + ## `DriverException::getErrorCode()` is deprecated The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. diff --git a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php index cede8da7eb0..376672d0a32 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractDB2Driver.php @@ -4,6 +4,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\DriverException as TheDriverException; +use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\DB2Platform; use Doctrine\DBAL\Schema\DB2SchemaManager; @@ -39,4 +41,14 @@ public function getSchemaManager(Connection $conn) { return new DB2SchemaManager($conn); } + + /** + * @param string $message + * + * @return DriverException + */ + public function convertException($message, TheDriverException $exception) + { + return new DriverException($message, $exception); + } } diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 1fd705a856f..073a40ad13c 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -5,6 +5,8 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\DriverException as TheDriverException; +use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform; use Doctrine\DBAL\Platforms\SQLServer2012Platform; @@ -92,4 +94,14 @@ public function getSchemaManager(Connection $conn) { return new SQLServerSchemaManager($conn); } + + /** + * @param string $message + * + * @return DriverException + */ + public function convertException($message, TheDriverException $exception) + { + return new DriverException($message, $exception); + } } diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php index 959ec4c0659..7137fcf3aa2 100644 --- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php +++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php @@ -2,11 +2,14 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Exception\DriverException; /** * Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions. + * + * @deprecated All implementors of the {@link Driver} interface will have to implement this API. */ interface ExceptionConverterDriver { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 3001de2f6bd..83965949b5d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -100,6 +100,11 @@ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php + + + lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php + + tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php From 15ef075855632e3de1e12a816817e77d10e03eca Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 22:04:54 -0700 Subject: [PATCH 54/93] Implement handling lost connection on MySQL --- lib/Doctrine/DBAL/Connection.php | 94 +++++++++++++++---- .../DBAL/Driver/AbstractMySQLDriver.php | 4 + .../DBAL/Exception/ConnectionLost.php | 10 ++ lib/Doctrine/DBAL/Statement.php | 25 ++--- phpstan.neon.dist | 4 + .../Connection/ConnectionLostTest.php | 52 ++++++++++ tests/Doctrine/Tests/DBAL/StatementTest.php | 5 +- 7 files changed, 157 insertions(+), 37 deletions(-) create mode 100644 lib/Doctrine/DBAL/Exception/ConnectionLost.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Connection/ConnectionLostTest.php diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 90517771ae4..9aaf21bdad2 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -13,6 +13,7 @@ use Doctrine\DBAL\Driver\PingableConnection; use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; +use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; @@ -614,7 +615,7 @@ public function fetchAssociative(string $query, array $params = [], array $types return $stmt->fetch(FetchMode::ASSOCIATIVE); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -641,7 +642,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [ return $stmt->fetch(FetchMode::NUMERIC); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -668,7 +669,7 @@ public function fetchOne(string $query, array $params = [], array $types = []) return $stmt->fetch(FetchMode::COLUMN); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -952,7 +953,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types return $stmt->fetchAll(FetchMode::NUMERIC); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -978,7 +979,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty return $stmt->fetchAll(FetchMode::ASSOCIATIVE); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -1004,7 +1005,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types return $stmt->fetchAll(FetchMode::COLUMN); } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -1032,7 +1033,7 @@ public function iterateNumeric(string $query, array $params = [], array $types = } } } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -1060,7 +1061,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ } } } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -1088,7 +1089,7 @@ public function iterateColumn(string $query, array $params = [], array $types = } } } catch (Throwable $e) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $e, $query); + $this->handleExceptionDuringQuery($e, $query, $params, $types); } } @@ -1105,8 +1106,8 @@ public function prepare($statement) { try { $stmt = new Statement($statement, $this); - } catch (Throwable $ex) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement); + } catch (Throwable $e) { + $this->handleExceptionDuringQuery($e, $statement); } $stmt->setFetchMode($this->defaultFetchMode); @@ -1156,8 +1157,8 @@ public function executeQuery($query, array $params = [], $types = [], ?QueryCach } else { $stmt = $connection->query($query); } - } catch (Throwable $ex) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $query, $this->resolveParams($params, $types)); + } catch (Throwable $e) { + $this->handleExceptionDuringQuery($e, $query, $params, $types); } $stmt->setFetchMode($this->defaultFetchMode); @@ -1263,8 +1264,8 @@ public function query() try { $statement = $connection->query(...$args); - } catch (Throwable $ex) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $args[0]); + } catch (Throwable $e) { + $this->handleExceptionDuringQuery($e, $args[0]); } $statement->setFetchMode($this->defaultFetchMode); @@ -1316,8 +1317,8 @@ public function executeUpdate($query, array $params = [], array $types = []) } else { $result = $connection->exec($query); } - } catch (Throwable $ex) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $query, $this->resolveParams($params, $types)); + } catch (Throwable $e) { + $this->handleExceptionDuringQuery($e, $query, $params, $types); } if ($logger) { @@ -1347,8 +1348,8 @@ public function exec($statement) try { $result = $connection->exec($statement); - } catch (Throwable $ex) { - throw DBALException::driverExceptionDuringQuery($this->_driver, $ex, $statement); + } catch (Throwable $e) { + $this->handleExceptionDuringQuery($e, $statement); } if ($logger) { @@ -1954,4 +1955,59 @@ public function ping() return false; } } + + /** + * @internal + * + * @param array|array $params + * @param array|array $types + * + * @throws DBALException + * + * @psalm-return never-return + */ + public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void + { + $this->throw( + DBALException::driverExceptionDuringQuery( + $this->_driver, + $e, + $sql, + $this->resolveParams($params, $types) + ) + ); + } + + /** + * @internal + * + * @throws DBALException + * + * @psalm-return never-return + */ + public function handleDriverException(Throwable $e): void + { + $this->throw( + DBALException::driverException( + $this->_driver, + $e + ) + ); + } + + /** + * @internal + * + * @throws DBALException + * + * @psalm-return never-return + */ + private function throw(DBALException $e): void + { + if ($e instanceof ConnectionLost) { + $this->close(); + } + + throw $e; + } } diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 565d055353d..c54da20fd75 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -7,6 +7,7 @@ use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; use Doctrine\DBAL\Exception\ConnectionException; +use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException; @@ -108,6 +109,9 @@ public function convertException($message, DeprecatedDriverException $exception) case '2005': return new ConnectionException($message, $exception); + case '2006': + return new ConnectionLost($message, $exception); + case '1048': case '1121': case '1138': diff --git a/lib/Doctrine/DBAL/Exception/ConnectionLost.php b/lib/Doctrine/DBAL/Exception/ConnectionLost.php new file mode 100644 index 00000000000..46a4247576e --- /dev/null +++ b/lib/Doctrine/DBAL/Exception/ConnectionLost.php @@ -0,0 +1,10 @@ +stopQuery(); } - throw DBALException::driverExceptionDuringQuery( - $this->conn->getDriver(), - $ex, - $this->sql, - $this->conn->resolveParams($this->params, $this->types) - ); + $this->conn->handleExceptionDuringQuery($ex, $this->sql, $this->params, $this->types); } if ($logger) { @@ -297,7 +292,7 @@ public function fetchNumeric() return $this->stmt->fetch(FetchMode::NUMERIC); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -315,7 +310,7 @@ public function fetchAssociative() return $this->stmt->fetch(FetchMode::ASSOCIATIVE); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -333,7 +328,7 @@ public function fetchOne() return $this->stmt->fetch(FetchMode::COLUMN); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -351,7 +346,7 @@ public function fetchAllNumeric(): array return $this->stmt->fetchAll(FetchMode::NUMERIC); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -369,7 +364,7 @@ public function fetchAllAssociative(): array return $this->stmt->fetchAll(FetchMode::ASSOCIATIVE); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -387,7 +382,7 @@ public function fetchFirstColumn(): array return $this->stmt->fetchAll(FetchMode::COLUMN); } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -411,7 +406,7 @@ public function iterateNumeric(): Traversable } } } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -435,7 +430,7 @@ public function iterateAssociative(): Traversable } } } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } @@ -459,7 +454,7 @@ public function iterateColumn(): Traversable } } } catch (Exception $e) { - throw DBALException::driverException($this->conn->getDriver(), $e); + $this->conn->handleDriverException($e); } } diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 74c2444e63e..fb8da4e2991 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -7,6 +7,10 @@ parameters: reportUnmatchedIgnoredErrors: false checkMissingIterableValueType: false checkGenericClassInNonGenericObjectType: false + earlyTerminatingMethodCalls: + Doctrine\DBAL\Connection: + - handleDriverException + - handleExceptionDuringQuery ignoreErrors: # extension not available - '~^(Used )?(Function|Constant) sasql_\S+ not found\.\z~i' diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/ConnectionLostTest.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/ConnectionLostTest.php new file mode 100644 index 00000000000..1c8e385a873 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/ConnectionLostTest.php @@ -0,0 +1,52 @@ +connection->getDatabasePlatform() instanceof MySqlPlatform) { + return; + } + + $this->markTestSkipped('Currently only supported with MySQL'); + } + + protected function tearDown(): void + { + $this->resetSharedConn(); + + parent::tearDown(); + } + + public function testConnectionLost(): void + { + $this->connection->query('SET SESSION wait_timeout=1'); + + sleep(2); + + $query = $this->connection->getDatabasePlatform() + ->getDummySelectSQL(); + + try { + // in addition to the error, PHP 7.3 will generate a warning that needs to be + // suppressed in order to not let PHPUnit handle it before the actual error + @$this->connection->executeQuery($query); + } catch (ConnectionLost $e) { + self::assertEquals(1, $this->connection->fetchOne($query)); + + return; + } + + self::fail('The connection should have lost'); + } +} diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 69cae985148..5cacf902cc6 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -131,10 +131,9 @@ public function testExecuteCallsLoggerStopQueryOnException(): void ->method('getSQLLogger') ->will($this->returnValue($logger)); - // Needed to satisfy construction of DBALException $this->conn->expects($this->any()) - ->method('resolveParams') - ->will($this->returnValue([])); + ->method('handleExceptionDuringQuery') + ->will($this->throwException(new DBALException())); $logger->expects($this->once()) ->method('startQuery'); From e603a2e2333e043b9bba081dfaa2eda88814f478 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 23:36:06 -0700 Subject: [PATCH 55/93] Deprecate PingableConnection --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/PingableConnection.php | 2 ++ 4 files changed, 10 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 20c6fedd97f..055cf619016 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## The `PingableConnection` interface is deprecated + +The wrapper connection will automatically handle the lost connection if the driver supports reporting it. + ## The `ExceptionConverterDriver` interface is deprecated All drivers will have to implement the exception conversion API. diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 9aaf21bdad2..33a38ab9dcc 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -1925,6 +1925,8 @@ public function createQueryBuilder() * It is responsibility of the developer to handle this case * and abort the request or reconnect manually: * + * @deprecated + * * @return bool * * @example diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 7746e24caaf..2e8dd185013 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -281,6 +281,8 @@ private function setDriverOptions(array $driverOptions = []): void /** * Pings the server and re-connects when `mysqli.reconnect = 1` * + * @deprecated + * * @return bool */ public function ping() diff --git a/lib/Doctrine/DBAL/Driver/PingableConnection.php b/lib/Doctrine/DBAL/Driver/PingableConnection.php index 06bfb9a7f26..42202e7ab87 100644 --- a/lib/Doctrine/DBAL/Driver/PingableConnection.php +++ b/lib/Doctrine/DBAL/Driver/PingableConnection.php @@ -4,6 +4,8 @@ /** * An interface for connections which support a "native" ping method. + * + * @deprecated */ interface PingableConnection { From 0a5bac1c2ce1d1b68944541e6a74e2325d274847 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 23:44:11 -0700 Subject: [PATCH 56/93] Mark statement constructors internal --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php | 2 ++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOStatement.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php | 2 ++ lib/Doctrine/DBAL/Statement.php | 2 ++ 8 files changed, 18 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 055cf619016..8fab44e6ab8 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Statement constructors are marked internal + +The driver and wrapper statement objects can be only created by the corresponding connection objects. + ## The `PingableConnection` interface is deprecated The wrapper connection will automatically handle the lost connection if the driver supports reporting it. diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php index 71954994e53..6cd89299daa 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Statement.php @@ -92,6 +92,8 @@ class DB2Statement implements IteratorAggregate, StatementInterface, Result private $result = false; /** + * @internal The statement can be only instantiated by its driver connection. + * * @param resource $stmt */ public function __construct($stmt) diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 0b07f87761a..8f31a203a30 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -82,6 +82,8 @@ class MysqliStatement implements IteratorAggregate, StatementInterface, Result private $result = false; /** + * @internal The statement can be only instantiated by its driver connection. + * * @param string $prepareString * * @throws MysqliException diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 255b665b63a..6bf427d797f 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -105,6 +105,8 @@ class OCI8Statement implements IteratorAggregate, StatementInterface, Result /** * Creates a new OCI8Statement that uses the given connection handle and SQL statement. * + * @internal The statement can be only instantiated by its driver connection. + * * @param resource $dbh The connection handle. * @param string $query The SQL query. */ diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 97b0407b556..dace9ea357c 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -46,6 +46,8 @@ class PDOStatement extends \PDOStatement implements StatementInterface, Result /** * Protected constructor. + * + * @internal The statement can be only instantiated by its driver connection. */ protected function __construct() { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php index 25e28e9a0e8..c64e715165b 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereStatement.php @@ -71,6 +71,8 @@ class SQLAnywhereStatement implements IteratorAggregate, Statement, Result /** * Prepares given statement for given connection. * + * @internal The statement can be only instantiated by its driver connection. + * * @param resource $conn The connection resource to use. * @param string $sql The SQL statement to prepare. * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index 0a0dd78df27..a340a8f1d57 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -136,6 +136,8 @@ class SQLSrvStatement implements IteratorAggregate, StatementInterface, Result public const LAST_INSERT_ID_SQL = ';SELECT SCOPE_IDENTITY() AS LastInsertId;'; /** + * @internal The statement can be only instantiated by its driver connection. + * * @param resource $conn * @param string $sql */ diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index eaa3e902b86..56c796bea98 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -66,6 +66,8 @@ class Statement implements IteratorAggregate, DriverStatement, Result /** * Creates a new Statement for the given SQL and Connection. * + * @internal The statement can be only instantiated by {@link Connection}. + * * @param string $sql The SQL of the statement. * @param Connection $conn The connection on which the statement should be executed. */ From b65aa9137ef4453d3bccaf1f7fb3159684f61a61 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 26 Jun 2020 18:33:22 -0700 Subject: [PATCH 57/93] Deprecate ServerInfoAwareConnection#requiresQueryForServerVersion() as an implementation detail --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 8fab44e6ab8..10eb5e062d5 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. + +The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. + ## Statement constructors are marked internal The driver and wrapper statement objects can be only created by the corresponding connection objects. diff --git a/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php b/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php index c97a60fa356..78ac3fda8e3 100644 --- a/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php +++ b/lib/Doctrine/DBAL/Driver/ServerInfoAwareConnection.php @@ -17,6 +17,8 @@ public function getServerVersion(); /** * Checks whether a query is required to retrieve the database server version. * + * @deprecated + * * @return bool True if a query is required to retrieve the database server version, false otherwise. */ public function requiresQueryForServerVersion(); From 3d10803a2e9a839035cad7b884329b5e74fb8558 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 27 Jun 2020 15:32:49 -0700 Subject: [PATCH 58/93] Remove a no longer needed PHP_CodeSniffer error suppression --- phpcs.xml.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 83965949b5d..534b91cec44 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -105,11 +105,6 @@ lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php - - - tests/Doctrine/Tests/DBAL/Functional/Driver/IBMDB2/StatementTest.php - - lib/Doctrine/DBAL/Schema/Comparator.php From 2136c9a6ee6a60c60776fc76d5a26da3bb680708 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 27 Jun 2020 15:33:01 -0700 Subject: [PATCH 59/93] Remove a no longer needed PHPStan error suppression --- phpstan.neon.dist | 5 ----- 1 file changed, 5 deletions(-) diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 5f168a48fcf..315d12d10de 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -23,11 +23,6 @@ parameters: - '~^Property Doctrine\\DBAL\\Schema\\Schema::\$_schemaConfig \(Doctrine\\DBAL\\Schema\\SchemaConfig\) does not accept default value of type false\.\z~' - '~^Return type \(int\|false\) of method Doctrine\\DBAL\\Driver\\OCI8\\OCI8Connection\:\:lastInsertId\(\) should be compatible with return type \(string\) of method Doctrine\\DBAL\\Driver\\Connection::lastInsertId\(\)~' - # https://github.com/phpstan/phpstan/issues/3527 - - - message: '~^Call to private method sqliteCreateFunction\(\) of parent class PDO\.$~' - path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php - # https://github.com/phpstan/phpstan/issues/2857 # TODO: remove in 4.0.0 - '~^Parameter #2 \$registeredAliases of static method Doctrine\\DBAL\\Query\\QueryException::nonUniqueAlias\(\) expects array, array given\.\z~' From 0231c36cb8ea6f3dc3efa9f713e82fa8b90f0864 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 09:52:11 -0700 Subject: [PATCH 60/93] Restore the PortWithoutHost exception parent class --- .../AbstractSQLServerDriver/Exception/PortWithoutHost.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php index ea8dcc461e5..c6dbf34bbd1 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver/Exception/PortWithoutHost.php @@ -4,14 +4,14 @@ namespace Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception; -use Doctrine\DBAL\Driver\AbstractException; +use Doctrine\DBAL\Driver\AbstractDriverException; /** * @internal * * @psalm-immutable */ -final class PortWithoutHost extends AbstractException +final class PortWithoutHost extends AbstractDriverException { public static function new(): self { From 20ec5d824a3091d38eeda159bd38c8a124bd1d95 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 10:27:31 -0700 Subject: [PATCH 61/93] Deprecate AbstractPlatform::fixSchemaElementName() --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 2 ++ 3 files changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 10eb5e062d5..d8cf618481d 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `AbstractPlatform::fixSchemaElementName()` is deprecated. + +The method is not used anywhere except for tests. + ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 38d934550d3..007bd723a42 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3478,6 +3478,8 @@ public function getSQLResultCasing($column) * Makes any fixes to a name of a schema element (table, sequence, ...) that are required * by restrictions of the platform, like a maximum length. * + * @deprecated + * * @param string $schemaElementName * * @return string diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index b0cdce3f03f..ddf07adc1e2 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -1075,6 +1075,8 @@ public function getTimeFormatString() /** * {@inheritDoc} + * + * @deprecated */ public function fixSchemaElementName($schemaElementName) { From dacd4baacb9e5c53ed175daffc24022b61894ad2 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 10:34:19 -0700 Subject: [PATCH 62/93] Fix base class alias in PDOSqlsrv\Connection --- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index a05f5898b22..8e36d2f1501 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Connection as BaseStatement; +use Doctrine\DBAL\Driver\PDO\Connection as BaseConnection; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; use PDO; @@ -14,7 +14,7 @@ /** * Sqlsrv Connection implementation. */ -class Connection extends BaseStatement +class Connection extends BaseConnection { /** * {@inheritdoc} From 54b04e3380c1719a2bf89ffc36c1bf4da77f6a27 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Mon, 29 Jun 2020 13:31:52 -0700 Subject: [PATCH 63/93] Fix reference to the class recommended instead of PDOException --- lib/Doctrine/DBAL/Driver/PDOException.php | 2 ++ phpcs.xml.dist | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/Doctrine/DBAL/Driver/PDOException.php b/lib/Doctrine/DBAL/Driver/PDOException.php index e82bcbcfc6b..b2c01eb4430 100644 --- a/lib/Doctrine/DBAL/Driver/PDOException.php +++ b/lib/Doctrine/DBAL/Driver/PDOException.php @@ -2,6 +2,8 @@ namespace Doctrine\DBAL\Driver; +use Doctrine\DBAL\Driver\PDO\Exception; + /** * @deprecated Use {@link Exception} instead * diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 534b91cec44..768e383c47d 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -103,6 +103,7 @@ lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php + lib/Doctrine/DBAL/Driver/PDOException.php From af7644edf7e418935b3042fecc106a6557e8dc48 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 1 Jul 2020 16:20:56 -0700 Subject: [PATCH 64/93] DBALException::invalidPlatformType() is unused as of v2.7.0 --- UPGRADE.md | 4 ++++ lib/Doctrine/DBAL/DBALException.php | 3 +++ 2 files changed, 7 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index d8cf618481d..848662992de 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## `DBALException` factory method deprecations + +1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. + ## `AbstractPlatform::fixSchemaElementName()` is deprecated. The method is not used anywhere except for tests. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 9a85c110bb8..65f6298b5fe 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -38,6 +38,9 @@ public static function notSupported($method) return new self(sprintf("Operation '%s' is not supported by platform.", $method)); } + /** + * @deprecated Use {@link invalidPlatformType()} instead. + */ public static function invalidPlatformSpecified(): self { return new self( From 0fe1dc4ba0cc8c62fabb9055e645d6ed325d9d61 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 1 Jul 2020 16:24:51 -0700 Subject: [PATCH 65/93] The usage of user-provided PDO instance is deprecated as of v2.10.0 --- UPGRADE.md | 1 + lib/Doctrine/DBAL/DBALException.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 848662992de..9898e669d57 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -3,6 +3,7 @@ ## `DBALException` factory method deprecations 1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. +2. `DBALException::invalidPdoInstance()` as passing a PDO instance via configuration is deprecated. ## `AbstractPlatform::fixSchemaElementName()` is deprecated. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 65f6298b5fe..18ca800f330 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -93,6 +93,8 @@ public static function invalidPlatformVersionSpecified($version, $expectedFormat } /** + * @deprecated Passing a PDO instance in connection parameters is deprecated. + * * @return DBALException */ public static function invalidPdoInstance() From ad96ce289bdc10a110fdab58dee2f34bf83a0a07 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 11:58:06 -0700 Subject: [PATCH 66/93] Deprecate driver exception conversion APIs --- UPGRADE.md | 10 ++++++---- lib/Doctrine/DBAL/DBALException.php | 4 ++++ lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php | 2 ++ lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php | 5 +++-- 8 files changed, 23 insertions(+), 6 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 9898e669d57..ad04122bd99 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,11 @@ # Upgrade to 2.11 +## Deprecations in driver-level exception handling + +1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated. +2. The `driverException()` and `driverExceptionDuringQuery()` factory methods of the `DBALException` class are deprecated. +3. Relying on the wrapper layer handling non-driver exceptions is deprecated. + ## `DBALException` factory method deprecations 1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. @@ -21,10 +27,6 @@ The driver and wrapper statement objects can be only created by the correspondin The wrapper connection will automatically handle the lost connection if the driver supports reporting it. -## The `ExceptionConverterDriver` interface is deprecated - -All drivers will have to implement the exception conversion API. - ## `DriverException::getErrorCode()` is deprecated The `DriverException::getErrorCode()` is deprecated as redundant and inconsistently supported by drivers. Use `::getCode()` or `::getSQLState()` instead. diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index 18ca800f330..c7ad96be0fd 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -139,6 +139,8 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers) } /** + * @deprecated + * * @param string $sql * @param mixed[] $params * @@ -157,6 +159,8 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri } /** + * @deprecated + * * @return self */ public static function driverException(Driver $driver, Throwable $driverEx) diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index c54da20fd75..7fd77aa5c51 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -39,6 +39,8 @@ abstract class AbstractMySQLDriver implements Driver, ExceptionConverterDriver, /** * {@inheritdoc} * + * @deprecated + * * @link https://dev.mysql.com/doc/refman/8.0/en/client-error-reference.html * @link https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html */ diff --git a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php index b3b58e58db6..be5826659d5 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractOracleDriver.php @@ -26,6 +26,8 @@ abstract class AbstractOracleDriver implements Driver, ExceptionConverterDriver { /** * {@inheritdoc} + * + * @deprecated */ public function convertException($message, DeprecatedDriverException $exception) { diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index bf0ac0d2a5f..2653746eb9b 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -38,6 +38,8 @@ abstract class AbstractPostgreSQLDriver implements Driver, ExceptionConverterDri /** * {@inheritdoc} * + * @deprecated + * * @link http://www.postgresql.org/docs/9.3/static/errcodes-appendix.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 52ecd4bcef2..668f765e1ca 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -37,6 +37,8 @@ abstract class AbstractSQLAnywhereDriver implements Driver, ExceptionConverterDr /** * {@inheritdoc} * + * @deprecated + * * @link http://dcx.sybase.com/index.html#sa160/en/saerrors/sqlerror.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php index f0cf8433e3d..2e7f640541b 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLiteDriver.php @@ -30,6 +30,8 @@ abstract class AbstractSQLiteDriver implements Driver, ExceptionConverterDriver /** * {@inheritdoc} * + * @deprecated + * * @link http://www.sqlite.org/c3ref/c_abort.html */ public function convertException($message, DeprecatedDriverException $exception) diff --git a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php index 7137fcf3aa2..19428cf94b1 100644 --- a/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php +++ b/lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php @@ -2,14 +2,13 @@ namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; use Doctrine\DBAL\Exception\DriverException; /** * Contract for a driver that is capable of converting DBAL driver exceptions into standardized DBAL driver exceptions. * - * @deprecated All implementors of the {@link Driver} interface will have to implement this API. + * @deprecated */ interface ExceptionConverterDriver { @@ -19,6 +18,8 @@ interface ExceptionConverterDriver * It evaluates the vendor specific error code and SQLSTATE and transforms * it into a unified {@link DriverException} subclass. * + * @deprecated + * * @param string $message The DBAL exception message to use. * @param TheDriverException $exception The DBAL driver exception to convert. * From 3b44f5594e943be32e53ce8ca79ae168be8559ca Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:07 -0700 Subject: [PATCH 67/93] Mark connection constructors internal --- UPGRADE.md | 6 ++++-- lib/Doctrine/DBAL/Connection.php | 2 ++ lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php | 2 ++ .../DBAL/Connections/PrimaryReadReplicaConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php | 2 ++ .../DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php | 2 ++ lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php | 2 ++ 12 files changed, 26 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index ad04122bd99..df5f752f7c4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -19,9 +19,11 @@ The method is not used anywhere except for tests. The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been deprecated as an implementation detail which is the same for almost all supported drivers. -## Statement constructors are marked internal +## Connection and Statement constructors are marked internal -The driver and wrapper statement objects can be only created by the corresponding connection objects. +1. Driver connection objects can be only created by the corresponding drivers. +2. Wrapper connection objects can be only created by the driver manager. +3. The driver and wrapper connection objects can be only created by the corresponding connection objects. ## The `PingableConnection` interface is deprecated diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 33a38ab9dcc..29eda274608 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -168,6 +168,8 @@ class Connection implements DriverConnection /** * Initializes a new instance of the Connection class. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params The connection parameters. * @param Driver $driver The driver to use. * @param Configuration|null $config The configuration, optional. diff --git a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php index 39b0c6165d5..156753457d6 100644 --- a/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php +++ b/lib/Doctrine/DBAL/Connections/MasterSlaveConnection.php @@ -20,6 +20,8 @@ class MasterSlaveConnection extends PrimaryReadReplicaConnection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index cb78b69c451..86aad20d14b 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -90,6 +90,8 @@ class PrimaryReadReplicaConnection extends Connection /** * Creates Primary Replica Connection. * + * @internal The connection can be only instantiated by the driver manager. + * * @param mixed[] $params * * @throws InvalidArgumentException diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 655bbb39d4c..8beef436b2e 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -40,6 +40,8 @@ class DB2Connection implements ConnectionInterface, ServerInfoAwareConnection private $conn = null; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 2e8dd185013..de009d4ed32 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -46,6 +46,8 @@ class MysqliConnection implements ConnectionInterface, PingableConnection, Serve private $conn; /** + * @internal The connection can be only instantiated by its driver. + * * @param mixed[] $params * @param string $username * @param string $password diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 2ee1e365fc3..7a56b6e1a56 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -41,6 +41,8 @@ class OCI8Connection implements ConnectionInterface, ServerInfoAwareConnection /** * Creates a Connection to an Oracle Database using oci8 extension. * + * @internal The connection can be only instantiated by its driver. + * * @param string $username * @param string $password * @param string $db diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 9e124e528bc..4f72e820b77 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -22,6 +22,8 @@ class PDOConnection extends PDO implements ConnectionInterface, ServerInfoAwareConnection { /** + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn * @param string|null $user * @param string|null $password diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 8e36d2f1501..d0262dcf6a7 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -17,6 +17,8 @@ class Connection extends BaseConnection { /** + * @internal The connection can be only instantiated by its driver. + * * {@inheritdoc} */ public function __construct($dsn, $user = null, $password = null, ?array $options = null) diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index b56fd61ff2d..cee7447129d 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -36,6 +36,8 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection /** * Connects to database with given connection string. * + * @internal The connection can be only instantiated by its driver. + * * @param string $dsn The connection string. * @param bool $persistent Whether or not to establish a persistent connection. * diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 10095cde411..de783309883 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -39,6 +39,8 @@ class SQLSrvConnection implements ConnectionInterface, ServerInfoAwareConnection protected $lastInsertId; /** + * @internal The connection can be only instantiated by its driver. + * * @param string $serverName * @param mixed[] $connectionOptions * diff --git a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php index 8c20139ac42..db81e381c85 100644 --- a/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php +++ b/lib/Doctrine/DBAL/Sharding/PoolingShardConnection.php @@ -65,6 +65,8 @@ class PoolingShardConnection extends Connection /** * {@inheritDoc} * + * @internal The connection can be only instantiated by the driver manager. + * * @throws InvalidArgumentException */ public function __construct(array $params, Driver $driver, ?Configuration $config = null, ?EventManager $eventManager = null) From f5714c57449744b6c248986d1196eff303ffb1bd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:48:53 -0700 Subject: [PATCH 68/93] Mark LastInsertId internal --- UPGRADE.md | 2 ++ lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index df5f752f7c4..41c0bd1b026 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -25,6 +25,8 @@ The `ServerInfoAwareConnection::requiresQueryForServerVersion()` method has been 2. Wrapper connection objects can be only created by the driver manager. 3. The driver and wrapper connection objects can be only created by the corresponding connection objects. +Additionally, the `SQLSrv\LastInsertId` class has been marked internal. + ## The `PingableConnection` interface is deprecated The wrapper connection will automatically handle the lost connection if the driver supports reporting it. diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php index 94c19f6effc..9406c425a1f 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/LastInsertId.php @@ -4,6 +4,8 @@ /** * Last Id Data Container. + * + * @internal */ class LastInsertId { From 67d6bb0395d3e3e1aadfd23f5658a2a846266dfd Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 2 Jul 2020 18:30:55 -0700 Subject: [PATCH 69/93] Deprecate classes in Driver\PDO* namespaces --- UPGRADE.md | 12 +++++ lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDO/OCI/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDO/PgSQL/Driver.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Connection.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Driver.php | 9 ++++ .../DBAL/Driver/PDO/SQLSrv/Statement.php | 9 ++++ .../DBAL/Driver/PDO/SQLite/Driver.php | 9 ++++ lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 6 ++- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 6 ++- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 13 ++--- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 6 ++- .../DBAL/Driver/PDOSqlsrv/Connection.php | 9 ++-- lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php | 5 +- .../DBAL/Driver/PDOSqlsrv/Statement.php | 9 ++-- lib/Doctrine/DBAL/DriverManager.php | 47 +++++++++---------- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 2 +- .../Tests/DBAL/Driver/PDOMySql/DriverTest.php | 2 +- .../DBAL/Driver/PDOOracle/DriverTest.php | 2 +- .../Tests/DBAL/Driver/PDOPgSql/DriverTest.php | 2 +- .../DBAL/Driver/PDOSqlite/DriverTest.php | 2 +- .../DBAL/Driver/PDOSqlsrv/DriverTest.php | 2 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 16 +++---- .../Tests/DBAL/Functional/BlobTest.php | 4 +- .../Tests/DBAL/Functional/DataAccessTest.php | 4 +- .../Functional/Driver/PDO/ConnectionTest.php | 10 ++-- .../Functional/Driver/PDOMySql/DriverTest.php | 2 +- .../Driver/PDOOracle/DriverTest.php | 2 +- .../Functional/Driver/PDOPgSql/DriverTest.php | 2 +- .../Driver/PDOSqlite/DriverTest.php | 2 +- .../Driver/PDOSqlsrv/DriverTest.php | 2 +- .../Tests/DBAL/Functional/StatementTest.php | 10 ++-- .../DBAL/Functional/TypeConversionTest.php | 4 +- .../DBAL/Functional/Types/BinaryTest.php | 4 +- 34 files changed, 166 insertions(+), 84 deletions(-) create mode 100644 lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/OCI/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/PgSQL/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Connection.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Driver.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLSrv/Statement.php create mode 100644 lib/Doctrine/DBAL/Driver/PDO/SQLite/Driver.php diff --git a/UPGRADE.md b/UPGRADE.md index 41c0bd1b026..45b4e26383b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,17 @@ # Upgrade to 2.11 +## PDO-related classes outside of the PDO namespace are deprecated + +The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: + +- `PDOMySql\Driver` → `PDO\MySQL\Driver` +- `PDOOracle\Driver` → `PDO\OCI\Driver` +- `PDOPgSql\Driver` → `PDO\PgSQL\Driver` +- `PDOSqlite\Driver` → `PDO\SQLite\Driver` +- `PDOSqlsrv\Driver` → `PDO\SQLSrv\Driver` +- `PDOSqlsrv\Connection` → `PDO\SQLSrv\Connection` +- `PDOSqlsrv\Statement` → `PDO\SQLSrv\Statement` + ## Deprecations in driver-level exception handling 1. The `ExceptionConverterDriver` interface and the usage of the `convertException()` method on the `Driver` objects are deprecated. diff --git a/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php b/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php new file mode 100644 index 00000000000..a42cb7d608f --- /dev/null +++ b/lib/Doctrine/DBAL/Driver/PDO/MySQL/Driver.php @@ -0,0 +1,9 @@ +constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index 88aa01a5434..2ea597d16f1 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; -use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\DBAL\Driver\PDO; use PDOException; /** @@ -14,6 +14,8 @@ * stuff. PDO Oracle is not maintained by Oracle or anyone in the PHP community, * which leads us to the recommendation to use the "oci8" driver to connect * to Oracle instead. + * + * @deprecated Use {@link PDO\OCI\Driver} instead. */ class Driver extends AbstractOracleDriver { @@ -23,7 +25,7 @@ class Driver extends AbstractOracleDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - return new Connection( + return new PDO\Connection( $this->constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index e3f15ab610f..d7a19181c4e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -4,14 +4,15 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; -use Doctrine\DBAL\Driver\PDO\Connection; -use PDO; +use Doctrine\DBAL\Driver\PDO; use PDOException; use function defined; /** * Driver that connects through pdo_pgsql. + * + * @deprecated Use {@link PDO\PgSQL\Driver} instead. */ class Driver extends AbstractPostgreSQLDriver { @@ -21,7 +22,7 @@ class Driver extends AbstractPostgreSQLDriver public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { try { - $pdo = new Connection( + $pdo = new PDO\Connection( $this->_constructPdoDsn($params), $username, $password, @@ -30,11 +31,11 @@ public function connect(array $params, $username = null, $password = null, array if ( defined('PDO::PGSQL_ATTR_DISABLE_PREPARES') - && (! isset($driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES]) - || $driverOptions[PDO::PGSQL_ATTR_DISABLE_PREPARES] === true + && (! isset($driverOptions[\PDO::PGSQL_ATTR_DISABLE_PREPARES]) + || $driverOptions[\PDO::PGSQL_ATTR_DISABLE_PREPARES] === true ) ) { - $pdo->setAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES, true); + $pdo->setAttribute(\PDO::PGSQL_ATTR_DISABLE_PREPARES, true); } /* defining client_encoding via SET NAMES to avoid inconsistent DSN support diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index 304043b9cdd..0c3b3900059 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLiteDriver; -use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; @@ -12,6 +12,8 @@ /** * The PDO Sqlite driver. + * + * @deprecated Use {@link PDO\SQLite\Driver} instead. */ class Driver extends AbstractSQLiteDriver { @@ -36,7 +38,7 @@ public function connect(array $params, $username = null, $password = null, array } try { - $pdo = new Connection( + $pdo = new PDO\Connection( $this->_constructPdoDsn($params), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index d0262dcf6a7..1fdb545dd40 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -2,10 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Connection as BaseConnection; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; -use PDO; use function is_string; use function strpos; @@ -13,8 +12,10 @@ /** * Sqlsrv Connection implementation. + * + * @deprecated Use {@link PDO\SQLSrv\Connection} instead. */ -class Connection extends BaseConnection +class Connection extends PDO\Connection { /** * @internal The connection can be only instantiated by its driver. @@ -24,7 +25,7 @@ class Connection extends BaseConnection public function __construct($dsn, $user = null, $password = null, ?array $options = null) { parent::__construct($dsn, $user, $password, $options); - $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, [Statement::class, []]); + $this->setAttribute(\PDO::ATTR_STATEMENT_CLASS, [PDO\SQLSrv\Statement::class, []]); } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php index bd0fd6a665c..d8f22505561 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Driver.php @@ -4,12 +4,15 @@ use Doctrine\DBAL\Driver\AbstractSQLServerDriver; use Doctrine\DBAL\Driver\AbstractSQLServerDriver\Exception\PortWithoutHost; +use Doctrine\DBAL\Driver\PDO; use function is_int; use function sprintf; /** * The PDO-based Sqlsrv driver. + * + * @deprecated Use {@link PDO\SQLSrv\Driver} instead. */ class Driver extends AbstractSQLServerDriver { @@ -28,7 +31,7 @@ public function connect(array $params, $username = null, $password = null, array } } - return new Connection( + return new PDO\SQLSrv\Connection( $this->_constructPdoDsn($params, $dsnOptions), $username, $password, diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index 7091eb375a3..3ce8ef8d60f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -2,14 +2,15 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv; -use Doctrine\DBAL\Driver\PDO\Statement as BaseStatement; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\ParameterType; -use PDO; /** * PDO SQL Server Statement + * + * @deprecated Use {@link PDO\SQLSrv\Statement} instead. */ -class Statement extends BaseStatement +class Statement extends PDO\Statement { /** * {@inheritdoc} @@ -20,7 +21,7 @@ public function bindParam($column, &$variable, $type = ParameterType::STRING, $l ($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) && $driverOptions === null ) { - $driverOptions = PDO::SQLSRV_ENCODING_BINARY; + $driverOptions = \PDO::SQLSRV_ENCODING_BINARY; } return parent::bindParam($column, $variable, $type, $length, $driverOptions); diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 691e7d42ca6..ed02e3a5b9e 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -3,18 +3,13 @@ namespace Doctrine\DBAL; use Doctrine\Common\EventManager; -use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySQLDriver; -use Doctrine\DBAL\Driver\IBMDB2\Driver as IBMDB2Driver; -use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; -use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver; -use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOCIDriver; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; -use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSQLiteDriver; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver; -use Doctrine\DBAL\Driver\SQLAnywhere\Driver as SQLAnywhereDriver; -use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; -use PDO; +use Doctrine\DBAL\Driver\DrizzlePDOMySql; +use Doctrine\DBAL\Driver\IBMDB2; +use Doctrine\DBAL\Driver\Mysqli; +use Doctrine\DBAL\Driver\OCI8; +use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Driver\SQLAnywhere; +use Doctrine\DBAL\Driver\SQLSrv; use function array_keys; use function array_map; @@ -45,17 +40,17 @@ final class DriverManager * @var string[] */ private static $_driverMap = [ - 'pdo_mysql' => PDOMySQLDriver::class, - 'pdo_sqlite' => PDOSQLiteDriver::class, - 'pdo_pgsql' => PDOPgSQLDriver::class, - 'pdo_oci' => PDOOCIDriver::class, - 'oci8' => OCI8Driver::class, - 'ibm_db2' => IBMDB2Driver::class, - 'pdo_sqlsrv' => PDOSQLSrvDriver::class, - 'mysqli' => MySQLiDriver::class, - 'drizzle_pdo_mysql' => DrizzlePDOMySQLDriver::class, - 'sqlanywhere' => SQLAnywhereDriver::class, - 'sqlsrv' => SQLSrvDriver::class, + 'pdo_mysql' => PDO\MySQL\Driver::class, + 'pdo_sqlite' => PDO\SQLite\Driver::class, + 'pdo_pgsql' => PDO\PgSQL\Driver::class, + 'pdo_oci' => PDO\OCI\Driver::class, + 'oci8' => OCI8\Driver::class, + 'ibm_db2' => IBMDB2\Driver::class, + 'pdo_sqlsrv' => PDO\SQLSrv\Driver::class, + 'mysqli' => Mysqli\Driver::class, + 'drizzle_pdo_mysql' => DrizzlePDOMySql\Driver::class, + 'sqlanywhere' => SQLAnywhere\Driver::class, + 'sqlsrv' => SQLSrv\Driver::class, ]; /** @@ -177,13 +172,13 @@ public static function getConnection( } // check for existing pdo object - if (isset($params['pdo']) && ! $params['pdo'] instanceof PDO) { + if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) { throw DBALException::invalidPdoInstance(); } if (isset($params['pdo'])) { - $params['pdo']->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $params['driver'] = 'pdo_' . $params['pdo']->getAttribute(PDO::ATTR_DRIVER_NAME); + $params['pdo']->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); + $params['driver'] = 'pdo_' . $params['pdo']->getAttribute(\PDO::ATTR_DRIVER_NAME); } else { self::_checkParams($params); } diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 2cba7534710..a0007208bd5 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -135,7 +135,7 @@ public function testGetPassword(): void public function testGetDriver(): void { - self::assertInstanceOf(\Doctrine\DBAL\Driver\PDOMySql\Driver::class, $this->connection->getDriver()); + self::assertInstanceOf(Driver\PDO\MySQL\Driver::class, $this->connection->getDriver()); } public function testGetEventManager(): void diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php index e67a0673402..9eef41ed4f5 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOMySql/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOMySql; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOMySql\Driver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest; class DriverTest extends AbstractMySQLDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php index ae647cbe0cd..3042d6633ec 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOOracle/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOOracle; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOOracle\Driver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver; use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest; class DriverTest extends AbstractOracleDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php index 1607207cc47..0e25298e9eb 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOPgSql/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDO\Connection; -use Doctrine\DBAL\Driver\PDOPgSql\Driver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use Doctrine\Tests\TestUtil; use PDO; diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php index b360a46cba6..004bb00f50a 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlite/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOSqlite; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlite\Driver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\Tests\DBAL\Driver\AbstractSQLiteDriverTest; class DriverTest extends AbstractSQLiteDriverTest diff --git a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php index e3ee50ff293..c83dd1cfb1b 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/PDOSqlsrv/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Driver\PDOSqlsrv; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver; use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest; class DriverTest extends AbstractSQLServerDriverTest diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index c88190f99f0..67b7a1f7f33 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -7,8 +7,8 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver; -use Doctrine\DBAL\Driver\PDOMySql\Driver as PDOMySQLDriver; -use Doctrine\DBAL\Driver\PDOSqlite\Driver as PDOSqliteDriver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDOMySQLDriver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver as PDOSQLiteDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -277,42 +277,42 @@ public function databaseUrls(): iterable 'sqlite://localhost/foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite absolute URL with host' => [ 'sqlite://localhost//tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite relative URL without host' => [ 'sqlite:///foo/dbname.sqlite', [ 'path' => 'foo/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite absolute URL without host' => [ 'sqlite:////tmp/dbname.sqlite', [ 'path' => '/tmp/dbname.sqlite', - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite memory' => [ 'sqlite:///:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'sqlite memory with host' => [ 'sqlite://localhost/:memory:', [ 'memory' => true, - 'driver' => PDOSqliteDriver::class, + 'driver' => PDOSQLiteDriver::class, ], ], 'params parsed from URL override individual params' => [ diff --git a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php index 20ea0870476..1683e666018 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/BlobTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use Doctrine\DBAL\Driver\OCI8\Driver as OCI8Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; @@ -23,7 +23,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDO\OCI\Driver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 785d0ac33d2..0861608d888 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -9,7 +9,7 @@ use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -945,7 +945,7 @@ private function beforeFetchClassTest(): void $this->markTestSkipped('Mysqli driver dont support this feature.'); } - if (! $driver instanceof PDOOracleDriver) { + if (! $driver instanceof PDOOCIDriver) { return; } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php index 602e4b541ce..c7a7507b75a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php @@ -4,9 +4,9 @@ use Doctrine\DBAL\Driver\PDO\Connection; use Doctrine\DBAL\Driver\PDO\Exception; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; -use Doctrine\DBAL\Driver\PDOPgSql\Driver as PDOPgSQLDriver; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSRVDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver as PDOPgSQLDriver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver as PDOSQLSrvDriver; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; @@ -73,7 +73,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void { $driver = $this->connection->getDriver(); - if ($driver instanceof PDOSQLSRVDriver) { + if ($driver instanceof PDOSQLSrvDriver) { $this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.'); } @@ -81,7 +81,7 @@ public function testThrowsWrappedExceptionOnPrepare(): void // even though emulated prepared statements are disabled, // so an exception is thrown only eventually. if ( - $driver instanceof PDOOracleDriver + $driver instanceof PDOOCIDriver || $driver instanceof PDOPgSQLDriver ) { self::markTestSkipped(sprintf( diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php index ebe6461c20a..0689c31abc8 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOMySql/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOMySql; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOMySql\Driver; +use Doctrine\DBAL\Driver\PDO\MySQL\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php index 0aa54ac92e0..d246c58ef0b 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOOracle/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOOracle; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOOracle\Driver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php index 3dc08b7e6e7..5cea99378f7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOPgSql/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOPgSql\Driver; +use Doctrine\DBAL\Driver\PDO\PgSQL\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php index d659815cac6..46672e88794 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlite/DriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlite; use Doctrine\DBAL\Driver as DriverInterface; -use Doctrine\DBAL\Driver\PDOSqlite\Driver; +use Doctrine\DBAL\Driver\PDO\SQLite\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use function extension_loaded; diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php index 5e52b5ca204..96f76ac4fdf 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOSqlsrv/DriverTest.php @@ -4,7 +4,7 @@ use Doctrine\DBAL\Driver as DriverInterface; use Doctrine\DBAL\Driver\PDO\Connection; -use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; +use Doctrine\DBAL\Driver\PDO\SQLSrv\Driver; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\TestUtil; use PDO; diff --git a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php index bf3f4abab67..ac028f323cf 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/StatementTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Functional; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; @@ -27,7 +27,7 @@ protected function setUp(): void public function testStatementIsReusableAfterClosingCursor(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } @@ -52,7 +52,7 @@ public function testStatementIsReusableAfterClosingCursor(): void public function testReuseStatementWithLongerResults(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()'); } @@ -89,7 +89,7 @@ public function testReuseStatementWithLongerResults(): void public function testFetchLongBlob(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); @@ -154,7 +154,7 @@ public function testIncompletelyFetchedStatementDoesNotBlockConnection(): void public function testReuseStatementAfterClosingCursor(): void { - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181'); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php index b987905569e..512bb9f1bc7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\DBAL\Functional; use DateTime; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; @@ -120,7 +120,7 @@ public static function floatProvider(): iterable */ public function testIdempotentConversionToString(string $type, $originalValue): void { - if ($type === 'text' && $this->connection->getDriver() instanceof PDOOracleDriver) { + if ($type === 'text' && $this->connection->getDriver() instanceof PDOOCIDriver) { // inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported // see http://php.net/manual/en/pdo.lobs.php#example-1035 $this->markTestSkipped('DBAL doesn\'t support storing LOBs represented as streams using PDO_OCI'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php index 70217b09ede..2c84cce461f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/BinaryTest.php @@ -5,7 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Types; use Doctrine\DBAL\Driver\IBMDB2\Driver; -use Doctrine\DBAL\Driver\PDOOracle\Driver as PDOOracleDriver; +use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Schema\Table; use Doctrine\Tests\DbalFunctionalTestCase; @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); - if ($this->connection->getDriver() instanceof PDOOracleDriver) { + if ($this->connection->getDriver() instanceof PDOOCIDriver) { $this->markTestSkipped('PDO_OCI doesn\'t support binding binary values'); } From c4325fd7cd7d8039f19328073085f5ea53d21231 Mon Sep 17 00:00:00 2001 From: Kristjan Siimson Date: Fri, 3 Jul 2020 21:46:59 +0200 Subject: [PATCH 70/93] Add support for MYSQLI_OPT_READ_TIMEOUT --- lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 2e8dd185013..9553296ca06 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -11,7 +11,6 @@ use Doctrine\DBAL\ParameterType; use mysqli; -use function defined; use function floor; use function func_get_args; use function in_array; @@ -28,6 +27,7 @@ use const MYSQLI_INIT_COMMAND; use const MYSQLI_OPT_CONNECT_TIMEOUT; use const MYSQLI_OPT_LOCAL_INFILE; +use const MYSQLI_OPT_READ_TIMEOUT; use const MYSQLI_READ_DEFAULT_FILE; use const MYSQLI_READ_DEFAULT_GROUP; use const MYSQLI_SERVER_PUBLIC_KEY; @@ -243,15 +243,13 @@ private function setDriverOptions(array $driverOptions = []): void $supportedDriverOptions = [ MYSQLI_OPT_CONNECT_TIMEOUT, MYSQLI_OPT_LOCAL_INFILE, + MYSQLI_OPT_READ_TIMEOUT, MYSQLI_INIT_COMMAND, MYSQLI_READ_DEFAULT_FILE, MYSQLI_READ_DEFAULT_GROUP, + MYSQLI_SERVER_PUBLIC_KEY, ]; - if (defined('MYSQLI_SERVER_PUBLIC_KEY')) { - $supportedDriverOptions[] = MYSQLI_SERVER_PUBLIC_KEY; - } - $exceptionMsg = "%s option '%s' with value '%s'"; foreach ($driverOptions as $option => $value) { From 66d682179d9fefde0fa6d8868430cb721469bc33 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 3 Jul 2020 19:16:30 -0700 Subject: [PATCH 71/93] Add TypeRegistry constructor --- lib/Doctrine/DBAL/Types/Type.php | 6 +++--- lib/Doctrine/DBAL/Types/TypeRegistry.php | 10 +++++++++- tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php | 7 ++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index 6dd4e9abb30..8a6a7cd7466 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -208,13 +208,13 @@ final public static function getTypeRegistry(): TypeRegistry private static function createTypeRegistry(): TypeRegistry { - $registry = new TypeRegistry(); + $instances = []; foreach (self::BUILTIN_TYPES_MAP as $name => $class) { - $registry->register($name, new $class()); + $instances[$name] = new $class(); } - return $registry; + return new TypeRegistry($instances); } /** diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index 362a5ccc9a4..4c2e31ecbcf 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -18,7 +18,15 @@ final class TypeRegistry { /** @var array Map of type names and their corresponding flyweight objects. */ - private $instances = []; + private $instances; + + /** + * @param array $instances + */ + public function __construct(array $instances = []) + { + $this->instances = $instances; + } /** * Finds a type by the given name. diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index be4ba0dddfe..98b0fd99a40 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -31,9 +31,10 @@ protected function setUp(): void $this->testType = new BlobType(); $this->otherTestType = new BinaryType(); - $this->registry = new TypeRegistry(); - $this->registry->register(self::TEST_TYPE_NAME, $this->testType); - $this->registry->register(self::OTHER_TEST_TYPE_NAME, $this->otherTestType); + $this->registry = new TypeRegistry([ + self::TEST_TYPE_NAME => $this->testType, + self::OTHER_TEST_TYPE_NAME => $this->otherTestType, + ]); } public function testGet(): void From 524a23b045d899a620f27f369acee7accf76cb2b Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 10 Jul 2020 19:03:16 -0700 Subject: [PATCH 72/93] Deprecate executeUpdate() in favor of executeStatement() --- UPGRADE.md | 4 ++ .../data-retrieval-and-manipulation.rst | 12 ++--- docs/en/reference/security.rst | 2 +- docs/en/reference/sharding_azure_tutorial.rst | 2 +- docs/examples/sharding/insert_data.php | 2 +- lib/Doctrine/DBAL/Connection.php | 47 +++++++++++++++---- .../PrimaryReadReplicaConnection.php | 16 ++++++- .../DBAL/Event/Listeners/MysqlSessionInit.php | 2 +- .../Event/Listeners/OracleSessionInit.php | 2 +- lib/Doctrine/DBAL/Id/TableGenerator.php | 2 +- lib/Doctrine/DBAL/Query/QueryBuilder.php | 5 +- .../DBAL/Schema/AbstractSchemaManager.php | 2 +- .../DBAL/Schema/OracleSchemaManager.php | 6 +-- .../Tools/Console/Command/RunSqlCommand.php | 2 +- .../Tests/DBAL/Connection/LoggingTest.php | 4 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 28 +++++------ .../DBAL/Events/MysqlSessionInitTest.php | 2 +- .../DBAL/Events/OracleSessionInitTest.php | 4 +- .../Tests/DBAL/Functional/DataAccessTest.php | 8 ++-- .../Functional/Driver/OCI8/ConnectionTest.php | 2 +- .../Tests/DBAL/Functional/ExceptionTest.php | 2 +- .../Functional/MasterSlaveConnectionTest.php | 2 +- .../PrimaryReadReplicaConnectionTest.php | 2 +- .../Schema/MySqlSchemaManagerTest.php | 2 +- .../SchemaManagerFunctionalTestCase.php | 2 +- .../DBAL/Functional/TemporaryTableTest.php | 2 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 4 +- .../Tests/DBAL/Functional/WriteTest.php | 18 +++---- .../DBAL/Tools/Console/RunSqlCommandTest.php | 8 ++-- 29 files changed, 118 insertions(+), 78 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 45b4e26383b..ea130f77144 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecations in the wrapper `Connection` class + +1. The `executeUpdate()` method has been deprecated in favor of `executeStatement()`. + ## PDO-related classes outside of the PDO namespace are deprecated The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: diff --git a/docs/en/reference/data-retrieval-and-manipulation.rst b/docs/en/reference/data-retrieval-and-manipulation.rst index e1afd8ec322..8a88deb6a64 100644 --- a/docs/en/reference/data-retrieval-and-manipulation.rst +++ b/docs/en/reference/data-retrieval-and-manipulation.rst @@ -142,7 +142,7 @@ use prepared statements: SQL query, bind the given params with their binding types and execute the query. This method returns the executed prepared statement for iteration and is useful for SELECT statements. -- ``executeUpdate($sql, $params, $types)`` - Create a prepared statement for the passed +- ``executeStatement($sql, $params, $types)`` - Create a prepared statement for the passed SQL query, bind the given params with their binding types and execute the query. This method returns the number of affected rows by the executed query and is useful for UPDATE, DELETE and INSERT statements. @@ -170,7 +170,7 @@ of this query using the fetch API of a statement: The fetch API of a prepared statement obviously works only for ``SELECT`` queries. If you find it tedious to write all the prepared statement code you can alternatively use -the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#executeUpdate()`` +the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#executeStatement()`` methods. See the API section below on details how to use them. Additionally there are lots of convenience methods for data-retrieval and manipulation @@ -208,7 +208,7 @@ which means this code works independent of the database you are using. .. note:: Be aware this type conversion only works with ``Statement#bindValue()``, - ``Connection#executeQuery()`` and ``Connection#executeUpdate()``. It + ``Connection#executeQuery()`` and ``Connection#executeStatement()``. It is not supported to pass a doctrine type name to ``Statement#bindParam()``, because this would not work with binding by reference. @@ -286,7 +286,7 @@ This is much more complicated and is ugly to write generically. .. note:: The parameter list support only works with ``Doctrine\DBAL\Connection::executeQuery()`` - and ``Doctrine\DBAL\Connection::executeUpdate()``, NOT with the binding methods of + and ``Doctrine\DBAL\Connection::executeStatement()``, NOT with the binding methods of a prepared statement. API @@ -319,7 +319,7 @@ Prepare a given SQL statement and return the ) */ -executeUpdate() +executeStatement() ~~~~~~~~~~~~~~~ Executes a prepared statement with the given SQL and parameters and @@ -328,7 +328,7 @@ returns the affected rows count: .. code-block:: php executeUpdate('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1)); + $count = $conn->executeStatement('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1)); echo $count; // 1 The ``$types`` variable contains the PDO or Doctrine Type constants diff --git a/docs/en/reference/security.rst b/docs/en/reference/security.rst index 82f159c87fb..89e19636922 100644 --- a/docs/en/reference/security.rst +++ b/docs/en/reference/security.rst @@ -135,7 +135,7 @@ are using just the DBAL there are also helper methods which simplify the usage q $sql = "SELECT * FROM users WHERE username = ?"; $stmt = $connection->executeQuery($sql, array($_GET['username'])); -There is also ``executeUpdate`` which does not return a statement but the number of affected rows. +There is also ``executeStatement`` which does not return a statement but the number of affected rows. Besides binding parameters you can also pass the type of the variable. This allows Doctrine or the underlying vendor to not only escape but also cast the value to the correct type. See the docs on querying and DQL in the diff --git a/docs/en/reference/sharding_azure_tutorial.rst b/docs/en/reference/sharding_azure_tutorial.rst index 71a4fab5594..cb8e85d488d 100644 --- a/docs/en/reference/sharding_azure_tutorial.rst +++ b/docs/en/reference/sharding_azure_tutorial.rst @@ -263,7 +263,7 @@ operation for us: 'LastName' => 'Brehm', )); - $conn->executeUpdate("DECLARE @orderId INT + $conn->executeStatement("DECLARE @orderId INT DECLARE @customerId INT diff --git a/docs/examples/sharding/insert_data.php b/docs/examples/sharding/insert_data.php index 57aeda6c9f8..9d6e5aabcff 100644 --- a/docs/examples/sharding/insert_data.php +++ b/docs/examples/sharding/insert_data.php @@ -90,7 +90,7 @@ 'LastName' => 'Brehm', )); -$conn->executeUpdate(" +$conn->executeStatement(" DECLARE @orderId INT DECLARE @customerId INT diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 29eda274608..3aa16f2b20b 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -749,7 +749,7 @@ public function delete($tableExpression, array $identifier, array $types = []) $this->addIdentifierCondition($identifier, $columns, $values, $conditions); - return $this->executeUpdate( + return $this->executeStatement( 'DELETE FROM ' . $tableExpression . ' WHERE ' . implode(' AND ', $conditions), $values, is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types @@ -777,7 +777,7 @@ public function setTransactionIsolation($level) { $this->transactionIsolationLevel = $level; - return $this->executeUpdate($this->getDatabasePlatform()->getSetTransactionIsolationSQL($level)); + return $this->executeStatement($this->getDatabasePlatform()->getSetTransactionIsolationSQL($level)); } /** @@ -827,7 +827,7 @@ public function update($tableExpression, array $data, array $identifier, array $ $sql = 'UPDATE ' . $tableExpression . ' SET ' . implode(', ', $set) . ' WHERE ' . implode(' AND ', $conditions); - return $this->executeUpdate($sql, $values, $types); + return $this->executeStatement($sql, $values, $types); } /** @@ -846,7 +846,7 @@ public function update($tableExpression, array $data, array $identifier, array $ public function insert($tableExpression, array $data, array $types = []) { if (empty($data)) { - return $this->executeUpdate('INSERT INTO ' . $tableExpression . ' () VALUES ()'); + return $this->executeStatement('INSERT INTO ' . $tableExpression . ' () VALUES ()'); } $columns = []; @@ -859,7 +859,7 @@ public function insert($tableExpression, array $data, array $types = []) $set[] = '?'; } - return $this->executeUpdate( + return $this->executeStatement( 'INSERT INTO ' . $tableExpression . ' (' . implode(', ', $columns) . ')' . ' VALUES (' . implode(', ', $set) . ')', $values, @@ -1285,6 +1285,8 @@ public function query() * * This method supports PDO binding types as well as DBAL mapping types. * + * @deprecated Use {@link executeStatement()} instead. + * * @param string $query The SQL query. * @param array $params The query parameters. * @param array $types The parameter types. @@ -1294,19 +1296,44 @@ public function query() * @throws DBALException */ public function executeUpdate($query, array $params = [], array $types = []) + { + return $this->executeStatement($query, $params, $types); + } + + /** + * Executes an SQL statement with the given parameters and returns the number of affected rows. + * + * Could be used for: + * - DML statements: INSERT, UPDATE, DELETE, etc. + * - DDL statements: CREATE, DROP, ALTER, etc. + * - DCL statements: GRANT, REVOKE, etc. + * - Session control statements: ALTER SESSION, SET, DECLARE, etc. + * - Other statements that don't yield a row set. + * + * This method supports PDO binding types as well as DBAL mapping types. + * + * @param string $sql The statement SQL + * @param array $params The query parameters + * @param array $types The parameter types + * + * @return int The number of affected rows. + * + * @throws DBALException + */ + public function executeStatement($sql, array $params = [], array $types = []) { $connection = $this->getWrappedConnection(); $logger = $this->_config->getSQLLogger(); if ($logger) { - $logger->startQuery($query, $params, $types); + $logger->startQuery($sql, $params, $types); } try { if ($params) { - [$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types); + [$sql, $params, $types] = SQLParserUtils::expandListParameters($sql, $params, $types); - $stmt = $connection->prepare($query); + $stmt = $connection->prepare($sql); if ($types) { $this->_bindTypedValues($stmt, $params, $types); @@ -1317,10 +1344,10 @@ public function executeUpdate($query, array $params = [], array $types = []) $result = $stmt->rowCount(); } else { - $result = $connection->exec($query); + $result = $connection->exec($sql); } } catch (Throwable $e) { - $this->handleExceptionDuringQuery($e, $query, $params, $types); + $this->handleExceptionDuringQuery($e, $sql, $params, $types); } if ($logger) { diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index 86aad20d14b..8819d34ecba 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -26,7 +26,7 @@ * * 1. Replica if primary was never picked before and ONLY if 'getWrappedConnection' * or 'executeQuery' is used. - * 2. Primary picked when 'exec', 'executeUpdate', 'insert', 'delete', 'update', 'createSavepoint', + * 2. Primary picked when 'exec', 'executeUpdate', 'executeStatement', 'insert', 'delete', 'update', 'createSavepoint', * 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or * 'prepare' is called. * 3. If Primary was picked once during the lifetime of the connection it will always get picked afterwards. @@ -41,7 +41,7 @@ * Be aware that Connection#executeQuery is a method specifically for READ * operations only. * - * Use Connection#executeUpdate for any SQL statement that changes/updates + * Use Connection#executeStatement for any SQL statement that changes/updates * state in the database (UPDATE, INSERT, DELETE or DDL statements). * * This connection is limited to replica operations using the @@ -256,6 +256,8 @@ protected function chooseConnectionConfiguration($connectionName, $params) /** * {@inheritDoc} + * + * @deprecated Use {@link executeStatement()} instead. */ public function executeUpdate($query, array $params = [], array $types = []) { @@ -264,6 +266,16 @@ public function executeUpdate($query, array $params = [], array $types = []) return parent::executeUpdate($query, $params, $types); } + /** + * {@inheritDoc} + */ + public function executeStatement($query, array $params = [], array $types = []) + { + $this->ensureConnectedToPrimary(); + + return parent::executeStatement($query, $params, $types); + } + /** * {@inheritDoc} */ diff --git a/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php index 9e722904050..8748dd17474 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php @@ -45,7 +45,7 @@ public function __construct($charset = 'utf8', $collation = false) public function postConnect(ConnectionEventArgs $args) { $collation = $this->collation ? ' COLLATE ' . $this->collation : ''; - $args->getConnection()->executeUpdate('SET NAMES ' . $this->charset . $collation); + $args->getConnection()->executeStatement('SET NAMES ' . $this->charset . $collation); } /** diff --git a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index 3e382f72c61..a907716f8ea 100644 --- a/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -61,7 +61,7 @@ public function postConnect(ConnectionEventArgs $args) } $sql = 'ALTER SESSION SET ' . implode(' ', $vars); - $args->getConnection()->executeUpdate($sql); + $args->getConnection()->executeStatement($sql); } /** diff --git a/lib/Doctrine/DBAL/Id/TableGenerator.php b/lib/Doctrine/DBAL/Id/TableGenerator.php index 6b5a62353a4..c6a11a9c5cf 100644 --- a/lib/Doctrine/DBAL/Id/TableGenerator.php +++ b/lib/Doctrine/DBAL/Id/TableGenerator.php @@ -131,7 +131,7 @@ public function nextValue($sequenceName) $sql = 'UPDATE ' . $this->generatorTableName . ' ' . 'SET sequence_value = sequence_value + sequence_increment_by ' . 'WHERE sequence_name = ? AND sequence_value = ?'; - $rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]); + $rows = $this->conn->executeStatement($sql, [$sequenceName, $row['sequence_value']]); if ($rows !== 1) { throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); diff --git a/lib/Doctrine/DBAL/Query/QueryBuilder.php b/lib/Doctrine/DBAL/Query/QueryBuilder.php index 5fe983c59f7..e48c370f709 100644 --- a/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -196,9 +196,6 @@ public function getState() /** * Executes this query using the bound parameters and their types. * - * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} - * for insert, update and delete statements. - * * @return ResultStatement|int */ public function execute() @@ -207,7 +204,7 @@ public function execute() return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes); } - return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes); + return $this->connection->executeStatement($this->getSQL(), $this->params, $this->paramTypes); } /** diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 7f9b8ad6572..93276b21ebc 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -1033,7 +1033,7 @@ protected function _getPortableTableForeignKeyDefinition($tableForeignKey) protected function _execSql($sql) { foreach ((array) $sql as $query) { - $this->_conn->executeUpdate($query); + $this->_conn->executeStatement($query); } } diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 301b7ae0184..f7e6a810577 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -307,10 +307,10 @@ public function createDatabase($database = null) $password = $params['password']; $query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password; - $this->_conn->executeUpdate($query); + $this->_conn->executeStatement($query); $query = 'GRANT DBA TO ' . $username; - $this->_conn->executeUpdate($query); + $this->_conn->executeStatement($query); } /** @@ -324,7 +324,7 @@ public function dropAutoincrement($table) $sql = $this->_platform->getDropAutoincrementSql($table); foreach ($sql as $query) { - $this->_conn->executeUpdate($query); + $this->_conn->executeStatement($query); } return true; diff --git a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php index 68d5a136fdd..82ef07006f5 100644 --- a/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php +++ b/lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php @@ -87,7 +87,7 @@ protected function execute(InputInterface $input, OutputInterface $output) if (stripos($sql, 'select') === 0 || $input->getOption('force-fetch')) { $resultSet = $conn->fetchAllAssociative($sql); } else { - $resultSet = $conn->executeUpdate($sql); + $resultSet = $conn->executeStatement($sql); } $output->write(Dumper::dump($resultSet, (int) $depth)); diff --git a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php index 7ffc32b6e06..9a9da438ab3 100644 --- a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php +++ b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php @@ -22,13 +22,13 @@ public function testLogExecuteQuery(): void ->executeQuery('SELECT * FROM table'); } - public function testLogExecuteUpdate(): void + public function testLogExecuteStatement(): void { $this->createConnection( $this->createStub(DriverConnection::class), 'UPDATE table SET foo = ?' ) - ->executeUpdate('UPDATE table SET foo = ?'); + ->executeStatement('UPDATE table SET foo = ?'); } public function testLogPrepareExecute(): void diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index a0007208bd5..0d4d380993e 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -54,7 +54,7 @@ protected function setUp(): void /** * @return Connection|MockObject */ - private function getExecuteUpdateMockConnection() + private function getExecuteStatementMockConnection() { $driverMock = $this->createMock(Driver::class); @@ -67,7 +67,7 @@ private function getExecuteUpdateMockConnection() $platform = $this->getMockForAbstractClass(AbstractPlatform::class); return $this->getMockBuilder(Connection::class) - ->onlyMethods(['executeUpdate']) + ->onlyMethods(['executeStatement']) ->setConstructorArgs([['platform' => $platform], $driverMock]) ->getMock(); } @@ -203,7 +203,7 @@ public static function getQueryMethods(): iterable ['exec'], ['query'], ['executeQuery'], - ['executeUpdate'], + ['executeStatement'], ['prepare'], ]; } @@ -372,10 +372,10 @@ public function testSwitchingAutoCommitModeCommitsAllCurrentTransactions(): void public function testEmptyInsert(): void { - $conn = $this->getExecuteUpdateMockConnection(); + $conn = $this->getExecuteStatementMockConnection(); $conn->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with('INSERT INTO footable () VALUES ()'); $conn->insert('footable', []); @@ -386,10 +386,10 @@ public function testEmptyInsert(): void */ public function testUpdateWithDifferentColumnsInDataAndIdentifiers(): void { - $conn = $this->getExecuteUpdateMockConnection(); + $conn = $this->getExecuteStatementMockConnection(); $conn->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with( 'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND name = ?', [ @@ -430,10 +430,10 @@ public function testUpdateWithDifferentColumnsInDataAndIdentifiers(): void */ public function testUpdateWithSameColumnInDataAndIdentifiers(): void { - $conn = $this->getExecuteUpdateMockConnection(); + $conn = $this->getExecuteStatementMockConnection(); $conn->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with( 'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND is_edited = ?', [ @@ -473,10 +473,10 @@ public function testUpdateWithSameColumnInDataAndIdentifiers(): void */ public function testUpdateWithIsNull(): void { - $conn = $this->getExecuteUpdateMockConnection(); + $conn = $this->getExecuteStatementMockConnection(); $conn->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with( 'UPDATE TestTable SET text = ?, is_edited = ? WHERE id IS NULL AND name = ?', [ @@ -515,10 +515,10 @@ public function testUpdateWithIsNull(): void */ public function testDeleteWithIsNull(): void { - $conn = $this->getExecuteUpdateMockConnection(); + $conn = $this->getExecuteStatementMockConnection(); $conn->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with( 'DELETE FROM TestTable WHERE id IS NULL AND name = ?', ['foo'], @@ -725,7 +725,7 @@ public static function dataCallConnectOnce(): iterable ['insert', ['tbl', ['data' => 'foo']]], ['update', ['tbl', ['data' => 'bar'], ['id' => 12345]]], ['prepare', ['select * from dual']], - ['executeUpdate', ['insert into tbl (id) values (?)'], [123]], + ['executeStatement', ['insert into tbl (id) values (?)'], [123]], ]; } diff --git a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php index 73df349a832..e2641e60106 100644 --- a/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php @@ -14,7 +14,7 @@ public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with($this->equalTo('SET NAMES foo COLLATE bar')); $eventArgs = new ConnectionEventArgs($connectionMock); diff --git a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php index a9dc64b8855..0de02b2f3c8 100644 --- a/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php +++ b/tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php @@ -16,7 +16,7 @@ public function testPostConnect(): void { $connectionMock = $this->createMock(Connection::class); $connectionMock->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with($this->isType('string')); $eventArgs = new ConnectionEventArgs($connectionMock); @@ -35,7 +35,7 @@ public function testPostConnectQuotesSessionParameterValues(string $name, string ->disableOriginalConstructor() ->getMock(); $connectionMock->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->with($this->stringContains(sprintf('%s = %s', $name, $value))); $eventArgs = new ConnectionEventArgs($connectionMock); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 0861608d888..eb388117140 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -437,12 +437,12 @@ public function testExecuteQueryBindDateTimeType(): void /** * @group DDC-697 */ - public function testExecuteUpdateBindDateTimeType(): void + public function testExecuteStatementBindDateTimeType(): void { $datetime = new DateTime('2010-02-02 20:20:20'); $sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'; - $affectedRows = $this->connection->executeUpdate($sql, [ + $affectedRows = $this->connection->executeStatement($sql, [ 1 => 50, 2 => 'foo', 3 => $datetime, @@ -800,7 +800,7 @@ public function testFetchAllSupportFetchClass(): void public function testFetchAllStyleColumn(): void { $sql = 'DELETE FROM fetch_table'; - $this->connection->executeUpdate($sql); + $this->connection->executeStatement($sql); $this->connection->insert('fetch_table', ['test_int' => 1, 'test_string' => 'foo']); $this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']); @@ -903,7 +903,7 @@ public function testEmptyParameters(): void */ public function testFetchColumnNullValue(): void { - $this->connection->executeUpdate( + $this->connection->executeStatement( 'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)', [2, 'foo'] ); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php index 6f296b6d286..70051407f77 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php @@ -40,7 +40,7 @@ public function testLastInsertIdAcceptsFqn(): void $schemaManager->dropAndCreateTable($table); - $this->connection->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)'); + $this->connection->executeStatement('INSERT INTO DBAL2595 (foo) VALUES (1)'); $schema = $this->connection->getDatabase(); $sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php index 70ce747fca1..95b2224f9d5 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php @@ -201,7 +201,7 @@ public function testForeignKeyConstraintViolationExceptionOnTruncate(): void $this->expectException(Exception\ForeignKeyConstraintViolationException::class); try { - $this->connection->executeUpdate($platform->getTruncateTableSQL('constraint_error_table')); + $this->connection->executeStatement($platform->getTruncateTableSQL('constraint_error_table')); } catch (Exception\ForeignKeyConstraintViolationException $exception) { $this->tearDownForeignKeyConstraintViolationExceptionTest(); diff --git a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php index ac7d84d030e..9cd2b5e3f4f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php @@ -43,7 +43,7 @@ protected function setUp(): void } catch (Throwable $e) { } - $this->connection->executeUpdate('DELETE FROM master_slave_table'); + $this->connection->executeStatement('DELETE FROM master_slave_table'); $this->connection->insert('master_slave_table', ['test_int' => 1]); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php index f2c714940a6..7dd14c355ee 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php @@ -43,7 +43,7 @@ protected function setUp(): void } catch (Throwable $e) { } - $this->connection->executeUpdate('DELETE FROM primary_replica_table'); + $this->connection->executeStatement('DELETE FROM primary_replica_table'); $this->connection->insert('primary_replica_table', ['test_int' => 1]); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php index ce175add9de..3f0d7bf1569 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php @@ -458,7 +458,7 @@ public function testColumnDefaultsAreValid(): void $this->schemaManager->dropAndCreateTable($table); - $this->connection->executeUpdate( + $this->connection->executeStatement( 'INSERT INTO test_column_defaults_are_valid () VALUES()' ); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index 54d7df5abbb..611cc727fa7 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -224,7 +224,7 @@ public function testListNamespaceNames(): void $namespaces = array_map('strtolower', $namespaces); if (! in_array('test_create_schema', $namespaces)) { - $this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')); + $this->connection->executeStatement($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema')); $namespaces = $this->schemaManager->listNamespaceNames(); $namespaces = array_map('strtolower', $namespaces); diff --git a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php index 7ee7fb23ff9..345005b69c3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php @@ -49,7 +49,7 @@ public function testDropTemporaryTableNotAutoCommitTransaction(): void $createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' (' . $platform->getColumnDeclarationListSQL($columnDefinitions) . ')'; - $this->connection->executeUpdate($createTempTableSQL); + $this->connection->executeStatement($createTempTableSQL); $table = new Table('nontemporary'); $table->addColumn('id', 'integer'); diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index ca63bc0dc6d..9f2b1a8ccc3 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -48,7 +48,7 @@ protected function tearDown(): void public function testBooleanConversionSqlLiteral(): void { - $this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)'); + $this->connection->executeStatement('INSERT INTO dbal630 (bool_col) VALUES(false)'); $id = $this->connection->lastInsertId('dbal630_id_seq'); self::assertNotEmpty($id); @@ -59,7 +59,7 @@ public function testBooleanConversionSqlLiteral(): void public function testBooleanConversionBoolParamRealPrepares(): void { - $this->connection->executeUpdate( + $this->connection->executeStatement( 'INSERT INTO dbal630 (bool_col) VALUES(?)', ['false'], [ParameterType::BOOLEAN] diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index aac223c39ff..ce5712f05e1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -32,39 +32,39 @@ protected function setUp(): void } catch (Throwable $e) { } - $this->connection->executeUpdate('DELETE FROM write_table'); + $this->connection->executeStatement('DELETE FROM write_table'); } /** * @group DBAL-80 */ - public function testExecuteUpdateFirstTypeIsNull(): void + public function testExecuteStatementFirstTypeIsNull(): void { $sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)'; - $this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]); + $this->connection->executeStatement($sql, ['text', 1111], [null, ParameterType::INTEGER]); $sql = 'SELECT * FROM write_table WHERE test_string = ? AND test_int = ?'; self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111])); } - public function testExecuteUpdate(): void + public function testExecuteStatement(): void { $sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')'; - $affected = $this->connection->executeUpdate($sql); + $affected = $this->connection->executeStatement($sql); - self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); + self::assertEquals(1, $affected, 'executeStatement() should return the number of affected rows!'); } - public function testExecuteUpdateWithTypes(): void + public function testExecuteStatementWithTypes(): void { $sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'; - $affected = $this->connection->executeUpdate( + $affected = $this->connection->executeStatement( $sql, [1, 'foo'], [ParameterType::INTEGER, ParameterType::STRING] ); - self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); + self::assertEquals(1, $affected, 'executeStatement() should return the number of affected rows!'); } public function testPrepareRowCountReturnsAffectedRows(): void diff --git a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php index 3c9013a0ca7..8a99dd366b8 100644 --- a/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php +++ b/tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php @@ -79,7 +79,7 @@ public function testSelectStatementsPrintsResult(): void public function testUpdateStatementsPrintsAffectedLines(): void { - $this->expectConnectionExecuteUpdate(); + $this->expectConnectionExecuteStatement(); $this->commandTester->execute([ 'command' => $this->command->getName(), @@ -90,11 +90,11 @@ public function testUpdateStatementsPrintsAffectedLines(): void self::assertDoesNotMatchRegularExpression('@array.*1.*@', $this->commandTester->getDisplay()); } - private function expectConnectionExecuteUpdate(): void + private function expectConnectionExecuteStatement(): void { $this->connectionMock ->expects($this->once()) - ->method('executeUpdate') + ->method('executeStatement') ->willReturn(42); $this->connectionMock @@ -111,7 +111,7 @@ private function expectConnectionFetchAllAssociative(): void $this->connectionMock ->expects($this->never()) - ->method('executeUpdate'); + ->method('executeStatement'); } public function testStatementsWithFetchResultPrintsResult(): void From 35e9150dd4813b6460cb3e0148a5ac241e95508e Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 10 Jul 2020 19:04:16 -0700 Subject: [PATCH 73/93] Deprecate query() and exec() in favor of executeQuery() and executeStatement() --- UPGRADE.md | 2 ++ lib/Doctrine/DBAL/Connection.php | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index ea130f77144..c6765ebf1bc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -3,6 +3,8 @@ ## Deprecations in the wrapper `Connection` class 1. The `executeUpdate()` method has been deprecated in favor of `executeStatement()`. +2. The `query()` method has been deprecated in favor of `executeQuery()`. +3. The `exec()` method has been deprecated in favor of `executeStatement()`. ## PDO-related classes outside of the PDO namespace are deprecated diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 3aa16f2b20b..cd4c33109eb 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -1249,6 +1249,8 @@ public function project($query, array $params, Closure $function) /** * Executes an SQL statement, returning a result set as a Statement object. * + * @deprecated Use {@link executeQuery()} instead. + * * @return \Doctrine\DBAL\Driver\Statement * * @throws DBALException @@ -1360,6 +1362,8 @@ public function executeStatement($sql, array $params = [], array $types = []) /** * Executes an SQL statement and return the number of affected rows. * + * @deprecated Use {@link executeStatement()} instead. + * * @param string $statement * * @return int The number of affected rows. From f63be598960bfdb6c0fdaea5aeaaa50f3c25faa7 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 10 Jul 2020 23:19:12 -0700 Subject: [PATCH 74/93] Deprecated usage of wrapper components as implementations of driver-level interfaces --- UPGRADE.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index c6765ebf1bc..54988217d35 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecated usage of wrapper-level components as implementations of driver-level interfaces + +The usage of the wrapper `Connection` and `Statement` classes as implementations of the `Driver\Connection` and `Driver\Statement` interfaces is deprecated. + ## Deprecations in the wrapper `Connection` class 1. The `executeUpdate()` method has been deprecated in favor of `executeStatement()`. @@ -8,7 +12,7 @@ ## PDO-related classes outside of the PDO namespace are deprecated -The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: +The following PDO-related classes outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: - `PDOMySql\Driver` → `PDO\MySQL\Driver` - `PDOOracle\Driver` → `PDO\OCI\Driver` From 82ce8868291f46992297844aabde62bfbaebaa0c Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 21 Jul 2020 13:08:24 -0700 Subject: [PATCH 75/93] Additional deprecation note for PrimaryReplicaConnection::query() --- UPGRADE.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 54988217d35..a467b387e5f 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -10,6 +10,14 @@ The usage of the wrapper `Connection` and `Statement` classes as implementations 2. The `query()` method has been deprecated in favor of `executeQuery()`. 3. The `exec()` method has been deprecated in favor of `executeStatement()`. +Note that `PrimaryReplicaConnection::query()` ensures connection to the primary instance while `executeQuery()` doesn't. + +Depending on the desired behavior: + +- If the statement doesn't have to be executed on the primary instance, use `executeQuery()`. +- If the statement has to be executed on the primary instance and yields rows (e.g. `SELECT`), prepend `executeQuery()` with `ensureConnectedToPrimary()`. +- Otherwise, use `executeStatement()`. + ## PDO-related classes outside of the PDO namespace are deprecated The following PDO-related classes outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace: From a851cbcc2ef09986edda91d27f1d4fd1aa8c0419 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 7 Aug 2020 08:50:31 -0700 Subject: [PATCH 76/93] Update PHPUnit to 9.3 $ composer update phpunit/phpunit nikic/php-parser --with-dependencies --- composer.json | 2 +- composer.lock | 795 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 505 insertions(+), 292 deletions(-) diff --git a/composer.json b/composer.json index 3c6e2abc437..1227ad25080 100644 --- a/composer.json +++ b/composer.json @@ -42,7 +42,7 @@ "jetbrains/phpstorm-stubs": "^2019.1", "nikic/php-parser": "^4.4", "phpstan/phpstan": "^0.12.31", - "phpunit/phpunit": "^9.2", + "phpunit/phpunit": "^9.3", "psalm/plugin-phpunit": "^0.10.0", "symfony/console": "^2.0.5|^3.0|^4.0|^5.0", "vimeo/psalm": "^3.11.4" diff --git a/composer.lock b/composer.lock index 1d893387a7f..8108036b477 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "1bf73ef9ed03dfdeaedaf678dde8ba13", + "content-hash": "5f410c8c6508d1d55fe96b64ab5353e4", "packages": [ { "name": "doctrine/cache", @@ -651,6 +651,10 @@ "constructor", "instantiate" ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.3.x" + }, "funding": [ { "url": "https://www.doctrine-project.org/sponsorship.html", @@ -801,20 +805,20 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.5", + "version": "1.10.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef" + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/b2c28789e80a97badd14145fda39b545d83ca3ef", - "reference": "b2c28789e80a97badd14145fda39b545d83ca3ef", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", + "reference": "969b211f9a51aa1f6c01d1d2aef56d3bd91598e5", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "replace": { "myclabs/deep-copy": "self.version" @@ -845,7 +849,17 @@ "object", "object graph" ], - "time": "2020-01-17T21:11:47+00:00" + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.x" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-06-29T13:22:24+00:00" }, { "name": "netresearch/jsonmapper", @@ -895,16 +909,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.4.0", + "version": "v4.7.0", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120" + "reference": "21dce06dfbf0365c6a7cc8fdbdc995926c6a9300" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", - "reference": "bd43ec7152eaaab3bd8c6d0aa95ceeb1df8ee120", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/21dce06dfbf0365c6a7cc8fdbdc995926c6a9300", + "reference": "21dce06dfbf0365c6a7cc8fdbdc995926c6a9300", "shasum": "" }, "require": { @@ -921,7 +935,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.3-dev" + "dev-master": "4.7-dev" } }, "autoload": { @@ -943,7 +957,11 @@ "parser", "php" ], - "time": "2020-04-10T16:34:50+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/master" + }, + "time": "2020-07-25T13:18:53+00:00" }, { "name": "openlss/lib-array2xml", @@ -996,28 +1014,29 @@ }, { "name": "phar-io/manifest", - "version": "1.0.3", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/phar-io/manifest.git", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4" + "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/manifest/zipball/7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", - "reference": "7761fcacf03b4d4f16e7ccb606d4879ca431fcf4", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", + "reference": "85265efd3af7ba3ca4b2a2c34dbfc5788dd29133", "shasum": "" }, "require": { "ext-dom": "*", "ext-phar": "*", - "phar-io/version": "^2.0", - "php": "^5.6 || ^7.0" + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { @@ -1047,24 +1066,28 @@ } ], "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", - "time": "2018-07-08T19:23:20+00:00" + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/master" + }, + "time": "2020-06-27T14:33:11+00:00" }, { "name": "phar-io/version", - "version": "2.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/phar-io/version.git", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6" + "reference": "c6bb6825def89e0a32220f88337f8ceaf1975fa0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phar-io/version/zipball/45a2ec53a73c70ce41d55cedef9063630abaf1b6", - "reference": "45a2ec53a73c70ce41d55cedef9063630abaf1b6", + "url": "https://api.github.com/repos/phar-io/version/zipball/c6bb6825def89e0a32220f88337f8ceaf1975fa0", + "reference": "c6bb6825def89e0a32220f88337f8ceaf1975fa0", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -1094,29 +1117,33 @@ } ], "description": "Library for handling version information and constraints", - "time": "2018-07-08T19:19:57+00:00" + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/master" + }, + "time": "2020-06-27T14:39:04+00:00" }, { "name": "phpdocumentor/reflection-common", - "version": "2.1.0", + "version": "2.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b" + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/6568f4687e5b41b054365f9ae03fcb1ed5f2069b", - "reference": "6568f4687e5b41b054365f9ae03fcb1ed5f2069b", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "php": ">=7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { @@ -1143,32 +1170,35 @@ "reflection", "static analysis" ], - "time": "2020-04-27T09:25:28+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.1.0", + "version": "5.2.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e" + "reference": "3170448f5769fe19f456173d833734e0ff1b84df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", - "reference": "cd72d394ca794d3466a3b2fc09d5a6c1dc86b47e", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/3170448f5769fe19f456173d833734e0ff1b84df", + "reference": "3170448f5769fe19f456173d833734e0ff1b84df", "shasum": "" }, "require": { - "ext-filter": "^7.1", - "php": "^7.2", - "phpdocumentor/reflection-common": "^2.0", - "phpdocumentor/type-resolver": "^1.0", - "webmozart/assert": "^1" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "doctrine/instantiator": "^1", - "mockery/mockery": "^1" + "mockery/mockery": "~1.3.2" }, "type": "library", "extra": { @@ -1196,34 +1226,37 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2020-02-22T12:28:44+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, + "time": "2020-07-20T20:05:34+00:00" }, { "name": "phpdocumentor/type-resolver", - "version": "1.1.0", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95" + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/7462d5f123dfc080dfdf26897032a6513644fc95", - "reference": "7462d5f123dfc080dfdf26897032a6513644fc95", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e878a14a65245fbe78f8080eba03b47c3b705651", + "reference": "e878a14a65245fbe78f8080eba03b47c3b705651", "shasum": "" }, "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "phpdocumentor/reflection-common": "^2.0" }, "require-dev": { - "ext-tokenizer": "^7.2", - "mockery/mockery": "~1" + "ext-tokenizer": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.x-dev" + "dev-1.x": "1.x-dev" } }, "autoload": { @@ -1242,37 +1275,41 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2020-02-18T18:59:58+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + }, + "time": "2020-06-27T10:12:23+00:00" }, { "name": "phpspec/prophecy", - "version": "v1.10.3", + "version": "1.11.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "451c3cd1418cf640de218914901e51b064abb093" + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/451c3cd1418cf640de218914901e51b064abb093", - "reference": "451c3cd1418cf640de218914901e51b064abb093", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/b20034be5efcdab4fb60ca3a29cba2949aead160", + "reference": "b20034be5efcdab4fb60ca3a29cba2949aead160", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.2.3|^2.0|^3.0|^4.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0|^4.0" + "doctrine/instantiator": "^1.2", + "php": "^7.2", + "phpdocumentor/reflection-docblock": "^5.0", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" }, "require-dev": { - "phpspec/phpspec": "^2.5 || ^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.10.x-dev" + "dev-master": "1.11.x-dev" } }, "autoload": { @@ -1305,7 +1342,11 @@ "spy", "stub" ], - "time": "2020-03-05T15:02:03+00:00" + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/master" + }, + "time": "2020-07-08T12:44:21+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -1414,32 +1455,35 @@ }, { "name": "phpunit/php-code-coverage", - "version": "8.0.2", + "version": "9.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc" + "reference": "ee24e82baca11d7d6fb3513e127d6000f541cf90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ca6647ffddd2add025ab3f21644a441d7c146cdc", - "reference": "ca6647ffddd2add025ab3f21644a441d7c146cdc", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ee24e82baca11d7d6fb3513e127d6000f541cf90", + "reference": "ee24e82baca11d7d6fb3513e127d6000f541cf90", "shasum": "" }, "require": { "ext-dom": "*", + "ext-libxml": "*", "ext-xmlwriter": "*", - "php": "^7.3", - "phpunit/php-file-iterator": "^3.0", - "phpunit/php-text-template": "^2.0", - "phpunit/php-token-stream": "^4.0", - "sebastian/code-unit-reverse-lookup": "^2.0", - "sebastian/environment": "^5.0", - "sebastian/version": "^3.0", - "theseer/tokenizer": "^1.1.3" + "nikic/php-parser": "^4.7", + "php": "^7.3 || ^8.0", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" }, "require-dev": { - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-pcov": "*", @@ -1448,7 +1492,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "8.0-dev" + "dev-master": "9.0-dev" } }, "autoload": { @@ -1474,30 +1518,34 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.0.0" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-05-23T08:02:54+00:00" + "time": "2020-08-07T04:12:30+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "3.0.2", + "version": "3.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2" + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2", - "reference": "eba15e538f2bb3fe018b7bbb47d2fe32d404bfd2", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/25fefc5b19835ca653877fe081644a3f8c1d915e", + "reference": "25fefc5b19835ca653877fe081644a3f8c1d915e", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -1530,30 +1578,34 @@ "filesystem", "iterator" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.4" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T12:54:35+00:00" + "time": "2020-07-11T05:18:21+00:00" }, { "name": "phpunit/php-invoker", - "version": "3.0.1", + "version": "3.1.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "62f696ad0d140e0e513e69eaafdebb674d622b4c" + "reference": "7a85b66acc48cacffdf87dadd3694e7123674298" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/62f696ad0d140e0e513e69eaafdebb674d622b4c", - "reference": "62f696ad0d140e0e513e69eaafdebb674d622b4c", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/7a85b66acc48cacffdf87dadd3694e7123674298", + "reference": "7a85b66acc48cacffdf87dadd3694e7123674298", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "ext-pcntl": "*", @@ -1565,7 +1617,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1589,30 +1641,34 @@ "keywords": [ "process" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.0" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:10:07+00:00" + "time": "2020-08-06T07:04:15+00:00" }, { "name": "phpunit/php-text-template", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "0c69cbf965d5317ba33f24a352539f354a25db09" + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c69cbf965d5317ba33f24a352539f354a25db09", - "reference": "0c69cbf965d5317ba33f24a352539f354a25db09", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", + "reference": "6ff9c8ea4d3212b88fcf74e25e516e2c51c99324", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -1644,30 +1700,34 @@ "keywords": [ "template" ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T12:52:43+00:00" + "time": "2020-06-26T11:55:37+00:00" }, { "name": "phpunit/php-timer", - "version": "5.0.0", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "b0d089de001ba60ffa3be36b23e1b8150d072238" + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/b0d089de001ba60ffa3be36b23e1b8150d072238", - "reference": "b0d089de001ba60ffa3be36b23e1b8150d072238", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/cc49734779cbb302bf51a44297dab8c4bbf941e7", + "reference": "cc49734779cbb302bf51a44297dab8c4bbf941e7", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.2" @@ -1699,115 +1759,64 @@ "keywords": [ "timer" ], - "funding": [ - { - "url": "https://github.com/sebastianbergmann", - "type": "github" - } - ], - "time": "2020-06-07T12:05:53+00:00" - }, - { - "name": "phpunit/php-token-stream", - "version": "4.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "e61c593e9734b47ef462340c24fca8d6a57da14e" + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/master" }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e61c593e9734b47ef462340c24fca8d6a57da14e", - "reference": "e61c593e9734b47ef462340c24fca8d6a57da14e", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": "^7.3" - }, - "require-dev": { - "phpunit/phpunit": "^9.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-16T07:00:44+00:00" + "time": "2020-06-26T11:58:13+00:00" }, { "name": "phpunit/phpunit", - "version": "9.2.3", + "version": "9.3.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "c1b1d62095ef78427f112a7a1c1502d4607e3c00" + "reference": "eacb57f3857cb6706550bd39ea500f9b1097b0bf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1b1d62095ef78427f112a7a1c1502d4607e3c00", - "reference": "c1b1d62095ef78427f112a7a1c1502d4607e3c00", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/eacb57f3857cb6706550bd39ea500f9b1097b0bf", + "reference": "eacb57f3857cb6706550bd39ea500f9b1097b0bf", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2.0", + "doctrine/instantiator": "^1.3.1", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.9.1", - "phar-io/manifest": "^1.0.3", - "phar-io/version": "^2.0.1", - "php": "^7.3", - "phpspec/prophecy": "^1.8.1", - "phpunit/php-code-coverage": "^8.0.1", - "phpunit/php-file-iterator": "^3.0", - "phpunit/php-invoker": "^3.0", - "phpunit/php-text-template": "^2.0", - "phpunit/php-timer": "^5.0", - "sebastian/code-unit": "^1.0.2", - "sebastian/comparator": "^4.0", - "sebastian/diff": "^4.0", - "sebastian/environment": "^5.0.1", - "sebastian/exporter": "^4.0", - "sebastian/global-state": "^4.0", - "sebastian/object-enumerator": "^4.0", - "sebastian/resource-operations": "^3.0", - "sebastian/type": "^2.1", - "sebastian/version": "^3.0" + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.1", + "phar-io/version": "^3.0.2", + "php": "^7.3 || ^8.0", + "phpspec/prophecy": "^1.11.1", + "phpunit/php-code-coverage": "^9.0", + "phpunit/php-file-iterator": "^3.0.4", + "phpunit/php-invoker": "^3.1", + "phpunit/php-text-template": "^2.0.2", + "phpunit/php-timer": "^5.0.1", + "sebastian/code-unit": "^1.0.5", + "sebastian/comparator": "^4.0.3", + "sebastian/diff": "^4.0.2", + "sebastian/environment": "^5.1.2", + "sebastian/exporter": "^4.0.2", + "sebastian/global-state": "^5.0", + "sebastian/object-enumerator": "^4.0.2", + "sebastian/resource-operations": "^3.0.2", + "sebastian/type": "^2.2.1", + "sebastian/version": "^3.0.1" }, "require-dev": { "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0" + "phpspec/prophecy-phpunit": "^2.0.1" }, "suggest": { "ext-soap": "*", @@ -1819,7 +1828,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.2-dev" + "dev-master": "9.3-dev" } }, "autoload": { @@ -1848,6 +1857,10 @@ "testing", "xunit" ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.3.2" + }, "funding": [ { "url": "https://phpunit.de/donate.html", @@ -1858,7 +1871,7 @@ "type": "github" } ], - "time": "2020-06-15T10:51:34+00:00" + "time": "2020-08-07T09:12:30+00:00" }, { "name": "psalm/plugin-phpunit", @@ -2009,20 +2022,20 @@ }, { "name": "sebastian/code-unit", - "version": "1.0.3", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit.git", - "reference": "d650ef9b1fece15ed4d6eaed6e6b469b7b81183a" + "reference": "c1e2df332c905079980b119c4db103117e5e5c90" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/d650ef9b1fece15ed4d6eaed6e6b469b7b81183a", - "reference": "d650ef9b1fece15ed4d6eaed6e6b469b7b81183a", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/c1e2df332c905079980b119c4db103117e5e5c90", + "reference": "c1e2df332c905079980b119c4db103117e5e5c90", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2051,30 +2064,34 @@ ], "description": "Collection of value objects that represent the PHP code units", "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:11:26+00:00" + "time": "2020-06-26T12:50:45+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "c771130f0e8669104a4320b7101a81c2cc2963ef" + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c771130f0e8669104a4320b7101a81c2cc2963ef", - "reference": "c771130f0e8669104a4320b7101a81c2cc2963ef", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ee51f9bb0c6d8a43337055db3120829fa14da819", + "reference": "ee51f9bb0c6d8a43337055db3120829fa14da819", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2102,30 +2119,34 @@ ], "description": "Looks up which function or method a line of code belongs to", "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T12:56:39+00:00" + "time": "2020-06-26T12:04:00+00:00" }, { "name": "sebastian/comparator", - "version": "4.0.2", + "version": "4.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "266d85ef789da8c41f06af4093c43e9798af2784" + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/266d85ef789da8c41f06af4093c43e9798af2784", - "reference": "266d85ef789da8c41f06af4093c43e9798af2784", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", + "reference": "dcc580eadfaa4e7f9d2cf9ae1922134ea962e14f", "shasum": "" }, "require": { - "php": "^7.3", + "php": "^7.3 || ^8.0", "sebastian/diff": "^4.0", "sebastian/exporter": "^4.0" }, @@ -2172,30 +2193,91 @@ "compare", "equality" ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/master" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:05:46+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "33fcd6a26656c6546f70871244ecba4b4dced097" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/33fcd6a26656c6546f70871244ecba4b4dced097", + "reference": "33fcd6a26656c6546f70871244ecba4b4dced097", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.0" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T15:04:48+00:00" + "time": "2020-07-25T14:01:34+00:00" }, { "name": "sebastian/diff", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a" + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3e523c576f29dacecff309f35e4cc5a5c168e78a", - "reference": "3e523c576f29dacecff309f35e4cc5a5c168e78a", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", + "reference": "1e90b4cf905a7d06c420b1d2e9d11a4dc8a13113", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0", @@ -2234,30 +2316,34 @@ "unidiff", "unified diff" ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-05-08T05:01:12+00:00" + "time": "2020-06-30T04:46:02+00:00" }, { "name": "sebastian/environment", - "version": "5.1.1", + "version": "5.1.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "16eb0fa43e29c33d7f2117ed23072e26fc5ab34e" + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/16eb0fa43e29c33d7f2117ed23072e26fc5ab34e", - "reference": "16eb0fa43e29c33d7f2117ed23072e26fc5ab34e", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", + "reference": "0a757cab9d5b7ef49a619f1143e6c9c1bc0fe9d2", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2293,35 +2379,39 @@ "environment", "hhvm" ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:00:01+00:00" + "time": "2020-06-26T12:07:24+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "d12fbca85da932d01d941b59e4b71a0d559db091" + "reference": "571d721db4aec847a0e59690b954af33ebf9f023" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d12fbca85da932d01d941b59e4b71a0d559db091", - "reference": "d12fbca85da932d01d941b59e4b71a0d559db091", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/571d721db4aec847a0e59690b954af33ebf9f023", + "reference": "571d721db4aec847a0e59690b954af33ebf9f023", "shasum": "" }, "require": { - "php": "^7.3", + "php": "^7.3 || ^8.0", "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-mbstring": "*", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.2" }, "type": "library", "extra": { @@ -2366,36 +2456,40 @@ "export", "exporter" ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:12:44+00:00" + "time": "2020-06-26T12:08:55+00:00" }, { "name": "sebastian/global-state", - "version": "4.0.0", + "version": "5.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72" + "reference": "22ae663c951bdc39da96603edc3239ed3a299097" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bdb1e7c79e592b8c82cb1699be3c8743119b8a72", - "reference": "bdb1e7c79e592b8c82cb1699be3c8743119b8a72", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/22ae663c951bdc39da96603edc3239ed3a299097", + "reference": "22ae663c951bdc39da96603edc3239ed3a299097", "shasum": "" }, "require": { - "php": "^7.3", + "php": "^7.3 || ^8.0", "sebastian/object-reflector": "^2.0", "sebastian/recursion-context": "^4.0" }, "require-dev": { "ext-dom": "*", - "phpunit/phpunit": "^9.0" + "phpunit/phpunit": "^9.3" }, "suggest": { "ext-uopz": "*" @@ -2403,7 +2497,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -2426,24 +2520,91 @@ "keywords": [ "global state" ], - "time": "2020-02-07T06:11:37+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-08-07T04:09:03+00:00" + }, + { + "name": "sebastian/lines-of-code", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "e02bf626f404b5daec382a7b8a6a4456e49017e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/e02bf626f404b5daec382a7b8a6a4456e49017e5", + "reference": "e02bf626f404b5daec382a7b8a6a4456e49017e5", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.6", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-07-22T18:33:42+00:00" }, { "name": "sebastian/object-enumerator", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "15f319d67c49fc55ebcdbffb3377433125588455" + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/15f319d67c49fc55ebcdbffb3377433125588455", - "reference": "15f319d67c49fc55ebcdbffb3377433125588455", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/074fed2d0a6d08e1677dd8ce9d32aecb384917b8", + "reference": "074fed2d0a6d08e1677dd8ce9d32aecb384917b8", "shasum": "" }, "require": { - "php": "^7.3", + "php": "^7.3 || ^8.0", "sebastian/object-reflector": "^2.0", "sebastian/recursion-context": "^4.0" }, @@ -2473,30 +2634,34 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:15:25+00:00" + "time": "2020-06-26T12:11:32+00:00" }, { "name": "sebastian/object-reflector", - "version": "2.0.1", + "version": "2.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "14e04b3c25b821cc0702d4837803fe497680b062" + "reference": "127a46f6b057441b201253526f81d5406d6c7840" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/14e04b3c25b821cc0702d4837803fe497680b062", - "reference": "14e04b3c25b821cc0702d4837803fe497680b062", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/127a46f6b057441b201253526f81d5406d6c7840", + "reference": "127a46f6b057441b201253526f81d5406d6c7840", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2524,30 +2689,34 @@ ], "description": "Allows reflection of object attributes, including inherited and non-public ones", "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:08:02+00:00" + "time": "2020-06-26T12:12:55+00:00" }, { "name": "sebastian/recursion-context", - "version": "4.0.1", + "version": "4.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "a32789e5f0157c10cf216ce6c5136db12a12b847" + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/a32789e5f0157c10cf216ce6c5136db12a12b847", - "reference": "a32789e5f0157c10cf216ce6c5136db12a12b847", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/062231bf61d2b9448c4fa5a7643b5e1829c11d63", + "reference": "062231bf61d2b9448c4fa5a7643b5e1829c11d63", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2583,30 +2752,34 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/master" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:06:44+00:00" + "time": "2020-06-26T12:14:17+00:00" }, { "name": "sebastian/resource-operations", - "version": "3.0.1", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/resource-operations.git", - "reference": "71421c1745788de4facae1b79af923650bd3ec15" + "reference": "0653718a5a629b065e91f774595267f8dc32e213" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/71421c1745788de4facae1b79af923650bd3ec15", - "reference": "71421c1745788de4facae1b79af923650bd3ec15", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0653718a5a629b065e91f774595267f8dc32e213", + "reference": "0653718a5a629b065e91f774595267f8dc32e213", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.0" @@ -2634,30 +2807,34 @@ ], "description": "Provides a list of PHP built-in functions that operate on resources", "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.2" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-15T13:17:14+00:00" + "time": "2020-06-26T12:16:22+00:00" }, { "name": "sebastian/type", - "version": "2.1.0", + "version": "2.2.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8" + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8", - "reference": "bad49207c6f854e7a25cef0ea948ac8ebe3ef9d8", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/86991e2b33446cd96e648c18bcdb1e95afb2c05a", + "reference": "86991e2b33446cd96e648c18bcdb1e95afb2c05a", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "require-dev": { "phpunit/phpunit": "^9.2" @@ -2665,7 +2842,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1-dev" + "dev-master": "2.2-dev" } }, "autoload": { @@ -2686,30 +2863,34 @@ ], "description": "Collection of value objects that represent the types of the PHP type system", "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.2.1" + }, "funding": [ { "url": "https://github.com/sebastianbergmann", "type": "github" } ], - "time": "2020-06-01T12:21:09+00:00" + "time": "2020-07-05T08:31:53+00:00" }, { "name": "sebastian/version", - "version": "3.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "0411bde656dce64202b39c2f4473993a9081d39e" + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/0411bde656dce64202b39c2f4473993a9081d39e", - "reference": "0411bde656dce64202b39c2f4473993a9081d39e", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/626586115d0ed31cb71483be55beb759b5af5a3c", + "reference": "626586115d0ed31cb71483be55beb759b5af5a3c", "shasum": "" }, "require": { - "php": "^7.3" + "php": "^7.3 || ^8.0" }, "type": "library", "extra": { @@ -2735,7 +2916,17 @@ ], "description": "Library that helps with managing the version number of Git-hosted PHP projects", "homepage": "https://github.com/sebastianbergmann/version", - "time": "2020-01-21T06:36:37+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-06-26T12:18:43+00:00" }, { "name": "slevomat/coding-standard", @@ -2993,16 +3184,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.17.0", + "version": "v1.18.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9" + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e94c8b1bbe2bc77507a1056cdb06451c75b427f9", - "reference": "e94c8b1bbe2bc77507a1056cdb06451c75b427f9", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/1c302646f6efc070cd46856e600e5e0684d6b454", + "reference": "1c302646f6efc070cd46856e600e5e0684d6b454", "shasum": "" }, "require": { @@ -3014,7 +3205,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.17-dev" + "dev-master": "1.18-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -3047,6 +3242,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.18.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -3061,7 +3259,7 @@ "type": "tidelift" } ], - "time": "2020-05-12T16:14:59+00:00" + "time": "2020-07-14T12:35:20+00:00" }, { "name": "symfony/polyfill-mbstring", @@ -3240,23 +3438,23 @@ }, { "name": "theseer/tokenizer", - "version": "1.1.3", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" + "reference": "75a63c33a8577608444246075ea0af0d052e452a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", - "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/75a63c33a8577608444246075ea0af0d052e452a", + "reference": "75a63c33a8577608444246075ea0af0d052e452a", "shasum": "" }, "require": { "ext-dom": "*", "ext-tokenizer": "*", "ext-xmlwriter": "*", - "php": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", "autoload": { @@ -3276,7 +3474,17 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-06-13T22:48:21+00:00" + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/master" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "time": "2020-07-12T23:59:07+00:00" }, { "name": "vimeo/psalm", @@ -3377,23 +3585,24 @@ }, { "name": "webmozart/assert", - "version": "1.8.0", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozart/assert.git", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/ab2cb0b3b559010b75981b1bdce728da3ee90ad6", - "reference": "ab2cb0b3b559010b75981b1bdce728da3ee90ad6", + "url": "https://api.github.com/repos/webmozart/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { + "phpstan/phpstan": "<0.12.20", "vimeo/psalm": "<3.9.1" }, "require-dev": { @@ -3421,7 +3630,11 @@ "check", "validate" ], - "time": "2020-04-18T12:12:48+00:00" + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, + "time": "2020-07-08T17:02:28+00:00" }, { "name": "webmozart/glob", @@ -3530,5 +3743,5 @@ "platform-overrides": { "php": "7.3.0" }, - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.0.0" } From 568bf0c0b27224a564ee69cae340604b9db4cca3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 7 Aug 2020 08:51:28 -0700 Subject: [PATCH 77/93] Use new configuration parameters and schema --- ci/github/phpunit.oci8.xml | 12 ++++++------ ci/github/phpunit.pdo-oci.xml | 12 ++++++------ phpunit.xml.dist | 12 ++++++------ .../appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml | 11 +++++------ tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml | 11 +++++------ tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml | 11 +++++------ tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml | 11 +++++------ tests/travis/ibm_db2.travis.xml | 10 +++++----- tests/travis/mariadb.docker.travis.xml | 10 +++++----- tests/travis/mariadb.mysqli.docker.travis.xml | 10 +++++----- tests/travis/mysql.docker.travis.xml | 10 +++++----- tests/travis/mysqli.docker.travis.xml | 10 +++++----- tests/travis/pdo_sqlsrv.travis.xml | 10 +++++----- tests/travis/pgsql.travis.xml | 10 +++++----- tests/travis/sqlite.travis.xml | 10 +++++----- tests/travis/sqlsrv.travis.xml | 10 +++++----- 16 files changed, 83 insertions(+), 87 deletions(-) diff --git a/ci/github/phpunit.oci8.xml b/ci/github/phpunit.oci8.xml index 34422a94211..f4454b2f9c4 100644 --- a/ci/github/phpunit.oci8.xml +++ b/ci/github/phpunit.oci8.xml @@ -1,6 +1,6 @@ - - - ../../lib - - + + + ../../lib/Doctrine + + diff --git a/ci/github/phpunit.pdo-oci.xml b/ci/github/phpunit.pdo-oci.xml index 4e899c10a22..900e5ce10b8 100644 --- a/ci/github/phpunit.pdo-oci.xml +++ b/ci/github/phpunit.pdo-oci.xml @@ -1,6 +1,6 @@ - - - ../../lib - - + + + ../../lib/Doctrine + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b093d11854f..6d693d9c924 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -12,7 +12,7 @@ Example: phpunit -c mysqlconf.xml --> - - - lib/Doctrine - - + + + lib/Doctrine + + diff --git a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml index cacadae2cb5..0b53d9dfffe 100644 --- a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml @@ -1,8 +1,7 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml index 9fea8d86683..f2b353ad94f 100644 --- a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml @@ -1,8 +1,7 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml index 88a1ea41b43..9b3f53bb246 100644 --- a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml @@ -1,8 +1,7 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml index ac1cfd08342..2f314611ff4 100644 --- a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml @@ -1,8 +1,7 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/ibm_db2.travis.xml b/tests/travis/ibm_db2.travis.xml index 8e81125da6e..30d3157cc61 100644 --- a/tests/travis/ibm_db2.travis.xml +++ b/tests/travis/ibm_db2.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/mariadb.docker.travis.xml b/tests/travis/mariadb.docker.travis.xml index 6805a5cce84..85c681c6f0d 100644 --- a/tests/travis/mariadb.docker.travis.xml +++ b/tests/travis/mariadb.docker.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/mariadb.mysqli.docker.travis.xml b/tests/travis/mariadb.mysqli.docker.travis.xml index bfb147b7fd9..5c2ed041e37 100644 --- a/tests/travis/mariadb.mysqli.docker.travis.xml +++ b/tests/travis/mariadb.mysqli.docker.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/mysql.docker.travis.xml b/tests/travis/mysql.docker.travis.xml index 6805a5cce84..85c681c6f0d 100644 --- a/tests/travis/mysql.docker.travis.xml +++ b/tests/travis/mysql.docker.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/mysqli.docker.travis.xml b/tests/travis/mysqli.docker.travis.xml index bfb147b7fd9..5c2ed041e37 100644 --- a/tests/travis/mysqli.docker.travis.xml +++ b/tests/travis/mysqli.docker.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/pdo_sqlsrv.travis.xml b/tests/travis/pdo_sqlsrv.travis.xml index 35ba2624cc6..4b813c1a21a 100644 --- a/tests/travis/pdo_sqlsrv.travis.xml +++ b/tests/travis/pdo_sqlsrv.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/pgsql.travis.xml b/tests/travis/pgsql.travis.xml index 7fb828fc7fe..2f9042034f5 100644 --- a/tests/travis/pgsql.travis.xml +++ b/tests/travis/pgsql.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/sqlite.travis.xml b/tests/travis/sqlite.travis.xml index c6e3e291fce..6eacf80bbcc 100644 --- a/tests/travis/sqlite.travis.xml +++ b/tests/travis/sqlite.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + diff --git a/tests/travis/sqlsrv.travis.xml b/tests/travis/sqlsrv.travis.xml index 890fb9d442a..7004fa993d8 100644 --- a/tests/travis/sqlsrv.travis.xml +++ b/tests/travis/sqlsrv.travis.xml @@ -1,6 +1,6 @@ - - + + ../../lib/Doctrine - - + + From 1946a1e11d7d247c634cb48d2dfa87d27de4699b Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Fri, 7 Aug 2020 09:19:33 -0700 Subject: [PATCH 78/93] Rework the usage of the deprecated at() matcher --- .../Tests/DBAL/Connection/LoggingTest.php | 2 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 14 ++-- .../DBAL/Driver/OCI8/OCI8StatementTest.php | 21 ++--- .../Tests/DBAL/Schema/ComparatorTest.php | 24 ++---- .../Doctrine/Tests/DBAL/Schema/SchemaTest.php | 38 ++++------ .../Visitor/CreateSchemaSqlCollectorTest.php | 37 +++++---- .../DBAL/Sharding/PoolingShardManagerTest.php | 76 ++++++++++--------- .../SQLAzure/SQLAzureShardManagerTest.php | 18 +++-- 8 files changed, 105 insertions(+), 125 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php index 9a9da438ab3..290624767ae 100644 --- a/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php +++ b/tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php @@ -54,7 +54,7 @@ private function createConnection(DriverConnection $driverConnection, string $ex $logger->expects($this->once()) ->method('startQuery') ->with($this->equalTo($expectedSQL), $this->equalTo([])); - $logger->expects($this->at(1)) + $logger->expects($this->once()) ->method('stopQuery'); $connection = new Connection([], $driver); diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index fe5fd41fc09..1bbb900f598 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -152,7 +152,7 @@ public function testConnectDispatchEvent(): void $eventManager->addEventListener([Events::postConnect], $listenerMock); $driverMock = $this->createMock(Driver::class); - $driverMock->expects($this->at(0)) + $driverMock->expects($this->once()) ->method('connect'); $conn = new Connection([], $driverMock, new Configuration(), $eventManager); @@ -846,13 +846,11 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting $originalException = new Exception('Original exception'); $fallbackException = new Exception('Fallback exception'); - $driverMock->expects($this->at(0)) - ->method('connect') - ->willThrowException($originalException); - - $driverMock->expects($this->at(1)) - ->method('connect') - ->willThrowException($fallbackException); + $driverMock->method('connect') + ->will(self::onConsecutiveCalls( + self::throwException($originalException), + self::throwException($fallbackException) + )); $this->expectExceptionMessage($originalException->getMessage()); diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index ce1ce87a5a0..e79869cf821 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -33,23 +33,12 @@ public function testExecute(array $params): void ->disableOriginalConstructor() ->getMock(); - $statement->expects($this->at(0)) + $statement->expects($this->exactly(3)) ->method('bindValue') - ->with( - $this->equalTo(1), - $this->equalTo($params[0]) - ); - $statement->expects($this->at(1)) - ->method('bindValue') - ->with( - $this->equalTo(2), - $this->equalTo($params[1]) - ); - $statement->expects($this->at(2)) - ->method('bindValue') - ->with( - $this->equalTo(3), - $this->equalTo($params[2]) + ->withConsecutive( + [1, $params[0]], + [2, $params[1]], + [3, $params[2]], ); // the return value is irrelevant to the test diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php index f1138ca9070..f2a8ec2fd15 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php @@ -1174,29 +1174,17 @@ public function testComparesNamespaces(): void ->method('getNamespaces') ->will($this->returnValue(['foo', 'bar'])); - $fromSchema->expects($this->at(0)) - ->method('hasNamespace') - ->with('bar') - ->will($this->returnValue(true)); - - $fromSchema->expects($this->at(1)) - ->method('hasNamespace') - ->with('baz') - ->will($this->returnValue(false)); + $fromSchema->method('hasNamespace') + ->withConsecutive(['bar'], ['baz']) + ->willReturnOnConsecutiveCalls(true, false); $toSchema->expects($this->once()) ->method('getNamespaces') ->will($this->returnValue(['bar', 'baz'])); - $toSchema->expects($this->at(1)) - ->method('hasNamespace') - ->with('foo') - ->will($this->returnValue(false)); - - $toSchema->expects($this->at(2)) - ->method('hasNamespace') - ->with('bar') - ->will($this->returnValue(true)); + $toSchema->method('hasNamespace') + ->withConsecutive(['foo'], ['bar']) + ->willReturnOnConsecutiveCalls(false, true); $expected = new SchemaDiff(); $expected->fromSchema = $fromSchema; diff --git a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php index 9e700939c66..35d884a95ac 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/SchemaTest.php @@ -371,7 +371,7 @@ public function testVisitsVisitor(): void [$schema->getSequence('war')] ); - self::assertNull($schema->visit($visitor)); + $schema->visit($visitor); } public function testVisitsNamespaceVisitor(): void @@ -392,34 +392,24 @@ public function testVisitsNamespaceVisitor(): void ->method('acceptSchema') ->with($schema); - $visitor->expects($this->at(1)) + $visitor->expects($this->exactly(3)) ->method('acceptNamespace') - ->with('foo'); + ->withConsecutive(['foo'], ['bar'], ['bla']); - $visitor->expects($this->at(2)) - ->method('acceptNamespace') - ->with('bar'); - - $visitor->expects($this->at(3)) - ->method('acceptNamespace') - ->with('bla'); - - $visitor->expects($this->at(4)) + $visitor->expects($this->exactly(2)) ->method('acceptTable') - ->with($schema->getTable('baz')); - - $visitor->expects($this->at(5)) - ->method('acceptTable') - ->with($schema->getTable('bla.bloo')); - - $visitor->expects($this->at(6)) - ->method('acceptSequence') - ->with($schema->getSequence('moo')); + ->withConsecutive( + [$schema->getTable('baz')], + [$schema->getTable('bla.bloo')] + ); - $visitor->expects($this->at(7)) + $visitor->expects($this->exactly(2)) ->method('acceptSequence') - ->with($schema->getSequence('war')); + ->withConsecutive( + [$schema->getSequence('moo')], + [$schema->getSequence('war')] + ); - self::assertNull($schema->visit($visitor)); + $schema->visit($visitor); } } diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index ae7ba2a1efc..4cf44892f7e 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -45,19 +45,20 @@ protected function setUp(): void ->willReturn(['foo']); } - public function testAcceptsNamespace(): void + public function testAcceptsNamespaceDoesNotSupportSchemas(): void { - $this->platformMock->expects($this->at(0)) - ->method('supportsSchemas') - ->will($this->returnValue(false)); - - $this->platformMock->expects($this->at(1)) - ->method('supportsSchemas') - ->will($this->returnValue(true)); + $this->platformMock->method('supportsSchemas') + ->willReturn(false); $this->visitor->acceptNamespace('foo'); self::assertEmpty($this->visitor->getQueries()); + } + + public function testAcceptsNamespaceSupportsSchemas(): void + { + $this->platformMock->method('supportsSchemas') + ->willReturn(true); $this->visitor->acceptNamespace('foo'); @@ -73,15 +74,10 @@ public function testAcceptsTable(): void self::assertSame(['foo'], $this->visitor->getQueries()); } - public function testAcceptsForeignKey(): void + public function testAcceptsForeignKeyDoesNotSupportCreateDropForeignKeyConstraints(): void { - $this->platformMock->expects($this->at(0)) - ->method('supportsCreateDropForeignKeyConstraints') - ->will($this->returnValue(false)); - - $this->platformMock->expects($this->at(1)) - ->method('supportsCreateDropForeignKeyConstraints') - ->will($this->returnValue(true)); + $this->platformMock->method('supportsCreateDropForeignKeyConstraints') + ->willReturn(false); $table = $this->createTableMock(); $foreignKey = $this->createForeignKeyConstraintMock(); @@ -89,6 +85,15 @@ public function testAcceptsForeignKey(): void $this->visitor->acceptForeignKey($table, $foreignKey); self::assertEmpty($this->visitor->getQueries()); + } + + public function testAcceptsForeignKeySupportsCreateDropForeignKeyConstraints(): void + { + $this->platformMock->method('supportsCreateDropForeignKeyConstraints') + ->willReturn(true); + + $table = $this->createTableMock(); + $foreignKey = $this->createForeignKeyConstraintMock(); $this->visitor->acceptForeignKey($table, $foreignKey); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index 37a7116ef15..d2ce7b7f94f 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -63,13 +63,11 @@ public function testSelectShard(): void $shardId = 10; $conn = $this->createConnectionMock(); - $conn->expects($this->at(0)) - ->method('getParams') + $conn->method('getParams') ->willReturn(['shardChoser' => $this->createPassthroughShardChoser()]); - $conn->expects($this->at(1)) - ->method('connect') - ->with($this->equalTo($shardId)); + $conn->method('connect') + ->with($shardId); $shardManager = new PoolingShardManager($conn); $shardManager->selectShard($shardId); @@ -99,22 +97,24 @@ public function testQueryAll(): void $types = [1]; $conn = $this->createConnectionMock(); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] - )); - $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createPassthroughShardChoser()] - )); - $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); - $conn->expects($this->at(3)) - ->method('fetchAllAssociative') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([['id' => 1]])); - $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); - $conn->expects($this->at(5)) - ->method('fetchAllAssociative') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([['id' => 2]])); + + $conn->method('getParams')->willReturn([ + 'shards' => [ + ['id' => 1], + ['id' => 2], + ], + 'shardChoser' => $this->createPassthroughShardChoser(), + ]); + + $conn->method('connect') + ->withConsecutive([1], [2]); + + $conn->method('fetchAllAssociative') + ->with($sql, $params, $types) + ->willReturnOnConsecutiveCalls( + [['id' => 1]], + [['id' => 2]], + ); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); @@ -129,22 +129,24 @@ public function testQueryAllWithStaticShardChoser(): void $types = [1]; $conn = $this->createConnectionMock(); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue( - ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] - )); - $conn->expects($this->at(1))->method('getParams')->will($this->returnValue( - ['shards' => [['id' => 1], ['id' => 2]], 'shardChoser' => $this->createStaticShardChooser()] - )); - $conn->expects($this->at(2))->method('connect')->with($this->equalTo(1)); - $conn->expects($this->at(3)) - ->method('fetchAllAssociative') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([['id' => 1]])); - $conn->expects($this->at(4))->method('connect')->with($this->equalTo(2)); - $conn->expects($this->at(5)) - ->method('fetchAllAssociative') - ->with($this->equalTo($sql), $this->equalTo($params), $this->equalTo($types)) - ->will($this->returnValue([['id' => 2]])); + + $conn->method('getParams')->willReturn([ + 'shards' => [ + ['id' => 1], + ['id' => 2], + ], + 'shardChoser' => $this->createStaticShardChooser(), + ]); + + $conn->method('connect') + ->withConsecutive([1], [2]); + + $conn->method('fetchAllAssociative') + ->with($sql, $params, $types) + ->willReturnOnConsecutiveCalls( + [['id' => 1]], + [['id' => 2]], + ); $shardManager = new PoolingShardManager($conn); $result = $shardManager->queryAll($sql, $params, $types); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php index 55e54ac9b54..09a8f933a37 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php @@ -60,7 +60,8 @@ public function testSelectGlobalTransactionActive(): void ], ]); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); + $conn->method('isTransactionActive') + ->willReturn(true); $this->expectException(ShardingException::class); $this->expectExceptionMessage('Cannot switch shard during an active transaction.'); @@ -79,8 +80,12 @@ public function testSelectGlobal(): void ], ]); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(false)); - $conn->expects($this->at(2))->method('exec')->with($this->equalTo('USE FEDERATION ROOT WITH RESET')); + $conn->method('isTransactionActive') + ->willReturn(false); + + $conn->expects($this->once()) + ->method('exec') + ->with('USE FEDERATION ROOT WITH RESET'); $sm = new SQLAzureShardManager($conn); $sm->selectGlobal(); @@ -96,7 +101,8 @@ public function testSelectShard(): void ], ]); - $conn->expects($this->at(1))->method('isTransactionActive')->will($this->returnValue(true)); + $conn->method('isTransactionActive') + ->willReturn(true); $this->expectException(ShardingException::class); $this->expectExceptionMessage('Cannot switch shard during an active transaction.'); @@ -118,7 +124,9 @@ private function createConnection(array $params): Connection ->onlyMethods(['getParams', 'exec', 'isTransactionActive']) ->disableOriginalConstructor() ->getMock(); - $conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params)); + + $conn->method('getParams') + ->willReturn($params); return $conn; } From 7532e41391238368fae3407edcbef596a73872c5 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 18 Aug 2020 07:29:06 -0700 Subject: [PATCH 79/93] Deprecate the Synchronizer package --- UPGRADE.md | 4 ++++ docs/en/reference/sharding.rst | 4 ++-- .../DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php | 2 ++ lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php | 2 ++ .../DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index a467b387e5f..6479312d553 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 2.11 +## Deprecated `Synchronizer` package + +The `Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer` interface and all its implementations are deprecated. + ## Deprecated usage of wrapper-level components as implementations of driver-level interfaces The usage of the wrapper `Connection` and `Statement` classes as implementations of the `Driver\Connection` and `Driver\Statement` interfaces is deprecated. diff --git a/docs/en/reference/sharding.rst b/docs/en/reference/sharding.rst index 2b2f804da53..8780593a0b6 100644 --- a/docs/en/reference/sharding.rst +++ b/docs/en/reference/sharding.rst @@ -269,8 +269,8 @@ you have to sort the data in the application. $sql = "SELECT * FROM customers"; $rows = $shardManager->queryAll($sql, $params); -Schema Operations: SchemaSynchronizer Interface ------------------------------------------------ +Schema Operations: SchemaSynchronizer Interface (deprecated) +------------------------------------------------------------ Schema Operations in a sharding architecture are tricky. You have to perform them on all databases instances (shards) at the same time. Also Doctrine diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php index 9b1974747e7..7cfd1f2c00f 100644 --- a/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php +++ b/lib/Doctrine/DBAL/Schema/Synchronizer/AbstractSchemaSynchronizer.php @@ -7,6 +7,8 @@ /** * Abstract schema synchronizer with methods for executing batches of SQL. + * + * @deprecated */ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer { diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php index 3e7beea7508..a10d3b7f327 100644 --- a/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php +++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SchemaSynchronizer.php @@ -7,6 +7,8 @@ /** * The synchronizer knows how to synchronize a schema with the configured * database. + * + * @deprecated */ interface SchemaSynchronizer { diff --git a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php index 43c0fc6a544..62a58577780 100644 --- a/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php +++ b/lib/Doctrine/DBAL/Schema/Synchronizer/SingleDatabaseSynchronizer.php @@ -12,6 +12,8 @@ /** * Schema Synchronizer for Default DBAL Connection. + * + * @deprecated */ class SingleDatabaseSynchronizer extends AbstractSchemaSynchronizer { From fe834e3ba18536dc079b9b5010cedcb457bb2373 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 19 Aug 2020 10:53:39 -0700 Subject: [PATCH 80/93] Remove test group configuration leftovers --- tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml | 7 ------- tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml | 7 ------- tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml | 7 ------- tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml | 7 ------- tests/travis/ibm_db2.travis.xml | 7 ------- tests/travis/mariadb.docker.travis.xml | 7 ------- tests/travis/mariadb.mysqli.docker.travis.xml | 7 ------- tests/travis/mysql.docker.travis.xml | 7 ------- tests/travis/mysqli-tls.docker.travis.xml | 7 ------- tests/travis/mysqli.docker.travis.xml | 7 ------- tests/travis/pdo_sqlsrv.travis.xml | 7 ------- tests/travis/pgsql.travis.xml | 7 ------- tests/travis/sqlite.travis.xml | 7 ------- tests/travis/sqlsrv.travis.xml | 7 ------- 14 files changed, 98 deletions(-) diff --git a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml index 0b53d9dfffe..f9e1c220ec8 100644 --- a/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2008r2sp2.sqlsrv.appveyor.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml index f2b353ad94f..0b060018623 100644 --- a/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2012sp1.sqlsrv.appveyor.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml index 9b3f53bb246..dcf655bee08 100644 --- a/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2017.pdo_sqlsrv.appveyor.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml index 2f314611ff4..bf908ed9b5c 100644 --- a/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml +++ b/tests/appveyor/mssql.sql2017.sqlsrv.appveyor.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/ibm_db2.travis.xml b/tests/travis/ibm_db2.travis.xml index 30d3157cc61..3089c56c47a 100644 --- a/tests/travis/ibm_db2.travis.xml +++ b/tests/travis/ibm_db2.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/mariadb.docker.travis.xml b/tests/travis/mariadb.docker.travis.xml index 85c681c6f0d..67f63b2fde4 100644 --- a/tests/travis/mariadb.docker.travis.xml +++ b/tests/travis/mariadb.docker.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/mariadb.mysqli.docker.travis.xml b/tests/travis/mariadb.mysqli.docker.travis.xml index 5c2ed041e37..d93ca5ceda5 100644 --- a/tests/travis/mariadb.mysqli.docker.travis.xml +++ b/tests/travis/mariadb.mysqli.docker.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/mysql.docker.travis.xml b/tests/travis/mysql.docker.travis.xml index 85c681c6f0d..67f63b2fde4 100644 --- a/tests/travis/mysql.docker.travis.xml +++ b/tests/travis/mysql.docker.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/mysqli-tls.docker.travis.xml b/tests/travis/mysqli-tls.docker.travis.xml index a7b2ef6af44..f6f653c42bf 100644 --- a/tests/travis/mysqli-tls.docker.travis.xml +++ b/tests/travis/mysqli-tls.docker.travis.xml @@ -34,11 +34,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/mysqli.docker.travis.xml b/tests/travis/mysqli.docker.travis.xml index 5c2ed041e37..d93ca5ceda5 100644 --- a/tests/travis/mysqli.docker.travis.xml +++ b/tests/travis/mysqli.docker.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/pdo_sqlsrv.travis.xml b/tests/travis/pdo_sqlsrv.travis.xml index 4b813c1a21a..38802c599e9 100644 --- a/tests/travis/pdo_sqlsrv.travis.xml +++ b/tests/travis/pdo_sqlsrv.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/pgsql.travis.xml b/tests/travis/pgsql.travis.xml index 2f9042034f5..0a1a5c1bebb 100644 --- a/tests/travis/pgsql.travis.xml +++ b/tests/travis/pgsql.travis.xml @@ -27,11 +27,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/sqlite.travis.xml b/tests/travis/sqlite.travis.xml index 6eacf80bbcc..ce3c1d0f914 100644 --- a/tests/travis/sqlite.travis.xml +++ b/tests/travis/sqlite.travis.xml @@ -22,11 +22,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - diff --git a/tests/travis/sqlsrv.travis.xml b/tests/travis/sqlsrv.travis.xml index 7004fa993d8..de56350ce9d 100644 --- a/tests/travis/sqlsrv.travis.xml +++ b/tests/travis/sqlsrv.travis.xml @@ -28,11 +28,4 @@ ../../lib/Doctrine - - - - performance - locking_functional - - From 12346644c4e2894592f907319e06a2f42b09b230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Mon, 24 Aug 2020 08:35:20 +0200 Subject: [PATCH 81/93] Use consistent parameter names --- .../Connections/PrimaryReadReplicaConnection.php | 12 ++++++------ .../Connection/BackwardCompatibility/Connection.php | 4 ++-- .../Connection/BackwardCompatibility/Statement.php | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php index 682d85bc929..78cb755d805 100644 --- a/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php +++ b/lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php @@ -317,11 +317,11 @@ public function rollBack() /** * {@inheritDoc} */ - public function delete($tableName, array $identifier, array $types = []) + public function delete($table, array $identifier, array $types = []) { $this->ensureConnectedToPrimary(); - return parent::delete($tableName, $identifier, $types); + return parent::delete($table, $identifier, $types); } /** @@ -340,21 +340,21 @@ public function close() /** * {@inheritDoc} */ - public function update($tableName, array $data, array $identifier, array $types = []) + public function update($table, array $data, array $identifier, array $types = []) { $this->ensureConnectedToPrimary(); - return parent::update($tableName, $data, $identifier, $types); + return parent::update($table, $data, $identifier, $types); } /** * {@inheritDoc} */ - public function insert($tableName, array $data, array $types = []) + public function insert($table, array $data, array $types = []) { $this->ensureConnectedToPrimary(); - return parent::insert($tableName, $data, $types); + return parent::insert($table, $data, $types); } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php index ff86f9f93ce..b864a794236 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Connection.php @@ -15,9 +15,9 @@ class Connection extends BaseConnection /** * {@inheritdoc} */ - public function executeQuery($query, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) + public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) { - return new Statement(parent::executeQuery($query, $params, $types, $qcp)); + return new Statement(parent::executeQuery($sql, $params, $types, $qcp)); } /** diff --git a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php index fc935fc9569..97fa03fed09 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Connection/BackwardCompatibility/Statement.php @@ -30,11 +30,11 @@ public function __construct($stmt) /** * {@inheritdoc} */ - public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null) + public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null) { assert($this->stmt instanceof DriverStatement); - return $this->stmt->bindParam($column, $variable, $type, $length); + return $this->stmt->bindParam($param, $variable, $type, $length); } /** @@ -102,9 +102,9 @@ public function execute($params = null) * * @deprecated Use one of the fetch- or iterate-related methods. */ - public function setFetchMode($fetchMode, $arg1 = null, $arg2 = null) + public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null) { - return $this->stmt->setFetchMode($fetchMode, $arg1, $arg2); + return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3); } /** From dd87ed0ec330864a0c404177b6600b81d7a242ff Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 25 Aug 2020 21:25:51 -0700 Subject: [PATCH 82/93] Deprecate AbstractPlatform::getSQLResultCasing() --- UPGRADE.md | 5 +++-- lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/DB2Platform.php | 2 ++ lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | 2 ++ 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/UPGRADE.md b/UPGRADE.md index 6479312d553..23cbf9f35b4 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -45,9 +45,10 @@ The following PDO-related classes outside of the PDO namespace have been depreca 1. `DBALException::invalidPlatformType()` is deprecated as unused as of v2.7.0. 2. `DBALException::invalidPdoInstance()` as passing a PDO instance via configuration is deprecated. -## `AbstractPlatform::fixSchemaElementName()` is deprecated. +## Deprecated `AbstractPlatform` methods. -The method is not used anywhere except for tests. +1. `fixSchemaElementName()`. +2. `getSQLResultCasing()`. ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 3becfb65d13..dd02f31ae27 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3481,6 +3481,8 @@ public function supportsLimitOffset() /** * Gets the character casing of a column in an SQL result set of this platform. * + * @deprecated + * * @param string $column The column name for which to get the correct character casing. * * @return string The column name in the character casing used in SQL result sets. diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 9b9a0622b62..0b6c38e0afb 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -864,6 +864,8 @@ public function prefersIdentityColumns() * {@inheritDoc} * * DB2 returns all column names in SQL result sets in uppercase. + * + * @deprecated */ public function getSQLResultCasing($column) { diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index faf76de197b..b5403c6b212 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -1055,6 +1055,8 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) * {@inheritDoc} * * Oracle returns all column names in SQL result sets in uppercase. + * + * @deprecated */ public function getSQLResultCasing($column) { diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index db9bec13d52..3dcbf49f198 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -1090,6 +1090,8 @@ public function getName() * {@inheritDoc} * * PostgreSQL returns all column names in SQL result sets in lowercase. + * + * @deprecated */ public function getSQLResultCasing($column) { From fef8e7a11353cd9660498736f2c949494c7c54a8 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 25 Aug 2020 21:27:08 -0700 Subject: [PATCH 83/93] Deprecate AbstractPlatform::prefersSequences() --- UPGRADE.md | 1 + lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | 2 ++ 4 files changed, 7 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 23cbf9f35b4..ed0a062cfdf 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -49,6 +49,7 @@ The following PDO-related classes outside of the PDO namespace have been depreca 1. `fixSchemaElementName()`. 2. `getSQLResultCasing()`. +3. `prefersSequences()`. ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index dd02f31ae27..6cf6d2d7aa0 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -2651,6 +2651,8 @@ public function getColumnCollationDeclarationSQL($collation) * Whether the platform prefers sequences for ID generation. * Subclasses should override this method to return TRUE if they prefer sequences. * + * @deprecated + * * @return bool */ public function prefersSequences() diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index b5403c6b212..678b36ce470 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -968,6 +968,8 @@ protected function getRenameIndexSQL($oldIndexName, Index $index, $tableName) /** * {@inheritDoc} + * + * @deprecated */ public function prefersSequences() { diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 3dcbf49f198..9d5b88cc344 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -210,6 +210,8 @@ public function supportsCommentOnStatement() /** * {@inheritDoc} + * + * @deprecated */ public function prefersSequences() { From acd58378367259cda9c500047123acfba1b2d30c Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 25 Aug 2020 21:28:20 -0700 Subject: [PATCH 84/93] Deprecate AbstractPlatform::supportsForeignKeyOnUpdate() --- UPGRADE.md | 1 + lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 ++ lib/Doctrine/DBAL/Platforms/OraclePlatform.php | 2 ++ 3 files changed, 5 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index ed0a062cfdf..5c22213f691 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -50,6 +50,7 @@ The following PDO-related classes outside of the PDO namespace have been depreca 1. `fixSchemaElementName()`. 2. `getSQLResultCasing()`. 3. `prefersSequences()`. +4. `supportsForeignKeyOnUpdate()`. ##`ServerInfoAwareConnection::requiresQueryForServerVersion()` is deprecated. diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 6cf6d2d7aa0..ec2aab5ce5c 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3232,6 +3232,8 @@ public function supportsCreateDropForeignKeyConstraints(): bool /** * Whether this platform supports onUpdate in foreign key constraints. * + * @deprecated + * * @return bool */ public function supportsForeignKeyOnUpdate() diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index 678b36ce470..ccf1e600822 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -1130,6 +1130,8 @@ public function supportsSequences() /** * {@inheritDoc} + * + * @deprecated */ public function supportsForeignKeyOnUpdate() { From 5c2a367cf781e10041e9099c88656c3a8ec3baf0 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Tue, 25 Aug 2020 22:47:50 -0700 Subject: [PATCH 85/93] Deprecate the functionality of dropping client connections when dropping a database --- UPGRADE.md | 5 +++++ lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/UPGRADE.md b/UPGRADE.md index 6479312d553..8d5273a206c 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,10 @@ # Upgrade to 2.11 +## Deprecated the functionality of dropping client connections when dropping a database + +The corresponding `getDisallowDatabaseConnectionsSQL()` and `getCloseActiveDatabaseConnectionsSQL` methods +of the `PostgreSqlPlatform` class have been deprecated. + ## Deprecated `Synchronizer` package The `Doctrine\DBAL\Schema\Synchronizer\SchemaSynchronizer` interface and all its implementations are deprecated. diff --git a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index db9bec13d52..0000284173c 100644 --- a/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -442,6 +442,8 @@ public function getCreateDatabaseSQL($name) * * This is useful to force DROP DATABASE operations which could fail because of active connections. * + * @deprecated + * * @param string $database The name of the database to disallow new connections for. * * @return string @@ -456,6 +458,8 @@ public function getDisallowDatabaseConnectionsSQL($database) * * This is useful to force DROP DATABASE operations which could fail because of active connections. * + * @deprecated + * * @param string $database The name of the database to close currently active connections for. * * @return string From 6c2d6292023436041bfbea371a58fbe6f8ca3f67 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 3 Sep 2020 07:02:00 -0700 Subject: [PATCH 86/93] Remove redundant condition --- lib/Doctrine/DBAL/Exception/DriverException.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lib/Doctrine/DBAL/Exception/DriverException.php b/lib/Doctrine/DBAL/Exception/DriverException.php index c0dd5d89d8a..b8953390713 100644 --- a/lib/Doctrine/DBAL/Exception/DriverException.php +++ b/lib/Doctrine/DBAL/Exception/DriverException.php @@ -4,7 +4,6 @@ use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; -use Exception; /** * Base class for all errors detected in the driver. @@ -26,13 +25,7 @@ class DriverException extends DBALException */ public function __construct($message, DeprecatedDriverException $driverException) { - $exception = null; - - if ($driverException instanceof Exception) { - $exception = $driverException; - } - - parent::__construct($message, 0, $exception); + parent::__construct($message, 0, $driverException); $this->driverException = $driverException; } From a2ec3abdd800584e557762e53aa743dac8e9ebed Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 3 Sep 2020 07:02:00 -0700 Subject: [PATCH 87/93] Clean up exception handling in Connection --- lib/Doctrine/DBAL/Connection.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 507a5170d10..6c4dea7fd22 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -20,7 +20,6 @@ use Doctrine\DBAL\Query\QueryBuilder; use Doctrine\DBAL\Schema\AbstractSchemaManager; use Doctrine\DBAL\Types\Type; -use Exception; use Throwable; use Traversable; @@ -406,7 +405,7 @@ private function detectDatabasePlatform(): void * * @return string|null * - * @throws Exception + * @throws Throwable */ private function getDatabasePlatformVersion() { @@ -1470,7 +1469,6 @@ public function lastInsertId($name = null) * * @return mixed The value returned by $func * - * @throws Exception * @throws Throwable */ public function transactional(Closure $func) @@ -1481,10 +1479,6 @@ public function transactional(Closure $func) $this->commit(); return $res; - } catch (Exception $e) { - $this->rollBack(); - - throw $e; } catch (Throwable $e) { $this->rollBack(); From c115e9fbf0503363348289a2a6179611036afb94 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 3 Sep 2020 07:02:00 -0700 Subject: [PATCH 88/93] Remove redundant @throws annotations from test methods --- .../Platforms/AbstractSQLServerPlatformTestCase.php | 9 --------- .../Tests/DBAL/Platforms/SQLServer2012PlatformTest.php | 10 ---------- 2 files changed, 19 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index 6c166ac2dff..fba77a86756 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -469,9 +469,6 @@ public function testModifyLimitQueryWithAggregateFunctionInOrderByClause(): void $this->expectCteWithMaxRowNum($alteredSql, 1, $sql); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -493,9 +490,6 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -517,9 +511,6 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi $this->expectCteWithMaxRowNum($alteredSql, 5, $sql); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php index 47fe7ec69b3..1c21098b678 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLServer2012PlatformTest.php @@ -2,7 +2,6 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLServer2012Platform; use Doctrine\DBAL\Schema\Sequence; @@ -370,9 +369,6 @@ public function testModifyLimitQueryWithComplexOrderByExpression(): void self::assertEquals($sql, $expected); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBaseTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -393,9 +389,6 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromBas self::assertEquals($alteredSql, $sql); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoinTable(): void { $querySql = 'SELECT DISTINCT id_0, name_1 ' @@ -416,9 +409,6 @@ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnFromJoi self::assertEquals($alteredSql, $sql); } - /** - * @throws DBALException - */ public function testModifyLimitSubqueryWithJoinAndSubqueryOrderedByColumnsFromBothTables(): void { $querySql = 'SELECT DISTINCT id_0, name_1, foo_2 ' From ad1e48238b38a8ec10a7f461e7426c7f3985b603 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Thu, 3 Sep 2020 07:02:00 -0700 Subject: [PATCH 89/93] Deprecate DBAL\DBALException in favor of DBAL\Exception --- UPGRADE.md | 4 + lib/Doctrine/DBAL/Abstraction/Result.php | 8 +- lib/Doctrine/DBAL/Cache/CacheException.php | 4 +- lib/Doctrine/DBAL/Connection.php | 63 +++--- lib/Doctrine/DBAL/ConnectionException.php | 2 +- lib/Doctrine/DBAL/DBALException.php | 77 +++---- .../DBAL/Driver/AbstractMySQLDriver.php | 12 +- .../DBAL/Driver/AbstractPostgreSQLDriver.php | 4 +- .../DBAL/Driver/AbstractSQLAnywhereDriver.php | 4 +- .../DBAL/Driver/AbstractSQLServerDriver.php | 4 +- lib/Doctrine/DBAL/Driver/Mysqli/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/OCI8/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php | 4 +- lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php | 4 +- .../DBAL/Driver/SQLAnywhere/Driver.php | 6 +- lib/Doctrine/DBAL/DriverManager.php | 22 +- lib/Doctrine/DBAL/Exception.php | 10 + .../DBAL/Exception/DriverException.php | 4 +- .../Exception/InvalidArgumentException.php | 4 +- lib/Doctrine/DBAL/Id/TableGenerator.php | 12 +- .../DBAL/Platforms/AbstractPlatform.php | 192 +++++++++--------- lib/Doctrine/DBAL/Platforms/DB2Platform.php | 4 +- .../DBAL/Platforms/OraclePlatform.php | 6 +- .../DBAL/Platforms/SQLAnywherePlatform.php | 4 +- .../DBAL/Platforms/SqlitePlatform.php | 16 +- lib/Doctrine/DBAL/Query/QueryException.php | 4 +- lib/Doctrine/DBAL/SQLParserUtilsException.php | 2 +- .../DBAL/Schema/AbstractSchemaManager.php | 6 +- lib/Doctrine/DBAL/Schema/SchemaException.php | 4 +- .../DBAL/Schema/SqliteSchemaManager.php | 6 +- lib/Doctrine/DBAL/Schema/Table.php | 14 +- .../DBAL/Sharding/ShardingException.php | 4 +- lib/Doctrine/DBAL/Statement.php | 20 +- .../DBAL/Types/ConversionException.php | 4 +- lib/Doctrine/DBAL/Types/Type.php | 8 +- lib/Doctrine/DBAL/Types/TypeRegistry.php | 22 +- .../DBAL/VersionAwarePlatformDriver.php | 2 +- tests/Doctrine/Tests/DBAL/ConnectionTest.php | 11 +- .../Doctrine/Tests/DBAL/DBALExceptionTest.php | 19 +- .../Tests/DBAL/Driver/AbstractDriverTest.php | 4 +- .../Doctrine/Tests/DBAL/DriverManagerTest.php | 14 +- .../Tests/DBAL/Functional/DataAccessTest.php | 4 +- .../Schema/SqliteSchemaManagerTest.php | 4 +- .../DBAL/Functional/Ticket/DBAL630Test.php | 4 +- .../Platforms/AbstractPlatformTestCase.php | 20 +- .../AbstractSQLServerPlatformTestCase.php | 4 +- .../DBAL/Platforms/OraclePlatformTest.php | 8 +- .../Platforms/SQLAnywherePlatformTest.php | 6 +- .../DBAL/Platforms/SqlitePlatformTest.php | 8 +- .../Doctrine/Tests/DBAL/Schema/TableTest.php | 4 +- tests/Doctrine/Tests/DBAL/StatementTest.php | 9 +- .../Tests/DBAL/Types/TypeRegistryTest.php | 14 +- 54 files changed, 363 insertions(+), 352 deletions(-) create mode 100644 lib/Doctrine/DBAL/Exception.php diff --git a/UPGRADE.md b/UPGRADE.md index 0392cdad627..9eb98d764a3 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -84,6 +84,10 @@ The non-interface methods of driver-level classes have been marked internal: - `OCI8Connection::getExecuteMode()` - `OCI8Statement::convertPositionalToNamedPlaceholders()` +## Deprecated `DBALException` + +The `Doctrine\DBAL\DBALException` class has been deprecated in favor of `Doctrine\DBAL\Exception`. + ## Inconsistently and ambiguously named driver-level classes are deprecated The following classes under the `Driver` namespace have been deprecated in favor of their consistently named counterparts: diff --git a/lib/Doctrine/DBAL/Abstraction/Result.php b/lib/Doctrine/DBAL/Abstraction/Result.php index 5e163785405..42ff3419e37 100644 --- a/lib/Doctrine/DBAL/Abstraction/Result.php +++ b/lib/Doctrine/DBAL/Abstraction/Result.php @@ -4,8 +4,8 @@ namespace Doctrine\DBAL\Abstraction; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Result as DriverResult; +use Doctrine\DBAL\Exception; use Traversable; /** @@ -19,7 +19,7 @@ interface Result extends DriverResult * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateNumeric(): Traversable; @@ -28,7 +28,7 @@ public function iterateNumeric(): Traversable; * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateAssociative(): Traversable; @@ -37,7 +37,7 @@ public function iterateAssociative(): Traversable; * * @return Traversable * - * @throws DBALException + * @throws Exception */ public function iterateColumn(): Traversable; } diff --git a/lib/Doctrine/DBAL/Cache/CacheException.php b/lib/Doctrine/DBAL/Cache/CacheException.php index db5680812e2..3db115bdfae 100644 --- a/lib/Doctrine/DBAL/Cache/CacheException.php +++ b/lib/Doctrine/DBAL/Cache/CacheException.php @@ -2,12 +2,12 @@ namespace Doctrine\DBAL\Cache; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; /** * @psalm-immutable */ -class CacheException extends DBALException +class CacheException extends Exception { /** * @return CacheException diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index 6c4dea7fd22..82ef5d80170 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -174,7 +174,7 @@ class Connection implements DriverConnection * @param Configuration|null $config The configuration, optional. * @param EventManager|null $eventManager The event manager, optional. * - * @throws DBALException + * @throws Exception */ public function __construct( array $params, @@ -192,7 +192,7 @@ public function __construct( if (isset($params['platform'])) { if (! $params['platform'] instanceof Platforms\AbstractPlatform) { - throw DBALException::invalidPlatformType($params['platform']); + throw Exception::invalidPlatformType($params['platform']); } $this->platform = $params['platform']; @@ -320,7 +320,7 @@ public function getEventManager() * * @return AbstractPlatform * - * @throws DBALException + * @throws Exception */ public function getDatabasePlatform() { @@ -378,7 +378,7 @@ public function connect() * * Evaluates custom platform class and version in order to set the correct platform. * - * @throws DBALException If an invalid platform was specified for this connection. + * @throws Exception If an invalid platform was specified for this connection. */ private function detectDatabasePlatform(): void { @@ -549,7 +549,7 @@ public function setFetchMode($fetchMode) * * @return mixed[]|false False is returned if no rows are found. * - * @throws DBALException + * @throws Exception */ public function fetchAssoc($sql, array $params = [], array $types = []) { @@ -586,7 +586,7 @@ public function fetchArray($sql, array $params = [], array $types = []) * * @return mixed|false False is returned if no rows are found. * - * @throws DBALException + * @throws Exception */ public function fetchColumn($sql, array $params = [], $column = 0, array $types = []) { @@ -603,7 +603,7 @@ public function fetchColumn($sql, array $params = [], $column = 0, array $types * * @return array|false False is returned if no rows are found. * - * @throws DBALException + * @throws Exception */ public function fetchAssociative(string $query, array $params = [], array $types = []) { @@ -630,7 +630,7 @@ public function fetchAssociative(string $query, array $params = [], array $types * * @return array|false False is returned if no rows are found. * - * @throws DBALException + * @throws Exception */ public function fetchNumeric(string $query, array $params = [], array $types = []) { @@ -657,7 +657,7 @@ public function fetchNumeric(string $query, array $params = [], array $types = [ * * @return mixed|false False is returned if no rows are found. * - * @throws DBALException + * @throws Exception */ public function fetchOne(string $query, array $params = [], array $types = []) { @@ -702,7 +702,7 @@ public function isTransactionActive() * @param mixed[] $values Column values * @param string[] $conditions Key conditions * - * @throws DBALException + * @throws Exception */ private function addIdentifierCondition( array $identifier, @@ -735,8 +735,7 @@ private function addIdentifierCondition( * * @return int The number of affected rows. * - * @throws DBALException - * @throws InvalidArgumentException + * @throws Exception */ public function delete($table, array $identifier, array $types = []) { @@ -805,7 +804,7 @@ public function getTransactionIsolation() * * @return int The number of affected rows. * - * @throws DBALException + * @throws Exception */ public function update($table, array $data, array $identifier, array $types = []) { @@ -840,7 +839,7 @@ public function update($table, array $data, array $identifier, array $types = [] * * @return int The number of affected rows. * - * @throws DBALException + * @throws Exception */ public function insert($table, array $data, array $types = []) { @@ -941,7 +940,7 @@ public function fetchAll($sql, array $params = [], $types = []) * * @return array> * - * @throws DBALException + * @throws Exception */ public function fetchAllNumeric(string $query, array $params = [], array $types = []): array { @@ -967,7 +966,7 @@ public function fetchAllNumeric(string $query, array $params = [], array $types * * @return array> * - * @throws DBALException + * @throws Exception */ public function fetchAllAssociative(string $query, array $params = [], array $types = []): array { @@ -993,7 +992,7 @@ public function fetchAllAssociative(string $query, array $params = [], array $ty * * @return array * - * @throws DBALException + * @throws Exception */ public function fetchFirstColumn(string $query, array $params = [], array $types = []): array { @@ -1019,7 +1018,7 @@ public function fetchFirstColumn(string $query, array $params = [], array $types * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateNumeric(string $query, array $params = [], array $types = []): Traversable { @@ -1048,7 +1047,7 @@ public function iterateNumeric(string $query, array $params = [], array $types = * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateAssociative(string $query, array $params = [], array $types = []): Traversable { @@ -1076,7 +1075,7 @@ public function iterateAssociative(string $query, array $params = [], array $typ * * @return Traversable * - * @throws DBALException + * @throws Exception */ public function iterateColumn(string $query, array $params = [], array $types = []): Traversable { @@ -1102,7 +1101,7 @@ public function iterateColumn(string $query, array $params = [], array $types = * * @return Statement The prepared statement. * - * @throws DBALException + * @throws Exception */ public function prepare($sql) { @@ -1130,7 +1129,7 @@ public function prepare($sql) * * @return ResultStatement The executed statement. * - * @throws DBALException + * @throws Exception */ public function executeQuery($sql, array $params = [], $types = [], ?QueryCacheProfile $qcp = null) { @@ -1264,7 +1263,7 @@ public function project($sql, array $params, Closure $function) * * @return \Doctrine\DBAL\Driver\Statement * - * @throws DBALException + * @throws Exception */ public function query() { @@ -1306,7 +1305,7 @@ public function query() * * @return int The number of affected rows. * - * @throws DBALException + * @throws Exception */ public function executeUpdate($sql, array $params = [], array $types = []) { @@ -1331,7 +1330,7 @@ public function executeUpdate($sql, array $params = [], array $types = []) * * @return int The number of affected rows. * - * @throws DBALException + * @throws Exception */ public function executeStatement($sql, array $params = [], array $types = []) { @@ -1384,7 +1383,7 @@ public function executeStatement($sql, array $params = [], array $types = []) * * @return int The number of affected rows. * - * @throws DBALException + * @throws Exception */ public function exec($sql) { @@ -2008,14 +2007,14 @@ public function ping() * @param array|array $params * @param array|array $types * - * @throws DBALException + * @throws Exception * * @psalm-return never-return */ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $params = [], array $types = []): void { $this->throw( - DBALException::driverExceptionDuringQuery( + Exception::driverExceptionDuringQuery( $this->_driver, $e, $sql, @@ -2027,14 +2026,14 @@ public function handleExceptionDuringQuery(Throwable $e, string $sql, array $par /** * @internal * - * @throws DBALException + * @throws Exception * * @psalm-return never-return */ public function handleDriverException(Throwable $e): void { $this->throw( - DBALException::driverException( + Exception::driverException( $this->_driver, $e ) @@ -2044,11 +2043,11 @@ public function handleDriverException(Throwable $e): void /** * @internal * - * @throws DBALException + * @throws Exception * * @psalm-return never-return */ - private function throw(DBALException $e): void + private function throw(Exception $e): void { if ($e instanceof ConnectionLost) { $this->close(); diff --git a/lib/Doctrine/DBAL/ConnectionException.php b/lib/Doctrine/DBAL/ConnectionException.php index f1914f5294e..8426ca28891 100644 --- a/lib/Doctrine/DBAL/ConnectionException.php +++ b/lib/Doctrine/DBAL/ConnectionException.php @@ -5,7 +5,7 @@ /** * @psalm-immutable */ -class ConnectionException extends DBALException +class ConnectionException extends Exception { /** * @return ConnectionException diff --git a/lib/Doctrine/DBAL/DBALException.php b/lib/Doctrine/DBAL/DBALException.php index f208a14ae92..b9a33cf1f70 100644 --- a/lib/Doctrine/DBAL/DBALException.php +++ b/lib/Doctrine/DBAL/DBALException.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Types\Type; -use Exception; use Throwable; use function array_map; @@ -24,18 +23,20 @@ use function sprintf; /** + * @deprecated Use {@link Exception} instead + * * @psalm-immutable */ -class DBALException extends Exception +class DBALException extends \Exception { /** * @param string $method * - * @return DBALException + * @return Exception */ public static function notSupported($method) { - return new self(sprintf("Operation '%s' is not supported by platform.", $method)); + return new Exception(sprintf("Operation '%s' is not supported by platform.", $method)); } /** @@ -43,7 +44,7 @@ public static function notSupported($method) */ public static function invalidPlatformSpecified(): self { - return new self( + return new Exception( "Invalid 'platform' option specified, need to give an instance of " . AbstractPlatform::class . '.' ); } @@ -54,7 +55,7 @@ public static function invalidPlatformSpecified(): self public static function invalidPlatformType($invalidPlatform): self { if (is_object($invalidPlatform)) { - return new self( + return new Exception( sprintf( "Option 'platform' must be a subtype of '%s', instance of '%s' given", AbstractPlatform::class, @@ -63,7 +64,7 @@ public static function invalidPlatformType($invalidPlatform): self ); } - return new self( + return new Exception( sprintf( "Option 'platform' must be an object and subtype of '%s'. Got '%s'", AbstractPlatform::class, @@ -78,11 +79,11 @@ public static function invalidPlatformType($invalidPlatform): self * @param string $version The invalid platform version given. * @param string $expectedFormat The expected platform version format. * - * @return DBALException + * @return Exception */ public static function invalidPlatformVersionSpecified($version, $expectedFormat) { - return new self( + return new Exception( sprintf( 'Invalid platform version "%s" specified. ' . 'The platform version has to be specified in the format: "%s".', @@ -95,11 +96,11 @@ public static function invalidPlatformVersionSpecified($version, $expectedFormat /** * @deprecated Passing a PDO instance in connection parameters is deprecated. * - * @return DBALException + * @return Exception */ public static function invalidPdoInstance() { - return new self( + return new Exception( "The 'pdo' option was used in DriverManager::getConnection() but no " . 'instance of PDO was given.' ); @@ -108,12 +109,12 @@ public static function invalidPdoInstance() /** * @param string|null $url The URL that was provided in the connection parameters (if any). * - * @return DBALException + * @return Exception */ public static function driverRequired($url = null) { if ($url) { - return new self( + return new Exception( sprintf( "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . 'is given to DriverManager::getConnection(). Given URL: %s', @@ -122,7 +123,7 @@ public static function driverRequired($url = null) ); } - return new self("The options 'driver' or 'driverClass' are mandatory if no PDO " . + return new Exception("The options 'driver' or 'driverClass' are mandatory if no PDO " . 'instance is given to DriverManager::getConnection().'); } @@ -130,11 +131,11 @@ public static function driverRequired($url = null) * @param string $unknownDriverName * @param string[] $knownDrivers * - * @return DBALException + * @return Exception */ public static function unknownDriver($unknownDriverName, array $knownDrivers) { - return new self("The given 'driver' " . $unknownDriverName . ' is unknown, ' . + return new Exception("The given 'driver' " . $unknownDriverName . ' is unknown, ' . 'Doctrine currently supports only the following drivers: ' . implode(', ', $knownDrivers)); } @@ -144,7 +145,7 @@ public static function unknownDriver($unknownDriverName, array $knownDrivers) * @param string $sql * @param mixed[] $params * - * @return self + * @return Exception */ public static function driverExceptionDuringQuery(Driver $driver, Throwable $driverEx, $sql, array $params = []) { @@ -161,7 +162,7 @@ public static function driverExceptionDuringQuery(Driver $driver, Throwable $dri /** * @deprecated * - * @return self + * @return Exception */ public static function driverException(Driver $driver, Throwable $driverEx) { @@ -169,7 +170,7 @@ public static function driverException(Driver $driver, Throwable $driverEx) } /** - * @return self + * @return Exception */ private static function wrapException(Driver $driver, Throwable $driverEx, string $msg) { @@ -181,7 +182,7 @@ private static function wrapException(Driver $driver, Throwable $driverEx, strin return $driver->convertException($msg, $driverEx); } - return new self($msg, 0, $driverEx); + return new Exception($msg, 0, $driverEx); } /** @@ -213,22 +214,22 @@ private static function formatParameters(array $params) /** * @param string $wrapperClass * - * @return DBALException + * @return Exception */ public static function invalidWrapperClass($wrapperClass) { - return new self("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' . + return new Exception("The given 'wrapperClass' " . $wrapperClass . ' has to be a ' . 'subtype of \Doctrine\DBAL\Connection.'); } /** * @param string $driverClass * - * @return DBALException + * @return Exception */ public static function invalidDriverClass($driverClass) { - return new self( + return new Exception( "The given 'driverClass' " . $driverClass . ' has to implement the ' . Driver::class . ' interface.' ); } @@ -236,49 +237,49 @@ public static function invalidDriverClass($driverClass) /** * @param string $tableName * - * @return DBALException + * @return Exception */ public static function invalidTableName($tableName) { - return new self('Invalid table name specified: ' . $tableName); + return new Exception('Invalid table name specified: ' . $tableName); } /** * @param string $tableName * - * @return DBALException + * @return Exception */ public static function noColumnsSpecifiedForTable($tableName) { - return new self('No columns specified for table ' . $tableName); + return new Exception('No columns specified for table ' . $tableName); } /** - * @return DBALException + * @return Exception */ public static function limitOffsetInvalid() { - return new self('Invalid Offset in Limit Query, it has to be larger than or equal to 0.'); + return new Exception('Invalid Offset in Limit Query, it has to be larger than or equal to 0.'); } /** * @param string $name * - * @return DBALException + * @return Exception */ public static function typeExists($name) { - return new self('Type ' . $name . ' already exists.'); + return new Exception('Type ' . $name . ' already exists.'); } /** * @param string $name * - * @return DBALException + * @return Exception */ public static function unknownColumnType($name) { - return new self('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' . + return new Exception('Unknown column type "' . $name . '" requested. Any Doctrine type that you use has ' . 'to be registered with \Doctrine\DBAL\Types\Type::addType(). You can get a list of all the ' . 'known types with \Doctrine\DBAL\Types\Type::getTypesMap(). If this error occurs during database ' . 'introspection then you might have forgotten to register all database types for a Doctrine Type. Use ' . @@ -290,23 +291,23 @@ public static function unknownColumnType($name) /** * @param string $name * - * @return DBALException + * @return Exception */ public static function typeNotFound($name) { - return new self('Type to be overwritten ' . $name . ' does not exist.'); + return new Exception('Type to be overwritten ' . $name . ' does not exist.'); } public static function typeNotRegistered(Type $type): self { - return new self( + return new Exception( sprintf('Type of the class %s@%s is not registered.', get_class($type), spl_object_hash($type)) ); } public static function typeAlreadyRegistered(Type $type): self { - return new self( + return new Exception( sprintf('Type of the class %s@%s is already registered.', get_class($type), spl_object_hash($type)) ); } diff --git a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php index 7fd77aa5c51..edb33b89a40 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConnectionLost; use Doctrine\DBAL\Exception\DeadlockException; @@ -131,7 +131,7 @@ public function convertException($message, DeprecatedDriverException $exception) /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function createDatabasePlatformForVersion($version) { @@ -160,7 +160,7 @@ public function createDatabasePlatformForVersion($version) * * @param string $versionString Version string returned by the driver, i.e. '5.7.10' * - * @throws DBALException + * @throws Exception */ private function getOracleMysqlVersionNumber(string $versionString): string { @@ -171,7 +171,7 @@ private function getOracleMysqlVersionNumber(string $versionString): string $versionParts ) ) { - throw DBALException::invalidPlatformVersionSpecified( + throw Exception::invalidPlatformVersionSpecified( $versionString, '..' ); @@ -194,7 +194,7 @@ private function getOracleMysqlVersionNumber(string $versionString): string * * @param string $versionString Version string as returned by mariadb server, i.e. '5.5.5-Mariadb-10.0.8-xenial' * - * @throws DBALException + * @throws Exception */ private function getMariaDbMysqlVersionNumber(string $versionString): string { @@ -205,7 +205,7 @@ private function getMariaDbMysqlVersionNumber(string $versionString): string $versionParts ) ) { - throw DBALException::invalidPlatformVersionSpecified( + throw Exception::invalidPlatformVersionSpecified( $versionString, '^(?:5\.5\.5-)?(mariadb-)?..' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php index 2653746eb9b..33b383392ec 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DriverException; @@ -102,7 +102,7 @@ public function convertException($message, DeprecatedDriverException $exception) public function createDatabasePlatformForVersion($version) { if (! preg_match('/^(?P\d+)(?:\.(?P\d+)(?:\.(?P\d+))?)?/', $version, $versionParts)) { - throw DBALException::invalidPlatformVersionSpecified( + throw Exception::invalidPlatformVersionSpecified( $version, '..' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php index 668f765e1ca..7fc71870d55 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLAnywhereDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DeprecatedDriverException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\DeadlockException; use Doctrine\DBAL\Exception\DriverException; @@ -103,7 +103,7 @@ public function createDatabasePlatformForVersion($version) $versionParts ) ) { - throw DBALException::invalidPlatformVersionSpecified( + throw Exception::invalidPlatformVersionSpecified( $version, '...' ); diff --git a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php index 0d85a938dfb..2550ec5a87f 100644 --- a/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php +++ b/lib/Doctrine/DBAL/Driver/AbstractSQLServerDriver.php @@ -3,9 +3,9 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as TheDriverException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\SQLServer2005Platform; use Doctrine\DBAL\Platforms\SQLServer2008Platform; @@ -35,7 +35,7 @@ public function createDatabasePlatformForVersion($version) $versionParts ) ) { - throw DBALException::invalidPlatformVersionSpecified( + throw Exception::invalidPlatformVersionSpecified( $version, '...' ); diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php index 561b51ba0f3..9ac74f27d07 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\Mysqli; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractMySQLDriver; +use Doctrine\DBAL\Exception; class Driver extends AbstractMySQLDriver { @@ -15,7 +15,7 @@ public function connect(array $params, $username = null, $password = null, array try { return new Connection($params, (string) $username, (string) $password, $driverOptions); } catch (MysqliException $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php index d83c2bdc30f..5f7e3c0a9e8 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/Driver.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\OCI8; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; +use Doctrine\DBAL\Exception; use const OCI_NO_AUTO_COMMIT; @@ -27,7 +27,7 @@ public function connect(array $params, $username = null, $password = null, array $params['persistent'] ?? false ); } catch (OCI8Exception $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php index eec433a9924..25eb2fbdb6f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOMySql/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOMySql; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractMySQLDriver; use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Exception; use PDOException; /** @@ -27,7 +27,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } return $conn; diff --git a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php index 2ea597d16f1..b6792996c71 100644 --- a/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOOracle/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOOracle; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractOracleDriver; use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Exception; use PDOException; /** @@ -32,7 +32,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index d7a19181c4e..83076aa8c06 100644 --- a/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOPgSql; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver; use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Exception; use PDOException; use function defined; @@ -48,7 +48,7 @@ public function connect(array $params, $username = null, $password = null, array return $pdo; } catch (PDOException $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php index 0c3b3900059..fc2b881ffce 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlite/Driver.php @@ -2,9 +2,9 @@ namespace Doctrine\DBAL\Driver\PDOSqlite; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLiteDriver; use Doctrine\DBAL\Driver\PDO; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SqlitePlatform; use PDOException; @@ -45,7 +45,7 @@ public function connect(array $params, $username = null, $password = null, array $driverOptions ); } catch (PDOException $ex) { - throw DBALException::driverException($this, $ex); + throw Exception::driverException($this, $ex); } foreach ($this->_userDefinedFunctions as $fn => $data) { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php index bc29466e1a9..95b59274e9e 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/Driver.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Driver\SQLAnywhere; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver; +use Doctrine\DBAL\Exception; use function array_keys; use function array_map; @@ -17,7 +17,7 @@ class Driver extends AbstractSQLAnywhereDriver /** * {@inheritdoc} * - * @throws DBALException If there was a problem establishing the connection. + * @throws Exception If there was a problem establishing the connection. */ public function connect(array $params, $username = null, $password = null, array $driverOptions = []) { @@ -35,7 +35,7 @@ public function connect(array $params, $username = null, $password = null, array $params['persistent'] ?? false ); } catch (SQLAnywhereException $e) { - throw DBALException::driverException($this, $e); + throw Exception::driverException($this, $e); } } diff --git a/lib/Doctrine/DBAL/DriverManager.php b/lib/Doctrine/DBAL/DriverManager.php index 70894eaa4a5..6c21d806580 100644 --- a/lib/Doctrine/DBAL/DriverManager.php +++ b/lib/Doctrine/DBAL/DriverManager.php @@ -117,7 +117,7 @@ private function __construct() * @param Configuration|null $config The configuration to use. * @param EventManager|null $eventManager The event manager to use. * - * @throws DBALException + * @throws Exception * * @phpstan-param mixed[] $params * @psalm-return ($params is array{wrapperClass:mixed} ? T : Connection) @@ -175,7 +175,7 @@ public static function getConnection( // check for existing pdo object if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) { - throw DBALException::invalidPdoInstance(); + throw Exception::invalidPdoInstance(); } if (isset($params['pdo'])) { @@ -192,7 +192,7 @@ public static function getConnection( $wrapperClass = Connection::class; if (isset($params['wrapperClass'])) { if (! is_subclass_of($params['wrapperClass'], $wrapperClass)) { - throw DBALException::invalidWrapperClass($params['wrapperClass']); + throw Exception::invalidWrapperClass($params['wrapperClass']); } $wrapperClass = $params['wrapperClass']; @@ -216,7 +216,7 @@ public static function getAvailableDrivers(): array * * @param mixed[] $params The list of parameters. * - * @throws DBALException + * @throws Exception */ private static function _checkParams(array $params): void { @@ -224,21 +224,21 @@ private static function _checkParams(array $params): void // driver if (! isset($params['driver']) && ! isset($params['driverClass'])) { - throw DBALException::driverRequired(); + throw Exception::driverRequired(); } // check validity of parameters // driver if (isset($params['driver']) && ! isset(self::$_driverMap[$params['driver']])) { - throw DBALException::unknownDriver($params['driver'], array_keys(self::$_driverMap)); + throw Exception::unknownDriver($params['driver'], array_keys(self::$_driverMap)); } if ( isset($params['driverClass']) && ! in_array(Driver::class, class_implements($params['driverClass'], true)) ) { - throw DBALException::invalidDriverClass($params['driverClass']); + throw Exception::invalidDriverClass($params['driverClass']); } } @@ -262,7 +262,7 @@ private static function normalizeDatabaseUrlPath(string $urlPath): string * @return mixed[] A modified list of parameters with info from a database * URL extracted into indidivual parameter parts. * - * @throws DBALException + * @throws Exception */ private static function parseDatabaseUrl(array $params): array { @@ -277,7 +277,7 @@ private static function parseDatabaseUrl(array $params): array $url = parse_url($url); if ($url === false) { - throw new DBALException('Malformed parameter "url".'); + throw new Exception('Malformed parameter "url".'); } $url = array_map('rawurldecode', $url); @@ -417,7 +417,7 @@ private static function parseSqliteDatabaseUrlPath(array $url, array $params): a * * @return mixed[] The resolved connection parameters. * - * @throws DBALException If parsing failed or resolution is not possible. + * @throws Exception If parsing failed or resolution is not possible. */ private static function parseDatabaseUrlScheme(array $url, array $params): array { @@ -442,7 +442,7 @@ private static function parseDatabaseUrlScheme(array $url, array $params): array // If a schemeless connection URL is given, we require a default driver or default custom driver // as connection parameter. if (! isset($params['driverClass']) && ! isset($params['driver'])) { - throw DBALException::driverRequired($params['url']); + throw Exception::driverRequired($params['url']); } return $params; diff --git a/lib/Doctrine/DBAL/Exception.php b/lib/Doctrine/DBAL/Exception.php new file mode 100644 index 00000000000..34442da6a8a --- /dev/null +++ b/lib/Doctrine/DBAL/Exception.php @@ -0,0 +1,10 @@ +getDriver() instanceof Driver\PDOSqlite\Driver) { - throw new DBALException('Cannot use TableGenerator with SQLite.'); + throw new Exception('Cannot use TableGenerator with SQLite.'); } $this->conn = DriverManager::getConnection( @@ -90,7 +90,7 @@ public function __construct(Connection $conn, $generatorTableName = 'sequences') * * @return int * - * @throws DBALException + * @throws Exception */ public function nextValue($sequence) { @@ -134,7 +134,7 @@ public function nextValue($sequence) $rows = $this->conn->executeStatement($sql, [$sequence, $row['sequence_value']]); if ($rows !== 1) { - throw new DBALException('Race-condition detected while updating sequence. Aborting generation'); + throw new Exception('Race-condition detected while updating sequence. Aborting generation'); } } else { $this->conn->insert( @@ -148,7 +148,7 @@ public function nextValue($sequence) } catch (Throwable $e) { $this->conn->rollBack(); - throw new DBALException( + throw new Exception( 'Error occurred while generating ID with TableGenerator, aborted generation: ' . $e->getMessage(), 0, $e diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index b29596681ee..61c6a81d742 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -3,7 +3,6 @@ namespace Doctrine\DBAL\Platforms; use Doctrine\Common\EventManager; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Event\SchemaAlterTableAddColumnEventArgs; use Doctrine\DBAL\Event\SchemaAlterTableChangeColumnEventArgs; use Doctrine\DBAL\Event\SchemaAlterTableEventArgs; @@ -13,6 +12,7 @@ use Doctrine\DBAL\Event\SchemaCreateTableEventArgs; use Doctrine\DBAL\Event\SchemaDropTableEventArgs; use Doctrine\DBAL\Events; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -343,11 +343,11 @@ public function getJsonTypeDeclarationSQL(array $column) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) { - throw DBALException::notSupported('VARCHARs not supported by Platform.'); + throw Exception::notSupported('VARCHARs not supported by Platform.'); } /** @@ -358,11 +358,11 @@ protected function getVarcharTypeDeclarationSQLSnippet($length, $fixed) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ protected function getBinaryTypeDeclarationSQLSnippet($length, $fixed) { - throw DBALException::notSupported('BINARY/VARBINARY column types are not supported by this platform.'); + throw Exception::notSupported('BINARY/VARBINARY column types are not supported by this platform.'); } /** @@ -398,7 +398,7 @@ abstract public function getName(); * * @return void * - * @throws DBALException If the type is not found. + * @throws Exception If the type is not found. */ public function registerDoctrineTypeMapping($dbType, $doctrineType) { @@ -407,7 +407,7 @@ public function registerDoctrineTypeMapping($dbType, $doctrineType) } if (! Types\Type::hasType($doctrineType)) { - throw DBALException::typeNotFound($doctrineType); + throw Exception::typeNotFound($doctrineType); } $dbType = strtolower($dbType); @@ -429,7 +429,7 @@ public function registerDoctrineTypeMapping($dbType, $doctrineType) * * @return string * - * @throws DBALException + * @throws Exception */ public function getDoctrineTypeMapping($dbType) { @@ -440,7 +440,7 @@ public function getDoctrineTypeMapping($dbType) $dbType = strtolower($dbType); if (! isset($this->doctrineTypeMapping[$dbType])) { - throw new DBALException( + throw new Exception( 'Unknown database type ' . $dbType . ' requested, ' . static::class . ' may not support it.' ); } @@ -639,11 +639,11 @@ public function getWildcards() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getRegexpExpression() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -653,11 +653,11 @@ public function getRegexpExpression() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getGuidExpression() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -885,11 +885,11 @@ public function getLowerExpression($str) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getLocateExpression($str, $substr, $startPos = false) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1056,11 +1056,11 @@ public function getCosExpression($value) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateDiffExpression($date1, $date2) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1071,7 +1071,7 @@ public function getDateDiffExpression($date1, $date2) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddSecondsExpression($date, $seconds) { @@ -1086,7 +1086,7 @@ public function getDateAddSecondsExpression($date, $seconds) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubSecondsExpression($date, $seconds) { @@ -1101,7 +1101,7 @@ public function getDateSubSecondsExpression($date, $seconds) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddMinutesExpression($date, $minutes) { @@ -1116,7 +1116,7 @@ public function getDateAddMinutesExpression($date, $minutes) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubMinutesExpression($date, $minutes) { @@ -1131,7 +1131,7 @@ public function getDateSubMinutesExpression($date, $minutes) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddHourExpression($date, $hours) { @@ -1146,7 +1146,7 @@ public function getDateAddHourExpression($date, $hours) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubHourExpression($date, $hours) { @@ -1161,7 +1161,7 @@ public function getDateSubHourExpression($date, $hours) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddDaysExpression($date, $days) { @@ -1176,7 +1176,7 @@ public function getDateAddDaysExpression($date, $days) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubDaysExpression($date, $days) { @@ -1191,7 +1191,7 @@ public function getDateSubDaysExpression($date, $days) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddWeeksExpression($date, $weeks) { @@ -1206,7 +1206,7 @@ public function getDateAddWeeksExpression($date, $weeks) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubWeeksExpression($date, $weeks) { @@ -1221,7 +1221,7 @@ public function getDateSubWeeksExpression($date, $weeks) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddMonthExpression($date, $months) { @@ -1236,7 +1236,7 @@ public function getDateAddMonthExpression($date, $months) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubMonthExpression($date, $months) { @@ -1251,7 +1251,7 @@ public function getDateSubMonthExpression($date, $months) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddQuartersExpression($date, $quarters) { @@ -1266,7 +1266,7 @@ public function getDateAddQuartersExpression($date, $quarters) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubQuartersExpression($date, $quarters) { @@ -1281,7 +1281,7 @@ public function getDateSubQuartersExpression($date, $quarters) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateAddYearsExpression($date, $years) { @@ -1296,7 +1296,7 @@ public function getDateAddYearsExpression($date, $years) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateSubYearsExpression($date, $years) { @@ -1314,11 +1314,11 @@ public function getDateSubYearsExpression($date, $years) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ protected function getDateArithmeticIntervalExpression($date, $operator, $interval, $unit) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1541,7 +1541,7 @@ public function getDropForeignKeySQL($foreignKey, $table) * * @return string[] The sequence of SQL statements. * - * @throws DBALException + * @throws Exception * @throws InvalidArgumentException */ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDEXES) @@ -1553,7 +1553,7 @@ public function getCreateTableSQL(Table $table, $createFlags = self::CREATE_INDE } if (count($table->getColumns()) === 0) { - throw DBALException::noColumnsSpecifiedForTable($table->getName()); + throw Exception::noColumnsSpecifiedForTable($table->getName()); } $tableName = $table->getQuotedName($this); @@ -1682,12 +1682,12 @@ public function getCommentOnColumnSQL($tableName, $columnName, $comment) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getInlineColumnCommentSQL($comment) { if (! $this->supportsInlineColumnComments()) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } return 'COMMENT ' . $this->quoteStringLiteral($comment); @@ -1755,11 +1755,11 @@ public function getCreateTemporaryTableSnippetSQL() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getCreateSequenceSQL(Sequence $sequence) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1767,11 +1767,11 @@ public function getCreateSequenceSQL(Sequence $sequence) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getAlterSequenceSQL(Sequence $sequence) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1895,11 +1895,11 @@ public function getCreatePrimaryKeySQL(Index $index, $table) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getCreateSchemaSQL($schemaName) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -1964,11 +1964,11 @@ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) * * @return string[] * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getAlterTableSQL(TableDiff $diff) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2793,11 +2793,11 @@ protected function _getTransactionIsolationLevelSQL($level) /** * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListDatabasesSQL() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2805,11 +2805,11 @@ public function getListDatabasesSQL() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListNamespacesSQL() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2817,11 +2817,11 @@ public function getListNamespacesSQL() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListSequencesSQL($database) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2829,11 +2829,11 @@ public function getListSequencesSQL($database) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListTableConstraintsSQL($table) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2842,31 +2842,31 @@ public function getListTableConstraintsSQL($table) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListTableColumnsSQL($table, $database = null) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListTablesSQL() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListUsersSQL() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2876,11 +2876,11 @@ public function getListUsersSQL() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListViewsSQL($database) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2898,11 +2898,11 @@ public function getListViewsSQL($database) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListTableIndexesSQL($table, $database = null) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2910,11 +2910,11 @@ public function getListTableIndexesSQL($table, $database = null) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getListTableForeignKeysSQL($table) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2923,11 +2923,11 @@ public function getListTableForeignKeysSQL($table) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getCreateViewSQL($name, $sql) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2935,11 +2935,11 @@ public function getCreateViewSQL($name, $sql) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDropViewSQL($name) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2949,11 +2949,11 @@ public function getDropViewSQL($name) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDropSequenceSQL($sequence) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2961,11 +2961,11 @@ public function getDropSequenceSQL($sequence) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getSequenceNextValSQL($sequence) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2975,11 +2975,11 @@ public function getSequenceNextValSQL($sequence) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getCreateDatabaseSQL($database) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -2989,11 +2989,11 @@ public function getCreateDatabaseSQL($database) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getSetTransactionIsolationSQL($level) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3004,11 +3004,11 @@ public function getSetTransactionIsolationSQL($level) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateTimeTypeDeclarationSQL(array $column) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3031,11 +3031,11 @@ public function getDateTimeTzTypeDeclarationSQL(array $column) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDateTypeDeclarationSQL(array $column) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3046,11 +3046,11 @@ public function getDateTypeDeclarationSQL(array $column) * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getTimeTypeDeclarationSQL(array $column) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3124,11 +3124,11 @@ public function usesSequenceEmulatedIdentityColumns() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getIdentitySequenceName($tableName, $columnName) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3269,11 +3269,11 @@ public function canEmulateSchemas() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ public function getDefaultSchemaName() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** @@ -3423,7 +3423,7 @@ public function getTimeFormatString() * * @return string * - * @throws DBALException + * @throws Exception */ final public function modifyLimitQuery($query, $limit, $offset = null) { @@ -3434,14 +3434,14 @@ final public function modifyLimitQuery($query, $limit, $offset = null) $offset = (int) $offset; if ($offset < 0) { - throw new DBALException(sprintf( + throw new Exception(sprintf( 'Offset must be a positive integer or zero, %d given', $offset )); } if ($offset > 0 && ! $this->supportsLimitOffset()) { - throw new DBALException(sprintf( + throw new Exception(sprintf( 'Platform %s does not support offset values in limit queries.', $this->getName() )); @@ -3605,7 +3605,7 @@ public function rollbackSavePoint($savepoint) * * @return KeywordList * - * @throws DBALException If no keyword list is specified. + * @throws Exception If no keyword list is specified. */ final public function getReservedKeywordsList() { @@ -3617,7 +3617,7 @@ final public function getReservedKeywordsList() $class = $this->getReservedKeywordsClass(); $keywords = new $class(); if (! $keywords instanceof KeywordList) { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } // Store the instance so it doesn't need to be generated on every request. @@ -3631,11 +3631,11 @@ final public function getReservedKeywordsList() * * @return string * - * @throws DBALException If not supported on this platform. + * @throws Exception If not supported on this platform. */ protected function getReservedKeywordsClass() { - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/lib/Doctrine/DBAL/Platforms/DB2Platform.php index d0d58f9a371..3d75866e198 100644 --- a/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\ColumnDiff; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -481,7 +481,7 @@ public function getCurrentTimestampSQL() public function getIndexDeclarationSQL($name, Index $index) { // Index declaration in statements like CREATE TABLE is not supported. - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index e6b97576f2e..9d2e44cbb8d 100644 --- a/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\ForeignKeyConstraint; use Doctrine\DBAL\Schema\Identifier; use Doctrine\DBAL\Schema\Index; @@ -40,12 +40,12 @@ class OraclePlatform extends AbstractPlatform * * @return void * - * @throws DBALException + * @throws Exception */ public static function assertValidIdentifier($identifier) { if (! preg_match('(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)', $identifier)) { - throw new DBALException('Invalid Oracle identifier'); + throw new Exception('Invalid Oracle identifier'); } } diff --git a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index 006671bc81e..f7921cbde48 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -691,7 +691,7 @@ public function getGuidTypeDeclarationSQL(array $column) public function getIndexDeclarationSQL($name, Index $index) { // Index declaration in statements like CREATE TABLE is not supported. - throw DBALException::notSupported(__METHOD__); + throw Exception::notSupported(__METHOD__); } /** diff --git a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index 1f3a099ac95..9317c64a37b 100644 --- a/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\Constraint; use Doctrine\DBAL\Schema\ForeignKeyConstraint; @@ -697,7 +697,7 @@ protected function getReservedKeywordsClass() protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) { if (! $diff->fromTable instanceof Table) { - throw new DBALException( + throw new Exception( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } @@ -720,7 +720,7 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) protected function getPostAlterTableIndexForeignKeySQL(TableDiff $diff) { if (! $diff->fromTable instanceof Table) { - throw new DBALException( + throw new Exception( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } @@ -805,7 +805,7 @@ public function supportsCreateDropForeignKeyConstraints(): bool */ public function getCreatePrimaryKeySQL(Index $index, $table) { - throw new DBALException('Sqlite platform does not support alter primary key.'); + throw new Exception('Sqlite platform does not support alter primary key.'); } /** @@ -813,7 +813,7 @@ public function getCreatePrimaryKeySQL(Index $index, $table) */ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) { - throw new DBALException( + throw new Exception( 'Sqlite platform does not support alter foreign key, ' . 'the table must be fully recreated using getAlterTableSQL.' ); @@ -824,7 +824,7 @@ public function getCreateForeignKeySQL(ForeignKeyConstraint $foreignKey, $table) */ public function getDropForeignKeySQL($foreignKey, $table) { - throw new DBALException( + throw new Exception( 'Sqlite platform does not support alter foreign key, ' . 'the table must be fully recreated using getAlterTableSQL.' ); @@ -835,7 +835,7 @@ public function getDropForeignKeySQL($foreignKey, $table) */ public function getCreateConstraintSQL(Constraint $constraint, $table) { - throw new DBALException('Sqlite platform does not support alter constraint.'); + throw new Exception('Sqlite platform does not support alter constraint.'); } /** @@ -875,7 +875,7 @@ public function getAlterTableSQL(TableDiff $diff) $fromTable = $diff->fromTable; if (! $fromTable instanceof Table) { - throw new DBALException( + throw new Exception( 'Sqlite platform requires for alter table the table diff with reference to original table schema' ); } diff --git a/lib/Doctrine/DBAL/Query/QueryException.php b/lib/Doctrine/DBAL/Query/QueryException.php index 76bb9ba7559..58e941e9843 100644 --- a/lib/Doctrine/DBAL/Query/QueryException.php +++ b/lib/Doctrine/DBAL/Query/QueryException.php @@ -2,14 +2,14 @@ namespace Doctrine\DBAL\Query; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use function implode; /** * @psalm-immutable */ -class QueryException extends DBALException +class QueryException extends Exception { /** * @param string $alias diff --git a/lib/Doctrine/DBAL/SQLParserUtilsException.php b/lib/Doctrine/DBAL/SQLParserUtilsException.php index 99cdb8d4a66..297b0761b8d 100644 --- a/lib/Doctrine/DBAL/SQLParserUtilsException.php +++ b/lib/Doctrine/DBAL/SQLParserUtilsException.php @@ -9,7 +9,7 @@ * * @psalm-immutable */ -class SQLParserUtilsException extends DBALException +class SQLParserUtilsException extends Exception { /** * @param string $paramName diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 2bff61a8e90..35f2c612780 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -4,10 +4,10 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ConnectionException; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Event\SchemaColumnDefinitionEventArgs; use Doctrine\DBAL\Event\SchemaIndexDefinitionEventArgs; use Doctrine\DBAL\Events; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Throwable; @@ -776,11 +776,11 @@ protected function _getPortableSequencesList($sequences) * * @return Sequence * - * @throws DBALException + * @throws Exception */ protected function _getPortableSequenceDefinition($sequence) { - throw DBALException::notSupported('Sequences'); + throw Exception::notSupported('Sequences'); } /** diff --git a/lib/Doctrine/DBAL/Schema/SchemaException.php b/lib/Doctrine/DBAL/Schema/SchemaException.php index 6317679de0a..64f4b250a8a 100644 --- a/lib/Doctrine/DBAL/Schema/SchemaException.php +++ b/lib/Doctrine/DBAL/Schema/SchemaException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use function implode; use function sprintf; @@ -10,7 +10,7 @@ /** * @psalm-immutable */ -class SchemaException extends DBALException +class SchemaException extends Exception { public const TABLE_DOESNT_EXIST = 10; public const TABLE_ALREADY_EXISTS = 20; diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index eb85f32c2ed..de7b1375032 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -2,8 +2,8 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Types\StringType; use Doctrine\DBAL\Types\TextType; use Doctrine\DBAL\Types\Type; @@ -455,7 +455,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) * * @return TableDiff * - * @throws DBALException + * @throws Exception */ private function getTableDiffForAlterForeignKey($table) { @@ -463,7 +463,7 @@ private function getTableDiffForAlterForeignKey($table) $tableDetails = $this->tryMethod('listTableDetails', $table); if ($tableDetails === false) { - throw new DBALException( + throw new Exception( sprintf('Sqlite schema manager requires to modify foreign keys table definition "%s".', $table) ); } diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 4d8b362a0d0..909b349107b 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Schema; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema\Visitor\Visitor; use Doctrine\DBAL\Types\Type; @@ -51,7 +51,7 @@ class Table extends AbstractAsset * @param int $idGeneratorType * @param mixed[] $options * - * @throws DBALException + * @throws Exception */ public function __construct( $name, @@ -62,7 +62,7 @@ public function __construct( array $options = [] ) { if (strlen($name) === 0) { - throw DBALException::invalidTableName($name); + throw Exception::invalidTableName($name); } $this->_setName($name); @@ -316,11 +316,11 @@ public function addColumn($name, $typeName, array $options = []) * * @return void * - * @throws DBALException + * @throws Exception */ public function renameColumn($oldName, $name) { - throw new DBALException('Table#renameColumn() was removed, because it drops and recreates ' . + throw new Exception('Table#renameColumn() was removed, because it drops and recreates ' . 'the column instead. There is no fix available, because a schema diff cannot reliably detect if a ' . 'column was renamed or one column was created and another one dropped.'); } @@ -727,14 +727,14 @@ public function getPrimaryKey() * * @return string[] * - * @throws DBALException + * @throws Exception */ public function getPrimaryKeyColumns() { $primaryKey = $this->getPrimaryKey(); if ($primaryKey === null) { - throw new DBALException('Table ' . $this->getName() . ' has no primary key.'); + throw new Exception('Table ' . $this->getName() . ' has no primary key.'); } return $primaryKey->getColumns(); diff --git a/lib/Doctrine/DBAL/Sharding/ShardingException.php b/lib/Doctrine/DBAL/Sharding/ShardingException.php index 2df764a6ff2..d3363a126cd 100644 --- a/lib/Doctrine/DBAL/Sharding/ShardingException.php +++ b/lib/Doctrine/DBAL/Sharding/ShardingException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Sharding; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; /** * Sharding related Exceptions @@ -11,7 +11,7 @@ * * @psalm-immutable */ -class ShardingException extends DBALException +class ShardingException extends Exception { /** * @return ShardingException diff --git a/lib/Doctrine/DBAL/Statement.php b/lib/Doctrine/DBAL/Statement.php index 080c48e2061..0e47e09303c 100644 --- a/lib/Doctrine/DBAL/Statement.php +++ b/lib/Doctrine/DBAL/Statement.php @@ -143,7 +143,7 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le * * @return bool TRUE on success, FALSE on failure. * - * @throws DBALException + * @throws Exception */ public function execute($params = null) { @@ -280,7 +280,7 @@ public function fetchColumn($columnIndex = 0) /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function fetchNumeric() { @@ -298,7 +298,7 @@ public function fetchNumeric() /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function fetchAssociative() { @@ -316,7 +316,7 @@ public function fetchAssociative() /** * {@inheritDoc} * - * @throws DBALException + * @throws Exception */ public function fetchOne() { @@ -334,7 +334,7 @@ public function fetchOne() /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function fetchAllNumeric(): array { @@ -352,7 +352,7 @@ public function fetchAllNumeric(): array /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function fetchAllAssociative(): array { @@ -370,7 +370,7 @@ public function fetchAllAssociative(): array /** * {@inheritdoc} * - * @throws DBALException + * @throws Exception */ public function fetchFirstColumn(): array { @@ -390,7 +390,7 @@ public function fetchFirstColumn(): array * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateNumeric(): Traversable { @@ -414,7 +414,7 @@ public function iterateNumeric(): Traversable * * @return Traversable> * - * @throws DBALException + * @throws Exception */ public function iterateAssociative(): Traversable { @@ -438,7 +438,7 @@ public function iterateAssociative(): Traversable * * @return Traversable * - * @throws DBALException + * @throws Exception */ public function iterateColumn(): Traversable { diff --git a/lib/Doctrine/DBAL/Types/ConversionException.php b/lib/Doctrine/DBAL/Types/ConversionException.php index 55dfedee754..5be4743a5e5 100644 --- a/lib/Doctrine/DBAL/Types/ConversionException.php +++ b/lib/Doctrine/DBAL/Types/ConversionException.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Throwable; use function get_class; @@ -19,7 +19,7 @@ * * @psalm-immutable */ -class ConversionException extends DBALException +class ConversionException extends Exception { /** * Thrown when a Database to Doctrine Type Conversion fails. diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index b0344062537..f75a4905673 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -2,7 +2,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; @@ -225,7 +225,7 @@ private static function createTypeRegistry(): TypeRegistry * * @return Type * - * @throws DBALException + * @throws Exception */ public static function getType($name) { @@ -240,7 +240,7 @@ public static function getType($name) * * @return void * - * @throws DBALException + * @throws Exception */ public static function addType($name, $className) { @@ -267,7 +267,7 @@ public static function hasType($name) * * @return void * - * @throws DBALException + * @throws Exception */ public static function overrideType($name, $className) { diff --git a/lib/Doctrine/DBAL/Types/TypeRegistry.php b/lib/Doctrine/DBAL/Types/TypeRegistry.php index 4c2e31ecbcf..fdae6d603c8 100644 --- a/lib/Doctrine/DBAL/Types/TypeRegistry.php +++ b/lib/Doctrine/DBAL/Types/TypeRegistry.php @@ -4,7 +4,7 @@ namespace Doctrine\DBAL\Types; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use function array_search; use function in_array; @@ -31,12 +31,12 @@ public function __construct(array $instances = []) /** * Finds a type by the given name. * - * @throws DBALException + * @throws Exception */ public function get(string $name): Type { if (! isset($this->instances[$name])) { - throw DBALException::unknownColumnType($name); + throw Exception::unknownColumnType($name); } return $this->instances[$name]; @@ -45,14 +45,14 @@ public function get(string $name): Type /** * Finds a name for the given type. * - * @throws DBALException + * @throws Exception */ public function lookupName(Type $type): string { $name = $this->findTypeName($type); if ($name === null) { - throw DBALException::typeNotRegistered($type); + throw Exception::typeNotRegistered($type); } return $name; @@ -69,16 +69,16 @@ public function has(string $name): bool /** * Registers a custom type to the type map. * - * @throws DBALException + * @throws Exception */ public function register(string $name, Type $type): void { if (isset($this->instances[$name])) { - throw DBALException::typeExists($name); + throw Exception::typeExists($name); } if ($this->findTypeName($type) !== null) { - throw DBALException::typeAlreadyRegistered($type); + throw Exception::typeAlreadyRegistered($type); } $this->instances[$name] = $type; @@ -87,16 +87,16 @@ public function register(string $name, Type $type): void /** * Overrides an already defined type to use a different implementation. * - * @throws DBALException + * @throws Exception */ public function override(string $name, Type $type): void { if (! isset($this->instances[$name])) { - throw DBALException::typeNotFound($name); + throw Exception::typeNotFound($name); } if (! in_array($this->findTypeName($type), [$name, null], true)) { - throw DBALException::typeAlreadyRegistered($type); + throw Exception::typeAlreadyRegistered($type); } $this->instances[$name] = $type; diff --git a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php index a4864d0b287..8bdae926442 100644 --- a/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php +++ b/lib/Doctrine/DBAL/VersionAwarePlatformDriver.php @@ -22,7 +22,7 @@ interface VersionAwarePlatformDriver * * @return AbstractPlatform * - * @throws DBALException If the given version string could not be evaluated. + * @throws Exception If the given version string could not be evaluated. */ public function createDatabasePlatformForVersion($version); } diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 1bbb900f598..8bcf1b817fe 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -9,13 +9,13 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; use Doctrine\DBAL\ConnectionException; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Events; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Logging\DebugStack; @@ -23,7 +23,6 @@ use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\Tests\DbalTestCase; -use Exception; use PHPUnit\Framework\MockObject\MockObject; use stdClass; @@ -183,7 +182,7 @@ public function testEventManagerPassedToPlatform(): void */ public function testDriverExceptionIsWrapped(string $method): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->expectExceptionMessage(<<createMock(Driver::class); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); new Connection($connectionParams, $driver); } @@ -843,8 +842,8 @@ public function testRethrowsOriginalExceptionOnDeterminingPlatformWhenConnecting $driverMock = $this->createMock(FutureVersionAwarePlatformDriver::class); $connection = new Connection(['dbname' => 'foo'], $driverMock); - $originalException = new Exception('Original exception'); - $fallbackException = new Exception('Fallback exception'); + $originalException = new \Exception('Original exception'); + $fallbackException = new \Exception('Fallback exception'); $driverMock->method('connect') ->will(self::onConsecutiveCalls( diff --git a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php index 8fa510e8d0a..5f7f137225d 100644 --- a/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php +++ b/tests/Doctrine/Tests/DBAL/DBALExceptionTest.php @@ -2,12 +2,11 @@ namespace Doctrine\Tests\DBAL; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as InnerDriverException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\DriverException; use Doctrine\Tests\DbalTestCase; -use Exception; use stdClass; use function chr; @@ -19,7 +18,7 @@ class DBALExceptionTest extends DbalTestCase public function testDriverExceptionDuringQueryAcceptsBinaryData(): void { $driver = $this->createMock(Driver::class); - $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]); + $e = Exception::driverExceptionDuringQuery($driver, new \Exception(), '', ['ABC', chr(128)]); self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage()); } @@ -27,9 +26,9 @@ public function testDriverExceptionDuringQueryAcceptsResource(): void { $driver = $this->createMock(Driver::class); - $e = DBALException::driverExceptionDuringQuery( + $e = Exception::driverExceptionDuringQuery( $driver, - new Exception(), + new \Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')] ); @@ -44,16 +43,16 @@ public function testAvoidOverWrappingOnDriverException(): void $inner = $this->createMock(InnerDriverException::class); $ex = new DriverException('', $inner); - $e = DBALException::driverExceptionDuringQuery($driver, $ex, ''); + $e = Exception::driverExceptionDuringQuery($driver, $ex, ''); self::assertSame($ex, $e); } public function testDriverRequiredWithUrl(): void { $url = 'mysql://localhost'; - $exception = DBALException::driverRequired($url); + $exception = Exception::driverRequired($url); - self::assertInstanceOf(DBALException::class, $exception); + self::assertInstanceOf(Exception::class, $exception); self::assertSame( sprintf( "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . @@ -66,7 +65,7 @@ public function testDriverRequiredWithUrl(): void public function testInvalidPlatformTypeObject(): void { - $exception = DBALException::invalidPlatformType(new stdClass()); + $exception = Exception::invalidPlatformType(new stdClass()); self::assertSame( "Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', " @@ -77,7 +76,7 @@ public function testInvalidPlatformTypeObject(): void public function testInvalidPlatformTypeScalar(): void { - $exception = DBALException::invalidPlatformType('some string'); + $exception = Exception::invalidPlatformType('some string'); self::assertSame( "Option 'platform' must be an object and subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform'. " diff --git a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php index 29a8441f646..078875a4086 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/AbstractDriverTest.php @@ -3,10 +3,10 @@ namespace Doctrine\Tests\DBAL\Driver; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DriverException as DriverExceptionInterface; use Doctrine\DBAL\Driver\ExceptionConverterDriver; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Exception\ConnectionException; use Doctrine\DBAL\Exception\ConstraintViolationException; use Doctrine\DBAL\Exception\DatabaseObjectExistsException; @@ -138,7 +138,7 @@ public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion( $this->markTestSkipped('This test is only intended for version aware platform drivers.'); } - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->driver->createDatabasePlatformForVersion('foo'); } diff --git a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php index 03117de7f32..e6544de56f5 100644 --- a/tests/Doctrine/Tests/DBAL/DriverManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/DriverManagerTest.php @@ -4,13 +4,13 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connections\PrimaryReadReplicaConnection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver as DrizzlePDOMySqlDriver; use Doctrine\DBAL\Driver\PDO\MySQL\Driver as PDOMySQLDriver; use Doctrine\DBAL\Driver\PDO\SQLite\Driver as PDOSQLiteDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; use Doctrine\DBAL\DriverManager; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Sharding\PoolingShardConnection; use Doctrine\DBAL\Sharding\ShardChoser\MultiTenantShardChoser; @@ -30,7 +30,7 @@ class DriverManagerTest extends DbalTestCase */ public function testInvalidPdoInstance(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); DriverManager::getConnection(['pdo' => 'test']); } @@ -61,14 +61,14 @@ public function testPdoInstanceSetErrorMode(): void public function testCheckParams(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); DriverManager::getConnection([]); } public function testInvalidDriver(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); DriverManager::getConnection(['driver' => 'invalid_driver']); } @@ -111,7 +111,7 @@ public function testCustomWrapper(): void */ public function testInvalidWrapperClass(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $options = [ 'pdo' => new PDO('sqlite::memory:'), @@ -123,7 +123,7 @@ public function testInvalidWrapperClass(): void public function testInvalidDriverClass(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $options = ['driverClass' => stdClass::class]; @@ -227,7 +227,7 @@ public function testDatabaseUrl($url, $expected): void $options = is_array($url) ? $url : ['url' => $url]; if ($expected === false) { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); } $conn = DriverManager::getConnection($options); diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 6984f7a471d..ef68b5be62f 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -4,13 +4,13 @@ use DateTime; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\IBMDB2\Driver as IBMDB2Driver; use Doctrine\DBAL\Driver\Mysqli\Driver as MySQLiDriver; use Doctrine\DBAL\Driver\OCI8\Driver as Oci8Driver; use Doctrine\DBAL\Driver\PDO\Connection as PDOConnection; use Doctrine\DBAL\Driver\PDO\OCI\Driver as PDOOCIDriver; use Doctrine\DBAL\Driver\SQLSrv\Driver as SQLSrvDriver; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\SqlitePlatform; @@ -267,7 +267,7 @@ public function testFetchAllWithMissingTypes(callable $fetch): void $datetime = new DateTime($datetimeString); $sql = 'SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?'; - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $fetch($this->connection, $sql, [1, $datetime]); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php index 53914d48c6d..d94a8f8dabe 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Schema; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\Connection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Types\BlobType; @@ -19,7 +19,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase */ public function testListDatabases(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->schemaManager->listDatabases(); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php index 0abb50bdf92..77cd108b595 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php @@ -2,8 +2,8 @@ namespace Doctrine\Tests\DBAL\Functional\Ticket; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver\PDO\Connection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\ParameterType; use Doctrine\Tests\DbalFunctionalTestCase; use PDO; @@ -28,7 +28,7 @@ protected function setUp(): void try { $this->connection->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);'); $this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);'); - } catch (DBALException $e) { + } catch (Exception $e) { } $this->running = true; diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index c59d966c265..b098f617ece 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -3,8 +3,8 @@ namespace Doctrine\Tests\DBAL\Platforms; use Doctrine\Common\EventManager; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Events; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\Keywords\KeywordList; use Doctrine\DBAL\Schema\Column; @@ -90,7 +90,7 @@ public function testGetInvalidForeignKeyReferentialActionSQL(): void public function testGetUnknownDoctrineMappingType(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getDoctrineTypeMapping('foobar'); } @@ -102,7 +102,7 @@ public function testRegisterDoctrineMappingType(): void public function testRegisterUnknownDoctrineMappingType(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->registerDoctrineTypeMapping('foo', 'bar'); } @@ -151,7 +151,7 @@ public function testCreateWithNoColumns(): void { $table = new Table('test'); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $sql = $this->platform->getCreateTableSQL($table); } @@ -724,7 +724,7 @@ public function testQuotesReservedKeywordInIndexDeclarationSQL(): void $index = new Index('select', ['foo']); if (! $this->supportsInlineIndexDeclaration()) { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); } self::assertSame( @@ -752,7 +752,7 @@ protected function supportsCommentOnStatement(): bool public function testGetCreateSchemaSQL(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getCreateSchemaSQL('schema'); } @@ -783,7 +783,7 @@ public function testUsesSequenceEmulatedIdentityColumns(): void public function testReturnsIdentitySequenceName(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getIdentitySequenceName('mytable', 'mycolumn'); } @@ -810,7 +810,7 @@ protected function getBinaryMaxLength(): int public function testReturnsBinaryTypeDeclarationSQL(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getBinaryTypeDeclarationSQL([]); } @@ -1218,7 +1218,7 @@ public function testThrowsExceptionOnGeneratingInlineColumnCommentSQLIfUnsupport $this->markTestSkipped(sprintf('%s supports inline column comments.', get_class($this->platform))); } - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->expectExceptionMessage( "Operation '" . AbstractPlatform::class . "::getInlineColumnCommentSQL' is not supported by platform." ); @@ -1247,7 +1247,7 @@ public function testQuoteStringLiteral(): void public function testReturnsGuidTypeDeclarationSQL(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getGuidTypeDeclarationSQL([]); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php index fba77a86756..ddb7df84a00 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractSQLServerPlatformTestCase.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\SQLServerPlatform; use Doctrine\DBAL\Schema\Column; use Doctrine\DBAL\Schema\ColumnDiff; @@ -61,7 +61,7 @@ public function getGenerateAlterTableSql(): array public function testDoesNotSupportRegexp(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getRegexpExpression(); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 22e02ee405d..333a6e26bae 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\DBAL\Schema\Column; @@ -74,7 +74,7 @@ public static function dataInvalidIdentifiers(): iterable */ public function testInvalidIdentifiers(string $identifier): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $platform = $this->createPlatform(); $platform->assertValidIdentifier($identifier); @@ -120,7 +120,7 @@ public function getGenerateAlterTableSql(): array public function testRLike(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); self::assertEquals('RLIKE', $this->platform->getRegexpExpression()); } @@ -156,7 +156,7 @@ public function testGeneratesTransactionsCommands(): void public function testCreateDatabaseThrowsException(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); self::assertEquals('CREATE DATABASE foobar', $this->platform->getCreateDatabaseSQL('foobar')); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php index 6e0ae423063..5f3bd50e2ac 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SQLAnywherePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\LockMode; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SQLAnywherePlatform; @@ -522,7 +522,7 @@ public function testGeneratesCreateIndexWithAdvancedPlatformOptionsSQL(): void public function testDoesNotSupportIndexDeclarationInCreateAlterTableStatements(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getIndexDeclarationSQL('index', new Index('index', [])); } @@ -712,7 +712,7 @@ public function testGeneratesSQLSnippets(): void public function testDoesNotSupportRegexp(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getRegexpExpression(); } diff --git a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php index 83e25717ed6..1bf0fd63ef5 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/SqlitePlatformTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Platforms; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Column; @@ -256,14 +256,14 @@ public function getGenerateUniqueIndexSql(): string public function testGeneratesForeignKeyCreationSql(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); parent::testGeneratesForeignKeyCreationSql(); } public function testGeneratesConstraintCreationSql(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); parent::testGeneratesConstraintCreationSql(); } @@ -345,7 +345,7 @@ public function testAlterTableAddColumns(): void */ public function testAlterTableAddComplexColumns(TableDiff $diff): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->platform->getAlterTableSQL($diff); } diff --git a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php index 25a50ba999e..c596fecfc9c 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/TableTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/TableTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\DBAL\Schema; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Schema\Column; @@ -20,7 +20,7 @@ class TableTest extends DbalTestCase { public function testCreateWithInvalidTableName(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); new Table(''); } diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 5cacf902cc6..e40c0d15378 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -4,15 +4,14 @@ use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\DBALException; use Doctrine\DBAL\Driver; use Doctrine\DBAL\Driver\Connection as DriverConnection; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\Logging\SQLLogger; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Statement; use Doctrine\Tests\DbalTestCase; -use Exception; use PDOStatement; use PHPUnit\Framework\MockObject\MockObject; @@ -133,7 +132,7 @@ public function testExecuteCallsLoggerStopQueryOnException(): void $this->conn->expects($this->any()) ->method('handleExceptionDuringQuery') - ->will($this->throwException(new DBALException())); + ->will($this->throwException(new Exception())); $logger->expects($this->once()) ->method('startQuery'); @@ -143,11 +142,11 @@ public function testExecuteCallsLoggerStopQueryOnException(): void $this->pdoStatement->expects($this->once()) ->method('execute') - ->will($this->throwException(new Exception('Mock test exception'))); + ->will($this->throwException(new \Exception('Mock test exception'))); $statement = new Statement('', $this->conn); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $statement->execute(); } diff --git a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php index 98b0fd99a40..1cd7dca4fe1 100644 --- a/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/TypeRegistryTest.php @@ -4,7 +4,7 @@ namespace Doctrine\Tests\DBAL\Types; -use Doctrine\DBAL\DBALException; +use Doctrine\DBAL\Exception; use Doctrine\DBAL\Types\BinaryType; use Doctrine\DBAL\Types\BlobType; use Doctrine\DBAL\Types\StringType; @@ -42,7 +42,7 @@ public function testGet(): void self::assertSame($this->testType, $this->registry->get(self::TEST_TYPE_NAME)); self::assertSame($this->otherTestType, $this->registry->get(self::OTHER_TEST_TYPE_NAME)); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->get('unknown'); } @@ -65,7 +65,7 @@ public function testLookupName(): void $this->registry->lookupName($this->otherTestType) ); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->lookupName(new TextType()); } @@ -90,7 +90,7 @@ public function testRegisterWithAlradyRegisteredName(): void { $this->registry->register('some', new TextType()); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->register('some', new TextType()); } @@ -100,7 +100,7 @@ public function testRegisterWithAlreadyRegisteredInstance(): void $this->registry->register('some', $newType); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->register('other', $newType); } @@ -132,13 +132,13 @@ public function testOverrideWithAlreadyRegisteredInstance(): void $this->registry->register('first', $newType); $this->registry->register('second', new StringType()); - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->override('second', $newType); } public function testOverrideWithUnknownType(): void { - $this->expectException(DBALException::class); + $this->expectException(Exception::class); $this->registry->override('unknown', new TextType()); } From dd0c75189f0615b3cab18ad2d6733200ff0ebfc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Fri, 11 Sep 2020 23:48:32 +0200 Subject: [PATCH 90/93] Add explanation about implicit indexes --- docs/en/explanation/implicit-indexes.rst | 62 ++++++++++++++++++++++++ docs/en/sidebar.rst | 2 + lib/Doctrine/DBAL/Schema/Table.php | 12 +++-- 3 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 docs/en/explanation/implicit-indexes.rst diff --git a/docs/en/explanation/implicit-indexes.rst b/docs/en/explanation/implicit-indexes.rst new file mode 100644 index 00000000000..f68edbe3ffb --- /dev/null +++ b/docs/en/explanation/implicit-indexes.rst @@ -0,0 +1,62 @@ +Implicit indexes +================ + +Ever noticed the DBAL creating indexes you did not remember asking for, +with names such as ``IDX_885DBAFAA76ED395``? In this document, we will +distinguish three types of indexes: + +user-defined indexes + indexes you did ask for + +DBAL-defined indexes + indexes you did not ask for, created on your behalf by the DBAL + +RDBMS-defined indexes + indexes you did not ask for, created on your behalf by the RDBMS + +RDBMS-defined indexes can be created by some database platforms when you +create a foreign key: they will create an index on the referencing +table, using the referencing columns. + +The rationale behind this is that these indexes improve performance, for +instance for checking that a delete operation can be performed on a +referenced table without violating the constraint in the referencing +table. + +Here are some database platforms that are known to create indexes when +creating a foreign key: + +- `MySQL `_ +- `MariaDB `_ + +These platforms can drop an existing implicit index once it is fulfilled +by a newly created user-defined index. + +Some other will not do so, on grounds that such indexes are not always +needed, and can be created in many different ways. They instead leave +that responsibility to the user: + +- `PostgreSQL `_ +- `SQLite `_ +- `SQL Server `_ + +Regardless of the behavior of the platform, the DBAL will create an +index for you and will automatically pick an index name that obeys +string length constraints of the platform you are using. That way, +differences between platforms are reduced because you always end up with +an index. + +This is a detail, but these indexes will be prefixed with ``IDX_``, and +typically look like this: + +.. code-block:: sql + + CREATE INDEX IDX_885DBAFAA76ED395 ON posts (user_id) + +In the case of MariaDB and MySQL, the creation of that DBAL-defined +index will result in the RDBMS-defined index being dropped. + +You can still explicitly create such indexes yourself, and the DBAL will +notice when your index fulfills the indexing and constraint needs of the +implicit index it would create, and will refrain from doing so, much +like some platforms drop indexes that are redundant as explained above. diff --git a/docs/en/sidebar.rst b/docs/en/sidebar.rst index 0935c8dc179..4ada9f1caf1 100644 --- a/docs/en/sidebar.rst +++ b/docs/en/sidebar.rst @@ -20,3 +20,5 @@ reference/caching reference/known-vendor-issues reference/upgrading + + explanation/implicit-indexes diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index 909b349107b..bd0462151a4 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -554,11 +554,13 @@ protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) $this->_fkConstraints[$name] = $constraint; - // Add an explicit index on the foreign key columns. - // If there is already an index that fulfils this requirements drop the request. - // In the case of __construct calling this method during hydration from schema-details - // all the explicitly added indexes lead to duplicates. This creates computation overhead in this case, - // however no duplicate indexes are ever added (based on columns). + /* Add an implicit index (defined by the DBAL) on the foreign key + columns. If there is already a user-defined index that fulfills these + requirements drop the request. In the case of __construct() calling + this method during hydration from schema-details, all the explicitly + added indexes lead to duplicates. This creates computation overhead in + this case, however no duplicate indexes are ever added (based on + columns). */ $indexName = $this->_generateIdentifierName( array_merge([$this->getName()], $constraint->getColumns()), 'idx', From d333f7c0e0f5eacdf3baa903b1c18badcd49c9fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 3 Sep 2020 22:17:14 +0200 Subject: [PATCH 91/93] Setup automatic release workflow --- .../workflows/release-on-milestone-closed.yml | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/release-on-milestone-closed.yml diff --git a/.github/workflows/release-on-milestone-closed.yml b/.github/workflows/release-on-milestone-closed.yml new file mode 100644 index 00000000000..0a8bf324d97 --- /dev/null +++ b/.github/workflows/release-on-milestone-closed.yml @@ -0,0 +1,45 @@ +name: "Automatic Releases" + +on: + milestone: + types: + - "closed" + +jobs: + release: + name: "Git tag, release & create merge-up PR" + runs-on: "ubuntu-20.04" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Release" + uses: "laminas/automatic-releases@1.0.1" + with: + command-name: "laminas:automatic-releases:release" + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create Merge-Up Pull Request" + uses: "laminas/automatic-releases@1.0.1" + with: + command-name: "laminas:automatic-releases:create-merge-up-pull-request" + env: + "GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} + + - name: "Create and/or Switch to new Release Branch" + uses: "laminas/automatic-releases@v1" + with: + command-name: "laminas:automatic-releases:switch-default-branch-to-next-minor" + env: + "GITHUB_TOKEN": ${{ secrets.ORGANIZATION_ADMIN_TOKEN }} + "SIGNING_SECRET_KEY": ${{ secrets.SIGNING_SECRET_KEY }} + "GIT_AUTHOR_NAME": ${{ secrets.GIT_AUTHOR_NAME }} + "GIT_AUTHOR_EMAIL": ${{ secrets.GIT_AUTHOR_EMAIL }} From 7b58fd22bbd90b77dbabc892d28bc7500b5a5189 Mon Sep 17 00:00:00 2001 From: Joe Danis Date: Mon, 14 Sep 2020 10:16:29 -0400 Subject: [PATCH 92/93] Support ASCII parameter binding Closes #4263 --- docs/en/reference/types.rst | 10 +++ .../DBAL/Driver/Mysqli/MysqliStatement.php | 1 + .../DBAL/Driver/PDOSqlsrv/Statement.php | 19 +++-- lib/Doctrine/DBAL/Driver/PDOStatement.php | 1 + .../DBAL/Driver/SQLSrv/SQLSrvStatement.php | 9 +++ lib/Doctrine/DBAL/ParameterType.php | 5 ++ .../DBAL/Platforms/AbstractPlatform.php | 11 +++ .../DBAL/Platforms/SQLServerPlatform.php | 14 ++++ lib/Doctrine/DBAL/Types/AsciiStringType.php | 32 +++++++++ lib/Doctrine/DBAL/Types/Type.php | 1 + lib/Doctrine/DBAL/Types/Types.php | 1 + .../Functional/ParameterTypes/AsciiTest.php | 28 ++++++++ .../DBAL/Functional/Types/AsciiStringTest.php | 70 +++++++++++++++++++ .../Platforms/AbstractPlatformTestCase.php | 22 ++++++ .../DBAL/Platforms/OraclePlatformTest.php | 11 +++ .../Tests/DBAL/Types/AsciiStringTest.php | 43 ++++++++++++ 16 files changed, 273 insertions(+), 5 deletions(-) create mode 100644 lib/Doctrine/DBAL/Types/AsciiStringType.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/ParameterTypes/AsciiTest.php create mode 100644 tests/Doctrine/Tests/DBAL/Functional/Types/AsciiStringTest.php create mode 100644 tests/Doctrine/Tests/DBAL/Types/AsciiStringTest.php diff --git a/docs/en/reference/types.rst b/docs/en/reference/types.rst index f4916a69672..ee9214c20cf 100644 --- a/docs/en/reference/types.rst +++ b/docs/en/reference/types.rst @@ -157,6 +157,13 @@ or ``null`` if no data is present. This can lead to type inconsistencies when reverse engineering the type from the database. +ascii_string +++++++++++++ + +Similar to the ``string`` type but for binding non-unicode data. This type +should be used with database vendors where a binding type mismatch +can trigger an implicit cast and lead to performance problems. + text ++++ @@ -607,6 +614,9 @@ Please also notice the mapping specific footnotes for additional information. | | | | +----------------------------------------------------------+ | | | | | ``NCHAR(n)`` [4]_ | +-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ +| **ascii_string** | ``string`` | **SQL Server** | | ``VARCHAR(n)`` | +| | | | | ``CHAR(n)`` | ++-------------------+---------------+--------------------------+---------+----------------------------------------------------------+ | **text** | ``string`` | **MySQL** | *all* | ``TINYTEXT`` [17]_ | | | | | +----------------------------------------------------------+ | | | | | ``TEXT`` [18]_ | diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index 0efd36b3293..c97f879cf8b 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -38,6 +38,7 @@ class MysqliStatement implements IteratorAggregate, StatementInterface, Result { /** @var string[] */ protected static $_paramTypeMap = [ + ParameterType::ASCII => 's', ParameterType::STRING => 's', ParameterType::BINARY => 's', ParameterType::BOOLEAN => 'i', diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php index eef6d12c27f..5669ccc270e 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Statement.php @@ -17,11 +17,20 @@ class Statement extends PDO\Statement */ public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null, $driverOptions = null) { - if ( - ($type === ParameterType::LARGE_OBJECT || $type === ParameterType::BINARY) - && $driverOptions === null - ) { - $driverOptions = \PDO::SQLSRV_ENCODING_BINARY; + switch ($type) { + case ParameterType::LARGE_OBJECT: + case ParameterType::BINARY: + if ($driverOptions === null) { + $driverOptions = \PDO::SQLSRV_ENCODING_BINARY; + } + + break; + + case ParameterType::ASCII: + $type = ParameterType::STRING; + $length = 0; + $driverOptions = \PDO::SQLSRV_ENCODING_SYSTEM; + break; } return parent::bindParam($param, $variable, $type, $length, $driverOptions); diff --git a/lib/Doctrine/DBAL/Driver/PDOStatement.php b/lib/Doctrine/DBAL/Driver/PDOStatement.php index 9ef5bf23b43..4a244ab4617 100644 --- a/lib/Doctrine/DBAL/Driver/PDOStatement.php +++ b/lib/Doctrine/DBAL/Driver/PDOStatement.php @@ -30,6 +30,7 @@ class PDOStatement extends \PDOStatement implements StatementInterface, Result ParameterType::NULL => PDO::PARAM_NULL, ParameterType::INTEGER => PDO::PARAM_INT, ParameterType::STRING => PDO::PARAM_STR, + ParameterType::ASCII => PDO::PARAM_STR, ParameterType::BINARY => PDO::PARAM_LOB, ParameterType::LARGE_OBJECT => PDO::PARAM_LOB, ParameterType::BOOLEAN => PDO::PARAM_BOOL, diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php index f2f54e9987d..af98476e1af 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php @@ -34,6 +34,7 @@ use function stripos; use const SQLSRV_ENC_BINARY; +use const SQLSRV_ENC_CHAR; use const SQLSRV_ERR_ERRORS; use const SQLSRV_FETCH_ASSOC; use const SQLSRV_FETCH_BOTH; @@ -306,6 +307,14 @@ private function prepare() ]; break; + case ParameterType::ASCII: + $params[$column - 1] = [ + &$variable, + SQLSRV_PARAM_IN, + SQLSRV_PHPTYPE_STRING(SQLSRV_ENC_CHAR), + ]; + break; + default: $params[$column - 1] =& $variable; break; diff --git a/lib/Doctrine/DBAL/ParameterType.php b/lib/Doctrine/DBAL/ParameterType.php index 564adfce344..2c4c3ad18c2 100644 --- a/lib/Doctrine/DBAL/ParameterType.php +++ b/lib/Doctrine/DBAL/ParameterType.php @@ -49,6 +49,11 @@ final class ParameterType */ public const BINARY = 16; + /** + * Represents an ASCII string data type + */ + public const ASCII = 17; + /** * This class cannot be instantiated. * diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 61c6a81d742..0f25bd9bf92 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -245,6 +245,17 @@ private function initializeAllDoctrineTypeMappings() } } + /** + * Returns the SQL snippet used to declare a column that can + * store characters in the ASCII character set + * + * @param mixed[] $column + */ + public function getAsciiStringTypeDeclarationSQL(array $column): string + { + return $this->getVarcharTypeDeclarationSQL($column); + } + /** * Returns the SQL snippet used to declare a VARCHAR column type. * diff --git a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index fc551e0fe49..c1da7ab8e83 100644 --- a/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -1191,6 +1191,20 @@ public function getGuidTypeDeclarationSQL(array $column) return 'UNIQUEIDENTIFIER'; } + /** + * {@inheritDoc} + */ + public function getAsciiStringTypeDeclarationSQL(array $column): string + { + $length = $column['length'] ?? null; + + if (! isset($column['fixed'])) { + return sprintf('VARCHAR(%d)', $length); + } + + return sprintf('CHAR(%d)', $length); + } + /** * {@inheritDoc} */ diff --git a/lib/Doctrine/DBAL/Types/AsciiStringType.php b/lib/Doctrine/DBAL/Types/AsciiStringType.php new file mode 100644 index 00000000000..e7975748678 --- /dev/null +++ b/lib/Doctrine/DBAL/Types/AsciiStringType.php @@ -0,0 +1,32 @@ +getAsciiStringTypeDeclarationSQL($column); + } + + /** + * {@inheritdoc} + */ + public function getBindingType() + { + return ParameterType::ASCII; + } + + public function getName(): string + { + return Types::ASCII_STRING; + } +} diff --git a/lib/Doctrine/DBAL/Types/Type.php b/lib/Doctrine/DBAL/Types/Type.php index f75a4905673..5ff51c4c9bb 100644 --- a/lib/Doctrine/DBAL/Types/Type.php +++ b/lib/Doctrine/DBAL/Types/Type.php @@ -99,6 +99,7 @@ abstract class Type */ private const BUILTIN_TYPES_MAP = [ Types::ARRAY => ArrayType::class, + Types::ASCII_STRING => AsciiStringType::class, Types::BIGINT => BigIntType::class, Types::BINARY => BinaryType::class, Types::BLOB => BlobType::class, diff --git a/lib/Doctrine/DBAL/Types/Types.php b/lib/Doctrine/DBAL/Types/Types.php index 37a3d444bc0..3ca677942c5 100644 --- a/lib/Doctrine/DBAL/Types/Types.php +++ b/lib/Doctrine/DBAL/Types/Types.php @@ -10,6 +10,7 @@ final class Types { public const ARRAY = 'array'; + public const ASCII_STRING = 'ascii_string'; public const BIGINT = 'bigint'; public const BINARY = 'binary'; public const BLOB = 'blob'; diff --git a/tests/Doctrine/Tests/DBAL/Functional/ParameterTypes/AsciiTest.php b/tests/Doctrine/Tests/DBAL/Functional/ParameterTypes/AsciiTest.php new file mode 100644 index 00000000000..940152352d7 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/ParameterTypes/AsciiTest.php @@ -0,0 +1,28 @@ +connection->getDriver() instanceof AbstractSQLServerDriver) { + self::markTestSkipped('Driver does not support ascii string binding'); + } + + $statement = $this->connection->prepare('SELECT sql_variant_property(?, \'BaseType\')'); + + $statement->bindValue(1, 'test', ParameterType::ASCII); + $statement->execute(); + + $results = $statement->fetchOne(); + + self::assertEquals('varchar', $results); + } +} diff --git a/tests/Doctrine/Tests/DBAL/Functional/Types/AsciiStringTest.php b/tests/Doctrine/Tests/DBAL/Functional/Types/AsciiStringTest.php new file mode 100644 index 00000000000..d0559c7027a --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Functional/Types/AsciiStringTest.php @@ -0,0 +1,70 @@ +addColumn('id', 'ascii_string', [ + 'length' => 3, + 'fixed' => true, + ]); + + $table->addColumn('val', 'ascii_string', ['length' => 4]); + $table->setPrimaryKey(['id']); + + $sm = $this->connection->getSchemaManager(); + $sm->dropAndCreateTable($table); + } + + public function testInsertAndSelect(): void + { + $id1 = 'id1'; + $id2 = 'id2'; + + $value1 = 'val1'; + $value2 = 'val2'; + + $this->insert($id1, $value1); + $this->insert($id2, $value2); + + self::assertSame($value1, $this->select($id1)); + self::assertSame($value2, $this->select($id2)); + } + + private function insert(string $id, string $value): void + { + $result = $this->connection->insert('ascii_table', [ + 'id' => $id, + 'val' => $value, + ], [ + ParameterType::ASCII, + ParameterType::ASCII, + ]); + + self::assertSame(1, $result); + } + + private function select(string $id): string + { + $value = $this->connection->fetchOne( + 'SELECT val FROM ascii_table WHERE id = ?', + [$id], + [ParameterType::ASCII] + ); + + self::assertIsString($value); + + return $value; + } +} diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index b098f617ece..c63eb1a9e2f 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -1443,6 +1443,28 @@ public function testZeroOffsetWithoutLimitIsIgnored(): void $this->platform->modifyLimitQuery($query, null, 0) ); } + + /** + * @param array $column + * + * @dataProvider asciiStringSqlDeclarationDataProvider + */ + public function testAsciiSQLDeclaration(string $expectedSql, array $column): void + { + $declarationSql = $this->platform->getAsciiStringTypeDeclarationSQL($column); + self::assertEquals($expectedSql, $declarationSql); + } + + /** + * @return array}> + */ + public function asciiStringSqlDeclarationDataProvider(): array + { + return [ + ['VARCHAR(12)', ['length' => 12]], + ['CHAR(12)', ['length' => 12, 'fixed' => true]], + ]; + } } interface GetCreateTableSqlDispatchEventListener diff --git a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php index 333a6e26bae..092c073551d 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/OraclePlatformTest.php @@ -976,4 +976,15 @@ public function testQuotesDatabaseNameInListTableColumnsSQL(): void $this->platform->getListTableColumnsSQL('foo_table', "Foo'Bar\\") ); } + + /** + * @return array}> + */ + public function asciiStringSqlDeclarationDataProvider(): array + { + return [ + ['VARCHAR2(12)', ['length' => 12]], + ['CHAR(12)', ['length' => 12, 'fixed' => true]], + ]; + } } diff --git a/tests/Doctrine/Tests/DBAL/Types/AsciiStringTest.php b/tests/Doctrine/Tests/DBAL/Types/AsciiStringTest.php new file mode 100644 index 00000000000..0e4d5d299f7 --- /dev/null +++ b/tests/Doctrine/Tests/DBAL/Types/AsciiStringTest.php @@ -0,0 +1,43 @@ +type = new AsciiStringType(); + } + + public function testReturnCorrectBindingType(): void + { + self::assertEquals($this->type->getBindingType(), ParameterType::ASCII); + } + + public function testDelegateToPlatformForSqlDeclaration(): void + { + $columnDefinitions = [ + [['length' => 12, 'fixed' => true]], + [['length' => 14]], + ]; + + foreach ($columnDefinitions as $column) { + $platform = $this->createMock(AbstractPlatform::class); + $platform->expects(self::once()) + ->method('getAsciiStringTypeDeclarationSQL') + ->with($column); + + $this->type->getSQLDeclaration($column, $platform); + } + } +} From 0d4e1a8b29dd987704842f0465aded378f441dca Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sun, 20 Sep 2020 16:17:48 -0700 Subject: [PATCH 93/93] Release 2.11.0 --- .doctrine-project.json | 20 +++-- README.md | 26 +++--- composer.json | 3 +- composer.lock | 150 +++++++++++++++++++++++++++++++++- lib/Doctrine/DBAL/Version.php | 2 +- 5 files changed, 177 insertions(+), 24 deletions(-) diff --git a/.doctrine-project.json b/.doctrine-project.json index 7b97cb45129..f68f2fd0bc3 100644 --- a/.doctrine-project.json +++ b/.doctrine-project.json @@ -11,21 +11,27 @@ "slug": "latest", "upcoming": true }, + { + "name": "2.11", + "branchName": "2.11.x", + "slug": "2.11", + "current": true, + "aliases": [ + "current", + "stable" + ] + }, { "name": "2.10", - "branchName": "master", + "branchName": "2.10.x", "slug": "2.10", - "upcoming": true + "maintained": false }, { "name": "2.9", "branchName": "2.9", "slug": "2.9", - "current": true, - "aliases": [ - "current", - "stable" - ] + "maintained": false }, { "name": "2.8", diff --git a/README.md b/README.md index 5a3582b8951..8f21ee0b5b5 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Doctrine DBAL -| [Master][Master] | [2.10][2.10] | +| [Master][Master] | [2.11][2.11] | |:----------------:|:----------:| -| [![Build status][Master image]][Master] | [![Build status][2.10 image]][2.10] | -| [![GitHub Actions][GA master image]][GA master] | [![GitHub Actions][GA 2.10 image]][GA 2.10] | -| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.10 image]][AppVeyor 2.10] | -| [![Code Coverage][Coverage image]][CodeCov Master] | [![Code Coverage][Coverage 2.10 image]][CodeCov 2.10] | +| [![Build status][Master image]][Master] | [![Build status][2.11 image]][2.11] | +| [![GitHub Actions][GA master image]][GA master] | [![GitHub Actions][GA 2.11 image]][GA 2.11] | +| [![AppVeyor][AppVeyor master image]][AppVeyor master] | [![AppVeyor][AppVeyor 2.11 image]][AppVeyor 2.11] | +| [![Code Coverage][Coverage image]][CodeCov Master] | [![Code Coverage][Coverage 2.11 image]][CodeCov 2.11] | Powerful database abstraction layer with many features for database schema introspection, schema management and PDO abstraction. @@ -24,11 +24,11 @@ Powerful database abstraction layer with many features for database schema intro [GA master]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3Amaster [GA master image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg - [2.10 image]: https://img.shields.io/travis/doctrine/dbal/2.10.x.svg?style=flat-square - [Coverage 2.10 image]: https://codecov.io/gh/doctrine/dbal/branch/2.10.x/graph/badge.svg - [2.10]: https://github.com/doctrine/dbal/tree/2.10.x - [CodeCov 2.10]: https://codecov.io/gh/doctrine/dbal/branch/2.10.x - [AppVeyor 2.10]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.10.x - [AppVeyor 2.10 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.10.x?svg=true - [GA 2.10]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A2.10.x - [GA 2.10 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg?branch=2.10.x + [2.11 image]: https://img.shields.io/travis/doctrine/dbal/2.11.x.svg?style=flat-square + [Coverage 2.11 image]: https://codecov.io/gh/doctrine/dbal/branch/2.11.x/graph/badge.svg + [2.11]: https://github.com/doctrine/dbal/tree/2.11.x + [CodeCov 2.11]: https://codecov.io/gh/doctrine/dbal/branch/2.11.x + [AppVeyor 2.11]: https://ci.appveyor.com/project/doctrine/dbal/branch/2.11.x + [AppVeyor 2.11 image]: https://ci.appveyor.com/api/projects/status/i88kitq8qpbm0vie/branch/2.11.x?svg=true + [GA 2.11]: https://github.com/doctrine/dbal/actions?query=workflow%3A%22Continuous+Integration%22+branch%3A2.11.x + [GA 2.11 image]: https://github.com/doctrine/dbal/workflows/Continuous%20Integration/badge.svg?branch=2.11.x diff --git a/composer.json b/composer.json index 28b74a542d8..e3c26687995 100644 --- a/composer.json +++ b/composer.json @@ -65,8 +65,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.10.x-dev", - "dev-develop": "3.0.x-dev" + "dev-master": "4.0.x-dev" } } } diff --git a/composer.lock b/composer.lock index a826b9c29e3..c0e3434b50c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a197851427d005342e778cba6dbffd04", + "content-hash": "2a7bb91be55d10f401c5f03dd7f235bc", "packages": [ { "name": "doctrine/cache", @@ -78,6 +78,10 @@ "cache", "caching" ], + "support": { + "issues": "https://github.com/doctrine/cache/issues", + "source": "https://github.com/doctrine/cache/tree/v1.7.1" + }, "time": "2017-08-25T07:02:50+00:00" }, { @@ -152,6 +156,10 @@ "eventdispatcher", "eventmanager" ], + "support": { + "issues": "https://github.com/doctrine/event-manager/issues", + "source": "https://github.com/doctrine/event-manager/tree/master" + }, "time": "2018-06-11T11:59:03+00:00" } ], @@ -232,6 +240,11 @@ "non-blocking", "promise" ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/amp/issues", + "source": "https://github.com/amphp/amp/tree/master" + }, "funding": [ { "url": "https://github.com/amphp", @@ -304,6 +317,11 @@ "non-blocking", "stream" ], + "support": { + "irc": "irc://irc.freenode.org/amphp", + "issues": "https://github.com/amphp/byte-stream/issues", + "source": "https://github.com/amphp/byte-stream/tree/master" + }, "time": "2020-06-29T18:35:05+00:00" }, { @@ -359,6 +377,10 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", + "support": { + "issues": "https://github.com/composer/package-versions-deprecated/issues", + "source": "https://github.com/composer/package-versions-deprecated/tree/1.10.99.1" + }, "funding": [ { "url": "https://packagist.com", @@ -434,6 +456,11 @@ "validation", "versioning" ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/semver/issues", + "source": "https://github.com/composer/semver/tree/1.5.1" + }, "time": "2020-01-13T12:06:48+00:00" }, { @@ -478,6 +505,11 @@ "Xdebug", "performance" ], + "support": { + "irc": "irc://irc.freenode.org/composer", + "issues": "https://github.com/composer/xdebug-handler/issues", + "source": "https://github.com/composer/xdebug-handler/tree/1.4.3" + }, "funding": [ { "url": "https://packagist.com", @@ -558,6 +590,10 @@ "stylecheck", "tests" ], + "support": { + "issues": "https://github.com/dealerdirect/phpcodesniffer-composer-installer/issues", + "source": "https://github.com/dealerdirect/phpcodesniffer-composer-installer" + }, "time": "2020-06-25T14:57:39+00:00" }, { @@ -614,6 +650,10 @@ "standard", "style" ], + "support": { + "issues": "https://github.com/doctrine/coding-standard/issues", + "source": "https://github.com/doctrine/coding-standard/tree/8.1.x" + }, "time": "2020-07-05T20:35:22+00:00" }, { @@ -729,6 +769,10 @@ } ], "description": "A more advanced JSONRPC implementation", + "support": { + "issues": "https://github.com/felixfbecker/php-advanced-json-rpc/issues", + "source": "https://github.com/felixfbecker/php-advanced-json-rpc/tree/master" + }, "time": "2020-03-11T15:21:41+00:00" }, { @@ -776,6 +820,10 @@ "php", "server" ], + "support": { + "issues": "https://github.com/felixfbecker/php-language-server-protocol/issues", + "source": "https://github.com/felixfbecker/php-language-server-protocol/tree/v1.4.0" + }, "time": "2019-06-23T21:03:50+00:00" }, { @@ -820,6 +868,9 @@ "stubs", "type" ], + "support": { + "source": "https://github.com/JetBrains/phpstorm-stubs/tree/master" + }, "time": "2019-12-05T16:56:26+00:00" }, { @@ -924,6 +975,11 @@ } ], "description": "Map nested JSON structures onto PHP classes", + "support": { + "email": "cweiske@cweiske.de", + "issues": "https://github.com/cweiske/jsonmapper/issues", + "source": "https://github.com/cweiske/jsonmapper/tree/master" + }, "time": "2020-04-16T18:48:43+00:00" }, { @@ -976,6 +1032,10 @@ "parser", "php" ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/master" + }, "time": "2020-08-18T19:48:01+00:00" }, { @@ -1025,6 +1085,10 @@ "xml", "xml conversion" ], + "support": { + "issues": "https://github.com/nullivex/lib-array2xml/issues", + "source": "https://github.com/nullivex/lib-array2xml/tree/master" + }, "time": "2019-03-29T20:06:56+00:00" }, { @@ -1185,6 +1249,10 @@ "reflection", "static analysis" ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, "time": "2020-06-27T09:03:43+00:00" }, { @@ -1237,6 +1305,10 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, "time": "2020-08-15T11:14:08+00:00" }, { @@ -1282,6 +1354,10 @@ } ], "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.x" + }, "time": "2020-06-27T10:12:23+00:00" }, { @@ -1398,6 +1474,10 @@ "MIT" ], "description": "PHPDoc parser with support for nullable, intersection and generic types", + "support": { + "issues": "https://github.com/phpstan/phpdoc-parser/issues", + "source": "https://github.com/phpstan/phpdoc-parser/tree/master" + }, "time": "2020-04-13T16:28:46+00:00" }, { @@ -1929,6 +2009,10 @@ } ], "description": "Psalm plugin for PHPUnit", + "support": { + "issues": "https://github.com/psalm/psalm-plugin-phpunit/issues", + "source": "https://github.com/psalm/psalm-plugin-phpunit/tree/0.10.1" + }, "time": "2020-05-24T20:30:10+00:00" }, { @@ -1978,6 +2062,10 @@ "container-interop", "psr" ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/master" + }, "time": "2017-02-14T16:28:37+00:00" }, { @@ -2025,6 +2113,9 @@ "psr", "psr-3" ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.3" + }, "time": "2020-03-23T09:12:05+00:00" }, { @@ -2980,6 +3071,10 @@ "MIT" ], "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", + "support": { + "issues": "https://github.com/slevomat/coding-standard/issues", + "source": "https://github.com/slevomat/coding-standard/tree/6.3.10" + }, "funding": [ { "url": "https://github.com/kukulich", @@ -3041,6 +3136,11 @@ "phpcs", "standards" ], + "support": { + "issues": "https://github.com/squizlabs/PHP_CodeSniffer/issues", + "source": "https://github.com/squizlabs/PHP_CodeSniffer", + "wiki": "https://github.com/squizlabs/PHP_CodeSniffer/wiki" + }, "time": "2020-04-17T01:09:41+00:00" }, { @@ -3117,6 +3217,23 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/console/tree/v4.4.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], "time": "2020-03-30T11:41:10+00:00" }, { @@ -3173,6 +3290,9 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/debug/tree/4.0" + }, "time": "2018-02-28T21:50:02+00:00" }, { @@ -3235,6 +3355,9 @@ "polyfill", "portable" ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.18.0" + }, "funding": [ { "url": "https://symfony.com/sponsor", @@ -3308,6 +3431,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/master" + }, "time": "2019-11-27T14:18:11+00:00" }, { @@ -3366,6 +3492,9 @@ "portable", "shim" ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.13.0" + }, "time": "2019-11-27T16:25:15+00:00" }, { @@ -3424,6 +3553,9 @@ "interoperability", "standards" ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.8" + }, "time": "2019-10-14T12:27:06+00:00" }, { @@ -3571,6 +3703,10 @@ "inspection", "php" ], + "support": { + "issues": "https://github.com/vimeo/psalm/issues", + "source": "https://github.com/vimeo/psalm/tree/3.14.2" + }, "time": "2020-08-22T14:01:26+00:00" }, { @@ -3620,6 +3756,10 @@ "check", "validate" ], + "support": { + "issues": "https://github.com/webmozart/assert/issues", + "source": "https://github.com/webmozart/assert/tree/master" + }, "time": "2020-07-08T17:02:28+00:00" }, { @@ -3667,6 +3807,10 @@ } ], "description": "A PHP implementation of Ant's glob.", + "support": { + "issues": "https://github.com/webmozart/glob/issues", + "source": "https://github.com/webmozart/glob/tree/master" + }, "time": "2015-12-29T11:14:33+00:00" }, { @@ -3713,6 +3857,10 @@ } ], "description": "A robust cross-platform utility for normalizing, comparing and modifying file paths.", + "support": { + "issues": "https://github.com/webmozart/path-util/issues", + "source": "https://github.com/webmozart/path-util/tree/2.3.0" + }, "time": "2015-12-17T08:42:14+00:00" } ], diff --git a/lib/Doctrine/DBAL/Version.php b/lib/Doctrine/DBAL/Version.php index 454a28884e6..cc4069ee9d2 100644 --- a/lib/Doctrine/DBAL/Version.php +++ b/lib/Doctrine/DBAL/Version.php @@ -17,7 +17,7 @@ class Version /** * Current Doctrine Version. */ - public const VERSION = '2.11.0-DEV'; + public const VERSION = '2.11.0'; /** * Compares a Doctrine version with the current one.