Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83759 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87196 invoked from network); 25 Feb 2015 10:21:54 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Feb 2015 10:21:54 -0000 Authentication-Results: pb1.pair.com smtp.mail=thomas@gielfeldt.dk; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=thomas@gielfeldt.dk; sender-id=unknown Received-SPF: error (pb1.pair.com: domain gielfeldt.dk from 209.85.215.48 cause and error) X-PHP-List-Original-Sender: thomas@gielfeldt.dk X-Host-Fingerprint: 209.85.215.48 mail-la0-f48.google.com Received: from [209.85.215.48] ([209.85.215.48:34116] helo=mail-la0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E5/15-62407-042ADE45 for ; Wed, 25 Feb 2015 05:21:54 -0500 Received: by labhs14 with SMTP id hs14so2865710lab.1 for ; Wed, 25 Feb 2015 02:21:49 -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=tHdfpZDAo+c+psbupJTvej1mJcBZcrlNam/1YGMXxo4=; b=UAorw52smLaxqzNY70GkTQgpwaLSbIm2MtNnDB234HWm6skZ8+uQdf9eZM1jl0N1L3 tnuZCE+IYosf6ExOe0Puyrx16kskT73o8HhRXwFHUklSWdX75b/P08TZ7Pj8Og9gV9Z8 RHuLvIeUkUSuRqES5EqggI7UYTeK+OjiErOGbODQFjH+g8QHLDoHkJH2DFzz5kw3nFPV 6AWKuu4t4MUvFtrHV6Ai1hpxt08Z96Ez6Q1li+nh+sRXrqWn/9Oa/B+AOqBTf8l/IuEq K/LTO4kbqB/KVirl460QcL/4s1cBKaemQuSr4axYiyeWhWYordSX69ovGYRa+/TvMv8q saYQ== X-Gm-Message-State: ALoCoQkKp12jiS16ss65fTZ44gSExs9hMmZ5hCKbqUf5if2MG8SCV/xXI4g8CwbGdJ19je+ciepb X-Received: by 10.153.5.33 with SMTP id cj1mr2172082lad.66.1424859709204; Wed, 25 Feb 2015 02:21:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.144.194 with HTTP; Wed, 25 Feb 2015 02:21:29 -0800 (PST) In-Reply-To: References: Date: Wed, 25 Feb 2015 11:21:29 +0100 Message-ID: To: Benjamin Eberlei Cc: PHP Internals Content-Type: multipart/alternative; boundary=001a11349628d27fd7050fe70010 Subject: Re: [PHP-DEV] Feature request and RFC From: thomas@gielfeldt.dk (Thomas Gielfeldt) --001a11349628d27fd7050fe70010 Content-Type: text/plain; charset=UTF-8 2015-02-24 17:36 GMT+01:00 Benjamin Eberlei : > Hi, > > On Tue, Feb 24, 2015 at 5:17 PM, Thomas Gielfeldt > wrote: > >> Hi internals. >> >> I've made PR proposing a feature request: A new interface Sortable. >> >> https://github.com/php/php-src/pull/1116 >> >> If possible, I would like to create and RFC describing this in more >> detail, >> and perhaps get a voting on. >> > > so you need to implement all methods? This can probably be considered a > violation of the Interface Segregation Principle. But adding an interface > for each method seems a bit much as well. > >> >> 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? 1 interface with 2 methods, controlled by flags. /** @ingroup SPL * @brief This Interface allows to hook into the global sort() functions. * @since PHP 5.1 */ interface Sortable { /** * Sort values or keys. * @param int $flags * SORT_REGULAR * SORT_NUMERIC * SORT_STRING * SORT_LOCALE_STRING * SORT_NATURAL * -- bitwise flags * SORT_SORT_FLAG_CASE - case insensitive sorting. * SORT_REVERSE - sort in reverse. * SORT_KEYS - sort keys. * SORT_INDEX - maintain indexes. * @return bool * TRUE on success. */ function sort($flags); /** * Sort values or keys. * @param callback $cmp_function * Compare callback * @return bool * TRUE on success. */ function usort($cmp_function); } ----------------------------- 4 interfaces with 1 method, controlled by flags. /** @ingroup SPL * @brief This Interface allows to hook into the global sort() functions. * @since PHP 5.1 */ interface Sortable { /** * Sort values. * @param int $flags * SORT_REGULAR * SORT_NUMERIC * SORT_STRING * SORT_LOCALE_STRING * SORT_NATURAL * -- bitwise flags * SORT_SORT_FLAG_CASE - case insensitive sorting. * SORT_REVERSE - sort in reverse. * @return bool * TRUE on success. */ function sort($flags); } /** @ingroup SPL * @brief This Interface allows to hook into the global aXsort() functions. * @since PHP 5.1 */ interface SortableIndex { /** * Sort values and maintain index association. * @param int $flags * SORT_REGULAR * SORT_NUMERIC * SORT_STRING * SORT_LOCALE_STRING * SORT_NATURAL * -- bitwise flags * SORT_SORT_FLAG_CASE - case insensitive sorting. * SORT_REVERSE - sort in reverse. * @return bool * TRUE on success. */ function asort($flags); } /** @ingroup SPL * @brief This Interface allows to hook into the global kXsort() functions. * @since PHP 5.1 */ interface SortableKeys { /** * Sort keys. * @param int $flags * SORT_REGULAR * SORT_NUMERIC * SORT_STRING * SORT_LOCALE_STRING * SORT_NATURAL * -- bitwise flags * SORT_SORT_FLAG_CASE - case insensitive sorting. * SORT_REVERSE - sort in reverse. * @return bool * TRUE on success. */ function ksort($flags); } /** @ingroup SPL * @brief This Interface allows to hook into the global uXsort() functions. * @since PHP 5.1 */ interface SortableUser { /** * Sort values or keys. * @param callback $cmp_function * Compare callback * @return bool * TRUE on success. */ function usort($cmp_function); } The natsort() and natcasesort() can already be covered by sort() through flags, so I think we should leave them out. > Thanks >> >> Br, >> >> Thomas Gielfeldt >> > > --001a11349628d27fd7050fe70010--