Skip to content

Commit aba25ed

Browse files
authored
Allow type enums in some parameters (#36)
1 parent ed6f847 commit aba25ed

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/DatabaseSelectBuilder.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ final class DatabaseSelectBuilder
2222
public const DEFAULT_LIMIT = 20;
2323
private QueryBuilder $builder;
2424
private Table $from;
25-
/** @var array<string, string> [class => doctrine type, ...] */
25+
/** @var array<string, string|ParameterType|Type|ArrayParameterType> [class => doctrine type, ...] */
2626
private array $types;
2727
/** @var array<string, string> [model field => query field, ...] */
2828
private array $sortMap = [];
@@ -31,7 +31,7 @@ final class DatabaseSelectBuilder
3131
/** @var array<string, string> */
3232
private array $fieldSelect = [];
3333

34-
/** @param array<string, string> $types */
34+
/** @param array<string, string|ParameterType|Type|ArrayParameterType> $types */
3535
public function __construct(Connection $connection, array $types = [DateTimeImmutable::class => 'DateTimeImmutable'])
3636
{
3737
$this->builder = $connection->createQueryBuilder();
@@ -52,7 +52,7 @@ public function resetForConnection(Connection $connection): self
5252
return $copy;
5353
}
5454

55-
/** @param array<string, string> $types */
55+
/** @param array<string, string|ParameterType|Type|ArrayParameterType> $types */
5656
public function withTypes(array $types): self
5757
{
5858
$copy = clone $this;
@@ -125,7 +125,7 @@ public function rightJoin(Table $join, string $condition): self
125125

126126
/**
127127
* @param array<string, mixed> $params
128-
* @param array<string, string> $types
128+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
129129
*/
130130
public function where(string $condition, array $params = [], array $types = []): self
131131
{
@@ -140,7 +140,7 @@ public function where(string $condition, array $params = [], array $types = []):
140140

141141
/**
142142
* @param array<string, mixed> $params
143-
* @param array<string, string> $types
143+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
144144
*/
145145
public function having(string $condition, array $params = [], array $types = []): self
146146
{
@@ -278,7 +278,7 @@ public function withParameter(string $key, mixed $value, string|ParameterType|Ty
278278

279279
/**
280280
* @param array<string, mixed> $params
281-
* @param array<string|int, string> $types
281+
* @param array<string|int, string|ParameterType|Type|ArrayParameterType> $types
282282
*/
283283
public function withParameters(array $params = [], array $types = []): self
284284
{
@@ -328,7 +328,7 @@ public function startOffset(): int
328328
return $this->startOffset;
329329
}
330330

331-
private function paramType(mixed $object): string|ParameterType|ArrayParameterType
331+
private function paramType(mixed $object): string|ParameterType|Type|ArrayParameterType
332332
{
333333
if (is_array($object)) {
334334
return ArrayParameterType::STRING;

src/Query/AbstractDatabaseQuery.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
namespace GW\DQO\Query;
44

5+
use Doctrine\DBAL\ArrayParameterType;
56
use Doctrine\DBAL\Connection;
7+
use Doctrine\DBAL\ParameterType;
8+
use Doctrine\DBAL\Types\Type;
69
use GW\DQO\DatabaseSelectBuilder;
710
use GW\DQO\Table;
811
use function in_array;
@@ -36,7 +39,7 @@ public function resetForConnection(Connection $connection): self
3639
/**
3740
* @return static
3841
* @param array<string, mixed> $params
39-
* @param array<string, string> $types
42+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
4043
*/
4144
public function join(Table $join, string $condition, array $params = [], array $types = []): self
4245
{
@@ -50,7 +53,7 @@ public function join(Table $join, string $condition, array $params = [], array $
5053
/**
5154
* @return static
5255
* @param array<string, mixed> $params
53-
* @param array<string, string> $types
56+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
5457
*/
5558
public function leftJoin(Table $join, string $condition, array $params = [], array $types = []): self
5659
{
@@ -76,7 +79,7 @@ public function joinOnce(Table $join, string $condition): self
7679
/**
7780
* @return static
7881
* @param array<string, mixed> $params
79-
* @param array<string, string> $types
82+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
8083
*/
8184
public function where(string $condition, array $params = [], array $types = []): self
8285
{
@@ -89,7 +92,7 @@ public function where(string $condition, array $params = [], array $types = []):
8992
/**
9093
* @return static
9194
* @param array<string, mixed> $params
92-
* @param array<string, string> $types
95+
* @param array<string, string|ParameterType|Type|ArrayParameterType> $types
9396
*/
9497
public function having(string $condition, array $params = [], array $types = []): self
9598
{

0 commit comments

Comments
 (0)