Ioc container. Remove 'Reference Parameter' support
Closed this issue · 2 comments
alchimik commented
Opulence/src/Opulence/Ioc/Container.php
Lines 327 to 332 in 843da06
1. it doesn't work
I checked: HEAD, v1.0.0, v1.0.0-rc2
1.1 test is wrong
ContainerTest::testResolvingClassWithReferenceParameter
should be something like:
public function testResolvingClassWithReferenceParameter()
{
// preparing
$bar = new Bar();
$this->container->bindInstance($this->fooInterface, $bar);
/** @var ConstructorWithReference $instance1 */
$instance1 = $this->container->resolve($this->constructorWithReference);
/** @var ConstructorWithReference $withRef2 */
$instance2 = $this->container->resolve($this->constructorWithReference);
$this->assertInstanceOf($this->constructorWithReference, $instance1);
$this->assertInstanceOf($this->constructorWithReference, $instance2);
$this->assertNotSame($instance1, $instance2);
$this->assertSame($instance1->getFoo(), $instance2->getFoo());
// start useful check
$instance1->setFoo(new Bar());
$this->assertSame($instance1->getFoo(), $instance2->getFoo());
$instance2->setFoo(new Bar());
$this->assertSame($instance1->getFoo(), $instance2->getFoo());
}
2. other containers don't support this
- illuminate/container
- symfony/dependency-injection
but I could be wrong
3. this is a really dangerous feature (imho)
davidbyoung commented
So, you're suggesting to replace
Opulence/src/Opulence/Ioc/Container.php
Lines 327 to 332 in 843da06
$resolvedParameters[] = $resolvedParameter;
?alchimik commented
So, you're suggesting to replace
with $resolvedParameters[] = $resolvedParameter;?Opulence/src/Opulence/Ioc/Container.php
Lines 327 to 332 in 843da06
yes, and remove ContainerTest::testResolvingClassWithReferenceParameter
test