Skip to content

Widget::end will crash if widget is configured by closure in di container #20267

@jrajamaki

Description

@jrajamaki

What steps will reproduce the problem?

Using basic app as an example, create your own widget, e.g.

class ActiveForm extends yii\bootstrap5\ActiveForm {}

and configure di container to replace the original implementation using closure:

'container' => [
    'definitions' => [
        yii\bootstrap5\ActiveForm::class => fn ($container, $params, $config) => new ActiveForm($config),
    ]
],

Now when accessing basic app's "Contact" page, then app crashes with error "Cannot use object of type Closure as array".

What is the expected result?

It would work.

What do you get instead?

"Cannot use object of type Closure as array" error.

Additional info

Similar to yiisoft/yii2-debug#234.
Caused by commit 0dbc4d3.

Q A
Yii version 2.0.51
PHP version 8.3.9
Operating system macOS 14.5 Sonoma

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions