underscore-php
underscore-php copied to clipboard
Array::filter doesn't conform to spec
According to the documentation:
Arrays::filter(array(1, 2, 3), function($value) {
return $value % 2 != 0; // Returns array(1, 3)
});
However the actual return value is array ( 0 => 1, 2 => 3, ).
This is obviously because it delegates to array_filter which is documented to leave keys intact.
After reading the documentation and tests, it looks like this is intentional. Possibly this should be made explicit in the documentation.