Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83870 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 39005 invoked from network); 26 Feb 2015 06:36:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2015 06:36:35 -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.217.179 cause and error) X-PHP-List-Original-Sender: thomas@gielfeldt.dk X-Host-Fingerprint: 209.85.217.179 mail-lb0-f179.google.com Received: from [209.85.217.179] ([209.85.217.179:32964] helo=mail-lb0-f179.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F5/12-23986-1FEBEE45 for ; Thu, 26 Feb 2015 01:36:34 -0500 Received: by lbvp9 with SMTP id p9so8851582lbv.0 for ; Wed, 25 Feb 2015 22:36:30 -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=ZsLs7hAon3ntAdpPiAXUpAdI6Nm/eALFQJ2h6eXs2rA=; b=ENGQTQFryZcD/UrApHnU5TUScvZ7Bohn01LSdTaOEwv0OsfjpN/Sb/Y/7rzlKCglsD V4WXOOZ2MOqTeAlqnTAFcxDfr1BJj7STj9yYVPqFAlmndyE43FliWFuKNLjc7lHbESaf h7L1S7S+o0WJAiBk5SwfjpdzLeknWfZ+z58lTl4uXcoLUk+7IHXspJXCHi6jYuKS682r XUxXsuL3SF6inFPKZDhr07H+T4vXwr85gxTNDOv0tqx7/DHN4QWWWRj0L5zBcXrCoN47 d22d0Ou+oEXJsMWenAlyJhfcNmkPwY7N5UJLGN5KANyw/7VkpxyubDBT6Dp3Z7fmjeOA HLcA== X-Gm-Message-State: ALoCoQmajJ07AMtWc5238jaW+OZRkW1niCkyTfRVU3kUPWIdBiGMlKjAZ4ghfVSw203f76vNMO67 X-Received: by 10.112.155.98 with SMTP id vv2mr5958669lbb.121.1424932590360; Wed, 25 Feb 2015 22:36:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.152.144.194 with HTTP; Wed, 25 Feb 2015 22:36:09 -0800 (PST) In-Reply-To: References: Date: Thu, 26 Feb 2015 07:36:09 +0100 Message-ID: To: Benjamin Eberlei Cc: PHP Internals Content-Type: multipart/alternative; boundary=089e0116048ee0b36f050ff7f8d4 Subject: Re: [PHP-DEV] Feature request and RFC From: thomas@gielfeldt.dk (Thomas Gielfeldt) --089e0116048ee0b36f050ff7f8d4 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. > >> >> Another solution could be: /** @ingroup SPL * @brief This Interface allows to hook into the global Xsort() functions. * @since PHP 5.6 */ interface Sortable { /** * Sort the entries by values. * * @param integer $sort_flags * SORT_REGULAR: compare items normally (don't change types) * SORT_NUMERIC: compare items numerically * SORT_STRING: compare items as strings * SORT_LOCALE_STRING: compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale() * SORT_NATURAL: compare items as strings using "natural ordering" like natsort() * SORT_FLAG_CASE: can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively * SORT_FLAG_REVERSE: can be combined (bitwise OR) with any of the other options to sort in reverse */ function sort($sort_flags = SORT_REGULAR); /** Sort the entries by values using user defined function. */ function usort(mixed cmp_function); } /** @ingroup SPL * @brief This Interface allows to hook into the global XaXsort() functions. * @since PHP 5.6 */ interface SortableAssoc { /** * Sort the entries by values and maintain indexes. * * @param integer $sort_flags * SORT_REGULAR: compare items normally (don't change types) * SORT_NUMERIC: compare items numerically * SORT_STRING: compare items as strings * SORT_LOCALE_STRING: compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale() * SORT_NATURAL: compare items as strings using "natural ordering" like natsort() * SORT_FLAG_CASE: can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively * SORT_FLAG_REVERSE: can be combined (bitwise OR) with any of the other options to sort in reverse */ function asort($sort_flags = SORT_REGULAR); /** Sort the entries by values using user defined function and maintain index. */ function uasort(mixed cmp_function); } /** @ingroup SPL * @brief This Interface allows to hook into the global XkXsort() functions. * @since PHP 5.6 */ interface SortableKeys { /** * Sort the entries by key. * * @param integer $sort_flags * SORT_REGULAR: compare items normally (don't change types) * SORT_NUMERIC: compare items numerically * SORT_STRING: compare items as strings * SORT_LOCALE_STRING: compare items as strings, based on the current locale. It uses the locale, which can be changed using setlocale() * SORT_NATURAL: compare items as strings using "natural ordering" like natsort() * SORT_FLAG_CASE: can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively * SORT_FLAG_REVERSE: can be combined (bitwise OR) with any of the other options to sort in reverse */ function ksort($sort_flags = SORT_REGULAR); /** Sort the entries by key using user defined function. */ function uksort(mixed cmp_function); } I have a working implementation of this also. > Thanks >> >> Br, >> >> Thomas Gielfeldt >> > > --089e0116048ee0b36f050ff7f8d4--