Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120280 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40501 invoked from network); 15 May 2023 08:33:16 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 May 2023 08:33:16 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 69F211804D0 for ; Mon, 15 May 2023 01:33:15 -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,HTML_MESSAGE, 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-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) (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 ; Mon, 15 May 2023 01:33:14 -0700 (PDT) Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-55a00da4e53so218188987b3.0 for ; Mon, 15 May 2023 01:33:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684139594; x=1686731594; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZaMo2EcbrLCprFxQTawMiFoWrnJ6dH3GbPwcZKqjOJY=; b=oVAY9Fwr2G6ed/pC9dxmKKOlfmoOWD9EEUbEHmupjueIizq3ZeDvnq8Rr5EJpHdJIz INvTfUjs4T6xsiA4thr0TzxsAKfBF0yJixwjCFopeXRs1/5GPGZL9Uo3FfQs3n4rqkFS K/HLitlauETpZFF5nT9Po34iNm6XWzLNHpvTWxb9DaizS7YK5zu/rZwnPCGLwtxB8hKg g/BofbIOzPV9TbxqOhrFL6e0HWSR8ZE2b/XgW7Y7JetAFBFoL7LXOhhAX9/m7AkNhCVr SgIW/mo0cCF5d9VtM+QdjZByfuaKVVvyIcghGBnNlnYjOCaB/3st56arxuTY6SVMGro8 guWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684139594; x=1686731594; h=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=ZaMo2EcbrLCprFxQTawMiFoWrnJ6dH3GbPwcZKqjOJY=; b=QUa1TeNPulb9idNPpZIBKEsUVZpra05yn3tXfsBqGRQa6Tpw4aeu05AxHZ1TScgYDW NDemKTHlpDuU5HHjbedFZdWVwc7V2RjvvN8oSe0QpyFN6B5P8uchkUXzoSsKEdwD6j65 Oz2OPE1WrOyp8I4f4UvzUaCzTVc1CiQTeWILHpyQKPhzWd3Qt1l9k4h5nE/fYphUkWAH dEs/KnUwjuuca3ZmhvsLw88HgAnv0PJR+iV7x2geXn4inpGQ0sOy30kQjzicTlgI5z0A cVEAcZ5WrLB6xw5K4ScHet9qziKuUlARB0vCSpIfQRZOrS3GIumKLCX9fSuyebJeM6ch Eosg== X-Gm-Message-State: AC+VfDzbaInWc7xulLieJ60jxcEsvGbS5+l+6iWPsKij1TGTof/KY8ef UmzaZUor6rGEfn3MswTOqp8ljv0iVOiJZNd7LTkqTKiNygs= X-Google-Smtp-Source: ACHHUZ5lcVe1biPyhTFL59riZzpXBO8cTQmpfQvK/rJeOmifFqrjce7xoTlX2B88OgBiAvXy9ovDPW0xINDtE5CkLkU= X-Received: by 2002:a0d:e842:0:b0:550:5b29:ba08 with SMTP id r63-20020a0de842000000b005505b29ba08mr31593546ywe.8.1684139594274; Mon, 15 May 2023 01:33:14 -0700 (PDT) MIME-Version: 1.0 References: <641b1ca0-d33f-4f38-ae64-81b4abce24da@app.fastmail.com> In-Reply-To: Date: Mon, 15 May 2023 10:32:48 +0200 Message-ID: To: Hendra Gunawan Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="00000000000044da6205fbb74e22" Subject: Re: [PHP-DEV] [RFC] Property hooks, nee accessors From: kjarli@gmail.com (Lynn) --00000000000044da6205fbb74e22 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 15, 2023 at 1:41=E2=80=AFAM Hendra Gunawan wrote: > 2. The shorthand notations supported (the shortest one) creates > impaired syntax, and not pretty to look at for constructor property > promotion. > It's starting to get crowded in object constructors. The following example is so much more readable and maintainable imo. Would it be possible to still add the quick assignment as a language feature? I'm personally not happy having property definitions in both the class body _and_ the constructor signature. ```php class User { private string $first; private string $last; public string $fullName { get =3D> $this->first . ' ' . $this->last; set =3D> [$this->first, $this->last] =3D explode(' ', $value, 2); } public function __construct($this->fullName) {} } // vs class User { private string $first; private string $last; public function __construct( public string $fullName { get =3D> $this->first . ' ' . $this->last; set =3D> [$this->first, $this->last] =3D explode(' ', $value, 2= ); } ) {} } // or class User { private string $first; private string $last; public string $fullName { get =3D> $this->first . ' ' . $this->last; set =3D> [$this->first, $this->last] =3D explode(' ', $value, 2); } public function __construct(string $fullName) { $this->fullName =3D $fullName; } } ``` --00000000000044da6205fbb74e22--