Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122450 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 7A0581ACEBF for ; Thu, 22 Feb 2024 01:14:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1708564493; bh=dV6nnjP5b0S+mZTnOQb2wnueVPKyPvFlopGiCtX9DG4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=U+EpJK+ZTbz6UJ9oGb+0K/cI7HCfpZGk+NzAvyY8tQD4KI2/tzXwyiel2GAYr1q1n yr7pbEq2dcy85S69oK6HkAHMSFOswp4Oc8qOzagrVlkgYrkAcoxPoSmRDh1SnFFWzP TndVgNBIR+G55X2h5dqUX/iG7CmJ55hEeQ5e0qzrmEyby97PyjjgPdoXbRhwa+G+y5 czY0bztOtT2F0FsoH5i6JFuwRaljEHN7t65GWCtjSvEv9GOKGUu+36UemiQZBflMdN +C9wRB+rt4YbIfA77H+B0+6To140OF6PieBLw/hQXJfbUHE+7Fca13k4koLlHD1gRx gUBcx7X2yYsSw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 332B41801DD for ; Thu, 22 Feb 2024 01:14:51 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) (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, 21 Feb 2024 17:14:50 -0800 (PST) Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5a020f5a4c5so312801eaf.1 for ; Wed, 21 Feb 2024 17:14:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708564485; x=1709169285; darn=lists.php.net; 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=5MKy/fQATRvSHltC76gzdkJahqplcpA9+4/J+n7e6F8=; b=Gr/KgJhU6CD1g6U3U40kiUR2uvIn+AqWyh2duf5m0on4icifgVGWwce3tpwJdMi6H1 aery8vAyRPOAK/Y96MxkIy5G8styLRbMoVaB/ZoNGeA2rUhcqZu0LMBw/qSGRspwS8Le 47vUaVi5xZa+ex/Oxztu3TYoditHoe/Z+cE9vn++GqTnAGl1KVZTa+Go93iRVOUO8SgS CESEcB1SffQIymKpBg6vJQ5M6KVR7b44haPLRTHohWOUdy/15LDotlhbtpOg+4HlQWqj crD2BeayDCvaYBgrY7nOsXt8I+3spJPv6W9MDWk11NTgXjrZIkJJ3/DKvbduQDlSeCvg Tt2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708564485; x=1709169285; 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=5MKy/fQATRvSHltC76gzdkJahqplcpA9+4/J+n7e6F8=; b=CBOttc9BQDJLM7syDbW38ljFcjWMUs6fvaDhcu3RT/XAKkCp/LqPZIZeMV5mMYgfaN RFysZZHRUOTIH7s00j11OnVnHdLXjiwbpyahci2VkYwPVtXcTy9SMWpmGH3WWe/xJNNn FcMXt9KlRw7L/eN2WQWqgHZBxGphgo/R9Vj+iWoXW+9qtnr7jXJYJZVSdou10APtTBXI oVEYqpwebaq9bB1TamGfa1Xvq9OXyKl/RkgvQPyBXSCfe7eBSg+vBgTJKl0b09fKzRVu 3/jBYC9PMTwkzXtjSDJ6DbTp2ABFpSvhtlqfY9evvoH5U7pX9M88ZHL172R1bBEnmY6n iIAg== X-Gm-Message-State: AOJu0YwfWPyd4UwU3TrVffCcoGpjmZkZzxoqvxKEt1ndwjQ8JAGedoMY ojpH9EQEt+MIiJeRi1pWJyttKzLy2JuDjrpk4XeaIvFiFqoYgIAK0B35H2SF2xYFfga4WAJ2F/T ogHXwb/NNYkuMDtONT5rEonV3V9L8PFNhCSGBI7KD X-Google-Smtp-Source: AGHT+IFe7sKk0CU2YWkJLNSCAW+sh9IRi+aLBRrfuQD+6VkCUvdxx9QrxJR6Ulp6OpQ3qFKttoJs9tqKNJuALHz0BDM= X-Received: by 2002:a4a:3c0f:0:b0:59f:9073:57da with SMTP id d15-20020a4a3c0f000000b0059f907357damr18373124ooa.7.1708564484706; Wed, 21 Feb 2024 17:14:44 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Feb 2024 02:14:32 +0100 Message-ID: Subject: Re: [PHP-DEV] [RFC[ Property accessor hooks, take 2 To: Pierre Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: landers.robert@gmail.com (Robert Landers) On Thu, Feb 22, 2024 at 1:03=E2=80=AFAM Pierre w= rote: > > Le 21/02/2024 =C3=A0 19:55, Larry Garfield a =C3=A9crit : > > Hello again, fine Internalians. > > > > After much on-again/off-again work, Ilija and I are back with a more po= lished property access hooks/interface properties RFC. It=E2=80=99s 99% un= changed from last summer; the PR is now essentially complete and more robus= t, and we were able to squish the last remaining edge cases. > > > > Baring any major changes, we plan to bring this to a vote in mid-March. > > > > https://wiki.php.net/rfc/property-hooks > > > > It=E2=80=99s long, but that=E2=80=99s because we=E2=80=99re handling ev= ery edge case we could think of. Properties involve dealing with both refe= rences and inheritance, both of which have complex implications. We believ= e we=E2=80=99ve identified the most logical handling for all cases, though. > > > > Note the FAQ question at the end, which explains some design choices. > > > > There=E2=80=99s one outstanding question, which is slightly painful to = ask: Originally, this RFC was called =E2=80=9Cproperty accessors,=E2=80=9D = which is the terminology used by most languages. During early development,= when we had 4 accessors like Swift, we changed the name to =E2=80=9Chooks= =E2=80=9D to better indicate that one was =E2=80=9Chooking into=E2=80=9D th= e property lifecycle. However, later refinement brought it back down to 2 = operations, get and set. That makes the =E2=80=9Chooks=E2=80=9D name less = applicable, and inconsistent with what other languages call it. > > > > However, changing it back at this point would be a non-small amount of = grunt work. There would be no functional changes from doing so, but it=E2= =80=99s lots of renaming things both in the PR and the RFC. We are willing = to do so if the consensus is that it would be beneficial, but want to ask b= efore putting in the effort. > > > Yes please ! Pass ! > > I don't have voting rights, but we need this. > > Cheers, > > Pierre R. I apologize if this has already been covered: > There are two shorthand notations supported, beyond the optional argument= to set. > First, if a hook's body is a single expression, then the { } and return s= tatement may be omitted and replaced with =3D>, just like with arrow functi= ons. Does =3D> do any special auto-capturing of variables like arrow functions or is it just a shorthand? Also, is this a meaningful shorthand to the example a little further down: public string $phone { set =3D $this->sanitizePhone(...); } or do we always have to write it out? public string $phone { set =3D> $field =3D $this->sanitizePhone($value); } Would __PROPERTY__ be set inside sanitizePhone() as well? You mention several ways values are displayed (whether or not they use the get-hook), but what does the default implementation of `__debugInfo()` look like now (or is that out of scope or a silly question?) For attributes, it would be nice to be able to target hooks specifically with attributes instead of also all methods (e.g., a Attribute::TARGET_GET_HOOK const). For example, if I were writing a serialization library, I may want to specify #[UseRawValue] only on getters to ensure that only the raw value is serialized instead of the getter (which may be specific to the application logic, or #[GetFromMethod] to tell the serialization library to get the value from a completely different method. It wouldn't make sense to target just any method with that attribute.