yii2: BC break in ArrayHelper on 2.0.36
What steps will reproduce the problem?
$list = self::find()
->select(['lng', 'name' => 'name_' . Yii::$app->language])
->orderBy('sort, name')
->all();
$test = ArrayHelper::map($list, 'lng', 'name');
var_dump($test);
What is the expected result?
2.0.35 result
array(9) {
["Icao"]=>
string(27) "ICAO/NATO phonetic alphabet"
["Lapd"]=>
string(19) "LAPD radio alphabet"
["NlBe"]=>
string(15) "Dutch (Belgium)"
["NlNl"]=>
string(23) "Dutch (The Netherlands)"
["Fr"]=>
string(6) "French"
["De"]=>
string(6) "German"
["It"]=>
string(7) "Italian"
["Es"]=>
string(7) "Spanish"
["Useless"]=>
string(49) "The Non-Phonetic Alphabet (Use at your own risk!)"
}
What do you get instead?
2.0.36-dev result
array(9) {
["Icao"]=>
NULL
["Lapd"]=>
NULL
["NlBe"]=>
NULL
["NlNl"]=>
NULL
["Fr"]=>
NULL
["De"]=>
NULL
["It"]=>
NULL
["Es"]=>
NULL
["Useless"]=>
NULL
}
Additional info
| Q | A |
|---|---|
| Yii version | 2.0.36-dev |
| PHP version | 7.4.6 |
| Operating system | Debian 9 |
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 42 (39 by maintainers)
wrote to email
Looking good from my end!
With my example here, https://github.com/yiisoft/yii2/issues/18086#issuecomment-649557239
var_dumpvar_dumpNULL(or whatever$defaultis) even though property existsI could fix it with checking first with
offsetExistsThese smart individuals came to that conclusion based on my report and code. I have never even looked at
ArrayAccessto say anything useful in this matter.Right. I will come back with a correct test this evening then 😃