From 44a8825cdf796f276f5012ac74345db0724a62e4 Mon Sep 17 00:00:00 2001 From: Michael Demmer Date: Mon, 4 Jan 2021 06:39:26 -0800 Subject: [PATCH 1/2] manually generate the exported map in sorted order For projects that commit the autoload map, this makes the diffs more sensible. --- src/Writer.hack | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Writer.hack b/src/Writer.hack index 99b19b6..12f3050 100644 --- a/src/Writer.hack +++ b/src/Writer.hack @@ -164,9 +164,20 @@ final class Writer { true, ); - $map = \var_export($map, true) - |> \str_replace('array (', 'dict[', $$) - |> \str_replace(')', ']', $$); + \ksort(inout $map); + $map_export = "darray[\n"; + foreach ($map as $type => $mapping) { + $map_export .= " '{$type}' => \n darray[\n"; + $mapping = $mapping as KeyedContainer<_, _>; + \ksort(inout $mapping); + foreach ($mapping as $k => $v) { + $v = (string)$v; + $map_export .= " '{$k}' => '{$v}',\n"; + } + $map_export = $map_export." ],\n"; + } + $map_export = $map_export."];\n"; + $map = $map_export; if ($this->relativeAutoloadRoot) { try { From 07658ccb39fb7125fb4d39f8cce720a8df0f2b08 Mon Sep 17 00:00:00 2001 From: Michael Demmer Date: Fri, 8 Jan 2021 14:26:00 -0800 Subject: [PATCH 2/2] oops -- change to dict not darray to match the latest code --- src/Writer.hack | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Writer.hack b/src/Writer.hack index 12f3050..636748c 100644 --- a/src/Writer.hack +++ b/src/Writer.hack @@ -165,9 +165,9 @@ final class Writer { ); \ksort(inout $map); - $map_export = "darray[\n"; + $map_export = "dict[\n"; foreach ($map as $type => $mapping) { - $map_export .= " '{$type}' => \n darray[\n"; + $map_export .= " '{$type}' => \n dict[\n"; $mapping = $mapping as KeyedContainer<_, _>; \ksort(inout $mapping); foreach ($mapping as $k => $v) {