Skip to content

Commit d3a6d14

Browse files
Merge branch '4.4' into 5.4
* 4.4: [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 f58f67c + 7b1a208 commit d3a6d14

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
@@ -155,6 +155,10 @@ abstract protected function describeCallable($callable, array $options = []);
155155
*/
156156
protected function formatValue($value): string
157157
{
158+
if ($value instanceof \UnitEnum) {
159+
return ltrim(var_export($value, true), '\\');
160+
}
161+
158162
if (\is_object($value)) {
159163
return sprintf('object(%s)', \get_class($value));
160164
}
@@ -163,7 +167,7 @@ protected function formatValue($value): string
163167
return $value;
164168
}
165169

166-
return preg_replace("/\n\s*/s", '', var_export($value, true));
170+
return preg_replace("/\n\s*/s", '', ltrim(var_export($value, true)), '\\');
167171
}
168172

169173
/**
@@ -174,15 +178,15 @@ protected function formatValue($value): string
174178
protected function formatParameter($value): string
175179
{
176180
if ($value instanceof \UnitEnum) {
177-
return var_export($value, true);
181+
return ltrim(var_export($value, true), '\\');
178182
}
179183

180184
// Recursively search for enum values, so we can replace it
181185
// before json_encode (which will not display anything for \UnitEnum otherwise)
182186
if (\is_array($value)) {
183187
array_walk_recursive($value, static function (&$value) {
184188
if ($value instanceof \UnitEnum) {
185-
$value = var_export($value, true);
189+
$value = ltrim(var_export($value, true), '\\');
186190
}
187191
});
188192
}

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)