Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Array Subset does not work as expected on indexed / flat arrays #3101
In regards to the comment you wrote, "is it fixed in #2237?", no it is not. The the usage of array_replace_recursive and how indexed arrays work in PHP is the problem here. This seem to confuse a lot of people me included. If it works as intended is up for debate, but i will try to explain the confusion.
In set theories the set
@marcioAlmada has explained in #2069 (comment) that the current implementation of ArraySubset is only intended to be used with associative arrays. He proposed to use
I have tried this but it doesn't work as expected since
Another solution is to recurse over the data set and compare values directly. I've proposed a fix in #3161 which supports both flat and multidimensional indexed arrays, and is fully backwards compatible with the current implementation for associative arrays. All the original tests are untouched and passing.