Skip to content
This repository was archived by the owner on Feb 28, 2025. It is now read-only.

Commit 2503e45

Browse files
committed
Remove unused code and unescape backslashes in JSON
1 parent ab260b5 commit 2503e45

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

generator/src/OperatorTestGenerator.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
use RuntimeException;
1919
use Throwable;
2020

21-
use function array_walk_recursive;
2221
use function basename;
2322
use function get_object_vars;
2423
use function is_array;
@@ -31,6 +30,7 @@
3130
use function ucwords;
3231

3332
use const JSON_PRETTY_PRINT;
33+
use const JSON_UNESCAPED_SLASHES;
3434

3535
/**
3636
* Generates a tests for all operators.
@@ -90,15 +90,11 @@ public function createClass(GeneratorDefinition $definition, OperatorDefinition
9090
$caseName = str_replace([' ', '-'], '', ucwords(str_replace('$', '', $operator->name . ' ' . $test->name)));
9191

9292
$pipeline = $this->convertTypeRecursively($test->pipeline);
93-
$pipeline = $test->pipeline;
94-
array_walk_recursive($pipeline, function (mixed &$value): void {
95-
if ($value instanceof DateTimeInterface) {
96-
$value = new UTCDateTime($value);
97-
}
98-
});
9993

94+
// Wrap the pipeline array into a document
10095
$json = Document::fromPHP(['pipeline' => $pipeline])->toCanonicalExtendedJSON();
101-
$json = json_encode(json_decode($json)->pipeline, JSON_PRETTY_PRINT);
96+
// Unwrap the pipeline array and reformat for prettier JSON
97+
$json = json_encode(json_decode($json)->pipeline, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
10298
$case = $dataEnum->addCase($caseName, new Literal('<<<\'JSON\'' . "\n" . $json . "\n" . 'JSON'));
10399
$case->setComment($test->name);
104100
if ($test->link) {

tests/Builder/Accumulator/Pipelines.php

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/Builder/Expression/Pipelines.php

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)