Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

Array::filter doesn't conform to spec #77

Open
Odalrick opened this issue Nov 10, 2015 · 1 comment
Open

Array::filter doesn't conform to spec #77

Odalrick opened this issue Nov 10, 2015 · 1 comment

Comments

@Odalrick
Copy link

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.

@Odalrick
Copy link
Author

After reading the documentation and tests, it looks like this is intentional. Possibly this should be made explicit in the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant