Returns the ini file as an array.

@param string $ini Full path to the ini file
@return array List
@throws \Cake\Core\Exception\Exception
1023
public static function parseFile($ini) {
		if (!file_exists($ini)) {
			throw new Exception(sprintf('Missing TinyAuth config file (%s)', $ini));
		}

		if (function_exists('parse_ini_file')) {
			$iniArray = parse_ini_file($ini, true);
		} else {
			$content = file_get_contents($ini);
			if ($content === false) {
				throw new Exception('Cannot load INI file.');
			}
			$iniArray = parse_ini_string($content, true);
		}

		if (!is_array($iniArray)) {
			throw new Exception(sprintf('Invalid TinyAuth config file (%s)', $ini));
		}
		return $iniArray;
	}
510655
public function render(array $ini)
    {
        $output = [];

        foreach ($ini as $sectionName => $section) {
            $sectionOutput = [];

            if (!is_array($section)) {
                throw new RendererException('The section must contain an array of key-value pairs');
            }

            // Values without keys are stored in this temporary array
            $sectionIni = [];

            foreach ($section as $key => $value) {
                if (is_numeric($key)) {
                    if (!is_array($value)) {
                        $value = [$value];
                    }

                    $sectionIni = array_merge($sectionIni, $value);
                    continue;
                }

                $sectionOutput = array_merge($sectionOutput, $this->renderKeyValuePair($key, $value));
            }

            if (count($sectionIni) > 0) {
                $sectionOutput = array_merge($this->renderKeyValuePair($sectionName, $sectionIni), $sectionOutput);
            }

            array_unshift($sectionOutput, sprintf('[%s]', $sectionName));

            // Write a linefeed after sections
            $sectionOutput[] = '';

            $output = array_merge($output, $sectionOutput);
        }

        return implode("\n", $output);
    }
1272069
private static function retrieveFilesWithContents(Iterator $files): array
    {
        return array_reduce(
            iterator_to_array($files),
            static function (array $files, SplFileInfo $fileInfo): array {
                $file = $fileInfo->getRealPath();

                if (false === $file) {
                    throw new RuntimeException(
                        sprintf(
                            'Could not find the file "%s".',
                            (string) $fileInfo
                        )
                    );
                }

                if (false === is_readable($file)) {
                    throw new RuntimeException(
                        sprintf(
                            'Could not read the file "%s".',
                            $file
                        )
                    );
                }

                $files[$fileInfo->getRealPath()] = [$fileInfo->getRealPath(), file_get_contents($file)];

                return $files;
            },
            []
        );
    }
383031
protected function load_file($file)
	{
		$contents = $this->parse_vars(file_get_contents($file));
		return parse_ini_string($contents, true);
	}
1031285
protected function read(string $file):array{

		if(!is_readable($file) || !is_file($file)){
			throw new \Exception('invalid file: '.$file);
		}

		// Read file into an array of lines with auto-detected line endings
		$autodetect = ini_get('auto_detect_line_endings');
		ini_set('auto_detect_line_endings', '1');
		$lines = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
		ini_set('auto_detect_line_endings', $autodetect);

		if(!is_array($lines) || empty($lines)){
			throw new \Exception('error while reading file: '.$file);
		}

		return array_map('trim', $lines);
	}
775174
public function load($config)
    {
        if (is_string($config)) {
            if (!file_exists($config) || !is_readable($config)) {
                throw new Exception(sprintf('Input file "%s" is not exist or is not readable', $config));
            }

            $output = include $config;

            if (!is_array($output)) {
                throw new Exception('You must return array in config file');
            }

            return $output;
        } elseif (is_array($config)) {
            return $config;
        } else {
            throw new Exception('Input data is not valid');
        }
    }
260710
public static function exceptionToArray($exception, $includePrevious = false)
    {
        $array = [
            'message' => $exception->getMessage(),
            'code' => $exception->getCode(),
            'file' => $exception->getFile(),
            'line' => $exception->getLine(),
            'trace' => $exception->getTraceAsString(),
        ];

        if ($includePrevious) {
            $array['previous'] = self::exceptionToArray($exception->getPrevious(), true);
        }

        return $array;
    }
645942
public function getList(): array {
        $list = array();
        $dir = $this->_docRoot . $this->_path;
        if (is_dir($dir)) {
            if ($dh = opendir($dir)) {
                while (($file = readdir($dh)) !== false) {
                    if (substr($file, 0, 1) !== '.'
                        && strpos($file, '.') !== false
                    ) {
                        $list[] = $file;
                    }
                }
                closedir($dh);
            }
        } else {
            throw new Exception($dir . ' is not a directory.');
        }

        return $list;
    }
1186312
public function getArray()
    {
        $contents = include $this->context;

        if (gettype($contents) != 'array') {
            throw new InvalidFileException($this->context . ' does not return a valid array');
        }

        return $contents;
    }
411641
public function toArray()
    {
        $ini = [];

        foreach ($this->sections as $sectionName => $section) {
            $ini[$sectionName] = $section->getProperties();
        }

        return $ini;
    }
987526
public function evaluate(array $ini)
	{
		$disableFunctions = $this->findValue('disable_functions', $ini);

		if (isset($disableFunctions)) {
			$functions = explode(',', $disableFunctions);
			foreach ($functions as $function) {
				$search = array_search($function, $this->functions);
				if ($search !== false) {
					unset($this->functions[$search]);
				}
			}
		}
		if (!empty($this->functions)) {
			$this->setDescription('Methods still enabled - '.implode(', ', $this->functions));
			$this->fail();
			return false;
		} else {
			$this->pass();
			return true;
		}
	}
