Hacked to allow ini strings as well as ini files.

@param string|Garp_Config_Ini_String $filename If this is a Garp_Config_Ini_String, an ini
string is assumed instead of an ini file.
@return array
357071
protected function _parseIniFile($filename) {
        if ($filename instanceof Garp_Config_Ini_String) {
            $ini = $filename->getValue();
            return parse_ini_string($ini);
        }
        return parent::_parseIniFile($filename);
    }
737190
private function processTags($config, $filename)
    {
        if (!is_array($config)) {
            return $this->processSingleTag($config, $filename);
        }
        foreach ($config as $key => $item) {
            if (is_array($item)) {
                $config[$key] = $this->processTags($item, $filename);
            } else {
                $config[$key] = $this->processSingleTag($item, $filename, $key);
            }
        }

        return $config;
    }
540830
public static function split($fileName)
    {
        $ext = pathinfo($fileName);
        return [
            $ext['dirname'],
            $ext['filename'],
            empty($ext['extension']) ? '' : $ext['extension']
        ];
    }
1353449
public static function getConfigFile($filename)
    {
        $filename = addslashes($filename);
        if (is_file($filename)) {
            $data = str_replace("\\", "\\\\", file_get_contents($filename));
            $json = json_decode($data, true);

            if (empty($json)) {
                throw new \Exception("Config file has a json parse error, $filename");
            }

        } else {
            throw new \Exception("Config file not found, $filename");
        }
        
        return $json;
    }
1240715
public function parseFile($filename)
    {
        $data = @parse_ini_file($filename, true);
        return $this->parse($data, $filename);
    }
152322
private static function loadFileOrEmpty($filename)
    {
        if (!file_exists($filename)) {
            return [];
        }

        try {
            if (!is_array($content = Yaml::parse(file_get_contents($filename)))) {
                $content = [];
            }

            return $content;
        } catch (ParseException $exception) {
            $errorFormatter = new OutputFormatter(true);

            echo $errorFormatter->format(
                    sprintf(
                        '<error>[WARNING] YAML File "%s" is invalid, falling back to "[]" as parsed-value.</error>'.
                        PHP_EOL.
                        '<error>Error: %s</error>'.
                        PHP_EOL,
                        $errorFormatter->escape($filename),
                        $errorFormatter->escape($exception->getMessage())
                    )
                ).PHP_EOL
            ;

            return [];
        }
    }
1226775
public static function mapFileNameToClassName($fileName)
    {
        $matches = [];
        if (preg_match(static::MIGRATION_FILE_NAME_PATTERN, $fileName, $matches)) {
            $fileName = $matches[1];
        }

        return str_replace(' ', '', ucwords(str_replace('_', ' ', $fileName)));
    }
116329
public function getConfiguration($filename) {

        $cacheManager = new CacheManager();
        $configuration = $cacheManager->retrieveFromCache('/' . $filename);
        if (!is_array($configuration)) {
            return null;
        }
        $config = new Config($configuration);
        $cacheManager = null;

        return $config;
    }
797071
private function loadFromFile($iniFilename)
    {
        if (!file_exists($iniFilename)) {
            throw new \Exception("File $iniFilename doesn't exist.");
        }

        $configList = @parse_ini_file($iniFilename, true);

        if ($configList === false) {
            throw new \Exception("Parse Error: File $iniFilename has errors.");
        }

        $this->loadFromArray($configList);
    }
1012052
protected function extensionOfName($fileName)
    {
        if (mb_strpos($fileName, '.') === false) {
            return mb_strtolower($fileName);
        }

        return mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
    }
731097
public function load(string $filename)
  {
    # Attempt to load config file
    if ( \file_exists($filename) ) {
      # Set filename
      $this->filename = $filename;

      # Load the config
      $configArray = \json_decode( \file_get_contents($filename), true);

      if ($configArray) {
        // $configArray = $this->array_change_key_case_recursive($configArray); // Lowercase the keys
        # Merge the Config with existing config
        // $this->confValues = \array_replace_recursive($this->confValues, $configArray);
        $this->confValues = $configArray;
      } else {
        throw new SpinException('Invalid JSON file "'.$filename.'"');

      }
    }

    return $this;
  }
270232
static function load($filename)
	{
		if (isset(self::$stack[$filename])) return self::$stack[$filename];
		$path = self::get("apppath") . "config" . DS . $filename;
		if (!file_exists($path)) throw new \Exception("Config file '$filename' not found'");
		$config_data = include($path);
		self::set($filename, $config_data);
		return $config_data;
	}
771161
public function getRealFilename(string $filename): ?string
    {
        $app = App::get();
        if (substr($filename, 0, 10) === 'appdata://') {
            return $filename;
        } elseif (substr($filename, 0, 5) === 'data:') {
            return 'appdata://' . substr($filename, 5);
        } elseif (substr($filename, 0, 6) === 'addon:') {
            $temp = explode(':', $filename, 3);
            if (sizeof($temp) === 3) {
                $addon = \BearFramework\Addons::get($temp[1]);
                if ($addon !== null) {
                    return $addon->dir . '/' . $temp[2];
                }
            }
        }
        return null;
    }
