diff --git a/.gitignore b/.gitignore index 4795d92f..cbdaa31d 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ composer.phar # PHPUnit .phpunit.result.cache coverage/ -build/logs/ \ No newline at end of file +build/logs/* +!build/logs/.gitkeep \ No newline at end of file diff --git a/build/logs/.gitkeep b/build/logs/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/GameQ/Helpers/Arr.php b/src/GameQ/Helpers/Arr.php index afd9ab33..fa5a0a0d 100644 --- a/src/GameQ/Helpers/Arr.php +++ b/src/GameQ/Helpers/Arr.php @@ -58,18 +58,20 @@ public static function recursively(array $data, Closure $callback) $data, $recursiveIterator, $subIterator, - /* Update the current value */ - fn () => $subIterator->offsetSet( - /* Keep the original key */ - $key, - /* Execute the callback and use the return / modified value */ - $callback($value, $key, $subIterator) ?? $value - ) + function () use ($callback, &$value, $key, $subIterator) { + /* Update the current value */ + $subIterator->offsetSet( + /* Keep the original key */ + $key, + /* Execute the callback and use the return / modified value */ + $callback($value, $key, $subIterator) ?? $value + ); + } ); } /* Return the processed data */ - return $data; + return $arrayIterator->getArrayCopy(); } /** @@ -106,7 +108,7 @@ protected static function handleArrayIteratorCopyOrReference( /* Process all modified values */ foreach (array_keys($diff) as $modified) { /* Write the modified value to the original array */ - $data = static::set($data, [...$path, $modified], $iterator->offsetGet($modified)); + static::set($data, array_merge($path, [$modified]), $iterator->offsetGet($modified)); } } } else {