What steps will reproduce the problem?
class Foo
{
public function __construct(public Bar $bar)
{
}
}
class Bar
{
public function __construct(public string $value = 'default')
{
}
}
$config = ContainerConfig::create()
->withDefinitions([
Foo::class => [
'class' => Foo::class,
'__construct()' => [
'baz' => Reference::to('bar'), // Typo here
],
],
'bar' => [
'class' => Bar::class,
'__construct()' => [
'value' => 'custom',
],
],
]);
$container = new Container($config);
var_dump($container->get(Foo::class));
What is the expected result?
Exception with message, like:
Unknown parameter $baz in Foo::__construct() method. Available paraemeters: $bar
What do you get instead?
New instance of Foo with wrong Bar
class Foo#11 (1) {
public Bar $bar =>
class Bar#10 (1) {
public string $value =>
string(7) "default"
}
}
Additional info
| Q |
A |
| Version |
master |
| PHP version |
N/A |
| Operating system |
N/A |
What steps will reproduce the problem?
What is the expected result?
Exception with message, like:
Unknown parameter $baz in Foo::__construct() method. Available paraemeters: $barWhat do you get instead?
New instance of
Foowith wrongBarAdditional info