Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128177 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 BD5471A00BC for ; Tue, 22 Jul 2025 10:18:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753179375; bh=qAm4a+ie4v3KKvtlRCk+XHPLJbna/DKeMjohCQ1zJmY=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=CFQi7EMEF77tkLMoQe2K0G2jIwj/VmQWo1g7YQ1BhFPr1S8sl5CkGoMvucDYawaNG 5eAKHW75YwKNfmgqkXQYHyxsy8q80gX7HnsFZu5g2MwNmSJeNAGojvjLiG/NJ95asI rIESmOsup1pomGafpiMwtmz34+n6GYqymIAHWG1VGBs9mlnFcM8osUylkJgyO3t7kN Ce0SBBlY6fkyVXx1+BnGDpPsdiRIek2UpuZuB92dAurOWkTLSF7JG7vpYePp7a/WSs GWtBRl65mD3vR7TNRVYYiLl1uyD2q/iADvkjBxcH3HyPkJFFDjI+CD49p0JMMdraQ5 wOCQnrniAUGKw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 79AEB180079 for ; Tue, 22 Jul 2025 10:16:14 +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, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, 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-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (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 ; Tue, 22 Jul 2025 10:16:14 +0000 (UTC) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-ae0dd7ac1f5so961673566b.2 for ; Tue, 22 Jul 2025 03:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753179478; x=1753784278; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=XFlPtqcEUryrpTkrrLo2phWpxNILlerCtty9Pb9BmFE=; b=Xvi+O8CmD7LfdiFLpAy6sXTaKG0d3cIQQTCFzJrVTRWORMkMlbVqU/fUYH9BWLRwNw PMcBpU/2vxCzWreVtO771s5lE7gfMadALaY1NrorQf5hz9xgRbHvDNEaRXL1OehlGuXG m6Gb3Cb0R7KKSJlgppijpgHJf4u6iVIbuUyVaYHJLH21/JK5OxhMUz+YFujcz/Sv+M7m 2VRADstAY8szGiv7VOmenVrQH3MrDF4R/vwmcEin+YVsT2aqAVKAg4a2U6e/OXLGzIj9 u5wXmL7nOhU7acFj9b6KjeAELgxGFo3B2pYdbgRFW7RcUex01hPJp3lmFlobGFMA42gK tfYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753179478; x=1753784278; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XFlPtqcEUryrpTkrrLo2phWpxNILlerCtty9Pb9BmFE=; b=FcWdicxU3Y5hnIeeJlM0PmRAypprgYU+GG7LNlOud0Zv5CVtupGlqaqz1lvi8hAvq1 dBZqYSciNNdvVKXcM7x4PceD8lNojeqndNNn3WT1LnDFZlobwduthpAMiLcDaFJizA65 pP7/A+UivmXdok5vRkyuHnrVBjxQ42pnG+OseBEUX2LNFW1po09kyd06ygcg9laIse6A oEylNPlorb2F7K88cGmEkAhu7k9n3sr0TLcHWZdMf/CQ91ejnTURFslLigh4tMQLNiIe O1rdA4hjZ8KzSsMYuesi8z9lmsfDhYfmTmBgY5EU+rj6EBIjoGx3HjBXkjtpIhBQJTf+ I/4w== X-Forwarded-Encrypted: i=1; AJvYcCXF/JM6LeuGIUaIj9/pka/5v1u+UrtjIg90s/hgkwSltuo3nKgXXtN8sX+DgloCzU44uTlXqB1vjO8=@lists.php.net X-Gm-Message-State: AOJu0Yxct+lzITPza31ZqJnhzEzz0VWZGaY1MiAi5WxV+uSlOc1xWYwL 16yx2nhcfkvLwB/elf3xo/Ylf6+Yrf5jMe6rBPpTHGGM2+UahNs3g79b9GinqA== X-Gm-Gg: ASbGncuaJUFjbsis7cwmHfyQ/idQ6fxv72aLzE5L/Q5NnCm60nSceEbns+lphVnMp0x URL3OX92irdtF7g2UN3RPHYY0DyD/mWrpolONm2/4BRbFb8p4h9wL24PgJzNzNrqe8/Novl76/s Y3theqmK9GO0RPDNdPlFQUla+/mCB8MgXC3AydcupArUV7+9bn3dspe1j5+DAh+2a6fljWNP/2D Y1+k5PtgcOnxIb07WaK9OAW/kfCqzakvIGzapihx0rELUKjhyzi5tFe6KCeWzgRBeMHElnHGa1f S1qU7EICCODWY4/Y6Jig2EXaJDEkF7Uz/s7KpeGDeFqgO7rWnl/mIHxYD1rU/WBwJe5IKF3HmI3 9DzZt0hDF5LNAvFq0WLLTEktRt1LK0lwKe/Tk6YKNehDZICkiR9M= X-Google-Smtp-Source: AGHT+IG4LXeHVZWiPIGCrOD2wuZakcM58a2TkxTL39OP17nT2+uHpFV/QYKjcIJtPglHQAKeUx4/rQ== X-Received: by 2002:a17:907:3e93:b0:ae3:d026:36cd with SMTP id a640c23a62f3a-aec6a6235eemr1675427866b.42.1753179477875; Tue, 22 Jul 2025 03:17:57 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-aec6ca310ccsm841937566b.85.2025.07.22.03.17.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 Jul 2025 03:17:57 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_B0748626-797E-44C5-ABC0-BEA9B2F1089B" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: [PHP-DEV] [RFC] Readonly property hooks Date: Tue, 22 Jul 2025 12:17:46 +0200 In-Reply-To: <77df950f-894a-41c1-863b-89871522d14c@app.fastmail.com> Cc: erictnorris@gmail.com, php internals To: Rob Landers References: <378cd8b0-c4a8-4e53-b0bd-e9e4f30a454d@app.fastmail.com> <77128196-8D53-40D6-9BB7-77160AD71ED9@gmail.com> <247034b6-04cf-4f3e-a145-a30171af8c12@app.fastmail.com> <5a51401a-450b-46f0-8467-88d31efecb9c@app.fastmail.com> <4567d926-aaed-44a8-9cd6-68e8e12742f4@app.fastmail.com> <77df950f-894a-41c1-863b-89871522d14c@app.fastmail.com> X-Mailer: Apple Mail (2.3826.600.51.1.1) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_B0748626-797E-44C5-ABC0-BEA9B2F1089B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 22 juil. 2025 =C3=A0 11:25, Rob Landers a = =C3=A9crit : >=20 >=20 >>=20 >>> Should I be able to mark this class as readonly? I would think so. >>=20 >>=20 >> I don=E2=80=99t think so. >>=20 >> If you want to *document* the intended invariant, you can put a = @readonly tag in a phpdoc comment. >>=20 >> Adding a `readonly` keyword should *enforce* the invariant; the added = value is that it would choke on bugs like the one you wrote just above, = making it debugging much easier. >=20 > I=E2=80=99m not sure if you meant to, but I feel like you just argued = for allowing readonly on hooks so that these kinds of bugs aren=E2=80=99t = accidentally written=E2=80=A6 You are misinterpreting my statement, and I=E2=80=99m not sure how I = could be clearer (additional words will be subject to additional = misinterpretation). I didn=E2=80=99t say: =E2=80=9Cwe should allow = `readonly` somewhere=E2=80=9D, but: =E2=80=9Cif we add `readonly` = somewhere, it should enforce what it means, not just document an = intent=E2=80=9D. >=20 >>=20 >>=20 >>> The readonly keyword simplified that greatly, however, readonly has = been neutered compared to regular classes in the last couple of = versions. There are so many edge cases and non-implemented features with = them -- mostly due to this exact argument you are making -- that they're = nearly worthless to actually define immutable value objects in today's = PHP. >>>=20 >>=20 >> There are several issues with the readonly feature, mostly because of = the =E2=80=9Cworse-is-better=E2=80=9D philosophy. But we can slowly = correct the main issues instead of making them worse. >>=20 >> =E2=80=94Claude >=20 > I think this is the main crux of the issue, right? There is one camp = that says readonly means immutable and another that says readonly is = read-only. These two viewpoints are not compatible despite having a lot = of overlap. The original RFC explicitly and unambiguously gives the intended = interpretation, despite your attempts to find another interpretation in = it. I agree that the word =E2=80=9Creadonly=E2=80=9D is badly chosen and = confusing. But I don=E2=80=99t agree that we should reinterpret any = feature based on incorrect understanding of its intent (unless, of = course, there is consensus to reinterpret it). =E2=80=94Claude= --Apple-Mail=_B0748626-797E-44C5-ABC0-BEA9B2F1089B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 22 juil. 2025 =C3=A0 11:25, Rob Landers = <rob@bottled.codes> a =C3=A9crit :



Should I be able = to mark this class as readonly? I would think = so.

I don=E2=80=99t = think so.

If you want to *document* the = intended invariant, you can put a @readonly tag in a phpdoc = comment.

Adding a `readonly` keyword should = *enforce* the invariant; the added value is that it would choke on bugs = like the one you wrote just above, making it debugging much = easier.

I=E2=80=99m not sure if you meant to, but I feel = like you just argued for allowing readonly on hooks so that these kinds = of bugs aren=E2=80=99t accidentally = written=E2=80=A6

You are = misinterpreting my statement, and I=E2=80=99m not sure how I could be = clearer (additional words will be subject to additional = misinterpretation). I didn=E2=80=99t say: =E2=80=9Cwe should allow = `readonly` somewhere=E2=80=9D, but: =E2=80=9Cif we add `readonly` = somewhere, it should enforce what it means, not just document an = intent=E2=80=9D.




The readonly keyword simplified that greatly, = however, readonly has been neutered compared to regular classes in the = last couple of versions. There are so many edge cases and = non-implemented features with them -- mostly due to this exact argument = you are making -- that they're nearly worthless to actually define = immutable value objects in today's = PHP.


There = are several issues with the readonly feature, mostly because of the = =E2=80=9Cworse-is-better=E2=80=9D philosophy. But we can slowly correct = the main issues instead of making them = worse.

=E2=80=94Claude

I think this is = the main crux of the issue, right? There is one camp that says readonly = means immutable and another that says readonly is read-only. These two = viewpoints are not compatible despite having a lot of = overlap.

The original RFC = explicitly and unambiguously gives the intended interpretation, despite = your attempts to find another interpretation in it. I agree that the = word =E2=80=9Creadonly=E2=80=9D is badly chosen and confusing. But I = don=E2=80=99t agree that we should reinterpret any feature based on = incorrect understanding of its intent (unless, of course, there is = consensus to reinterpret = it).

=E2=80=94Claude
= --Apple-Mail=_B0748626-797E-44C5-ABC0-BEA9B2F1089B--