/** * @param Container $container * @param string $key * @param bool $same */ private function assertResult(Container $container, $key, $same) { $a = $container->get($key); $b = $container->get($key); $this->assertInstanceOf(DatabaseConnection::class, $a); $this->assertInstanceOf(DatabaseConnection::class, $b); $same ? $this->assertSame($a, $b) : $this->assertNotSame($a, $b); }
/** * {@inheritdoc} */ public function getPropertyValue(\ReflectionProperty $property) { // Check if an injection key is available for this property. $key = $this->injectionPolicy->getPropertyKey($property); if ($key !== null) { return $this->container->get($key); } // Try to resolve the property by type. $className = $this->reflectionTools->getPropertyClass($property); if ($className !== null) { if ($this->container->has($className)) { return $this->container->get($className); } } return $this->defaultValueResolver->getPropertyValue($property); }
/** * {@inheritdoc} */ public function resolve(Container $container) { $parameters = $container->get($this->usingParameters); $parameters = $parameters + $this->withParameters; if ($this->target instanceof \Closure) { return $container->getInjector()->invoke($this->target, $parameters); } return $container->getInjector()->instantiate($this->target, $parameters); }
/** * {@inheritdoc} */ public function resolve(Container $container) { return $container->get($this->target); }