protected function buildWithDefinition($id, array $config = [], $definition = null)
    {
        if (\is_string($definition)) {
            if ($definition !== $id) {
                return $this->build($definition, $config);
            }
            $definition = ['__class' => $definition];
        }

        if (\is_array($definition) && !isset($definition[0], $definition[1])) {
            return $this->buildFromConfig($id, array_merge($config, $definition));
        }

        if (\is_callable($definition)) {
            return $definition($this, $config);
        }

        if (\is_object($definition)) {
            return $definition;
        }

        throw new InvalidConfigException('Unexpected object definition type: ' . \gettype($definition));
    }
protected function buildWithDefinition($id, array $config = [], $definition = null)
    {
        if (\is_string($definition)) {
            if ($definition !== $id) {
                return $this->build($definition, $config);
            }
            $definition = ['__class' => $definition];
        }

        if (\is_array($definition) && !isset($definition[0], $definition[1])) {
            return $this->buildFromConfig($id, array_merge($config, $definition));
        }

        if (\is_callable($definition)) {
            return $definition($this, $config);
        }

        if (\is_object($definition)) {
            return $definition;
        }

        throw new InvalidConfigException('Unexpected object definition type: ' . \gettype($definition));
    }
protected function buildWithDefinition ( $ id , array $ config = [ ] , $ definition = null ) { if ( \ is_string ( $ definition ) ) { if ( $ definition !== $ id ) { return $ this -> build ( $ definition , $ config ) ; } $ definition = [ '__class' => $ definition ] ; } if ( \ is_array ( $ definition ) && ! isset ( $ definition [ 0 ] , $ definition [ 1 ] ) ) { return $ this -> buildFromConfig ( $ id , array_merge ( $ config , $ definition ) ) ; } if ( \ is_callable ( $ definition ) ) { return $ definition ( $ this , $ config ) ; } if ( \ is_object ( $ definition ) ) { return $ definition ; } throw new InvalidConfigException ( 'Unexpected object definition type: ' . \ gettype ( $ definition ) ) ; }
Creates new instance by given config and definition.

@param string $id the interface name or an alias name (e.g. `foo`) that was previously registered via [[set()]].
@param array $config
@param array|string|object $definition
@return object new built instance
@throws InvalidConfigException when definition type is not expected
@throws NotInstantiableException
Creates new instance by given config and definition .