mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-14 22:30:27 +08:00
Fixes #16266: Fixed yii\helpers\BaseStringHelper
where explode would not allow 0 as trim string
This commit is contained in:

committed by
Alexander Makarov

parent
e4b559d720
commit
a32cfcc8ef
@ -22,6 +22,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #16217: Fixed `yii\console\controllers\HelpController` to work well in Windows environment (samdark)
|
- Bug #16217: Fixed `yii\console\controllers\HelpController` to work well in Windows environment (samdark)
|
||||||
- Bug #14636: Views can now use relative paths even when using themed views (sammousa)
|
- Bug #14636: Views can now use relative paths even when using themed views (sammousa)
|
||||||
- Bug #16245: Fixed `__isset()` in `BaseActiveRecord` not catching errors (sammousa)
|
- Bug #16245: Fixed `__isset()` in `BaseActiveRecord` not catching errors (sammousa)
|
||||||
|
- Bug #16266: Fixed `yii\helpers\BaseStringHelper` where explode would not allow 0 as trim string (Thoulah)
|
||||||
- Enh #16191: Enhanced `yii\helpers\Inflector` to work correctly with UTF-8 (silverfire)
|
- Enh #16191: Enhanced `yii\helpers\Inflector` to work correctly with UTF-8 (silverfire)
|
||||||
- Bug: Fixed bad instnaceof check in `yii\db\Schema::getTableMetadata()` (samdark)
|
- Bug: Fixed bad instnaceof check in `yii\db\Schema::getTableMetadata()` (samdark)
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class BaseStringHelper
|
|||||||
public static function explode($string, $delimiter = ',', $trim = true, $skipEmpty = false)
|
public static function explode($string, $delimiter = ',', $trim = true, $skipEmpty = false)
|
||||||
{
|
{
|
||||||
$result = explode($delimiter, $string);
|
$result = explode($delimiter, $string);
|
||||||
if ($trim) {
|
if ($trim !== false) {
|
||||||
if ($trim === true) {
|
if ($trim === true) {
|
||||||
$trim = 'trim';
|
$trim = 'trim';
|
||||||
} elseif (!is_callable($trim)) {
|
} elseif (!is_callable($trim)) {
|
||||||
|
@ -267,6 +267,7 @@ class StringHelperTest extends TestCase
|
|||||||
$this->assertEquals(['It', 'is', 'a test with trimmed digits', '0', '1', '2'], StringHelper::explode('It, is, a test with trimmed digits, 0, 1, 2', ',', true, true));
|
$this->assertEquals(['It', 'is', 'a test with trimmed digits', '0', '1', '2'], StringHelper::explode('It, is, a test with trimmed digits, 0, 1, 2', ',', true, true));
|
||||||
$this->assertEquals(['It', 'is', 'a second', 'test'], StringHelper::explode('It+ is+ a second+ test', '+'));
|
$this->assertEquals(['It', 'is', 'a second', 'test'], StringHelper::explode('It+ is+ a second+ test', '+'));
|
||||||
$this->assertEquals(['Save', '', '', 'empty trimmed string'], StringHelper::explode('Save, ,, empty trimmed string', ','));
|
$this->assertEquals(['Save', '', '', 'empty trimmed string'], StringHelper::explode('Save, ,, empty trimmed string', ','));
|
||||||
|
$this->assertEquals(['44', '512'], StringHelper::explode('0 0 440 512', ' ', '0', true));
|
||||||
$this->assertEquals(['Здесь', 'multibyte', 'строка'], StringHelper::explode('Здесь我 multibyte我 строка', '我'));
|
$this->assertEquals(['Здесь', 'multibyte', 'строка'], StringHelper::explode('Здесь我 multibyte我 строка', '我'));
|
||||||
$this->assertEquals(['Disable', ' trim ', 'here but ignore empty'], StringHelper::explode('Disable, trim ,,,here but ignore empty', ',', false, true));
|
$this->assertEquals(['Disable', ' trim ', 'here but ignore empty'], StringHelper::explode('Disable, trim ,,,here but ignore empty', ',', false, true));
|
||||||
$this->assertEquals(['It/', ' is?', ' a', ' test with rtrim'], StringHelper::explode('It/, is?, a , test with rtrim', ',', 'rtrim'));
|
$this->assertEquals(['It/', ' is?', ' a', ' test with rtrim'], StringHelper::explode('It/, is?, a , test with rtrim', ',', 'rtrim'));
|
||||||
|
Reference in New Issue
Block a user