Adding config2json
Publish PHP Package / docker (push) Successful in 7s Details

This commit is contained in:
Pavel Shevaev 2025-02-27 20:00:38 +03:00
parent a15f4f935e
commit 458b72e367
1 changed files with 10 additions and 12 deletions

View File

@ -122,15 +122,13 @@ function config_includes_map_find_text_origin(array $map, string $file, string $
return $res;
}
//TODO:
//function conf2json(object $conf, int $json_flags = 0) : string
//{
// $arr = $conf->export(true);
// $arr['class'] = get_class($conf);
// unset($arr['id']);
// unset($arr['strid']);
// $json = json_encode($arr, $json_flags);
// $json = str_replace(array('\\\\', '\\n', '\/'), array('\\', "\n", '/'), $json);
// return $json;
//}
function config2json(object $conf, int $json_flags = 0) : string
{
$arr = $conf->export(true);
$arr['class'] = get_class($conf);
unset($arr['id']); // @phpstan-ignore-line
unset($arr['strid']); // @phpstan-ignore-line
$json = json_encode($arr, $json_flags);
$json = str_replace(array('\\\\', '\\n', '\/'), array('\\', "\n", '/'), $json);
return $json;
}