src/ContainerScope.php
public static function runScope(ContainerInterface $container, callable $scope)
    {
        list ($previous, self::$container) = [self::$container, $container];
        try {
            return $scope();
        } catch (\Throwable $e) {
            throw $e;
        } finally {
            self::$container = $previous;
        }
    }
public static function runScope(ContainerInterface $container, callable $scope)
    {
        list ($previous, self::$container) = [self::$container, $container];
        try {
            return $scope();
        } catch (\Throwable $e) {
            throw $e;
        } finally {
            self::$container = $previous;
        }
    }
public static function runScope ( ContainerInterface $ container , callable $ scope ) { list ( $ previous , self :: $ container ) = [ self :: $ container , $ container ] ; try { return $ scope ( ) ; } catch ( \ Throwable $ e ) { throw $ e ; } finally { self :: $ container = $ previous ; } }
Invokes given closure or function withing global IoC scope.

@param ContainerInterface $container
@param callable           $scope
@return mixed
@throws \Throwable
Invokes given closure or function withing global IoC scope .