Skip to content

Commit

Permalink
Added aritmetic check
Browse files Browse the repository at this point in the history
  • Loading branch information
akadlec committed Feb 8, 2024
1 parent 18b06c4 commit 12f74ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace FastyBird\JsonApi\Builder;

use DivisionByZeroError;
use FastyBird\JsonApi\JsonApi;
use InvalidArgumentException;
use Neomerx;
Expand Down Expand Up @@ -77,7 +76,6 @@ public function __construct(
* @param object|Array<object>|null $entity
* @param callable(string): bool $linkValidator
*
* @throws DivisionByZeroError
* @throws InvalidArgumentException
* @throws RuntimeException
*/
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions src/Hydrators/Hydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 12f74ec

Please sign in to comment.