Fixes for add, flatten, forget, get, merge_recursive, etc #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found a bug in one of the methods and then started down the road of creating tests for all of the methods and found a few more bugs!
Most of the line count changes come from the tests.
This pull request includes various changes to the
src/Arrays/Arr.phpfile, as well as adding new unit tests. The main focus is on improving array manipulation methods, adding new functionalitys, and enhancing test coverage.Improvements and Bug Fixes in Array Manipulation:
src/Arrays/Arr.php: Modified several methods to improve functionality and fix bugs. Notable changes include:add: Ensured the method handles dot notation keys and returns the modified array.dot: Removed the condition that checks for empty arrays, allowing the method to handle all arrays.except: Updated to return a new array after forgetting specified keys.exists: Simplified the method by using thehasmethod.flatten: Enhanced to preserve string keys and handle nested arrays more effectively.forget: Reworked to handle dot notation keys and nested arrays correctly.get: Improved to throw an exception if the variable is not accessible and handle dot notation keys.has: Enhanced to handle dot notation keys and check for key existence more efficiently.list_to_array: Fixed the regular expression to handle separators correctly.merge_recursive: Added support for merging arrays with numeric keys.recursive_ksort: Ensured numeric keys are sorted naturally.set: Changed to throw an exception if an invalid key is provided.sort_by_priority: Added validation to ensure the input is an array.stringify_keys: Simplified the method to generate unique prefixes.strpos: Added filtering for valid needles.to_list: Improved handling of null and empty lists.