+
+ /**
+ * Trim the tag on top of the value.
+ *
+ * Prevent values such as `!foo {quz: bar}` to be considered as
+ * a mapping block.
+ */
+ private function trimTag($value)
+ {
+ if ('!' === $value[0]) {
+ return ltrim(substr($value, 1, strcspn($value, " \r\n", 1)), ' ');
+ }
+
+ return $value;
+ }
+
+ private function getLineTag($value, $flags, $nextLineCheck = true)
+ {
+ if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) {
+ return;
+ }
+
+ if ($nextLineCheck && !$this->isNextLineIndented()) {
+ return;
+ }
+
+ $tag = substr($matches['tag'], 1);
+
+ // Built-in tags
+ if ($tag && '!' === $tag[0]) {
+ throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
+
+ if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
+ return $tag;
+ }
+
+ throw new ParseException(sprintf('Tags support is not enabled. You must use the flag `Yaml::PARSE_CUSTOM_TAGS` to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
+
+ private function getDeprecationMessage($message)
+ {
+ $message = rtrim($message, '.');
+
+ if (null !== $this->filename) {
+ $message .= ' in '.$this->filename;
+ }
+
+ $message .= ' on line '.($this->getRealCurrentLineNb() + 1);
+
+ return $message.'.';
+ }