Skip to content

Commit 10451b5

Browse files
authored
Remove ext-ctype from require section of composer.json (#936)
1 parent b5a8f8a commit 10451b5

4 files changed

Lines changed: 10 additions & 31 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
- Bug #933: Explicitly mark nullable parameters (@vjik)
6666
- Chg #911: Change supported PHP versions to `8.1 - 8.4` (@Tigrov)
6767
- Enh #911: Minor refactoring (@Tigrov)
68-
- Chg #938: Remove `ext-json` from `require` section of `composer.json` (@Tigrov)
68+
- Chg #938, #936: Remove `ext-json`, `ext-ctype` from `require` section of `composer.json` (@Tigrov)
69+
- Chg #936: Remove `hasLimit()` and `hasOffset()` methods from `AbstractDQLQueryBuilder` class (@Tigrov)
6970

7071
## 1.3.0 March 21, 2024
7172

UPGRADE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Each table column has its own class in the `Yiisoft\Db\Schema\Column` namespace
142142
- `DbArrayHelper::getColumn()` - use `array_column()` instead;
143143
- `DbArrayHelper::getValueByPath()`;
144144
- `DbArrayHelper::populate()` - use `DbArrayHelper::index()` instead;
145+
- `AbstractDQLQueryBuilder::hasLimit()` - use `$limit !== null` instead;
146+
- `AbstractDQLQueryBuilder::hasOffset()` - use `!empty($offset)` instead;
145147

146148
### Remove deprecated parameters
147149

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
],
3232
"require": {
3333
"php": "8.1 - 8.4",
34-
"ext-ctype": "*",
3534
"ext-mbstring": "*",
3635
"ext-pdo": "*",
3736
"psr/log": "^2.0|^3.0",

src/QueryBuilder/AbstractDQLQueryBuilder.php

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
use function array_filter;
3131
use function array_merge;
3232
use function array_shift;
33-
use function ctype_digit;
3433
use function implode;
3534
use function is_array;
3635
use function is_bool;
@@ -265,12 +264,14 @@ public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterf
265264
{
266265
$sql = '';
267266

268-
if ($this->hasLimit($limit)) {
269-
$sql = 'LIMIT ' . ($limit instanceof ExpressionInterface ? $this->buildExpression($limit) : (string) $limit);
267+
if ($limit !== null) {
268+
$sql = 'LIMIT '
269+
. ($limit instanceof ExpressionInterface ? $this->buildExpression($limit) : (string) $limit);
270270
}
271271

272-
if ($this->hasOffset($offset)) {
273-
$sql .= ' OFFSET ' . ($offset instanceof ExpressionInterface ? $this->buildExpression($offset) : (string) $offset);
272+
if (!empty($offset)) {
273+
$sql .= ' OFFSET '
274+
. ($offset instanceof ExpressionInterface ? $this->buildExpression($offset) : (string) $offset);
274275
}
275276

276277
return ltrim($sql);
@@ -552,30 +553,6 @@ protected function extractAlias(string $table): array|bool
552553
return false;
553554
}
554555

555-
/**
556-
* Checks to see if the given limit is effective.
557-
*
558-
* @param mixed $limit The given limit.
559-
*
560-
* @return bool Whether the limit is effective.
561-
*/
562-
protected function hasLimit(mixed $limit): bool
563-
{
564-
return ($limit instanceof ExpressionInterface) || ctype_digit((string) $limit);
565-
}
566-
567-
/**
568-
* Checks to see if the given offset is effective.
569-
*
570-
* @param mixed $offset The given offset.
571-
*
572-
* @return bool Whether the offset is effective.
573-
*/
574-
protected function hasOffset(mixed $offset): bool
575-
{
576-
return ($offset instanceof ExpressionInterface) || (ctype_digit((string)$offset) && (string)$offset !== '0');
577-
}
578-
579556
/**
580557
* @throws Exception
581558
* @throws InvalidConfigException

0 commit comments

Comments
 (0)