Revert "Refactor"

This reverts commit 1d1a003cfa.
This commit is contained in:
Sebastian Bergmann 2024-03-29 09:01:19 +01:00
parent 142b62c509
commit da0d6e7264
No known key found for this signature in database
GPG Key ID: 4AA394086372C20A
1 changed files with 10 additions and 6 deletions

View File

@ -51,7 +51,7 @@ final class Exporter
*/
public function export(mixed $value): string
{
return $this->doExport($value, new Context);
return $this->doExport($value);
}
public function shortenedRecursiveExport(array &$data, ?Context $context = null): string
@ -138,7 +138,7 @@ final class Exporter
return $this->export($value);
}
private function doExport(mixed &$value, Context $processed, int $indentation = 0): string
private function doExport(mixed &$value, int $indentation = 0, ?Context $processed = null): string
{
if ($value === null) {
return 'null';
@ -193,6 +193,10 @@ final class Exporter
$whitespace = str_repeat(' ', 4 * $indentation);
if (!$processed) {
$processed = new Context;
}
if (is_array($value)) {
return $this->exportArray($value, $processed, $whitespace, $indentation);
}
@ -258,9 +262,9 @@ final class Exporter
$values .=
$whitespace
. ' ' .
$this->doExport($k, new Context, $indentation)
$this->doExport($k, $indentation)
. ' => ' .
$this->doExport($value[$k], $processed, $indentation + 1)
$this->doExport($value[$k], $indentation + 1, $processed)
. ",\n";
}
@ -288,9 +292,9 @@ final class Exporter
$values .=
$whitespace
. ' ' .
$this->doExport($k, new Context, $indentation)
$this->doExport($k, $indentation)
. ' => ' .
$this->doExport($v, $processed, $indentation + 1)
$this->doExport($v, $indentation + 1, $processed)
. ",\n";
}