2015-02-25 11:31 GMT+01:00 Alexander Lisachenko <lisachenko...@gmail.com>:

>
> 2015-02-25 13:21 GMT+03:00 Thomas Gielfeldt <tho...@gielfeldt.dk>:
>
>> I have some more proposals for how to implement this interface. Should we
>> create an RFC for purposes of discussion, or do you usually do this in the
>> mailing lists?
>>
>
>
> Best interface is described by the one single method: sort() that accepts
> optional flags and callback function:
>
> So,
>
> interface Sortable {
>     const ASC = 1;
>     const DESC = 2;
>     const SORT_REGULAR = 4;
>     const SORT_NUMERIC = 8;
>     // more consts here...
>
>     public function sort($flags = 0, callable $callback = null);
> }
>
> Callback will accept key and value pair.
>

Yeah, but the "problem" with this, is that your class' sort method, you
have to implement all the possible permutations the flags can produce. This
basically just squeezes the 11 functions into 1. The 1 interface with
sort() and usort() splits this into 2 functions (8+3). With that in mind,
I'm more inclined to choose the 4 interface approach.

Reply via email to