Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119088 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14563 invoked from network); 5 Dec 2022 02:30:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Dec 2022 02:30:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFFBA1804C4 for ; Sun, 4 Dec 2022 18:30:29 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ua1-f49.google.com (mail-ua1-f49.google.com [209.85.222.49]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 4 Dec 2022 18:30:26 -0800 (PST) Received: by mail-ua1-f49.google.com with SMTP id v4so3465081ual.11 for ; Sun, 04 Dec 2022 18:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=/p/7/E4ZOX0co7KUiJZy0irbTFazQ0qBLfE3PPXLFis=; b=nTPOEUghcdXm9rlQJnkCWnSJQ90ZnAL2tQ28ismwSVnYDSRiNdLDhfz67v+uHFFZ0m E7+AFn3mgdaJUBrOmcR1LgnEnkcEmKqDGchrBQODHdLmiBHlycneHfMGqjr4SKtNCfWk TRckwyAxKUe5reUAtEEw/mFzG1Aw9U3oI/wEZl/yxaaqycqatQpfA0BJsmddfnw9iHyC FKCZjYdBLiZCtTkZIfNmL2vpvEWLsixMvNAfHsHBLJO68EO2aJUf3Ds2zPancGebGANr asU1VKlZ6+sEujZRvNxyPX7yOIfLKPtRITg2M/8OJvyvEmDyyxyElHWEwjjdCUytnjoq V5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/p/7/E4ZOX0co7KUiJZy0irbTFazQ0qBLfE3PPXLFis=; b=B1PR+mDxAz8oAED5H7PWW3TFXUCSBAzV33LJwBs7fWkLYwZ4VxogpyLLSZvCCaBmym PiUH/CpL+s0URiUDCeBqQWJJbn1r9AVIM2kPmAzjQ9G2kYz4hH+PouCYdLyfO1oNBbRz vXFtdBXFrsjAnfcto+0ffzsOpzYDe8bKUQR3BCS8Hd6uwtKNMWshnv7DrCLTW6+C4m0s KrmApCAXrPFgTPRIY32RzdzKcjMj50e0fxdDdhAFxBGXwIS6ewsiIbDGk+1aAlFVLI9k ZDQBi0uGR7K/TPeIGV+6xT4Hg9V+rvSbd6YqxsVCJJbU4cNf+etAG2nhVQKxb4DpHiW9 MHTQ== X-Gm-Message-State: ANoB5plciUX3hp723euGHTW3uIX3/1JS0SHMvZdOKUrRoZzb8soAk5oO +MIHgfNpj6sB6k6PVluI65uJps8A1H+SgsuCAFn1oJGw+4s= X-Google-Smtp-Source: AA0mqf5gBxmAPJ1tky+XzXMzIbN30F0UX7uhdgfM4ecSvwkTFxR5dhG6r2gh0vL2qVRX8CbRxBIAll4fzXVZo5DXufk= X-Received: by 2002:ab0:6994:0:b0:411:502d:7c67 with SMTP id t20-20020ab06994000000b00411502d7c67mr45503645uaq.29.1670207425325; Sun, 04 Dec 2022 18:30:25 -0800 (PST) MIME-Version: 1.0 Received: by 2002:ab0:69ca:0:b0:418:c3d2:e178 with HTTP; Sun, 4 Dec 2022 18:30:24 -0800 (PST) In-Reply-To: References: Date: Mon, 5 Dec 2022 07:30:24 +0500 Message-ID: To: Andreas Heigl Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Please allow an out of readonly properties From: office.hamzaahmad@gmail.com (Hamza Ahmad) Hello, If we keep the idea of using reflection aside, I still have a reason to consider readonly flag for private properties. There are two main uses I consider of readonly properties: prevention of property modification from the public scope and the securing the property from losing an important handle. What if the properties are set readonly with the private scope, so they are secured from getting modified, even within a class. IF it is a protected and read only property, it can also be further secured in sub classes. Internals, I want to appreciate Andreas for choosing a considerate tone for communicating the opinion that is different from the opinion shared above. What if we all at least try and adjust the tone like Andreas has done? Regards Hamza On 12/4/22, Andreas Heigl wrote: > Hey there > > On 03.12.22 23:55, Karoly Negyesi wrote: >> They refuse to compromise even on documentation issues. I am totally >> helpless. Not sure what could be done? > > When people design their systems and use final, private or readonly, > they have a reason for that. They have a plan on how their library > should be used and also how their library should not be used.That is the > API that is exposed via public methods that is described in the > documentation. > > When *your* code can only make use of a library by tweaking these > constraints, you are using the library in a way that is not intended by > the authors. > > There can be two reasons to that: Either you know exactly what you are > doing and you are willing to risk that the way you are using said > library might break with every patch version as the internal workings > might change. > > HERE BE DRAGONS: I sometimes actually need to do that (even with a > library I wrote myself) but instead of using reflection I then tend to > use monkey-patching in that case and actually rewrite the code of the > lib on installation. That way the execution is faster as I do not rely > on reflection but can access a public property directly. > > Or - and that is most of the time the case - you are using the library > wrong or even using the wrong library. > > And as you already contacted the authors and they declined your request > to change their API, the chances are high, that you are using their > Library in an unintended way. > > In that case you should reconsider what you are doing. Am I using the > right library? Why could I be using the library wrongly? How can I > change my code to use the provided API of the library? > > > In the end it always boils down to: Check whether your usecase is what > the library is intended to solve. And if there is no way around > rewriting upstream code: You are on your own! You can not rely upon > anything. Not even language features. You are not using upstream code, > you are abusing it. > > My 0.02 =E2=82=AC > > Cheers > > Andreas > >> >> On Sat, Dec 3, 2022 at 2:48 PM Marco Pivetta wrote: >> >>> Talk to the designers then: bringing your own political issues up to th= e >>> programming language/tooling only makes it worse long-term, for everyon= e >>> =F0=9F=98=9B >>> >>> On Sat, 3 Dec 2022, 23:45 Karoly Negyesi, wrote: >>> >>>> I do not have the luxury of designing my own system. I am forced to us= e >>>> upstream. I can't help it and given the history of private usage and >>>> the >>>> refusal on relaxing them I do not see this improving with the readonly= . >>>> At >>>> all. >>>> >>>> On Sat, Dec 3, 2022 at 2:42 PM Marco Pivetta >>>> wrote: >>>> >>>>> Terrible idea: reflection is mostly introspection tooling, and doesn'= t >>>>> really bend the rules of the type system, other than crossing scope >>>>> (it >>>>> "sees" more). >>>>> >>>>> Please consider designing your system to consider the constraints of >>>>> `readonly` properties, or design the constraints to fit your system >>>>> instead. >>>>> >>>>> Marco Pivetta >>>>> >>>>> https://twitter.com/Ocramius >>>>> >>>>> https://ocramius.github.io/ >>>>> >>>>> >>>>> On Sat, 3 Dec 2022 at 23:39, Karoly Negyesi >>>>> wrote: >>>>> >>>>>> Hello, >>>>>> >>>>>> If push comes to shove, private properties can be changed with >>>>>> reflection. >>>>>> >>>>>> Readonly properties can't. >>>>>> >>>>>> Please add a readonly toggle to reflection. >>>>>> >>>>>> Thanks >>>>>> >>>>>> Karoly Negyesi >>>>>> >>>>> >> > > -- > ,,, > (o o) > +---------------------------------------------------------ooO-(_)-Ooo-+ > | Andreas Heigl | > | mailto:andreas@heigl.org N 50=C2=B022'59.5" E 08=C2=B0= 23'58" | > | https://andreas.heigl.org | > +---------------------------------------------------------------------+ > | https://hei.gl/appointmentwithandreas | > +---------------------------------------------------------------------+ > | GPG-Key: https://hei.gl/keyandreasheiglorg | > +---------------------------------------------------------------------+ >