public static function Escaper::requiresSingleQuoting in Service Container 7.2
Same name and namespace in other branches
- 7 modules/providers/service_container_symfony/lib/Symfony/Component/Yaml/Escaper.php \Symfony\Component\Yaml\Escaper::requiresSingleQuoting()
Determines if a PHP value would require single quoting in YAML.
Parameters
string $value A PHP value:
Return value
bool True if the value would require single quotes.
1 call to Escaper::requiresSingleQuoting()
- Inline::dump in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php - Dumps a given PHP variable to a YAML string.
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Escaper.php, line 73
Class
- Escaper
- Escaper encapsulates escaping rules for single and double-quoted YAML strings.
Namespace
Symfony\Component\YamlCode
public static function requiresSingleQuoting($value) {
// Determines if a PHP value is entirely composed of a value that would
// require single quoting in YAML.
if (in_array(strtolower($value), array(
'null',
'~',
'true',
'false',
'y',
'n',
'yes',
'no',
'on',
'off',
))) {
return true;
}
// Determines if the PHP value contains any single characters that would
// cause it to require single quoting in YAML.
return preg_match('/[ \\s \' " \\: \\{ \\} \\[ \\] , & \\* \\# \\?] | \\A[ \\- ? | < > = ! % @ ` ]/x', $value);
}