diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php index ab77fbf23b0c0..d9b97171e163c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php @@ -150,6 +150,10 @@ abstract protected function describeCallable($callable, array $options = []); */ protected function formatValue($value): string { + if ($value instanceof \UnitEnum) { + return ltrim(var_export($value, true), '\\'); + } + if (\is_object($value)) { return sprintf('object(%s)', \get_class($value)); } @@ -158,7 +162,7 @@ protected function formatValue($value): string return $value; } - return preg_replace("/\n\s*/s", '', var_export($value, true)); + return preg_replace("/\n\s*/s", '', ltrim(var_export($value, true)), '\\'); } /** @@ -169,7 +173,7 @@ protected function formatValue($value): string protected function formatParameter($value): string { if ($value instanceof \UnitEnum) { - return var_export($value, true); + return ltrim(var_export($value, true), '\\'); } // Recursively search for enum values, so we can replace it @@ -177,7 +181,7 @@ protected function formatParameter($value): string if (\is_array($value)) { array_walk_recursive($value, static function (&$value) { if ($value instanceof \UnitEnum) { - $value = var_export($value, true); + $value = ltrim(var_export($value, true), '\\'); } }); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index 0b38ebf31c0f4..64841b1a25d4e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -162,7 +162,7 @@ private function writeData(array $data, array $options) // before json_encode (which will not display anything for \UnitEnum otherwise) array_walk_recursive($data, static function (&$value) { if ($value instanceof \UnitEnum) { - $value = var_export($value, true); + $value = ltrim(var_export($value, true), '\\'); } }); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 3441536ab8404..ea1d3a6abec31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -343,7 +343,7 @@ protected function describeContainerDefinition(Definition $definition, array $op } elseif ($argument instanceof Definition) { $argumentsInformation[] = 'Inlined Service'; } elseif ($argument instanceof \UnitEnum) { - $argumentsInformation[] = var_export($argument, true); + $argumentsInformation[] = ltrim(var_export($argument, true), '\\'); } else { $argumentsInformation[] = \is_array($argument) ? sprintf('Array (%d element(s))', \count($argument)) : $argument; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 44a79a8fa90bd..65e3dbc17b077 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -388,7 +388,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array } } elseif ($argument instanceof \UnitEnum) { $argumentXML->setAttribute('type', 'constant'); - $argumentXML->appendChild(new \DOMText(var_export($argument, true))); + $argumentXML->appendChild(new \DOMText(ltrim(var_export($argument, true), '\\'))); } else { $argumentXML->appendChild(new \DOMText($argument)); } diff --git a/src/Symfony/Component/VarExporter/Internal/Exporter.php b/src/Symfony/Component/VarExporter/Internal/Exporter.php index 7141b4e6d96c1..078359af55309 100644 --- a/src/Symfony/Component/VarExporter/Internal/Exporter.php +++ b/src/Symfony/Component/VarExporter/Internal/Exporter.php @@ -195,12 +195,13 @@ public static function prepare($values, $objectsPool, &$refsPool, &$objectsCount public static function export($value, $indent = '') { switch (true) { - case \is_int($value) || \is_float($value) || $value instanceof \UnitEnum: return var_export($value, true); + case \is_int($value) || \is_float($value): return var_export($value, true); case [] === $value: return '[]'; case false === $value: return 'false'; case true === $value: return 'true'; case null === $value: return 'null'; case '' === $value: return "''"; + case $value instanceof \UnitEnum: return ltrim(var_export($value, true), '\\'); } if ($value instanceof Reference) {
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: