Skip to content

Commit 70d29ed

Browse files
Add variables for immutability
1 parent 01b8a09 commit 70d29ed

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Differ/Differ.php

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function sortingFirstFile(mixed $tree1, mixed $tree2): mixed
3232
array_keys($tree1),
3333
function ($acc, $key) use ($tree1, $tree2) {
3434
$diff = [...$acc];
35+
$status = [];
3536

3637
if (!array_key_exists($key, $tree2)) {
3738
$status[$key]['status'] = 'remove';
@@ -75,6 +76,7 @@ function sortingSecondFile(mixed $tree2, mixed $tree1): mixed
7576
array_keys($tree2),
7677
function ($acc, $key) use ($tree1, $tree2) {
7778
$diff = [...$acc];
79+
$value = [];
7880

7981
if (!array_key_exists($key, $tree1)) {
8082
$value[$key]['value'] = getArrayContent($tree2[$key]);
@@ -100,6 +102,7 @@ function getArrayContent(mixed $tree): mixed
100102

101103
return array_reduce(array_keys($tree), function ($acc, $key) use ($tree) {
102104
$diff = [...$acc];
105+
$value = [];
103106
$value[$key]['value'] = getArrayContent($tree[$key]);
104107
return array_merge($diff, $value);
105108
}, []);
@@ -117,6 +120,8 @@ function ($left, $right) {
117120

118121
return array_reduce($keysSorted, function ($acc, $key) use ($tree) {
119122
$diff = [...$acc];
123+
$diffValue = [];
124+
$diffContent = [];
120125

121126
if (!is_array($tree[$key])) {
122127
$diffValue[$key] = $tree[$key];

src/Formatters/Plain.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function ($acc, $key) use ($tree, $path, $depth) {
3434

3535
if (is_array($keyData['value'])) {
3636
$string = plain($keyData['value'], $newPath, $depth + 1);
37-
$resultString = "{$resultString}{$string}";
37+
return "{$resultString}{$string}";
3838
}
3939

4040
return $resultString;

0 commit comments

Comments
 (0)