Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83762 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93301 invoked from network); 25 Feb 2015 10:37:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 10:37:32 -0000 Authentication-Results: pb1.pair.com header.from=thomas@gielfeldt.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=thomas@gielfeldt.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gielfeldt.dk from 209.85.215.49 cause and error) X-PHP-List-Original-Sender: thomas@gielfeldt.dk X-Host-Fingerprint: 209.85.215.49 mail-la0-f49.google.com Received: from [209.85.215.49] ([209.85.215.49:45599] helo=mail-la0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 2C/56-62407-AE5ADE45 for ; Wed, 25 Feb 2015 05:37:31 -0500 Received: by labge10 with SMTP id ge10so2853478lab.12 for ; Wed, 25 Feb 2015 02:37:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=/zGKUZlNQRnYesnnA/mn1e+AqU8dT1olmwr6Ug4h8C0=; b=fJ/M8HjBV+ykor9QctjM74omDW++mZcIwCCZJ6qfg2ihPatbbxB1Nd1V12HWmohROy C5kpvH7fmz5NtdrLaCFdLODEormjEiawKuiCipuxNqhmXa3Xqs4QNsSC3MvOP6TWIRB6 GzkeOqrmfzHjPqVAf2IWsx66eGsCpcCUE/l+n8RXtKV/SQ4GP2qkKL0Dd4X2DNavUh1K jcHd2eYA2y9QJMePG06DVSsBJnlyA4sDnPB4rM3QAvCiXfwpPY/yFSVzsfHE5u742vFn OKCYzF2CUiwtHvBSfcjRW0D1r1uhf/1rd8ZibE4ZCs28hYHksjdMvMi6f2gMzvh9aDaH B7lg== X-Gm-Message-State: ALoCoQk4b8TuIH9/KI4XnabGt7X5Siw7Mk0q6F1B6JCRBghp4RCULwU6v/G4veAPMY/rRX3ybcbz X-Received: by 10.112.56.139 with SMTP id a11mr2228987lbq.36.1424860646922; Wed, 25 Feb 2015 02:37:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.144.194 with HTTP; Wed, 25 Feb 2015 02:37:06 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 11:37:06 +0100 Message-ID: To: Alexander Lisachenko Cc: Benjamin Eberlei , PHP Internals Content-Type: multipart/alternative; boundary=001a1133a352b6ee6a050fe7389a Subject: Re: [PHP-DEV] Feature request and RFC From: thomas@gielfeldt.dk (Thomas Gielfeldt) --001a1133a352b6ee6a050fe7389a Content-Type: text/plain; charset=UTF-8 2015-02-25 11:31 GMT+01:00 Alexander Lisachenko : > > 2015-02-25 13:21 GMT+03:00 Thomas Gielfeldt : > >> 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. --001a1133a352b6ee6a050fe7389a--