public static function injectExternalContainer(ContainerInterface $container, string $setMethod = '')
    {
        if (static::$externalContainer) {
            throw new ContainerLogicException(
                'Can\'t inject external container when external container already exists.'
            );
        }
        if (static::$internalContainer) {
            throw new ContainerLogicException(
                'Can\'t inject external container when internal container already exists.'
            );
        }
        if ($setMethod) {
            if (!method_exists($container, $setMethod)) {
                throw new ContainerInvalidArgumentException(
                    'External container type[' . get_class($container) . '] has no method[' . $setMethod . '].');
            }
            static::$setMethod = $setMethod;
        } elseif ($container instanceof \ArrayAccess) {
            static::$setMethod = 'offsetSet';
        } elseif (!method_exists($container, 'set')) {
            throw new ContainerInvalidArgumentException(
                'Empty arg setMethod and external container type['
                . get_class($container) . '] has no set() method and is not ArrayAccess.'
            );
        }
        static::$externalContainer = $container;
    }
public static function injectExternalContainer(ContainerInterface $container, string $setMethod = '')
    {
        if (static::$externalContainer) {
            throw new ContainerLogicException(
                'Can\'t inject external container when external container already exists.'
            );
        }
        if (static::$internalContainer) {
            throw new ContainerLogicException(
                'Can\'t inject external container when internal container already exists.'
            );
        }
        if ($setMethod) {
            if (!method_exists($container, $setMethod)) {
                throw new ContainerInvalidArgumentException(
                    'External container type[' . get_class($container) . '] has no method[' . $setMethod . '].');
            }
            static::$setMethod = $setMethod;
        } elseif ($container instanceof \ArrayAccess) {
            static::$setMethod = 'offsetSet';
        } elseif (!method_exists($container, 'set')) {
            throw new ContainerInvalidArgumentException(
                'Empty arg setMethod and external container type['
                . get_class($container) . '] has no set() method and is not ArrayAccess.'
            );
        }
        static::$externalContainer = $container;
    }
public static function injectExternalContainer ( ContainerInterface $ container , string $ setMethod = '' ) { if ( static :: $ externalContainer ) { throw new ContainerLogicException ( 'Can\'t inject external container when external container already exists.' ) ; } if ( static :: $ internalContainer ) { throw new ContainerLogicException ( 'Can\'t inject external container when internal container already exists.' ) ; } if ( $ setMethod ) { if ( ! method_exists ( $ container , $ setMethod ) ) { throw new ContainerInvalidArgumentException ( 'External container type[' . get_class ( $ container ) . '] has no method[' . $ setMethod . '].' ) ; } static :: $ setMethod = $ setMethod ; } elseif ( $ container instanceof \ ArrayAccess ) { static :: $ setMethod = 'offsetSet' ; } elseif ( ! method_exists ( $ container , 'set' ) ) { throw new ContainerInvalidArgumentException ( 'Empty arg setMethod and external container type[' . get_class ( $ container ) . '] has no set() method and is not ArrayAccess.' ) ; } static :: $ externalContainer = $ container ; }
Inject external dependency injection container, and tell that that's
the container that'll be used from now on.

@param ContainerInterface $container
@param string $setMethod
Default: empty; auto, uses set() or \ArrayAccess::offsetSet().

@return void

@throws ContainerLogicException
\LogicException + \Psr\Container\ContainerExceptionInterface
If there already is an external or internal container.
@throws ContainerInvalidArgumentException
Empty arg setMethod and the container neither has a set() method
nor is \ArrayAccess.
Non-empty arg setMethod and container has no such method.
Inject external dependency injection container and tell that that s the container that ll be used from now on .