protected function walkFallbackChain(array $valueMap, string $localeCode, Environment $environment)
    {
        $loopCounter = 0;
        while (!isset($valueMap[$localeCode])) {
            $localeCode = $environment->getLocale($localeCode)->getFallbackCode();
            if (null === $localeCode) {
                // We reached the end of the fallback chain and there's no value
                return null;
            }

            ++$loopCounter;
            // The number is arbitrary
            if ($loopCounter > 100) {
                throw new \RuntimeException('Possible endless loop when trying to walk the locale fallback chain.');
            }
        }

        return $localeCode;
    }
protected function walkFallbackChain(array $valueMap, string $localeCode, Environment $environment)
    {
        $loopCounter = 0;
        while (!isset($valueMap[$localeCode])) {
            $localeCode = $environment->getLocale($localeCode)->getFallbackCode();
            if (null === $localeCode) {
                
                return null;
            }

            ++$loopCounter;
            
            if ($loopCounter > 100) {
                throw new \RuntimeException('Possible endless loop when trying to walk the locale fallback chain.');
            }
        }

        return $localeCode;
    }
protected function walkFallbackChain ( array $ valueMap , string $ localeCode , Environment $ environment ) { $ loopCounter = 0 ; while ( ! isset ( $ valueMap [ $ localeCode ] ) ) { $ localeCode = $ environment -> getLocale ( $ localeCode ) -> getFallbackCode ( ) ; if ( null === $ localeCode ) { // We reached the end of the fallback chain and there's no value return null ; } ++ $ loopCounter ; // The number is arbitrary if ( $ loopCounter > 100 ) { throw new \ RuntimeException ( 'Possible endless loop when trying to walk the locale fallback chain.' ) ; } } return $ localeCode ; }
@param array       $valueMap
@param string      $localeCode
@param Environment $environment

@throws \RuntimeException If we detect an endless loop

@return string|null the locale code for which a value can be found, or null if the end of the chain was reached
@param array $valueMap @param string $localeCode @param Environment $environment