Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120276 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99738 invoked from network); 14 May 2023 23:41:30 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 14 May 2023 23:41:30 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 93F4718004D for ; Sun, 14 May 2023 16:41:29 -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=-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-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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, 14 May 2023 16:41:26 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-3f3284dff6cso20209665e9.0 for ; Sun, 14 May 2023 16:41:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684107685; x=1686699685; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=eqtT2PeZWgpi98aS771uCsoq+8uFOBE4YnoHZSgQSz4=; b=Lzd969No9WwHX76NTFKTMKTkGIGOKuOk4CnMDQwOVDkXJC+3u6xP0Pnzv/PuHgqqLQ zmI9jPISMFqqbLTnWG2DA+obrLCPL9sWk9RZMmJ2L5wLgBfyau+6h/BjaV8auOjlLzyU 3JTtN3xNdNqi2bV/HizYmMcCQo6Rq8H+zgI9FhHHMPvTvLsbQlsuZkOlQ8q5kwicghxz gUT5NNlvrEKQdDEhhHaJ5nEGUpSfGINrch/rEL4+USWXkXSR8M6/jvuYPwDfbt6PgZuQ wVTUjlvzFy3+xohPr8pTSyhk2gvvNYQr4Yf4VDj6oj9ls08Ypg5KIbIZMcaFmjUSE/9X s70Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684107685; x=1686699685; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eqtT2PeZWgpi98aS771uCsoq+8uFOBE4YnoHZSgQSz4=; b=VL7GjWsK9gAR1Um5SbM7UZpEplRg+XtKzm1il5ApeqxPyhdhZvL6MBcMzR+T5si7ax gDRRypRKax0YZn8e/VmdcYaChpTv2AMpTmKi/V2j1BDjj5EFMHY8RiD0sNVQOjpXkyym ZNSZWHsH6IG0e9hEpVuV8+dm1nvLMbYHGDoR8+d5pDyAlyh2UlzTKPNd8zKEBYBgTKrO IT+JeT2ijNCwq86y9IQLB5xsXkyl/W63c9uM4KGf4kG8QXBqaaqL5pCOfC9gDg+Iswrp LjxLC1afxhUEK58Y5M34uCJ3ery7YZRyT1lLnY80IFv8omlOnfz46d71CQNI9ci6KuQI dD1Q== X-Gm-Message-State: AC+VfDzAbKn0WrXSSFmk/GA7F/+2NuN5K0RU6MVFRM3Owq21n8UoSuF3 K6bc/CjsBSWYZa7fSfoPPPZ90aVI0xL+HPJvkMJmjkpnPKR8gg== X-Google-Smtp-Source: ACHHUZ5xgLqiuM0kOQJF1B3l+1lUZGQZHVP9CxV53aBf8pmzJ5vAvo/SlbMIxN8JafJUmQnTs1UwDqc714dEYXpEhTs= X-Received: by 2002:a5d:4047:0:b0:306:c011:d563 with SMTP id w7-20020a5d4047000000b00306c011d563mr3645848wrp.3.1684107684378; Sun, 14 May 2023 16:41:24 -0700 (PDT) MIME-Version: 1.0 References: <641b1ca0-d33f-4f38-ae64-81b4abce24da@app.fastmail.com> In-Reply-To: <641b1ca0-d33f-4f38-ae64-81b4abce24da@app.fastmail.com> Date: Mon, 15 May 2023 06:41:12 +0700 Message-ID: To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] Property hooks, nee accessors From: the.liquid.metal@gmail.com (Hendra Gunawan) On Tue, May 9, 2023 at 4:38=E2=80=AFAM Larry Garfield wrote: > > Ilija Tovilo and I would like to offer another RFC for your consideration= . It's been a while in coming, and we've evolved the design quite a bit ju= st in the last week so if you saw an earlier draft of it in the past few mo= nths, I would encourage you to read it over again to make sure we're all on= the same page. I'm actually pretty happy with where it ended up, even if = it's not the original design. This approach eliminates several hard-to-imp= lement edge cases while still providing a lot of functionality in one packa= ge. > > https://wiki.php.net/rfc/property-hooks > > -- > Larry Garfield > larry@garfieldtech.com > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > Hi Larry. ``` public string $fullName =3D> $this->first . " " . $this->last; ``` 1. Suppose that I forgot to declare ```$this->first```. Based on the "deprecate dynamic properties" proposal, will I get an error/warning? 2. The shorthand notations supported (the shortest one) creates impaired syntax, and not pretty to look at for constructor property promotion. ``` public function __construct( public string $prop1 =3D> strtoupper($this->_prop1), public string $prop2 {set =3D> $field =3D strtolower($value);}, ){} ``` My suggestion is: use get/set keyword immediately after property name/default value rather than "=3D>" or "{" without losing multiline statements. ``` public function __construct( public string $prop1 get =3D> strtoupper($this->_prop1), public string $prop2 set =3D> $field =3D strtolower($value), public string $prop3 get { $temp =3D strtoupper($this->_prop1); return substr($temp, 0, 10) . '...'; } public string $prop4 set { $temp =3D strtolower($value); $field =3D substr($temp, 0, 10); } ){} ``` This syntax is aligned with a single statement if/for/foreach.