Skip to content

Incompatible with latest yiisoft/yii-http 1.1.0 #158

@batyrmastyr

Description

@batyrmastyr

After updating to yiisoft/yii-http I get and error: Yiisoft\Di\BuildingException with message "Caught unhandled error "Cannot modify readonly property Yiisoft\Yii\Http\Application::$dispatcher" while building "Yiisoft\Yii\Http\Application"

In yiisoft/yii-http v1.1.0 \Yiisoft\Yii\Http\Application

public function __construct(
        private readonly MiddlewareDispatcher $dispatcher, // was `private MiddlewareDispatcher $dispatcher`
        private readonly EventDispatcherInterface|null $eventDispatcher = null,
        private readonly RequestHandlerInterface $fallbackHandler = new UnhandledRequestHandler()
    ) {
    }

and $dispatcher is modified \Yiisoft\Yii\Debug\Api\Debug\Http\HttpApplicationWrapper

$closure = Closure::bind(
    static fn (Application $application) => $application->dispatcher = $middlewareDispatcher->withMiddlewares([
        ...$middlewareDefinitions,
        ['class' => MiddlewareDispatcherMiddleware::class, '$middlewareDispatcher' => $application->dispatcher],
    ]),
    null,
    $application
);

$closure($application);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions