public function sortProviders($providers)
    {
        foreach ($providers as $provider)
        {
            $providerName = get_class($provider);
            $this->reqs[$providerName] = $provider->getRequires();
            $this->pvds[$providerName] = $provider->getProvides();
            $this->instances[$providerName] = $provider;

            foreach ($provider->getProvides() as $resource)
            {
                $this->obtainableIn[$resource] = $providerName;
            }
        }

        $newOrder = [];

        foreach ($providers as $provider)
        {
            $orderedProviders = $this->orderProvider($provider);

            foreach ($orderedProviders as $orderedProvider)
            {
                $newOrder[] = $this->instances[$orderedProvider];
            }
        }

        return $newOrder;
    }
public function sortProviders($providers)
    {
        foreach ($providers as $provider)
        {
            $providerName = get_class($provider);
            $this->reqs[$providerName] = $provider->getRequires();
            $this->pvds[$providerName] = $provider->getProvides();
            $this->instances[$providerName] = $provider;

            foreach ($provider->getProvides() as $resource)
            {
                $this->obtainableIn[$resource] = $providerName;
            }
        }

        $newOrder = [];

        foreach ($providers as $provider)
        {
            $orderedProviders = $this->orderProvider($provider);

            foreach ($orderedProviders as $orderedProvider)
            {
                $newOrder[] = $this->instances[$orderedProvider];
            }
        }

        return $newOrder;
    }
public function sortProviders ( $ providers ) { foreach ( $ providers as $ provider ) { $ providerName = get_class ( $ provider ) ; $ this -> reqs [ $ providerName ] = $ provider -> getRequires ( ) ; $ this -> pvds [ $ providerName ] = $ provider -> getProvides ( ) ; $ this -> instances [ $ providerName ] = $ provider ; foreach ( $ provider -> getProvides ( ) as $ resource ) { $ this -> obtainableIn [ $ resource ] = $ providerName ; } } $ newOrder = [ ] ; foreach ( $ providers as $ provider ) { $ orderedProviders = $ this -> orderProvider ( $ provider ) ; foreach ( $ orderedProviders as $ orderedProvider ) { $ newOrder [ ] = $ this -> instances [ $ orderedProvider ] ; } } return $ newOrder ; }
Analyze required and provided dependencies of providers and sort the list to ensure right order while resolving
dependency tree.

@param ServiceProviderInterface[] $providers
@return ServiceProviderInterface[]
@throws OverflowException
@throws ResourceUndefinedException
Analyze required and provided dependencies of providers and sort the list to ensure right order while resolving dependency tree .