function SettingsEditor::isSimple

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Site/SettingsEditor.php \Drupal\Core\Site\SettingsEditor::isSimple()

Checks whether the given token represents a scalar or NULL.

Parameters

int $type: The token type.

string $value: The value of the token.

Return value

bool TRUE if this token represents a scalar or NULL.

See also

token_name()

1 call to SettingsEditor::isSimple()
SettingsEditor::rewrite in core/lib/Drupal/Core/Site/SettingsEditor.php
Replaces values in settings.php with values in the submitted array.

File

core/lib/Drupal/Core/Site/SettingsEditor.php, line 207

Class

SettingsEditor
Generates settings.php files for Drupal installations.

Namespace

Drupal\Core\Site

Code

private static function isSimple(int $type, string $value) : bool {
    $is_integer = $type === T_LNUMBER;
    $is_float = $type === T_DNUMBER;
    $is_string = $type === T_CONSTANT_ENCAPSED_STRING;
    $is_boolean_or_null = $type === T_STRING && in_array(strtoupper($value), [
        'TRUE',
        'FALSE',
        'NULL',
    ]);
    return $is_integer || $is_float || $is_string || $is_boolean_or_null;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.