1227567
public function parse($filename)
    {
        $tokens = token_get_all(file_get_contents($filename));
        $classNames = [];
        $interfaceNames = [];
        $traitNames = [];
        $namespace = [];
        $curleys = 0;
        $isInNamespace = false;
        $totalTokens = count($tokens);

        for ($i = 0; $i <= $totalTokens; $i++) {
            if (!isset($tokens[$i])) {
                break;
            }

            $token = $tokens[$i];
            if (is_string($token)) {
                if (in_array($token[0], ['{'])) {
                    $curleys++;
                }

                if (in_array($token[0], ['}'])) {
                    $curleys--;
                }
                $token = [0 => $token];
            }

            // iterate until space to get FQ NS name.
            if ($token[0] == T_NAMESPACE) {
                $namespace = [];
                $i = $i + 2; 
                for (; $i <= $totalTokens; $i++) {
                    if (!isset($tokens[$i])) {
                        break;
                    }
                    $token = $tokens[$i];

                    if ($token[0] == T_STRING) {
                        $namespace[] = $token[1];
                    }

                    if ($token[0] == ';') {
                        $isInNamespace = true;
                        break;
                    }

                    if ($token[0] == '{') {
                        $curleys++;
                        break;
                    }

                    if ($token[0] == '{') {
                        $curleys--;
                    }
                }
            }

            if ($token[0] == T_CLASS) {
                $prevToken = $tokens[$i - 1];
                if (is_array($prevToken) && $prevToken[0] == T_DOUBLE_COLON) {
                    continue;
                }
                
                $i = $i + 2;
                for (; $i <= count($tokens); $i++) {
                    $token = $tokens[$i];
                    if ($token[0] == T_STRING) {
                        if ($curleys == 0 && !$isInNamespace) {
                            $namespace = [];
                        }
                        $classParts = array_merge($namespace, [$token[1]]);
                        $classNames[] = join('\\', $classParts);
                        break;
                    }
                }
            }

            if ($token[0] == T_INTERFACE) {
                $i = $i + 2;
                for (; $i <= count($tokens); $i++) {
                    $token = $tokens[$i];
                    if ($token[0] == T_STRING) {
                        if ($curleys == 0 && !$isInNamespace) {
                            $namespace = [];
                        }
                        $interfaceParts = array_merge($namespace, [$token[1]]);
                        $interfaceNames[] = join('\\', $interfaceParts);
                        break;
                    }
                }
            }

            if ($token[0] == T_TRAIT) {
                $i = $i + 2;
                for (; $i <= count($tokens); $i++) {
                    $token = $tokens[$i];
                    if ($token[0] == T_STRING) {
                        if ($curleys == 0 && !$isInNamespace) {
                            $namespace = [];
                        }
                        $traitParts = array_merge($namespace, [$token[1]]);
                        $traitNames[] = join('\\', $traitParts);
                        break;
                    }
                }
            }
        }
        return [
            'classes' => $classNames,
            'interfaces' => $interfaceNames,
            'traits' => $traitNames
        ];
    }
111994
protected function getFileName(string $fileName): ?string
    {
        if (!$fileName) {
            return null;
        }

        if (filter_var($fileName, FILTER_VALIDATE_URL)) {

            try {
                $headers = (get_headers($fileName));
            } catch (Throwable $exception) {
                report($exception);
                sleep(1);

                if ($this->headerCallAttempts < 5) {

                    $this->headerCallAttempts++;

                    return $this->getFileName($fileName);
                }

                throw $exception;
            }

            $this->headerCallAttempts = 0;

            foreach ($headers as $header) {
                if (strpos($header, 'filename')) {
                    $name = explode('filename="', $header);
                    $name = rtrim($name[1], '"');

                    $name = explode('.', $name);

                    if (sizeof($name) > 1) {
                        return str_slug(implode('.', $name));
                    }
                }
            }
        }

        $explodeFileURL = explode('/', $fileName);
        $fileName = end($explodeFileURL);

        $explodedByParams = explode('?', $fileName);
        $fileName = head($explodedByParams);

        $string = sanitizeString(pathinfo($fileName, PATHINFO_FILENAME));

        if (strpos($fileName, '.') !== false && substr($fileName, -3) != 'php') {
            return $string . '.' . pathinfo($fileName, PATHINFO_EXTENSION);
        } else {
            return $string;
        }
    }
349336
public static function getCumulativeFilename($filename) {
        $filename = self::formatFilename($filename);

        $filenameParts = explode('.', $filename);
        $ext = array_pop($filenameParts);
        $base = implode('.', $filenameParts);
        $base = preg_match('/' . self::SEPERATOR . '\d+$/', $base) ?
            preg_replace_callback(
                '/' . self::SEPERATOR . '(\d+)$/',
                function ($matches) {
                    return Garp_File::SEPERATOR . ++$matches[1];
                },
                $base
            ) :
            $base . self::SEPERATOR . '2'
        ;

        return $base . '.' . $ext;
    }
753230
private function extractConfigFromMainFile(string $filename): string
  {
    $main = file_get_contents($filename);
    if ($main===false) $this->logError("Unable to read file '%s'.", $filename);

    preg_match('/^(.*requirejs.config)(.*}\))(.*)$/sm', $main, $matches);
    if (!isset($matches[2])) $this->logError("Unable to fine 'requirejs.config' in file '%s'.", $filename);

    return $matches[2];
  }