Skip to content

Commit fa39f26

Browse files
committed
Fix php-curl-class#517: Require mbstring extension.
Use global namespace for mb_* functions.
1 parent fc054f6 commit fa39f26

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
],
1515
"require": {
1616
"php": ">=5.3",
17-
"ext-curl": "*"
17+
"ext-curl": "*",
18+
"ext-mbstring": "*"
1819
},
1920
"require-dev": {
2021
"phpunit/phpunit": "*",

src/Curl/StrUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class StrUtil
1515
*/
1616
public static function startsWith($haystack, $needle)
1717
{
18-
return mb_substr($haystack, 0, mb_strlen($needle)) === $needle;
18+
return \mb_substr($haystack, 0, \mb_strlen($needle)) === $needle;
1919
}
2020
}

src/Curl/Url.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public static function removeDotSegments($input)
5656
// buffer; otherwise,
5757
} elseif (StrUtil::startsWith($input, '/../')) {
5858
$input = substr($input, 3);
59-
$output = substr_replace($output, '', mb_strrpos($output, '/'));
59+
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
6060
} elseif ($input === '/..') {
6161
$input = '/';
62-
$output = substr_replace($output, '', mb_strrpos($output, '/'));
62+
$output = substr_replace($output, '', \mb_strrpos($output, '/'));
6363

6464
// D. if the input buffer consists only of "." or "..", then remove
6565
// that from the input buffer; otherwise,
@@ -70,7 +70,7 @@ public static function removeDotSegments($input)
7070
// the output buffer, including the initial "/" character (if
7171
// any) and any subsequent characters up to, but not including,
7272
// the next "/" character or the end of the input buffer.
73-
} elseif (!(($pos = mb_strpos($input, '/', 1)) === false)) {
73+
} elseif (!(($pos = \mb_strpos($input, '/', 1)) === false)) {
7474
$output .= substr($input, 0, $pos);
7575
$input = substr_replace($input, '', 0, $pos);
7676
} else {
@@ -131,7 +131,7 @@ private function absolutizeUrl()
131131
if (StrUtil::startsWith($r['path'], '/')) {
132132
$target['path'] = self::removeDotSegments($r['path']);
133133
} else {
134-
$base = mb_strrchr($b['path'], '/', true);
134+
$base = \mb_strrchr($b['path'], '/', true);
135135
if ($base === false) {
136136
$base = '';
137137
}

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public function testExtensionsLoaded()
1212
{
1313
$this->assertTrue(extension_loaded('curl'));
1414
$this->assertTrue(extension_loaded('gd'));
15+
$this->assertTrue(extension_loaded('mbstring'));
1516
}
1617

1718
public function testArrayAssociative()

0 commit comments

Comments
 (0)