666202
protected function cast($ini)
    {
        if (is_array($ini)) {
            foreach ($ini as $key => $val) {
                $ini[$key] = $this->cast($val);
            }
        }

        if (is_string($ini)) {
            if (in_array(strtolower($ini), ['true', 'yes', 'on'])) {
                return true;
            }
            if (in_array(strtolower($ini), ['false', 'no', 'off'])) {
                return false;
            }
            if (in_array(strtolower($ini), ['', 'null'])) {
                return null;
            }
            if (is_numeric($ini)) {
                if (preg_match('/[.]+/', $ini)) {
                    return (float) $ini;
                }

                return (int) $ini;
            }
        }

        return $ini;
    }
937333
public function get_raw_config() {
		if(preg_match('/\.xml/', $this->configFile)) {
//			$rawConfig = _parseXml();
			$xml = new SimpleXMLElement(file_get_contents($this->configFile));
			$rawConfig = array();
			foreach($xml as $x => $y) {
				foreach($y as $i => $d) {
					$rawConfig["$x"]["$i"] = "$d";
				}
			}
		}
		elseif(preg_match('/\.ini/', strtolower($this->configFile))) {
			$rawConfig = parse_ini_file($this->configFile,true);
		}
		else {
			throw new exception(__METHOD__ .": unsupported filetype (". $this->configFile .")");
		}
		return $rawConfig;
	}
1115705
public function ini(string $filename): array {
		$ini = parse_ini_file($filename, true);
		if($ini !== false) {
			$parameters = $ini[Environment::choose()];
			return $parameters;
		} else {
			return [];
		}
	}
260238
public static function toArray(Exception $e = NULL, array $config = NULL)
	{
		$data = [];

		if (NULL !== $e) {
			NULL !== $config or $config = (array) static::config('exception.toArray', []);

			foreach ($config as $configKey => $dataKey) {
				$dataValue = NULL;

				switch ($configKey) {
					case 'message':
						FALSE === $dataKey or $dataValue = Kohana_Helpers_Text::trim($e->getMessage());
						break;
					case 'code':
						FALSE === $dataKey or $dataValue = $e->getCode();
						break;
					case 'line':
						FALSE === $dataKey or $dataValue = $e->getLine();
						break;
					case 'file':
						FALSE === $dataKey or $dataValue = $e->getFile();
						break;
					case 'trace':
						$asString = Arr::get(Kohana_Helpers_Arr::asArray($dataKey), 'asString', FALSE);
						$dataKey = Arr::get(Kohana_Helpers_Arr::asArray($dataKey), 'key', 'trace');
						FALSE === $dataKey or $dataValue = $asString
							? $e->getTraceAsString()
							: $e->getTrace()
						;
						break;
					case 'previous':
						if (FALSE !== $dataKey) {
							$previous = $e->getPrevious();
							NULL === $previous or $dataValue = static::toArray($previous, $config);
							NULL !== $dataValue or $dataKey = FALSE;
						}
						break;
					default:
						$dataKey = FALSE;
				}

				if (FALSE !== $dataKey) {
					$data[$dataKey] = $dataValue;
				}
			}
		}

		return $data;
	}
474311
private function getExceptionData($exception)
    {
        $data = [];

        $data['host'] = Request::server('HTTP_HOST');
        $data['method'] = Request::method();
        $data['fullUrl'] = Request::fullUrl();
        if (php_sapi_name() === 'cli') {
            $data['host'] = parse_url(config('app.url'), PHP_URL_HOST);
            $data['method'] = 'CLI';
        }
        $data['exception'] = $exception->getMessage();
        $data['error'] = $exception->getTraceAsString();
        $data['line'] = $exception->getLine();
        $data['file'] = $exception->getFile();
        $data['class'] = get_class($exception);
        $data['storage'] = array(
            'SERVER'  => Request::server(),
            'GET'     => Request::query(),
            'POST'    => $_POST,
            'FILE'    => Request::file(),
            'OLD'     => Request::hasSession() ? Request::old() : [],
            'COOKIE'  => Request::cookie(),
            'SESSION' => Request::hasSession() ? Session::all() : [],
            'HEADERS' => Request::header(),
        );

        // Remove empty, false and null values
        $data['storage'] = array_filter($data['storage']);

        // Censor sensitive field values
        array_walk_recursive($data['storage'], 'self::censorSensitiveFields');

        $count = $this->config['count'];
        
        $data['exegutor']   = [];
        $data['file_lines'] = [];
        
        $file = new SplFileObject($data['file']);
        for ($i = -1 * abs($count); $i <= abs($count); $i++) {
            list($line, $exegutorLine) = $this->getLineInfo($file, $data['line'], $i);
            if (!$line && !$exegutorLine) {
                continue;
            }
            $data['exegutor'][] = $exegutorLine;
            $data['file_lines'][$data['line'] + $i] = $line;
        }

        // to make Symfony exception more readable
        if ($data['class'] == 'Symfony\Component\Debug\Exception\FatalErrorException') {
            preg_match("~^(.+)' in ~", $data['exception'], $matches);
            if (isset($matches[1])) {
                $data['exception'] = $matches[1];
            }
        }

        return $data;
    }
307734
public static function parse($iniString)
    {
        $values = parse_ini_string($iniString);
        if (!empty($values)) {
            foreach ($values as &$value) {
                $value = (bool) $value ? true : false;
            }

            return $values;
        }

        return [];
    }