annotated-container
annotated-container copied to clipboard
Create test for container factory preparing an interface and having all implementations invoke method
We want to support being able to specify an interface method as a target for #[ServicePrepare] and all implementations of that interface have the appropriate method invoked. At least in the php-di container (and possibly others) this functionality is not supported.
A new test-case should be implemented in the ContainerFactoryTestCase to accommodate this use-case. Specifically, the following should be possible:
<?php
namespace Psr\Log {
interface LoggerAwareInterface {
#[ServicePrepare]
public function setLogger(LoggerInterface $logger) : void;
}
}
class MyClass implements LoggerAwareInterface {
public function setLogger(LoggerInterface $logger) : void {
// this is called automatically on object creation, passing in the LoggerInterface
// configured for this container
}
}
This test already exists and is passing for the php-di container. Need to dig further into what's happening here.
I don't think this is actually a problem anymore. Closing this.