You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -623,6 +623,40 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
623
623
thrownewParseException(sprintf('The string "%s" could not be parsed as a constant. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
624
624
}
625
625
626
+
returnnull;
627
+
casestr_starts_with($scalar, '!php/enum'):
628
+
if (self::$constantSupport) {
629
+
if (!isset($scalar[11])) {
630
+
thrownewParseException('Missing value for tag "!php/enum".', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
if ($useValue = str_ends_with($enum, '->value')) {
636
+
$enum = substr($enum, 0, -7);
637
+
}
638
+
if (!\defined($enum)) {
639
+
thrownewParseException(sprintf('The enum "%s" is not defined.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
640
+
}
641
+
642
+
$value = \constant($enum);
643
+
644
+
if (!$valueinstanceof \UnitEnum) {
645
+
thrownewParseException(sprintf('The string "%s" is not the name of a valid enum.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
646
+
}
647
+
if (!$useValue) {
648
+
return$value;
649
+
}
650
+
if (!$valueinstanceof \BackedEnum) {
651
+
thrownewParseException(sprintf('The enum "%s" defines no value next to its name.', $enum), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
652
+
}
653
+
654
+
return$value->value;
655
+
}
656
+
if (self::$exceptionOnInvalidType) {
657
+
thrownewParseException(sprintf('The string "%s" could not be parsed as an enum. Did you forget to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
658
+
}
659
+
626
660
returnnull;
627
661
casestr_starts_with($scalar, '!!float '):
628
662
return (float) substr($scalar, 8);
@@ -703,7 +737,7 @@ private static function parseTag(string $value, int &$i, int $flags): ?string
0 commit comments