Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Abstraction\Result #4294

Merged
merged 1 commit into from
Sep 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
68 changes: 0 additions & 68 deletions src/Abstraction/Result.php

This file was deleted.

5 changes: 3 additions & 2 deletions src/Cache/CachingResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is having a Doctrine\DBAL\Result in $result on purpose instead of a Driver\Result and planned for 3.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The caching layer only works with the wrapper-level result. Prior to this change, the wrapper result would implement the driver result interface, so this signature would work. As of this change, it's no longer true.

Additional references:

  1. The same is true for the wrapper Connection and Statement classes as of Do not implement driver-level interfaces by wrapper-level classes #4159.
  2. We may rework the caching layer into a driver-level middleware where it belongs but it's not a top priority for me. See Rework the portability layer to act as a middleware #4157, there's basically a similar issue here.


use function array_map;
use function array_values;
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Query/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 19 additions & 8 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<int,mixed>|false
*
* @throws Exception
*/
Expand All @@ -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<string,mixed>|false
*
* @throws Exception
*/
Expand All @@ -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
*/
Expand All @@ -70,7 +75,9 @@ public function fetchOne()
}

/**
* {@inheritDoc}
* Returns an array containing all of the result rows represented as numeric arrays.
*
* @return array<int,array<int,mixed>>
*
* @throws Exception
*/
Expand All @@ -84,7 +91,9 @@ public function fetchAllNumeric(): array
}

/**
* {@inheritDoc}
* Returns an array containing all of the result rows represented as associative arrays.
*
* @return array<int,array<string,mixed>>
*
* @throws Exception
*/
Expand All @@ -98,7 +107,9 @@ public function fetchAllAssociative(): array
}

/**
* {@inheritDoc}
* Returns an array containing the values of the first column of the result.
*
* @return array<mixed,mixed>
*
* @throws Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/ResultCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down