Skip to content

Commit 12f74ec

Browse files
committed
Added aritmetic check
1 parent 18b06c4 commit 12f74ec

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Builder/Builder.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
namespace FastyBird\JsonApi\Builder;
1717

18-
use DivisionByZeroError;
1918
use FastyBird\JsonApi\JsonApi;
2019
use InvalidArgumentException;
2120
use Neomerx;
@@ -77,7 +76,6 @@ public function __construct(
7776
* @param object|Array<object>|null $entity
7877
* @param callable(string): bool $linkValidator
7978
*
80-
* @throws DivisionByZeroError
8179
* @throws InvalidArgumentException
8280
* @throws RuntimeException
8381
*/
@@ -113,7 +111,7 @@ public function build(
113111
$pageLimit = null;
114112
}
115113

116-
if ($pageOffset !== null && $pageLimit !== null) {
114+
if ($pageOffset !== null && $pageLimit !== null && $pageLimit > 0) {
117115
$lastPage = (int) round($totalCount / $pageLimit) * $pageLimit;
118116

119117
if ($lastPage === $totalCount) {

src/Hydrators/Hydrator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,13 @@ protected function mapEntity(string $entityClassName): array
425425
$varAnnotation = $this->parseAnnotation($rp, 'var');
426426

427427
try {
428+
$propertyType = $rp->getType();
429+
430+
if ($propertyType instanceof ReflectionNamedType) {
431+
$varAnnotation = ($varAnnotation === null ? '' : $varAnnotation . '|')
432+
. $propertyType->getName() . ($propertyType->allowsNull() ? '|null' : '');
433+
}
434+
428435
$rm = $rc->getMethod('get' . ucfirst($fieldName));
429436

430437
$returnType = $rm->getReturnType();

0 commit comments

Comments
 (0)