di
di copied to clipboard
Container doesn't resolve properties of already built instances after their state reset
What steps will reproduce the problem?
Run yiisoft/demo via RR(yiisoft/yii-runner-roadrunner)
1st request is handled properly, after which StateResetter::reset() is invoked
in subsequent requests container returns instances with unresolved properties
Example for subsequent requests:
What is the expected result?

What do you get instead?

Additional info
| Q | A |
|---|---|
| Version | 1.1.0 |
| PHP version | 8.1.2 |
| Operating system | Ubuntu 22.04 |
Seems, problem here.
On first request container parse definitions and convert their to objects, but on reset this is not happening.
as a temporary solution for anyone who's running demo app on RR, amend reset:
'reset' => function (\Psr\Container\ContainerInterface $container) use ($params) {
/** @var WebView $this */
$this->clear();
$resolvedParams = [];
foreach ($params['yiisoft/view']['parameters'] as $id => $value) {
$resolvedParams[$id] = $value instanceof \Yiisoft\Definitions\Reference ? $value->resolve($container) : $value;
}
$this->setParameters($resolvedParams);
}