Skip to content

Commit

Permalink
Revert #56
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 17, 2024
1 parent 9d93450 commit d0d99db
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 212 deletions.
7 changes: 0 additions & 7 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.

## [6.1.0] - 2024-MM-DD

### Added

* [#56](https://github.com/sebastianbergmann/exporter/pull/56): The export of objects can now be customized using `ObjectExporter` objects

## [6.0.1] - 2024-03-02

### Changed
Expand Down Expand Up @@ -118,7 +112,6 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

* Remove HHVM-specific code that is no longer needed

[6.1.0]: https://github.com/sebastianbergmann/exporter/compare/6.0.1...main
[6.0.1]: https://github.com/sebastianbergmann/exporter/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/sebastianbergmann/exporter/compare/5.1...6.0.0
[5.1.2]: https://github.com/sebastianbergmann/exporter/compare/5.1.1...5.1.2
Expand Down
22 changes: 2 additions & 20 deletions src/Exporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@

final readonly class Exporter
{
private ?ObjectExporter $objectExporter;

public function __construct(?ObjectExporter $objectExporter = null)
{
$this->objectExporter = $objectExporter;
}

/**
* Exports a value as a string.
*
Expand Down Expand Up @@ -341,18 +334,7 @@ private function exportObject(object $value, RecursionContext $processed, int $i

$processed->add($value);

if ($this->objectExporter !== null && $this->objectExporter->handles($value)) {
$buffer = $this->objectExporter->export($value, $this, $indentation);
} else {
$buffer = $this->defaultObjectExport($value, $processed, $indentation);
}

return $class . ' Object #' . spl_object_id($value) . ' (' . $buffer . ')';
}

private function defaultObjectExport(object $object, RecursionContext $processed, int $indentation): string
{
$array = $this->toArray($object);
$array = $this->toArray($value);
$buffer = '';
$whitespace = str_repeat(' ', 4 * $indentation);

Expand All @@ -370,6 +352,6 @@ private function defaultObjectExport(object $object, RecursionContext $processed
$buffer = "\n" . $buffer . $whitespace;
}

return $buffer;
return $class . ' Object #' . spl_object_id($value) . ' (' . $buffer . ')';
}
}
17 changes: 0 additions & 17 deletions src/ObjectExporter.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/ObjectExporterChain.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/exception/Exception.php

This file was deleted.

16 changes: 0 additions & 16 deletions src/exception/ObjectNotSupportedException.php

This file was deleted.

21 changes: 0 additions & 21 deletions tests/ExporterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -502,27 +502,6 @@ public function testShortenedRecursiveOccurredRecursion(): void
$this->assertEquals('*RECURSION*', (new Exporter)->shortenedRecursiveExport($value, $context));
}

public function testExportOfObjectsCanBeCustomized(): void
{
$objectExporter = $this->createStub(ObjectExporter::class);
$objectExporter->method('handles')->willReturn(true);
$objectExporter->method('export')->willReturn('custom object export');

$exporter = new Exporter(new ObjectExporterChain([$objectExporter]));

$this->assertStringMatchesFormat(
<<<'EOT'
Array &0 [
0 => stdClass Object #%d (custom object export),
1 => stdClass Object #%d (custom object export),
]
EOT
,
$exporter->export([new stdClass, new stdClass]),
);

}

private function trimNewline(string $string): string
{
return preg_replace('/[ ]*\n/', "\n", $string);
Expand Down
64 changes: 0 additions & 64 deletions tests/ObjectExporterChainTest.php

This file was deleted.

0 comments on commit d0d99db

Please sign in to comment.