IcingaConfigHelper: re-order reserved words

This commit is contained in:
Thomas Gelf 2021-05-20 15:20:21 +02:00
parent 7de5b03877
commit 2c950e05ea

View File

@ -3,6 +3,16 @@
namespace Icinga\Module\Director\IcingaConfig; namespace Icinga\Module\Director\IcingaConfig;
use InvalidArgumentException; use InvalidArgumentException;
use function ctype_digit;
use function explode;
use function floor;
use function implode;
use function preg_match;
use function preg_split;
use function sprintf;
use function strlen;
use function strpos;
use function substr;
class IcingaConfigHelper class IcingaConfigHelper
{ {
@ -15,7 +25,7 @@ class IcingaConfigHelper
'template', 'template',
'include', 'include',
'include_recursive', 'include_recursive',
'ignore_on_error', 'include_zones',
'library', 'library',
'null', 'null',
'true', 'true',
@ -23,7 +33,13 @@ class IcingaConfigHelper
'const', 'const',
'var', 'var',
'this', 'this',
'globals',
'locals',
'use', 'use',
'default',
'ignore_on_error',
'current_filename',
'current_line',
'apply', 'apply',
'to', 'to',
'where', 'where',
@ -32,22 +48,16 @@ class IcingaConfigHelper
'ignore', 'ignore',
'function', 'function',
'return', 'return',
'break',
'continue',
'for', 'for',
'if', 'if',
'else', 'else',
'in',
'current_filename',
'current_line',
'include_zones',
'globals',
'locals',
'default',
'break',
'continue',
'while', 'while',
'throw', 'throw',
'try', 'try',
'except', 'except',
'in',
'using', 'using',
'namespace', 'namespace',
]; ];
@ -209,9 +219,9 @@ class IcingaConfigHelper
public static function renderDictionary($dictionary) public static function renderDictionary($dictionary)
{ {
$vals = []; $values = [];
foreach ($dictionary as $key => $value) { foreach ($dictionary as $key => $value) {
$vals[$key] = rtrim( $values[$key] = rtrim(
self::renderKeyValue( self::renderKeyValue(
self::renderDictionaryKey($key), self::renderDictionaryKey($key),
$value $value
@ -219,13 +229,13 @@ class IcingaConfigHelper
); );
} }
if (empty($vals)) { if (empty($values)) {
return '{}'; return '{}';
} }
ksort($vals, SORT_STRING); ksort($values, SORT_STRING);
// Prefix for toConfigString? // Prefix for toConfigString?
return "{\n" . implode("\n", $vals) . "\n}"; return "{\n" . implode("\n", $values) . "\n}";
} }
public static function renderExpression($string) public static function renderExpression($string)