Skip to content

Commit 327183a

Browse files
Merge branch '5.4' into 6.0
* 5.4: [DependencyInjection] Properly declare #[When] as allowed on functions [VarDumper] Fix dumping floats on PHP8 Fix dumping enums on PHP 8.2 [Cache] Prevent fatal errors on php 8 when running concurrently with TagAwareAdapter v6.1
2 parents 8d20154 + d3a6d14 commit 327183a

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

Console/Descriptor/Descriptor.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ abstract protected function describeCallable(mixed $callable, array $options = [
145145

146146
protected function formatValue(mixed $value): string
147147
{
148+
if ($value instanceof \UnitEnum) {
149+
return ltrim(var_export($value, true), '\\');
150+
}
151+
148152
if (\is_object($value)) {
149153
return sprintf('object(%s)', \get_class($value));
150154
}
@@ -153,21 +157,21 @@ protected function formatValue(mixed $value): string
153157
return $value;
154158
}
155159

156-
return preg_replace("/\n\s*/s", '', var_export($value, true));
160+
return preg_replace("/\n\s*/s", '', ltrim(var_export($value, true)), '\\');
157161
}
158162

159163
protected function formatParameter(mixed $value): string
160164
{
161165
if ($value instanceof \UnitEnum) {
162-
return var_export($value, true);
166+
return ltrim(var_export($value, true), '\\');
163167
}
164168

165169
// Recursively search for enum values, so we can replace it
166170
// before json_encode (which will not display anything for \UnitEnum otherwise)
167171
if (\is_array($value)) {
168172
array_walk_recursive($value, static function (&$value) {
169173
if ($value instanceof \UnitEnum) {
170-
$value = var_export($value, true);
174+
$value = ltrim(var_export($value, true), '\\');
171175
}
172176
});
173177
}

Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function writeData(array $data, array $options)
188188
// before json_encode (which will not display anything for \UnitEnum otherwise)
189189
array_walk_recursive($data, static function (&$value) {
190190
if ($value instanceof \UnitEnum) {
191-
$value = var_export($value, true);
191+
$value = ltrim(var_export($value, true), '\\');
192192
}
193193
});
194194

Console/Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
349349
} elseif ($argument instanceof Definition) {
350350
$argumentsInformation[] = 'Inlined Service';
351351
} elseif ($argument instanceof \UnitEnum) {
352-
$argumentsInformation[] = var_export($argument, true);
352+
$argumentsInformation[] = ltrim(var_export($argument, true), '\\');
353353
} elseif ($argument instanceof AbstractArgument) {
354354
$argumentsInformation[] = sprintf('Abstract argument (%s)', $argument->getText());
355355
} else {

Console/Descriptor/XmlDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private function getArgumentNodes(array $arguments, \DOMDocument $dom): array
421421
}
422422
} elseif ($argument instanceof \UnitEnum) {
423423
$argumentXML->setAttribute('type', 'constant');
424-
$argumentXML->appendChild(new \DOMText(var_export($argument, true)));
424+
$argumentXML->appendChild(new \DOMText(ltrim(var_export($argument, true), '\\')));
425425
} else {
426426
$argumentXML->appendChild(new \DOMText($argument));
427427
}

0 commit comments

Comments
 (0)