Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127974 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 lists.php.net (Postfix) with ESMTPS id 062F21A00BC for ; Wed, 9 Jul 2025 15:43:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1752075674; bh=NQsClfyKHtC/1sGXnUe8Pfoget12vX3UWjZy9FlWmGE=; h=References:In-Reply-To:Reply-To:From:Date:Subject:To:Cc:From; b=j76cj8O4s6NaocPd0YVwsLU9v+TsUW9tNzGs8SEOPRP0ZYsG8v5hk1sQbhyfOVXpZ G5mvqiaqM0Cf/Vl3WakBmsOk+l1Tdb64CYb6uQeVXbGou6Bl0Jt4bYIGuKC2Eypw6u uHESZoCl4KR5TEbK6ffcIXsnuPMOzWs5svgbN6fy9Hs9rF89Pzym4hgQyNcVZLY8JU 45+x5EeLPQkGW+Ynseqf452RWf8m2luGATQo28wm5gt6T8VifrU9Orqo98i8hzGmui c5aA7JdKsUSB/SfX1HldsQ9ibp52xD3qSF17wEW1j3yJRFWQSTKWm77UVpeXZR9ZrW V/ttrnrp0ugtw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C94B1180623 for ; Wed, 9 Jul 2025 15:41:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) 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, FREEMAIL_REPLYTO,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-il1-f175.google.com (mail-il1-f175.google.com [209.85.166.175]) (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, 9 Jul 2025 15:41:03 +0000 (UTC) Received: by mail-il1-f175.google.com with SMTP id e9e14a558f8ab-3e059b14cb1so5140395ab.0 for ; Wed, 09 Jul 2025 08:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752075773; x=1752680573; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=vOMhdjZHldyBLOUso5JtQ9HKnPuIFWaF4AFE55H0Bl8=; b=aTtomaC6T3WAGOSsnkozumF/mwxefcadWEzi0088Kjgb/oX8ulPXQqLDCYqUT4V2XW 6NIphByPx09nkP/b75k7U/jADG2kY52V0W2c7Bt6qHWbN7ijMezAeTw9PFJcPtkfS5Nv ALIObEzcND98j0ZQTJLsqeCu+Rzj3I+zVzb2ZXgZmD8CO9D+U6D9LDz6WxegJP1XY9OI Ld+Z75Bp4VH+zHr/MFdbuQdkRoHK7Imzm4YnVkcSTWn4QOrZqXN9pXPsM0l11XEDXRUu 49qbMnPbNO6/H2a6VF1pZtQWhAT92bT+z5PzlA4RpPIHaDRIziS+nhES9/snYp4d3NDb 9gBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752075773; x=1752680573; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=vOMhdjZHldyBLOUso5JtQ9HKnPuIFWaF4AFE55H0Bl8=; b=Mr8MpWyPdNZ1E21LrpglStk3oIAArA+9dp3i0Fb0g1oR2owfo8YQ5qdWM6Fjk9xezD LOZZX9wGot9Bjx/AfVs91O+6DTxBx7NBx+pDyWbDRoH8M+F0ef68Duy9U8TuiKqrpPpK 5XYLaNzwUAFOh3ooXd1kRyIdCEQyczlW5vPEHuVcrTsIFzHFEgYjoWsizFfr8VoS67ou ZYq3AQjNAarcrj7UXHALr1SsA4vZls7Q4tQ+DHZyrnP22wtBrRuLgV5HxB5hYbv2Mt1K nO1h+s+ZOBPOTJreeq6kg/cFYPKvGPUIt9uWNEqJGkHL9n6ZcOK6/76SrytZiVk//Ehn HsCA== X-Gm-Message-State: AOJu0YyECnbukfJSiOautPsl2OmUcHyW8jvNstiYDh8KORMNiBKT6Pn9 IoZiUmwN8t+aOjVzbtKzRCf+aIEBpcjGsxrGIR4qe7wO6/9umMTVdQsp6QCLH0AUf8Zx0JRvv7o cfVi8ovqRZ4fipHOMLNRlu5CLEmTEtgpxQUuq X-Gm-Gg: ASbGncvgssT9wNYMRUo+6kkJIsmB4vli9+oDBUfyB7sNk5JjFdAB6X6/dl2fi0M2eIE 3q6kr50EKJzbY5WwWVkYCpIBvQDtaa7MEV/LL4eZtxQ8pCd4w3hfbSddgym+pUKT1mbu8yEazRe Qj9Q1ZQHnePk5q5mZWmX5yIRza0MHyAO+fh2+8HR8zYWa14hPH+5e/MhjDPjIrNrGMbBMC+89QX DaCVw== X-Google-Smtp-Source: AGHT+IEGi1CxCHDbuk3bsfy7Kx/RS5e9RMgI3teYeUo5bLtRJk5ki2HFeEH4EkW4wUI+86s8FmHoKwf6bErYgYUuj7k= X-Received: by 2002:a05:6e02:32c1:b0:3dd:e6b2:1078 with SMTP id e9e14a558f8ab-3e16807b230mr28071745ab.6.1752075773054; Wed, 09 Jul 2025 08:42:53 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <1e8634d7-ac1a-4025-b4e2-1948aabf5251@app.fastmail.com> <46857A6D-5EAF-44AF-A2DE-9B40AF8DE8C8@gmail.com> <41241c3d-a601-4fb8-9f32-976bea3b660e@app.fastmail.com> In-Reply-To: <41241c3d-a601-4fb8-9f32-976bea3b660e@app.fastmail.com> Reply-To: erictnorris@gmail.com Date: Wed, 9 Jul 2025 11:42:36 -0400 X-Gm-Features: Ac12FXzYNjdIUZovWhqCUqbrrRumf1DthoWOHtCWsE5Jq2LJfiYYSDT_rdTGy-s Message-ID: Subject: Re: [PHP-DEV] [RFC] Readonly property hooks To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: eric.t.norris@gmail.com (Eric Norris) > An init hook would be clearer, certainly, though it also has its own edge= cases. Can you set something that has an init hook? What happens if ther= e's both a get and init hook? These probably have answers that could be so= rted out, but that's a different question from "why the does a r= eadonly class forbid me using even rudimentary hooks???" > > I'd be open to a follow up RFC for an init hook, though I likely wouldn't= write it myself. But that's a different topic than what we're addressing = here. > > --Larry Garfield I'm not entirely sure I follow - it sounds like your email states that `readonly` should be interpreted as `writeonce`, which makes sense, but then why would an `init` hook not be the appropriate answer here? The two scenarios you listed (`set` hooks for validation and lazy computed properties) seem like they could be solved by allowing `set` hooks (everyone seems +1 to that), an `init` hook, and disallowing `get` hooks. It would sidestep the controversial nature of a `get` hook for the property. It feels to me like an init hook would be the more conservative approach, and would (I imagine) still allow for potential `readonly` engine optimizations like Tim pointed out. Once we allow `get` hooks, there's no going back. If we still needed to add `get` hooks in the future, it's not off the table. I don't know that I feel strongly here, but there does seem something intuitively off with allowing a get hook for a readonly (writeonce) property.