public static YamlPecl::applyBooleanCallbacks($value, $tag, $flags)
Applies callbacks after parsing to ignore 1.1 style booleans.
Parameters
mixed $value: Value from YAML file.
string $tag: Tag that triggered the callback.
int $flags: Scalar entity style flags.
Return value
string|bool FALSE, false, TRUE and true are returned as booleans, everything else is returned as a string.
File
- core/lib/Drupal/Component/Serialization/YamlPecl.php, line 87
Class
- YamlPecl
- Provides default serialization for YAML using the PECL extension.
Namespace
Drupal\Component\Serialization
Code
public static function applyBooleanCallbacks($value, $tag, $flags) {
// YAML 1.1 spec dictates that 'Y', 'N', 'y' and 'n' are booleans. But, we
// want the 1.2 behavior, so we only consider 'false', 'FALSE', 'true' and
// 'TRUE' as booleans.
if (!in_array(strtolower($value), ['false', 'true'], TRUE)) {
return $value;
}
$map = [
'false' => FALSE,
'true' => TRUE,
];
return $map[strtolower($value)];
}
Please login to continue.