Skip to content

Commit ec70acb

Browse files
committed
Improve types in pool interface
1 parent 21043ab commit ec70acb

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

src/Finder.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function getType(): string
5252

5353
public function getSelectSql(): string
5454
{
55-
return $this->getSelectFieldsSql($this->pool->getEscapedTypeFields($this->type));
55+
return $this->getSelectFieldsSql($this->pool->getTypeFieldsReadStatement($this->type));
5656
}
5757

5858
public function getSelectIdsSql(): string
@@ -279,9 +279,13 @@ private function loadByTypeField(): bool
279279
return $this->load_by_type_field;
280280
}
281281

282-
private function getSelectFieldsSql(string $escaped_field_names): string
282+
private function getSelectFieldsSql(string $fields_read_statement): string
283283
{
284-
$result = "SELECT $escaped_field_names FROM " . $this->getEscapedTableName();
284+
$result = sprintf(
285+
'SELECT %s FROM %s',
286+
$fields_read_statement,
287+
$this->getEscapedTableName()
288+
);
285289

286290
if ($this->join) {
287291
$result .= " $this->join";

src/Pool.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public function forget(string $type, int ...$ids_to_forget): void
300300
*
301301
* @param array|string|null $conditions
302302
*/
303-
public function count(string $type, $conditions = null): int
303+
public function count(string $type, mixed $conditions = null): int
304304
{
305305
$this->requireRegisteredType($type);
306306

@@ -359,10 +359,7 @@ public function getDefaultFinderClass(): string
359359
return Finder::class;
360360
}
361361

362-
/**
363-
* {@inheritdoc}
364-
*/
365-
public function findBySql(string $type, string $sql, ...$arguments)
362+
public function findBySql(string $type, string $sql, mixed ...$arguments): mixed
366363
{
367364
if (empty($type)) {
368365
throw new InvalidArgumentException('Type is required');

src/PoolInterface.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ public function forget(string $type, int ...$ids_to_forget): void;
3636
/**
3737
* Return number of records of the given type that match the given conditions.
3838
*
39-
* @param string $type
4039
* @param array|string|null $conditions
41-
* @return int
4240
*/
43-
public function count(string $type, $conditions = null): int;
41+
public function count(string $type, mixed $conditions = null): int;
4442

4543
/**
4644
* Return true if object of the given type with the given ID exists.
@@ -62,13 +60,9 @@ public function find(string $type): FinderInterface;
6260
/**
6361
* Return result by a prepared SQL statement.
6462
*
65-
* @param string $type
66-
* @param string $sql
67-
* @param mixed $arguments
6863
* @return ResultInterface|EntityInterface[]|null
6964
*/
70-
public function findBySql(string $type, string $sql, ...$arguments);
71-
65+
public function findBySql(string $type, string $sql, mixed ...$arguments): mixed;
7266
public function getTypeTable(string $type, bool $escaped = false): string;
7367

7468
/**

0 commit comments

Comments
 (0)