Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130159 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 AE2431A00BC for ; Tue, 24 Feb 2026 19:50:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1771962656; bh=SGTveE1YlqeiD2C5UaeRV+bKJzn2RmfDeveK4ewqLZw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ZdLh3EeaEwD3jO+xbEp9PQEyHtA0u0JCOPAAS7tp16z3WZjpehlJn9m0V0x8Ap020 PtU6g+4egtM4P4ziitShiGJsm2P7IpfZnWgckvTHF80kLyKKw9IJCP7oxldD89ZuhC DRJw29buNNgOhetW26PLxXkO9WP4ucoiv6XWw6cd8IREn4QuI1piG4I1cXXnlAoOOp AfHqIeQZBV3wu6Id6DY0NXqfVnZ+5YuyPmTTYQ3191Zc099c8tGq5QMfNy4XaRb8x+ 0uWHMHKAAc51393IoUkwMhh2F3NvHQScDD37h3uTk69wWpUD86WlYbCBWegwILGD90 3Acd2+amSg70A== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ACCCB180796 for ; Tue, 24 Feb 2026 19:50:55 +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.9 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,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: No X-Envelope-From: Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 19:50:55 +0000 (UTC) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-385bc6910eeso56313551fa.2 for ; Tue, 24 Feb 2026 11:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771962649; cv=none; d=google.com; s=arc-20240605; b=dMfegf0pwZdR0eAV1ytWFUA3Bmur9xFNk3ofR3rQmL0YaSrGDaXcGGP6k8XdS/tfED 02AKKTKXyv8/FDSRSHf3VS2kEmalxV7giCGSksoIXzgP5ezKoVH1FfWJhe5g0BjFq7IQ Nb0t2KyjQcaI8uz6o4NFv0XBgo3U1UlyOP/HBYF0ciLI2oJ9W7mq4Ms5tY8iHObgnrdL HObfVqEPqYkNAsVyGwUHBhRmLQs0wqTEUlUczX0gepUJnnkk7+vT3ChiBBDyAGVyx0XN IIzhPSFSKz7ikU8j7cCiyh4bYpnBzEuSwh7eAc4PZiTt57YifkQpFQXp05xyxjKA7K2D R0zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6HJvwD8jYRWZFQYe8xilz/3y82+flHVRPmeHj62DnkU=; fh=Ofn+XpSLefQyxrNYeqFK5V6BgIEzMTvoqvpJ6/SQfuk=; b=CA1+iSI5ClwVNVba6WPT8ZW0y0onmiaO/azM94yT4HhpgDb7CqfA9Ydk9XKsVBMIfU M902jci51MR6diD+B/S4JddOk0BlZajtaCTRN3NbZCGgTwDfwjf/4uIvjpitcGhv1BLf GkM2elu7uv63fBmenUk4bI9aggAKQx0oQ5P3m5OHzmsgsJFacMHWftf9R6Lu56PgIsXy jpTc/kadT1igONRsGoagCaF92nvEyJBtDBGm1IujJZf7QnLci5UH39378HtmkIQTdW11 rLaWsrGa6WluT3z0m3wJMvavraCsglgjTaUfRLZQB9IbYFjK4JfFykgLzuqp+ZA7/l/O 6pgQ==; 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=1771962649; x=1772567449; 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=6HJvwD8jYRWZFQYe8xilz/3y82+flHVRPmeHj62DnkU=; b=L1vE3V+r5eO+V4B/bjfxcqZi7CekH40McUI/D+ZiZlEi8tcVIJf4iL+kvbFOpBLYRN ZAHt4jLga0xfQyjIzmnC3A10lvzD6E77ymunsciahy9PczpcNKuBhAZUTl+S0iTIRZcT HvEqE+6jId5swVoBUOd4+U7GkaRgXttoHrA+zQHcejHkaKydQ3XzljE0mAe23CE0GeIv 0AYHFJUbY2u5pkJnjugFsdUCmvMlNhMWbK/58/xkrxOyssFhjeeEFMXUwccyBkzYjSyc Hsel7DjZSJgn0SOFmwLjenssWOSaC9BegNGrF+4Kd694ZalfZY0ZBSbc5agzBnQjSVT+ +vtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771962649; x=1772567449; h=content-transfer-encoding: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=6HJvwD8jYRWZFQYe8xilz/3y82+flHVRPmeHj62DnkU=; b=rWLWSdEg6sXxUXcZm/BLSE8dTy1+F5CfHAIBHAcNrFwtBvejiO8PPn5tz9JiJxPky7 LhVt7V3w/o8X0hwGAfLjFdqRpSDnpiWbChP+czPlm1YeLs662YnKMB7rYfpN4qQck5oG DCk46VFiJuZdBIF7gYlESmrK4EQCbcKKqiXycitfX8bXO6pqOV/U1l83Ejehp+hnm1HK MN51xVUXF+qBQhTq2k8XiwlH4HdXd3VbIRaM4OFnuZtgQ9sSWFkWy4naMaBVLJAujkXX gnm5FaHV+ZpDBJIBoMMp6OmuJWWiAXY1QMnvTaH5athv+6hLmLHhvl7en3aaiRQTf86v 2UPA== X-Gm-Message-State: AOJu0YzKXsPjXj7+3nXCnWvqeKBPCc+fOR/GBSbVqIasrWATreC7VGzp Hg07Qh9fxhccDW/af9Mgx36lfJ+3Quq0oG077vtGuz7PdiDY7pt4F1uxeDs/3tYjQZEsqbFRqyV GaPih+gwnRwML8aDYupIEb3DjMg2Y61mz2A== X-Gm-Gg: ATEYQzxKsJjWm/UZLNAi92xG9k+VdzyTQN0SHjDX24ZiSr05Qh/VqGxJG0kHVwndv1V sb32pHl4M2KdfeuYr2qbq+lumFR8Ff9xQ55PBEU6S0LVjC2As4/+nCVE639Im+JcNId1fab1JOc WzitTp5lObZRI15K++9iEPk5FgT4X5VXAatT7unRGt5YzuXAmeL8kcir68jBAxEcGxt7xF+2wsE IfEkIA7xr6k5FlJf5zakErQsGXYHuE7xSC0mkILi4s2i8tJ7Rx2Eqx60wNXtPAWQcALvjJl4Sok QsS6bb8= X-Received: by 2002:a05:651c:981:b0:385:9b50:91a8 with SMTP id 38308e7fff4ca-389a5d4e691mr43512731fa.15.1771962648505; Tue, 24 Feb 2026 11:50:48 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <7FA75C32-BC65-487B-BE44-272FEED42F04@wcflabs.de> <96627211-d92f-4af4-ba45-6304a43e8575@app.fastmail.com> In-Reply-To: <96627211-d92f-4af4-ba45-6304a43e8575@app.fastmail.com> Date: Tue, 24 Feb 2026 19:50:37 +0000 X-Gm-Features: AaiRm52jhnFrh9lDRtDGsJKIpFKXuMY8ze785Wei9tbgH07PNLeN8RW3Ab6TQ9Q Message-ID: Subject: Re: [PHP-DEV] [RFC] Readonly Variables To: Larry Garfield Cc: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tekiela246@gmail.com (Kamil Tekiela) On Tue, 24 Feb 2026 at 19:32, Larry Garfield wrote= : > > On Tue, Feb 24, 2026, at 12:52 PM, Joshua R=C3=BCsweg wrote: > > >> I would prefer starting with readonly parameters as I feel that would > >> bring the most value. > > > > I find the idea of readonly parameters interesting and have already > > given it some thought. However, it is out of scope for this RFC, as I > > wanted to keep the initial proposal focused and manageable. I have > > already mentioned it in the Future Scope section of the RFC as a > > potential natural extension that could be addressed in a separate RFC > > in the future. > > A slight tangent here, but what would readonly parameters do? > > If you pass something by value, then already you cannot modify the value = in the caller. If the value is large, it's already kept efficient by copy-= on-write. > > If you pass by reference, then presumably you *want* to modify the value = in the caller. > > If the value is an object, then as already discussed, its internals are m= utable either way so you gain little, but the function cannot change the id= entity in the caller anyway. > > So I don't see what readonly parameters would even accomplish. The thing= they accomplish in JS or Java or C simply doesn't apply in PHP. > > I'm still undecided at the moment on readonly variables. > > --Larry Garfield A readonly parameter would mean that it would be impossible to reuse the variable within the function for something else. It's not uncommon for a function to preprocess the argument and still make use of the original value. A readonly modifier would prevent accidental overwrite. function foo(string|array $data) { if (is_string($data) ) { $data =3D [$data]; // Original argument lost } // .... return is_string($data) ? $result : [$result]; )