From 54f509ccd25fd873ad365b473756ec7f304dc275 Mon Sep 17 00:00:00 2001 From: Nikita Date: Tue, 22 Sep 2020 12:19:50 +0700 Subject: [PATCH] Cast getLimit() result to int instead of string Currently method getLimit() returns string, which is different from PHPDoc. It could affect PHP apps which used declare(strict_types=1); --- src/Parameters.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Parameters.php b/src/Parameters.php index 0280e47..8653b07 100644 --- a/src/Parameters.php +++ b/src/Parameters.php @@ -112,7 +112,15 @@ protected function getOffsetFromNumber($perPage) */ public function getLimit($max = null) { - $limit = $this->getPage('limit') ?: $this->getPage('size') ?: null; + $limit = (int) $this->getPage('limit'); + + if (! $limit) { + $limit = (int) $this->getPage('size'); + } + + if (! $limit) { + $limit = null; + } if ($limit && $max) { $limit = min($max, $limit);