yiisoft / yiisoft/yii-debug-api

Incompatible with latest yiisoft/yii-http 1.1.0

Open
#158 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
17
Forks
13
PR merge metrics
No merged PRs in 30d

Description

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);

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Yiisoft\Yii\Debug\Api\Debug\Http\HttpApplicationWrapper and compare its dispatcher replacement with the readonly dispatcher introduced in yiisoft/yii-http 1.1.0. Reproduce the failure while building Yiisoft\Yii\Http\Application, then inspect the surrounding integration for a compatible approach. Done means the wrapper works with yii-http 1.1.0 without the readonly-property error.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.