Get noticeUninitialized string offset 0 in /vendor/yiisoft/yii2/widgets/Menu.php:309 when using '' as a url. Since PHP 8 has E_ALL turned on by default, it will be a problem.
echo Menu::widget([
'items' => [
['label' => 'Some Label', 'url' => ['', '#' => 'someid']]
]
]);
| Q | A
| ---------------- | ---
| Yii version | 2.0.39.3
| PHP version | 7.4, 8.0
| Operating system | Linux, MacOS
How come? This is a valid array syntax with offset 0. And there is the check in line 307 anyway.
308: $route = Yii::getAlias($item['url'][0]);
309: $route[0]
Isn't that a [0] too many?
It's similar to #9754
Oh, right, lol, totally missed that, cheers. Yes, looks like old "using string as an array".
Shouldn't that be, substr($route,0,1) !== '/', while Yii::getAlias can return string|bool
if (false !== $route && '/' !== substr($route,0,1) && Yii::$app->controller) {
Yes, it should. And I think we can skip false !== $route since with the way getAlias() is called it will never be false.