diff --git a/src/Builder/Builder.php b/src/Builder/Builder.php index 9cca151..9967067 100644 --- a/src/Builder/Builder.php +++ b/src/Builder/Builder.php @@ -15,7 +15,6 @@ namespace FastyBird\JsonApi\Builder; -use DivisionByZeroError; use FastyBird\JsonApi\JsonApi; use InvalidArgumentException; use Neomerx; @@ -77,7 +76,6 @@ public function __construct( * @param object|Array|null $entity * @param callable(string): bool $linkValidator * - * @throws DivisionByZeroError * @throws InvalidArgumentException * @throws RuntimeException */ @@ -113,7 +111,7 @@ public function build( $pageLimit = null; } - if ($pageOffset !== null && $pageLimit !== null) { + if ($pageOffset !== null && $pageLimit !== null && $pageLimit > 0) { $lastPage = (int) round($totalCount / $pageLimit) * $pageLimit; if ($lastPage === $totalCount) { diff --git a/src/Hydrators/Hydrator.php b/src/Hydrators/Hydrator.php index 7824821..75c0c94 100644 --- a/src/Hydrators/Hydrator.php +++ b/src/Hydrators/Hydrator.php @@ -425,6 +425,13 @@ protected function mapEntity(string $entityClassName): array $varAnnotation = $this->parseAnnotation($rp, 'var'); try { + $propertyType = $rp->getType(); + + if ($propertyType instanceof ReflectionNamedType) { + $varAnnotation = ($varAnnotation === null ? '' : $varAnnotation . '|') + . $propertyType->getName() . ($propertyType->allowsNull() ? '|null' : ''); + } + $rm = $rc->getMethod('get' . ucfirst($fieldName)); $returnType = $rm->getReturnType();