-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11596 from doctrine/3.2.x
Merge 3.2.x up into 3.3.x
- Loading branch information
Showing
13 changed files
with
68 additions
and
47 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Doctrine\Tests\Mocks; | ||
|
||
use Doctrine\DBAL\Cache\ArrayResult; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Driver\PDO\SQLite\Driver; | ||
use Doctrine\DBAL\Result; | ||
use ReflectionMethod; | ||
|
||
use function array_keys; | ||
use function array_map; | ||
use function array_values; | ||
|
||
final class ArrayResultFactory | ||
{ | ||
/** @param list<array<string, mixed>> $resultSet */ | ||
public static function createDriverResultFromArray(array $resultSet): ArrayResult | ||
{ | ||
if ((new ReflectionMethod(ArrayResult::class, '__construct'))->getNumberOfRequiredParameters() < 2) { | ||
// DBAL < 4.2 | ||
return new ArrayResult($resultSet); | ||
} | ||
|
||
// DBAL 4.2+ | ||
return new ArrayResult( | ||
array_keys($resultSet[0] ?? []), | ||
array_map(array_values(...), $resultSet), | ||
); | ||
} | ||
|
||
/** @param list<array<string, mixed>> $resultSet */ | ||
public static function createWrapperResultFromArray(array $resultSet, Connection|null $connection = null): Result | ||
{ | ||
return new Result( | ||
self::createDriverResultFromArray($resultSet), | ||
$connection ?? new Connection([], new Driver()), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters