Re: Feature request and RFC

From: Date: Wed, 25 Feb 2015 10:37:06 +0000
Subject: Re: Feature request and RFC
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-83762@lists.php.net to get a copy of this message
2015-02-25 11:31 GMT+01:00 Alexander Lisachenko <lisachenko.it@gmail.com>: > > 2015-02-25 13:21 GMT+03:00 Thomas Gielfeldt <thomas@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.

« previous php.internals (#83762) next »