From 4574d8760851b6a34558cb4703c3739f919ac51f Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Thu, 12 Jan 2023 17:39:29 +0100 Subject: [PATCH] [VarExporter] Fix exporting enums --- src/Symfony/Component/VarExporter/Internal/Exporter.php | 2 +- src/Symfony/Component/VarExporter/Tests/Fixtures/unit-enum.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index f4e5746f15e4..6ee3ee7f4ea0 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -198,7 +198,7 @@ public static function export($value, string $indent = '') case true === $value: return 'true'; case null === $value: return 'null'; case '' === $value: return "''"; - case $value instanceof \UnitEnum: return ltrim(var_export($value, true), '\\'); + case $value instanceof \UnitEnum: return '\\'.ltrim(var_export($value, true), '\\'); } if ($value instanceof Reference) { diff --git a/src/Symfony/Component/VarExporter/Tests/Fixtures/unit-enum.php b/src/Symfony/Component/VarExporter/Tests/Fixtures/unit-enum.php index 48ab51dd0141..98bc12272ed5 100644 --- a/src/Symfony/Component/VarExporter/Tests/Fixtures/unit-enum.php +++ b/src/Symfony/Component/VarExporter/Tests/Fixtures/unit-enum.php @@ -1,5 +1,5 @@