Skip to content

Commit e2835d5

Browse files
authored
Remove ext-mbstring from require section of composer.json (#937)
1 parent 10451b5 commit e2835d5

6 files changed

Lines changed: 6 additions & 68 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
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, #936: Remove `ext-json`, `ext-ctype` from `require` section of `composer.json` (@Tigrov)
68+
- Chg #938, #936, #937: Remove `ext-json`, `ext-ctype`, `ext-mbstring` from `require` section of `composer.json` (@Tigrov)
6969
- Chg #936: Remove `hasLimit()` and `hasOffset()` methods from `AbstractDQLQueryBuilder` class (@Tigrov)
70+
- Chg #937: Remove `baseName()` and `pascalCaseToId()` methods from `DbStringHelper` (@Tigrov)
7071

7172
## 1.3.0 March 21, 2024
7273

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+
- `DbStringHelper::baseName()`;
146+
- `DbStringHelper::pascalCaseToId()`;
145147
- `AbstractDQLQueryBuilder::hasLimit()` - use `$limit !== null` instead;
146148
- `AbstractDQLQueryBuilder::hasOffset()` - use `!empty($offset)` instead;
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-mbstring": "*",
3534
"ext-pdo": "*",
3635
"psr/log": "^2.0|^3.0",
3736
"psr/simple-cache": "^2.0|^3.0"

src/Cache/SchemaCache.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use function is_string;
1616
use function json_encode;
1717
use function json_last_error_msg;
18-
use function mb_strlen;
1918
use function md5;
19+
use function strlen;
2020
use function strpbrk;
2121

2222
/**
@@ -200,7 +200,7 @@ private function normalize(mixed $key): string
200200
{
201201
if (is_string($key) || is_int($key)) {
202202
$key = (string)$key;
203-
$length = mb_strlen($key, '8bit');
203+
$length = strlen($key);
204204
return (strpbrk($key, '{}()/\@:') !== false || $length < 1 || $length > 64) ? md5($key) : $key;
205205
}
206206

src/Helper/DbStringHelper.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,15 @@
55
namespace Yiisoft\Db\Helper;
66

77
use function is_float;
8-
use function mb_strrpos;
9-
use function mb_strtolower;
10-
use function mb_substr;
118
use function preg_match;
129
use function preg_replace;
13-
use function rtrim;
1410
use function str_replace;
15-
use function trim;
1611

1712
/**
1813
* String manipulation methods.
1914
*/
2015
final class DbStringHelper
2116
{
22-
/**
23-
* Returns the trailing name part of a path.
24-
*
25-
* This method is similar to the php function `basename()` except that it will treat both \ and / as directory
26-
* separators, independent of the operating system.
27-
*
28-
* This method was mainly created to work on php namespaces. When working with real file paths, PHP's `basename()`
29-
* should work fine for you.
30-
*
31-
* Note: this method isn't aware of the actual filesystem, or path components such as "..".
32-
*
33-
* @param string $path A path string.
34-
*
35-
* @return string The trailing name part of the given path.
36-
*
37-
* @link https://www.php.net/manual/en/function.basename.php
38-
*/
39-
public static function baseName(string $path): string
40-
{
41-
$path = rtrim(str_replace('\\', '/', $path), '/');
42-
$position = mb_strrpos($path, '/');
43-
44-
if ($position !== false) {
45-
return mb_substr($path, $position + 1);
46-
}
47-
48-
return $path;
49-
}
50-
5117
/**
5218
* Returns a value indicating whether an SQL statement is for read purpose.
5319
*
@@ -78,20 +44,4 @@ public static function normalizeFloat(float|string $value): string
7844
/** @var string */
7945
return preg_replace('/\.(?=.*\.)/', '', $value);
8046
}
81-
82-
/**
83-
* Converts a PascalCase name into an ID in lowercase.
84-
*
85-
* Words in the ID may be concatenated using '_'. For example, 'PostTag' will be converted to 'post_tag'.
86-
*
87-
* @param string $input The string to be converted.
88-
*
89-
* @return string The resulting ID.
90-
*/
91-
public static function pascalCaseToId(string $input): string
92-
{
93-
/** @var string $result */
94-
$result = preg_replace('/(?<=\p{L})(?<!\p{Lu})(\p{Lu})/u', '_\1', $input);
95-
return mb_strtolower(trim($result, '_'));
96-
}
9747
}

tests/Db/Helper/DbStringHelperTest.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
*/
1313
final class DbStringHelperTest extends TestCase
1414
{
15-
public function testBaseName(): void
16-
{
17-
$this->assertSame('TestCase', DbStringHelper::baseName(TestCase::class));
18-
$this->assertSame('TestCase', DbStringHelper::baseName('TestCase'));
19-
}
20-
2115
public function testIsReadQuery(): void
2216
{
2317
$this->assertTrue(DbStringHelper::isReadQuery('SELECT * FROM tbl'));
@@ -37,14 +31,6 @@ public static function pascalCaseToIdProvider(): array
3731
];
3832
}
3933

40-
/**
41-
* @dataProvider pascalCaseToIdProvider
42-
*/
43-
public function testPascalCaseToId(string $expectedResult, string $input): void
44-
{
45-
$this->assertEquals($expectedResult, DbStringHelper::pascalCaseToId($input));
46-
}
47-
4834
public function testNormalizeFloat()
4935
{
5036
$this->assertSame('123', DbStringHelper::normalizeFloat(123));

0 commit comments

Comments
 (0)