Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112038 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 27236 invoked from network); 12 Oct 2020 15:05:32 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Oct 2020 15:05:32 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5E56B1804C3 for ; Mon, 12 Oct 2020 07:20:27 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 12 Oct 2020 07:20:26 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id v19so17117018edx.9 for ; Mon, 12 Oct 2020 07:20:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Ae0qU0EmZoj1njbcndW0xV5cLxZROULyx9hN/Xb/5Uk=; b=R/fig+W9+RIPtgGAwFUVyprFiKrYs7uJw4ztzCjoFir2PDCvMfiB098X3eXHt3gBgB Qamhri4XsjmVnXgEZkUTFcSdv5iAhTG9membeDMyaLLchcMRTJwENFMEqhr2NWJP3hKH X7OGZmoijMkEiGOR+/13aNylczqh+o+bboloqId9awwCVDb6u+vjy5ec77Cu9dS93RwG S9IIeSWalCNYcaSqtKliKUGNH9nDRk8IhfhWDhKFKiQf1x4VFRZP9A+bCkU6H229+usa 4VYWfnN1dRQR3Bs7vfzPqximwpOdofasz8C6U8P/veUkQCcHttduZIEGEK/KiiublhOy oIGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Ae0qU0EmZoj1njbcndW0xV5cLxZROULyx9hN/Xb/5Uk=; b=U5IF4yf9JLM21hur2PsuUFGYSyKqQjcHBEbpZleqwLLGyTWusjm/Ne6yiBcDJOf4Nf 5phOtW/aYy4Pha7Y2n6tDilMvQHSueEHw45T1JaVuNoGP5IUM1omj0zupc+fKaL9SjVM vuOHTQYzBdFnhGoZRS/n2072umJr0NcjT6BOehXPSZHCW996J64uHU4RCOijfMNDm0HU x1xw0w7/Q2050Y7ywZWyy/NUCFeIycwtVr44bGF9xDEZaRP2lplaIpcneSkCKso2BGHg 0M2VJb9SLlv5xy2PhbzXe5BjPfCN/JZey7SkmyHilqttMhDwIzDQzXaV4E5ntsvIhFtT RxeQ== X-Gm-Message-State: AOAM533DJvhrsDy8r1uzOPoUb9BtH29ehiu+DiWaykxYJ6BYCcEnYdaF bBchNFRhagT/CL3V4fhn8N6Sl0xJuxlfE82uK38= X-Google-Smtp-Source: ABdhPJyFeWy1upxojDN7jtZz9qgWMaWZmfLfFsqjeMt2r0hPZOb6gzYR85WN0O7BXSPRNES2M4/d3x8T82OdcbR9J4k= X-Received: by 2002:a05:6402:1d13:: with SMTP id dg19mr14780513edb.217.1602512422608; Mon, 12 Oct 2020 07:20:22 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 12 Oct 2020 15:20:10 +0100 Message-ID: To: "Kingsquare.nl - Robin Speekenbrink" Cc: "Christoph M. Becker" , Hans Henrik Bergan , PHP internals Content-Type: multipart/alternative; boundary="000000000000b2a51005b179ff9f" Subject: Re: [PHP-DEV] Re: want an Object-oriented interface for HashContext From: george.banyard@gmail.com ("G. P. B.") --000000000000b2a51005b179ff9f Content-Type: text/plain; charset="UTF-8" On Mon, 12 Oct 2020 at 15:01, Kingsquare.nl - Robin Speekenbrink < robin@kingsquare.nl> wrote: > Op ma 12 okt. 2020 om 14:55 schreef Christoph M. Becker >: > > > On 12.10.2020 at 13:49, Hans Henrik Bergan wrote: > > > > > something like > > > > > > $result = (new > > HashContext("SHA1"))->update($str1)->update($str2)->final(); > > > > > > (userland sample imp: https://3v4l.org/lXd3u ) > > > > > > I tried asking on the bugtracker ( > https://bugs.php.net/bug.php?id=80221 > > ) , > > > but was told to ask on this mailing list instead. > > > > Thanks for bringing this up on the mailing list! > > > > I basically very much support a proper OOP interface, but I think the > > method names should use camel-case (e.g. ::updateFile() instead of > > ::update_file()), and it might be appropriate to rename ::final() to > > ::finalize(). More bikeshedding regarding the method names, and maybe > > their signatures might be in order. We do not necessarily have to make > > these methods aliases of the existing functions, although that's of > > course possible. > > > > > Dear all, > > As a user/developer of the language itself: it seems to me this is what a > package using composer could easily fix right? Does this really have to > land in core to be used in the wild? With the proliferation of all the up > and coming features and performance improvements it seems to me like these > types of improvements using lower level PHP interfaces / native functions > have no merit in core itself? > (packagist / composer packages don't always have to be full frameworks / > large solutions right IMHO) > > This would also allow the developer to pick and choose a personal style and > we don't have to flood the internals with bikeshedding ;) > > Robin Speekenbrink > The reason for the non existence of OO APIs is that until recently these objects were resources, HashContext is only an object since PHP 7.2. [1] We performed a bunch of resources to opaque object conversion in PHP 8.0 and the plan is to migrate *all* resources to objects. [2] That's the reason why the procedural API exists, and as most of these opaque objects are marked as final (among other things) to be drop-in replacements of resources while the design of the OO API is left at a later time. Therefore I am not sure what composer and a userland package can bring when one potential avenue to explore is introducing a more thought out and/or (possibly) better API which was hindered by the technical limitation of using a resource. This can also lead us to deprecate the procedural API in favour of said new OO API. This does not need to happen for *all* resource to object conversions but it's something to keep in mind. Moreover, I prefer to have the API be part of the relevant extension than tugged away in some random composer package. Best George P. Banyard [1] https://wiki.php.net/rfc/hash-context.as-resource [2] https://github.com/php/php-tasks/issues/6 --000000000000b2a51005b179ff9f--