diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 74b81d5cf6948..d15126a155e4e 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -62,7 +62,7 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount $value = self::prepare($value, $objectsPool, $refsPool, $objectsCount, $valueIsStatic); } goto handle_value; - } elseif (!\is_object($value) && !$value instanceof \__PHP_Incomplete_Class) { + } elseif (!\is_object($value) && !$value instanceof \__PHP_Incomplete_Class || $value instanceof \UnitEnum) { goto handle_value; } @@ -190,7 +190,7 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount public static function export($value, $indent = '') { switch (true) { - case \is_int($value) || \is_float($value): return var_export($value, true); + case \is_int($value) || \is_float($value) || $value instanceof \UnitEnum: return var_export($value, true); case [] === $value: return '[]'; case false === $value: return 'false'; case true === $value: return 'true'; diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/FooUnitEnum.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/FooUnitEnum.php new file mode 100644 index 0000000000000..0f569de8328b2 --- /dev/null +++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/FooUnitEnum.php @@ -0,0 +1,8 @@ += 80100) { + yield ['unit-enum', [FooUnitEnum::Bar], true]; + } } } diff --git a/src/Symfony/Component/VarExporter/VarExporter.php b/src/Symfony/Component/VarExporter/VarExporter.php index f1260d152dd87..a5cacb087572f 100644 --- a/src/Symfony/Component/VarExporter/VarExporter.php +++ b/src/Symfony/Component/VarExporter/VarExporter.php @@ -43,7 +43,7 @@ public static function export($value, bool &$isStaticValue = null): string { $isStaticValue = true; - if (!\is_object($value) && !(\is_array($value) && $value) && !$value instanceof \__PHP_Incomplete_Class && !\is_resource($value)) { + if (!\is_object($value) && !(\is_array($value) && $value) && !$value instanceof \__PHP_Incomplete_Class && !\is_resource($value) || $value instanceof \UnitEnum) { return Exporter::export($value); }
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: