Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130150 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 D85191A00BC for ; Tue, 24 Feb 2026 06:09:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1771913358; bh=dlwQTNvjQo/Hoq/dw1JoqwdEMFCZn4n5uo5OWPiA7bo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aUgQY9/evkS2jSPqbVaYI+v/EEa2KIWuEONRoSXVMoubEx8FR5cV12A2qwrkRp+kc s0VeT6/fyDmYnFBYO60TDp4VMDaJU42XlWwGkLBlZNAv11nA+WNUgXHAzpEA8XkFZG Y98bkL18lYhIZR+y/4+zmfqF5shzFRLmybdTfpzYVrCIghHTZPNH4MyCltWJhT5IDK Z3wtCpjwO9eMhTZYeouy+b9/BtdXfxdHcCYIP1dU8zzVQQl3kya9OzwjfhbO/CKrJ/ 4J4xCyKu1Muyg/cBz25ksKbuZCc+pNWbkPd8t8EstmlMqElPhlcQMnhwhu6ZOF7Tf4 Z4+CPhbmsKBfQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A55E8180048 for ; Tue, 24 Feb 2026 06:09:17 +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=ARC_SIGNED,ARC_VALID,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: No X-Envelope-From: Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (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, 24 Feb 2026 06:09:17 +0000 (UTC) Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-506a297c14bso44359441cf.2 for ; Mon, 23 Feb 2026 22:09:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771913352; cv=none; d=google.com; s=arc-20240605; b=bznjum8ZCCiY2O89xKPU5vOff3YqywBxB+qpHZGTyrH9VwVFg1sDCeWoTRcM7rV28J AoFH6KNGXMq0cGFYzaqHBa43MJprScm/n/Ohgr5LDi0HwbwUzqi05ZdHfoe6E4YUKkKg DUYFt6sdSWHXlA2asv+mSvD/my5DhK0Ry+ibhy8q8mvGvLu3/f0TuKYq2F7LV1WnXLQi lPv0r7hndc1gwB7tRWtpZUCVDLnWGxItadYLaRVrNXsKHYZrcr2Cw1ZY57/I6CVDJvnS McZvsJygTlco2QglCnIIKhGU5JZoNIbJXklr5vfU/GPYmHdPy1FDE4HvPzygtCF4TXxf Pagg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=dlwQTNvjQo/Hoq/dw1JoqwdEMFCZn4n5uo5OWPiA7bo=; fh=VrBKzdUWf4/btqRHSGumNy63zhREef05SZpD50vBQzI=; b=Qc9tramUHkqLrjJSOggxi0sY6QgI7e44gDtPKpJzxHYGmncrToybyTFMNKXZjFMD03 NkI//E8DP8UXtCtephQQ2TMk9Eef2WnKg/YlqUB7pdFjL53BOT7D5StkhhtLjrDxi0e6 1gzv2sLJau1/FgZcxE/C1L+/eLpj7GAAzW2BsGjeh480zPtlK0UzSt9+6WkWRBBqyEfK IR5NAkOi5fYGHQQEpnCPj25VJiT1FcqnZUkOO/kkyqldLLGy2XB/1PP/NJXvGneoD/rx DIj4f4QvPpxv1/BVz4fBAvUjj1yLmPPYgY6ANJEgo0VuqzD9MZPtl+3CMGXQhQAu6sOB jhjQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771913352; x=1772518152; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dlwQTNvjQo/Hoq/dw1JoqwdEMFCZn4n5uo5OWPiA7bo=; b=mvUs+AvFB8+2ViBHsI+u22FJbZXatYu0GEjfvxOS/oj2j+5nBR65SB9TPtOOOIv1JU 1kRZMyiSoUftiOu33SwDG0tNDg2YwkMfMoXcA427/9tz+5tY2PG4IUlD2Futqwvnc/iq Ka7j92yQ4n/4zUzgc+4GibZD2nXNNZEcHCH9BDOeV8Q3wkjMN1tLhlCXBuLMTEjAqAyU 95D4xzZgu2ax5Z9P8VJYX1UQD62laLJiuR4niyNcx6QaJ7UB8hGZ5rJE1fatSaT59CIr g4rvRDeMzUdgKio/PuXSsL5fS8yISOTzFc5FRyaZ125MwtLvq/NtEStijZVjz6V6gs4z Rzwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771913352; x=1772518152; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dlwQTNvjQo/Hoq/dw1JoqwdEMFCZn4n5uo5OWPiA7bo=; b=nk3R/3ptht0lVGM5lOiRtH5cf3QKjlvPl4MI/ojlkhcTKw6mGPi/ICn3rPHKR23L9h 1pzkZDW6DcWN1n2iAc54YDUxdqDIVHOMuZfd0Z6+8x1QlcJp1aHHG8GU6LjBPfObiDJX 7UuGb3YwvBsuMxAHlFTOkoCBFoQESDoSwqZzJuy17H5YeIZDr+GeZw+N15a2MUrrZdBj 5lVptzcVJcvkQ6JEwwTso5B9Gr6UCjQpL+/lc4Rey8DIEA/jEke3OW/GB0JjFIr5Zj3u lAV4YNl38b9lcLWIB1XbxWfSVX8X4tWen1yETrQP9b8Ha0+z+BsPw8YD6WKm9f9GfJrO XFtg== X-Forwarded-Encrypted: i=1; AJvYcCWDErB/587Gtd379CWD3mvdT8ux99dbH75wXUe+9k2ufPICXoxXwq4cqUnxvMF62m/Fpva/B2kT9xA=@lists.php.net X-Gm-Message-State: AOJu0YwLP7Ul1vTi1+bKWf2ffEgLHTPkvUFSio6HLGtCU+MNShWfXOjp czu+qAHJ3/GAYvIfbHcbmwcTWyO3uOXbo+86xJGfUpEHXp/8OaJGm/KJwrMTNuS9UpU3XubAFiZ X354LTYiVEIfOMXRgvsgIwtyNH/20MSi71w== X-Gm-Gg: AZuq6aLI8SzGdAYF/cVsCOIrmya11Aq9wfd+YF4s40nm/ycNw5nMIQRmFSL5fAZMmMk JLLz4n7efdKO8JBH4OZkr8TLco69eVRfwdDJnsgnG3cJPfHLn6hvMyYsiqUIWOVdZ/GssnEgsE7 poG0iuf05+yWd4S3/ymVN4RRuunC7FliJ7SlpZGjcoCSp+w/yT3vmWWhSEfg8Os5FghyQVYTKmc 7FIsbGJqWvBtra+UOVHn5YE2p2ja8kDMalS15udplXwecmeW4IKFB+cgpnB2iIFd0a6TvW8fAnI ODApw5uzUdS8yQQxqzY= X-Received: by 2002:a53:e1ce:0:b0:64a:dd99:5a21 with SMTP id 956f58d0204a3-64c789c7d64mr7188832d50.10.1771912954136; Mon, 23 Feb 2026 22:02:34 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 24 Feb 2026 08:02:21 +0200 X-Gm-Features: AaiRm50Ojo2xoqBP06sTugQ7v8a0csrn6zwebhHIoAycX6yhhrMkISuIsvZgI3w Message-ID: Subject: Re: [PHP-DEV] [RFC] Readonly Variables To: Kamil Tekiela Cc: =?UTF-8?Q?Joshua_R=C3=BCsweg?= , PHP internals Content-Type: multipart/alternative; boundary="0000000000003450e1064b8ba224" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --0000000000003450e1064b8ba224 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 24 Feb 2026, 00:00 Kamil Tekiela, wrote: > On Mon, 23 Feb 2026 at 21:29, Joshua R=C3=BCsweg wrote: > > > > Hi internals, > > > > I'd like to propose a new language feature for PHP: Readonly Variables. > > > > PHP currently has no way to declare a variable as immutable within a > local or functional scope. This RFC proposes the readonly modifier for > variables, which prevents reassignment after the initial declaration and > results in an error on any attempt to do so. > > > > The RFC is available at: > > https://wiki.php.net/rfc/readonly-variables > > > > I'm looking forward to your feedback and discussion. > > > > Cheers, > > Joshua R=C3=BCsweg > > Hi Joshua, > > This is a very interesting proposal, but I feel like you haven't > explained all your choices. I have some questions: > > 1. Why the use of readonly keyword? Why not const or some new keyword, > e.g. locked. > > I would prefer starting with readonly parameters as I feel that would > bring the most value. > I think it would also be worthwhile to investigate a simpler syntax > for define(). > > Hi Kamil, Joshua, I wrote on this topic in the past: https://news-web.php.net/php.internals/126909 and I think we already cannot use readonly and final for parameter, as that conflicts with constructor parameter promotion: > if we ever decide to use the final modifier for a parameter, it would not be possible. > it is already not possible to use the readonly modifier for a parameter because of this I think that using const keyword might be one of the best options. --=20 Alex --0000000000003450e1064b8ba224 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Tue, 24 Feb 2026, 00:00 Kamil= Tekiela, <tekiela246@gmail.com<= /a>> wrote:
On Mon, 23 Feb 2026 = at 21:29, Joshua R=C3=BCsweg <josh@wcflabs.de> wrote:
>
> Hi internals,
>
> I'd like to propose a new language feature for PHP: Readonly Varia= bles.
>
> PHP currently has no way to declare a variable as immutable within a l= ocal or functional scope. This RFC proposes the readonly modifier for varia= bles, which prevents reassignment after the initial declaration and results= in an error on any attempt to do so.
>
> The RFC is available at:
> https://wiki.php.net/rfc/readonly-variabl= es
>
> I'm looking forward to your feedback and discussion.
>
> Cheers,
> Joshua R=C3=BCsweg

Hi Joshua,

This is a very interesting proposal, but I feel like you haven't
explained all your choices. I have some questions:

1. Why the use of readonly keyword? Why not const or some new keyword,
e.g. locked.

I would prefer starting with readonly parameters as I feel that would
bring the most value.
I think it would also be worthwhile to investigate a simpler syntax
for define().


<= div dir=3D"auto">
Hi Kamil, Joshua,
I wrote on this topic in the past:=C2=A0https://news-web.php.net/php.internals/126909=
and I think we already cannot use readonly and = final for parameter, as that conflicts with constructor parameter promotion= :
> if we ever decide to use the final modifier f= or a
parameter, it would not be possible.
> it is already not possible to use the readonly modifier f= or a parameter
because of this

I think that using const keyword might be one= of the best options.

--= =C2=A0
Alex

--0000000000003450e1064b8ba224--