src/Viserio/Component/Container/Container.php
public function give($implementation)
    {
        if (! ($reflector = $this->getReflector($this->concrete))) {
            throw new UnresolvableDependencyException(\sprintf('[%s] is not resolvable.', $this->concrete));
        }

        if ($reflector instanceof ReflectionClass && ! ($reflector = $reflector->getConstructor())) {
            throw new UnresolvableDependencyException(\sprintf('[%s] must have a constructor.', $this->concrete));
        }

        $reflectionParameters = $reflector->getParameters();
        $contextualParameters = &$this->contextualParameters[$this->abstract];

        foreach ($reflectionParameters as $key => $parameter) {
            $class = $parameter->getClass();

            if ($this->parameter === $parameter->name) {
                return $contextualParameters[$key] = $implementation;
            }

            if ($class && $this->parameter === $class->name) {
                return $contextualParameters[$key] = $this->contextualBindingFormat($implementation, $class);
            }
        }

        $concrete = \gettype($this->concrete);

        if (\is_object($this->concrete)) {
            $concrete = \get_class($this->concrete);
        } elseif (\is_array($this->concrete)) {
            $concrete = $this->concrete[0];
        } elseif (\is_string($this->concrete)) {
            $concrete = $this->concrete;
        }

        throw new UnresolvableDependencyException(\sprintf(
            'Parameter [%s] cannot be injected in [%s].',
            $this->parameter,
            $concrete
        ));
    }
public function give($implementation)
    {
        if (! ($reflector = $this->getReflector($this->concrete))) {
            throw new UnresolvableDependencyException(\sprintf('[%s] is not resolvable.', $this->concrete));
        }

        if ($reflector instanceof ReflectionClass && ! ($reflector = $reflector->getConstructor())) {
            throw new UnresolvableDependencyException(\sprintf('[%s] must have a constructor.', $this->concrete));
        }

        $reflectionParameters = $reflector->getParameters();
        $contextualParameters = &$this->contextualParameters[$this->abstract];

        foreach ($reflectionParameters as $key => $parameter) {
            $class = $parameter->getClass();

            if ($this->parameter === $parameter->name) {
                return $contextualParameters[$key] = $implementation;
            }

            if ($class && $this->parameter === $class->name) {
                return $contextualParameters[$key] = $this->contextualBindingFormat($implementation, $class);
            }
        }

        $concrete = \gettype($this->concrete);

        if (\is_object($this->concrete)) {
            $concrete = \get_class($this->concrete);
        } elseif (\is_array($this->concrete)) {
            $concrete = $this->concrete[0];
        } elseif (\is_string($this->concrete)) {
            $concrete = $this->concrete;
        }

        throw new UnresolvableDependencyException(\sprintf(
            'Parameter [%s] cannot be injected in [%s].',
            $this->parameter,
            $concrete
        ));
    }
{@inheritdoc}