This commit is contained in:
Sebastian Bergmann 2024-03-31 08:34:19 +02:00
parent cb811556a5
commit 8f75583f15
No known key found for this signature in database
GPG Key ID: 4AA394086372C20A
1 changed files with 11 additions and 11 deletions

View File

@ -247,18 +247,16 @@ final readonly class Exporter
return $this->exportString($value);
}
$whitespace = str_repeat(' ', 4 * $indentation);
if (!$processed) {
$processed = new RecursionContext;
}
if (is_array($value)) {
return $this->exportArray($value, $processed, $whitespace, $indentation);
return $this->exportArray($value, $processed, $indentation);
}
if (is_object($value)) {
return $this->exportObject($value, $processed, $whitespace, $indentation);
return $this->exportObject($value, $processed, $indentation);
}
return var_export($value, true);
@ -303,15 +301,16 @@ final readonly class Exporter
"'";
}
private function exportArray(array &$value, RecursionContext $processed, string $whitespace, int $indentation): string
private function exportArray(array &$value, RecursionContext $processed, int $indentation): string
{
if (($key = $processed->contains($value)) !== false) {
return 'Array &' . $key;
}
$array = $value;
$key = $processed->add($value);
$values = '';
$array = $value;
$key = $processed->add($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);
if (count($array) > 0) {
foreach ($array as $k => $v) {
@ -330,7 +329,7 @@ final readonly class Exporter
return 'Array &' . (string) $key . ' [' . $values . ']';
}
private function exportObject(mixed $value, RecursionContext $processed, string $whitespace, int $indentation): string
private function exportObject(mixed $value, RecursionContext $processed, int $indentation): string
{
$class = $value::class;
@ -340,8 +339,9 @@ final readonly class Exporter
$processed->add($value);
$values = '';
$array = $this->toArray($value);
$array = $this->toArray($value);
$values = '';
$whitespace = str_repeat(' ', 4 * $indentation);
if (count($array) > 0) {
foreach ($array as $k => $v) {