Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124191 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by qa.php.net (Postfix) with ESMTPS id 53BBA1A009C for ; Wed, 3 Jul 2024 12:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1720010634; bh=yRD2Ts2zQVlyy9ZqdUPBsoEu7O5Oq0bDTr/lW+MaPu0=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=fhmNmjUYpzV+dGqNE975oAvjasrLOkM9l3/IaC+EAHEMADDFSFyZUYiN6fSxzMF2I J+gFxqnf07MDtmMsW0OfVv4JhxsR3Jf50ya/ppNOQQ9KV2kzlquxEhCENJ1YpwnKk9 slM4FovP9fljFLLB8RxfY+wsq/mx5yqTzx36JE1X8q0LvXojMEEKCmV3l2iPWC+opV uLlihoH8eEleGx+YjoS5dkY5NVPGxYWeA74mzxqtlFOjh9F5I9xKNP7cu6j9VZkgGR vHKyBfRs8Gnu8152uzKgmJG0NlrgT1w4MOiGV42gFsInW5CFpYhtXrwH8sV/NjGrFI HwnJcrXPrX4qg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C44B818069D for ; Wed, 3 Jul 2024 12:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 3 Jul 2024 12:43:53 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 2A06D11402C9; Wed, 3 Jul 2024 08:42:31 -0400 (EDT) Received: from imap49 ([10.202.2.99]) by compute1.internal (MEProxy); Wed, 03 Jul 2024 08:42:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm3; t=1720010551; x= 1720096951; bh=MWL4WVSFnsHUdim430RewBny3oNc5+ndqmRW1ecqw4Y=; b=P 5omt0OF4M+L04oM+p3JQe3KJ1zIgbQVwn1EpF0d/YYVfZuQnUkqKB94MVs+3LZsB fQ2KwK1h+vefLLuADPikob/4ZDsAGECbg0U5XUaMkF4XLhOJd1axUOLzMuyRihbh 7NIfw9STxeta3QeVwrulJEZh9etUEhnbrsChdqEZJH163uWx0e7KeD4mgx1bELIA +GnjjSp9iVa1Gg6lJ8mEK/1uQC8HHNskH63S3mDg7MVpSzZjlJOW7ndt78Izn7vp yH6UjDxGq9HAf0Bv/wcdEqPS5BIPs1pT3thPyhjvMyAgZpUqNQGhryA3bgzty7zE n/Z3XyMX0wiyPC15Cy1yQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1720010551; x=1720096951; bh=MWL4WVSFnsHUdim430RewBny3oNc 5+ndqmRW1ecqw4Y=; b=uw5HQkSlbWWLtsPbjD44mX46ZsVl0LapI7aN59JY1LHd BlQmEq09FhWzdY/exzCaX31q6gsKN8s1q9+AehEUtAJxutJ2SJ1Zb92hgwaNIqSK XqWOj3wuwgDHGYUtKfo57y3S3OpkVYI7lIXJEF+Wm5heMkEUMbrjv/mTAQ5upfPD ULS2j4UD03oQVx3HY5XIvC5ihrk9wZhaNMtsPDQVeoXMaYLQOSSY0bC3tgBQmRRp P7VWxm0hvS9O+j1TggSwB0+9GgYmpJuoq4SHi/G8RA7wT0XGZ0iUv0F1UA3ZBdM4 5CvhQRv9dtEZ+OWd71cSrFO8Rn/sxDQNwnsmUILEIw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudejgdehhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvvefutgesrgdtreerreerjeenucfhrhhomhepfdftohgs ucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrg htthgvrhhnpedvheekteelveetfeevgeekgfffvdeuhfelveehvdetiefggedtfeejheet gffhueenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hrohgssegsohhtthhlvggurdgtohguvghs X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id B67C715A0092; Wed, 3 Jul 2024 08:42:30 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-566-g3812ddbbc-fm-20240627.001-g3812ddbb Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 Message-ID: <557008ce-30c4-4002-b731-1faabe487e64@app.fastmail.com> In-Reply-To: References: <8A3C2FDA-60DF-45A1-BA9D-11B6FB6F755C@gmail.com> Date: Wed, 03 Jul 2024 14:42:10 +0200 To: "Claude Pache" , "Larry Garfield" Cc: "php internals" Subject: Re: [PHP-DEV] [RFC] Property Hook improvements Content-Type: multipart/alternative; boundary=947a888f9ed74860acfe150519f397c7 From: rob@bottled.codes ("Rob Landers") --947a888f9ed74860acfe150519f397c7 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable On Wed, Jul 3, 2024, at 14:28, Claude Pache wrote: >=20 >=20 >> Le 3 juil. 2024 =C3=A0 11:54, Claude Pache a= =C3=A9crit : >>=20 >>=20 >> 2. As for readonly, I think that the invariant it is supposed to prov= ide should be enforced as strictly as possible. It means that `readonly`= is only acceptable if there is no `get` hook. >=20 > Hi, >=20 > One more thing, why I think that we should be strict here. It is not j= ust for preventing the user to write *dumb* code, it is also for prevent= ing them to write *creative* code, e.g. >=20 > ```php > class doc { > public readonly int page { > get =3D> $this->page + $this->offset; > } > private int $offset =3D 0; > public function __construct(int $page) { > $this->page =3D $page; > } > public function foo() { > // $this->offset may be adjusted here > } > } > ``` >=20 > =E2=80=94Claude I don't see anything wrong with that code. $page doesn't say "immutable"= it says "readonly", as in "cannot write to". =E2=80=94 Rob --947a888f9ed74860acfe150519f397c7 Content-Type: text/html;charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Wed, Jul 3, = 2024, at 14:28, Claude Pache wrote:

Le 3 juil. 2024 =C3=A0 11:54, Cla= ude Pache <claude.pache@gmail.com> a =C3=A9crit :

2. As for readonly, I think that the invariant it is supposed to = provide should be enforced as strictly as possible. It means that `reado= nly` is only acceptable if there is no `get` hook.

Hi,

One more thing, wh= y I think that we should be strict here. It is not just for preventing t= he user to write *dumb* code, it is also for preventing them to write *c= reative* code, e.g.

```php
class doc {
    public readonly int page {
        get =3D> $this->page + $th= is->offset;
    }
   = private int $offset =3D 0;
    public function = __construct(int $page) {
        $this= ->page =3D $page;
    }
  =   public function foo() {
       = // $this->offset may be adjusted here
    }<= br>
}
```

=E2=80=94= Claude

I don't see= anything wrong with that code. $page doesn't say "immutable" it says "r= eadonly", as in "cannot write to".

=E2=80=94 Rob
--947a888f9ed74860acfe150519f397c7--