Related tickets:
- Class
- Factory
- Value
- Alias
- Array (new)
- String/concat (new)?
- Callback/Factory
- Array
- Class?
- Decorate (composition)?
For reference, in Symfony decoration is done that way: symfony/symfony#9003
Base config:
<?php
return [
Foo::class => object()
->constructorParam('param1', 0)
->constructorParam('param2', 1),
'logger.handlers' => [
link(StdOutHandler::class),
],
// String
'path.tmp' => '/tmp',
'path.log' => string(link('path.tmp'), '/app.log'),
];
Factory extension:
<?php
return [
Foo::class => extend()->factory(function (Foo $foo, ContainerInterface $container) {
$foo->setStuff(true);
return $foo;
}),
];
Array extension:
<?php
return [
'logger.handlers' => extend()->array([
link(PaperTrailHandler::class),
]),
];
Class extension:
<?php
return [
Foo::class => extend()->object()
->constructorParam('param2', 10),
];
What about chaining?
<?php
return [
Foo::class => object(Bar::class)
->constructor(original(Foo::class)),
];
Or more simply (and probably saner):
<?php
return [
Foo::class => object(),
Bar::class => object()
->constructor(link(Foo::class)),
SomeInterface::class => link(Bar::class),
];