Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112043 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 36660 invoked from network); 13 Oct 2020 10:28:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Oct 2020 10:28:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id E1C2218050B for ; Tue, 13 Oct 2020 02:43:53 -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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 ; Tue, 13 Oct 2020 02:43:53 -0700 (PDT) Received: by mail-pj1-f67.google.com with SMTP id j8so1828589pjy.5 for ; Tue, 13 Oct 2020 02:43:53 -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=wLSIe/vCMUaVW3UNDJnixgtXZzkZCMENG5RMJFpdZiY=; b=Jg89fk6lK24L6jHng8WfIyzuIxBkbhkiHaCnN2+ArGiELQKzOZqBmejhvW8O7kWUO0 7UxPWXz23HTJjPpILdAVElI30kmwY+g1KdBhu/W+Objy10M0bzriHC13V29hpdMlmxyX 9jMGQyOaHfTIHCLVyce2r+xZ1T/qNW0LEWe1f4Z0RWibc98glZFzhk2TH8qJXE7m6yjr O4E8leXuNKaD6Zji4HBPuWYOLvQJqf3ehrSUNJG5GKrA81ZUFtZTV7tQjYKfss8EYgYp /D+tHMkm2vnh7anJ/Y9kFY6eG7pj9fotNjMDZ6qtGccB7IY7GEHBPBzGK2KyaDtXjHYC t96A== 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=wLSIe/vCMUaVW3UNDJnixgtXZzkZCMENG5RMJFpdZiY=; b=cPi2pEFET4rXDw9GbeD5UTc1z8T1bCWNeMVm6QN0GYP6kqhPmW6u0GtlvDmuUcJsJr yFAc5ZEkQC+HuCTAKfyqa+TVk/wMj6DngqUar/SYTEwv+q8aCILaxvjPW3LlHdv0NV0I +wtFHZ/+e5N09IKOMTB6RI0cRSmtU2+K0PVMAlfWAE5QzXOjXvehn5XbYUwAGBNlOtau 1wgVQlYm0dcRjywkgRshuYk414vQFzokhBKm6IIJBy0oYi53carJ4hx+oZojxIVI5qDu T/vfIv9TCFKG0iaDmVWQA0TXNmPM3OnLRu0Sfgh91oCvGGv9rxSGo1USyLGMS9oSOnkL Cw+w== X-Gm-Message-State: AOAM533kco27HHZZpw9cK3JHDESC7YaC5tSEQwJbmMxheedK10I6fp/b YdJ4/XITaQzQhP+5NZyVEXbaD/51ZkMGYnnO99nqohLa/tE= X-Google-Smtp-Source: ABdhPJw1DU8HMC8NIejTWqa7I21w/3N8rbvEEodkY/iwNtjKuJ59YJp5KePp2zP6eI7ALmcfUFGHp4u+YMjZO+NI84g= X-Received: by 2002:a17:902:8202:b029:d4:e4c6:ec72 with SMTP id x2-20020a1709028202b02900d4e4c6ec72mr4836329pln.70.1602582230979; Tue, 13 Oct 2020 02:43:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 13 Oct 2020 11:43:38 +0200 Message-ID: To: internals@lists.php.net Cc: "Kingsquare.nl - Robin Speekenbrink" , Rowan Tommins , "Christoph M. Becker" , "G. P. B." Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] Re: want an Object-oriented interface for HashContext From: divinity76@gmail.com (Hans Henrik Bergan) i know this is unrelated to the thread at hand, but am i really supposed to find the email of everyone who has replied to a thread, and add them all manually to cc? (or is it sufficient to just send it to internals@list.php.net ? ) (also funfact, it seems if you regex the innerHTML after opening an email on gmail.com , the innerHTML contains *every single email you've ever interacted with*, i found 680 emails when checking the innerHTML for this thread, quite the surprise) @Christoph M. Becker > I think the > method names should use camel-case (e.g. ::updateFile() instead of > ::update_file()) that's fine by me (could mention that PHP already use both approaches, examples: procedural: numfmt_format_currency OO: NumberFormatter::formatCurrency procedural: MySQLi::affected_rows OO: mysqli_affected_rows() ) > it might be appropriate to rename ::final() to > ::finalize() that's fine by me (personally i'd prefer a str() function which didn't finalize anything, but i guess that's a separate issue altogether, besides, userland users can work around it with hash_copy() when it's really needed) @robin > 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 ;) yes a composer package could easily wrap the current api, and it doesn't have to be done in core, but i would prefer it to be in the core, and the current HashContext class looks.. underdeveloped/underutilized/untapped/unfinished/awkward (don't know what the correct word is, English isn't my native language, but something like that) but as G. P. B. mentioned below, there's a reason for that: it used to be a resource. @ G. P. B. > 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] interesting > 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. neat, TIL (that leaves the question of what happens to is_resource() and all the code using it, but that's a different topic altogether ^^ ) > 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. in this case i think some version of the OO api would be better in every way (since even with the current procedural api, you still need to carry around the HashContext object anyway, i can't think of any good reason it shouldn't have the functionality embedded as methods, instead of using 5 global functions to manipulate it.. then again, maybe the same can be said for nearly all resources) > This can also lead us to deprecate the procedural API in favour of said new OO API. if there is interest in deprecating the procedural one, i guess it'll have to start throwing E_DEPRECATED in some 8.x release, and be removed in 9.0.0? @Rowan Tommins > I'm not that familiar with the hash functions, so > can't really comment whether I would expect them to be usable "out of the > box" or just as primitives for a higher-level wrapper. i'd expect it to be "usable out of the box" (and it is, but...clunky) On Mon, 12 Oct 2020 at 16:30, Rowan Tommins wrote: > > On Mon, 12 Oct 2020 at 15:20, G. P. B. wrote: > > > Therefore I am not sure what composer and a userland package can bring... > > > > > As an example of this general approach, the MongoDB extension provides a > minimal set of low-level "driver" functionality, and the official userland > package builds on top of these to create a richer set of APIs. That means > the majority of development takes place in the userland library, making it > easier to maintain, easier for users to keep up to date, and so on. > > That's not always the appropriate approach, though - some built-in > functionality is useful precisely because it's "batteries included", like > the password_* functions. I'm not that familiar with the hash functions, so > can't really comment whether I would expect them to be usable "out of the > box" or just as primitives for a higher-level wrapper. > > Regards, > -- > Rowan Tommins > [IMSoP]