Re: Feature request and RFC

From: Date: Wed, 25 Feb 2015 11:42:15 +0000
Subject: Re: Feature request and RFC
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-83768@lists.php.net to get a copy of this message
2015-02-25 12:15 GMT+01:00 Alexander Lisachenko <lisachenko.it@gmail.com>: > > 2015-02-25 13:37 GMT+03:00 Thomas Gielfeldt <thomas@gielfeldt.dk>: > >> 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. > > > > For that case, move all configurations to the several classes and > configure these flags in the concrete constructors. Interface will be more > simple: > > interface Sortable { > const ASC = 1; > const DESC = 2; > > public function sort($direction = self::ASC, callable $callback = > null); > } > > class KeySorter implements Sortable {} > That seems a little backwards to me? How would the consumer of e.g. KeySorter know which sort variations are implemented?

« previous php.internals (#83768) next »