Optimize YAML::parse()

This commit is contained in:
Giuseppe Criscione 2019-12-11 11:57:37 +01:00
parent fb147fd094
commit 09092a3bd3

View File

@ -25,7 +25,7 @@ class YAML extends AbstractParser
public static function parse($input, array $options = [])
{
if (function_exists('yaml_parse') && ($options['usePHPYAML'] ?? static::PHPYAMLmode('parse'))) {
if (!preg_match('/^---\n/', $input)) {
if (strpos($input, "---\n") !== 0) {
$input = "---\n" . $input;
}
return (array) yaml_parse($input);