Changeset View
Changeset View
Standalone View
Standalone View
src/utils/utils.php
Show First 20 Lines • Show All 1,314 Lines • ▼ Show 20 Lines | |||||
* @param string | * @param string | ||||
* @return mixed | * @return mixed | ||||
*/ | */ | ||||
function phutil_ini_decode($string) { | function phutil_ini_decode($string) { | ||||
$results = null; | $results = null; | ||||
$trap = new PhutilErrorTrap(); | $trap = new PhutilErrorTrap(); | ||||
try { | try { | ||||
if (!function_exists('parse_ini_string')) { | $have_call = false; | ||||
if (function_exists('parse_ini_string')) { | |||||
if (defined('INI_SCANNER_RAW')) { | |||||
$results = @parse_ini_string($string, true, INI_SCANNER_RAW); | |||||
$have_call = true; | |||||
} | |||||
} | |||||
if (!$have_call) { | |||||
throw new PhutilMethodNotImplementedException( | throw new PhutilMethodNotImplementedException( | ||||
pht( | pht( | ||||
'%s is not compatible with your version of PHP (%s). This function '. | '%s is not compatible with your version of PHP (%s). This function '. | ||||
'is only supported on PHP versions newer than 5.3.0.', | 'is only supported on PHP versions newer than 5.3.0.', | ||||
__FUNCTION__, | __FUNCTION__, | ||||
phpversion())); | phpversion())); | ||||
} | } | ||||
$results = @parse_ini_string($string, true, INI_SCANNER_RAW); | |||||
if ($results === false) { | if ($results === false) { | ||||
throw new PhutilINIParserException(trim($trap->getErrorsAsString())); | throw new PhutilINIParserException(trim($trap->getErrorsAsString())); | ||||
} | } | ||||
foreach ($results as $section => $result) { | foreach ($results as $section => $result) { | ||||
if (!is_array($result)) { | if (!is_array($result)) { | ||||
// We JSON decode the value in ordering to perform the following | // We JSON decode the value in ordering to perform the following | ||||
// conversions: | // conversions: | ||||
▲ Show 20 Lines • Show All 305 Lines • Show Last 20 Lines |