Skip to content

Commit dd3c937

Browse files
committed
Returns NULL instead of FALSE for non-exists entities
1 parent 0dc3810 commit dd3c937

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

src/TQueryableEntity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function find($field, Query $query)
3333

3434
/**
3535
* Fetchs one entity by Query object
36-
* @return Entity|FALSE
36+
* @return Entity|NULL
3737
*/
3838
public function findOne($field, Query $query)
3939
{
@@ -42,7 +42,7 @@ public function findOne($field, Query $query)
4242
if ($entities) {
4343
return $entities[0];
4444
}
45-
return FALSE;
45+
return NULL;
4646
}
4747

4848

src/TQueryableRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ public function find(Query $query)
3131

3232
/**
3333
* Fetchs one entity by Query object
34-
* @return Entity|FALSE
34+
* @return Entity|NULL
3535
*/
3636
public function findOne(Query $query)
3737
{
3838
$row = $this->applyQuery($query)
3939
->removeClause('limit')
4040
->removeClause('offset')
4141
->fetch();
42-
return $row ? $this->createEntity($row) : FALSE;
42+
return $row ? $this->createEntity($row) : NULL;
4343
}
4444

4545

src/TRepository.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function createNewEntity()
2020

2121
/**
2222
* Fetchs entity by primary key
23-
* @return Entity|FALSE
23+
* @return Entity|NULL
2424
*/
2525
public function get($id)
2626
{
@@ -30,7 +30,7 @@ public function get($id)
3030

3131
/**
3232
* Fetchs entity by column value
33-
* @return Entity|FALSE
33+
* @return Entity|NULL
3434
*/
3535
protected function getByColumn($column, $value)
3636
{
@@ -39,9 +39,6 @@ protected function getByColumn($column, $value)
3939
->where('%n = ?', $column, $value)
4040
->fetch();
4141

42-
if ($row === FALSE) {
43-
return $row;
44-
}
45-
return $this->createEntity($row);
42+
return $row ? $this->createEntity($row) : NULL;
4643
}
4744
}

tests/InlmModel/TQueryableEntity.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ test(function () use ($authorRepository, $sql) {
7676
->where('@id > 9999')
7777
->findOne();
7878

79-
Assert::false($book);
79+
Assert::null($book);
8080
});
8181

8282

tests/InlmModel/TQueryableRepository.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ test(function () use ($bookRepository, $sql) {
6767
->where('@id > 9999')
6868
->findOne();
6969

70-
Assert::false($book);
70+
Assert::null($book);
7171
});
7272

7373

tests/InlmModel/TRepository.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ test(function () use ($bookRepository) {
4949

5050
test(function () use ($bookRepository) {
5151
$book = $bookRepository->get(9999);
52-
Assert::false($book);
52+
Assert::null($book);
5353
});

0 commit comments

Comments
 (0)