From 4f57b1d65b1bd615e2eb18a90b4bd757c2a5e6d3 Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Wed, 23 Sep 2020 18:36:32 -0700 Subject: [PATCH] Remove Abstraction\Result --- UPGRADE.md | 4 ++ src/Abstraction/Result.php | 68 ---------------------------- src/Cache/CachingResult.php | 5 +- src/Connection.php | 3 +- src/Query/QueryBuilder.php | 2 +- src/Result.php | 27 +++++++---- tests/ConnectionTest.php | 2 +- tests/Functional/ResultCacheTest.php | 2 +- tests/Functional/StatementTest.php | 2 +- 9 files changed, 31 insertions(+), 84 deletions(-) delete mode 100644 src/Abstraction/Result.php diff --git a/UPGRADE.md b/UPGRADE.md index eb92850dc1f..7fb4012a4dc 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK `Doctrine\DBAL\Abstraction\Result` removed + +The `Doctrine\DBAL\Abstraction\Result` interface is removed. Use the `Doctrine\DBAL\Result` class instead. + ## BC BREAK: `Doctrine\DBAL\Types\Type::getDefaultLength()` removed The `Doctrine\DBAL\Types\Type::getDefaultLength()` method has been removed as it served no purpose. diff --git a/src/Abstraction/Result.php b/src/Abstraction/Result.php deleted file mode 100644 index 4c192bf4bd0..00000000000 --- a/src/Abstraction/Result.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * @throws Exception - */ - public function fetchAllKeyValue(): array; - - /** - * Returns an iterator over the result set rows represented as numeric arrays. - * - * @return Traversable> - * - * @throws Exception - */ - public function iterateNumeric(): Traversable; - - /** - * Returns an iterator over the result set rows represented as associative arrays. - * - * @return Traversable> - * - * @throws Exception - */ - public function iterateAssociative(): Traversable; - - /** - * Returns an iterator over the result set with the keys mapped to the first column - * and the values mapped to the second column. - * - * The result must contain at least two columns. - * - * @return Traversable - * - * @throws Exception - */ - public function iterateKeyValue(): Traversable; - - /** - * Returns an iterator over the values of the first column of the result set. - * - * @return Traversable - * - * @throws Exception - */ - public function iterateColumn(): Traversable; -} diff --git a/src/Cache/CachingResult.php b/src/Cache/CachingResult.php index b634afa4f2d..84b2f96457c 100644 --- a/src/Cache/CachingResult.php +++ b/src/Cache/CachingResult.php @@ -5,7 +5,8 @@ use Doctrine\Common\Cache\Cache; use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\FetchUtils; -use Doctrine\DBAL\Driver\Result; +use Doctrine\DBAL\Driver\Result as DriverResult; +use Doctrine\DBAL\Result; use function array_map; use function array_values; @@ -23,7 +24,7 @@ * * @internal The class is internal to the caching layer implementation. */ -class CachingResult implements Result +class CachingResult implements DriverResult { /** @var Cache */ private $cache; diff --git a/src/Connection.php b/src/Connection.php index 096ee99f858..aa953993544 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -4,7 +4,6 @@ use Closure; use Doctrine\Common\EventManager; -use Doctrine\DBAL\Abstraction\Result as AbstractionResult; use Doctrine\DBAL\Cache\ArrayResult; use Doctrine\DBAL\Cache\CacheException; use Doctrine\DBAL\Cache\CachingResult; @@ -974,7 +973,7 @@ public function executeQuery( array $params = [], $types = [], ?QueryCacheProfile $qcp = null - ): AbstractionResult { + ): Result { if ($qcp !== null) { return $this->executeCacheQuery($sql, $params, $types, $qcp); } diff --git a/src/Query/QueryBuilder.php b/src/Query/QueryBuilder.php index 3ec6d5557a6..cdf50e1c6e5 100644 --- a/src/Query/QueryBuilder.php +++ b/src/Query/QueryBuilder.php @@ -3,11 +3,11 @@ namespace Doctrine\DBAL\Query; use Doctrine\DBAL\Connection; -use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Exception; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Query\Expression\CompositeExpression; use Doctrine\DBAL\Query\Expression\ExpressionBuilder; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Statement; use function array_key_exists; diff --git a/src/Result.php b/src/Result.php index 80d3a4ba601..6d75fc4c16b 100644 --- a/src/Result.php +++ b/src/Result.php @@ -4,13 +4,12 @@ namespace Doctrine\DBAL; -use Doctrine\DBAL\Abstraction\Result as ResultInterface; use Doctrine\DBAL\Driver\Exception as DriverException; use Doctrine\DBAL\Driver\Result as DriverResult; use Doctrine\DBAL\Exception\NoKeyValue; use Traversable; -final class Result implements ResultInterface +class Result { /** @var DriverResult */ private $result; @@ -28,7 +27,9 @@ public function __construct(DriverResult $result, Connection $connection) } /** - * {@inheritDoc} + * Returns the next row of the result as a numeric array or FALSE if there are no more rows. + * + * @return array|false * * @throws Exception */ @@ -42,7 +43,9 @@ public function fetchNumeric() } /** - * {@inheritDoc} + * Returns the next row of the result as an associative array or FALSE if there are no more rows. + * + * @return array|false * * @throws Exception */ @@ -56,7 +59,9 @@ public function fetchAssociative() } /** - * {@inheritDoc} + * Returns the first value of the next row of the result or FALSE if there are no more rows. + * + * @return mixed|false * * @throws Exception */ @@ -70,7 +75,9 @@ public function fetchOne() } /** - * {@inheritDoc} + * Returns an array containing all of the result rows represented as numeric arrays. + * + * @return array> * * @throws Exception */ @@ -84,7 +91,9 @@ public function fetchAllNumeric(): array } /** - * {@inheritDoc} + * Returns an array containing all of the result rows represented as associative arrays. + * + * @return array> * * @throws Exception */ @@ -98,7 +107,9 @@ public function fetchAllAssociative(): array } /** - * {@inheritDoc} + * Returns an array containing the values of the first column of the result. + * + * @return array * * @throws Exception */ diff --git a/tests/ConnectionTest.php b/tests/ConnectionTest.php index 4802d3e1011..462590d4dd4 100644 --- a/tests/ConnectionTest.php +++ b/tests/ConnectionTest.php @@ -4,7 +4,6 @@ use Doctrine\Common\Cache\Cache; use Doctrine\Common\EventManager; -use Doctrine\DBAL\Abstraction\Result; use Doctrine\DBAL\Cache\QueryCacheProfile; use Doctrine\DBAL\Configuration; use Doctrine\DBAL\Connection; @@ -19,6 +18,7 @@ use Doctrine\DBAL\Logging\DebugStack; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; +use Doctrine\DBAL\Result; use Doctrine\DBAL\VersionAwarePlatformDriver; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; diff --git a/tests/Functional/ResultCacheTest.php b/tests/Functional/ResultCacheTest.php index e0ddf392d3c..c780377d68e 100644 --- a/tests/Functional/ResultCacheTest.php +++ b/tests/Functional/ResultCacheTest.php @@ -4,8 +4,8 @@ use Doctrine\Common\Cache\ArrayCache; use Doctrine\DBAL\Cache\QueryCacheProfile; -use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\Logging\DebugStack; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; diff --git a/tests/Functional/StatementTest.php b/tests/Functional/StatementTest.php index 19bd319fa33..5292064d515 100644 --- a/tests/Functional/StatementTest.php +++ b/tests/Functional/StatementTest.php @@ -4,8 +4,8 @@ use Doctrine\DBAL\Driver\Exception; use Doctrine\DBAL\Driver\PDO; -use Doctrine\DBAL\Driver\Result; use Doctrine\DBAL\ParameterType; +use Doctrine\DBAL\Result; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Tests\FunctionalTestCase; use Doctrine\DBAL\Types\Type;