Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130170 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 D5FE31A00BC for ; Wed, 25 Feb 2026 14:41:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1772030497; bh=idoV/EK2xN0engXSfoAdPeTNITZ0hJVnjlINWtlFNmo=; h=From:Date:Subject:To:From; b=TY9RyB+cA56gi3i2KuUhB9AmjEI24zGFfMCThGaeDYbb4ingV8eMF6GS3MMUlwevE 1OSaaXEYWALtHhGgIdgTKdlbqjyZABP5wvJU75S8slsRaHHdVYtEAixp5nQnzAZ660 zwyv2kWy5N9OI8m3K9mN0+u7JY9JpP2lDviUuVgPaXMNryG77TNgiwQOot+I8b48xu c1Gsd9Dz4Tu8fJUrV6YfSDkN/M9XIVqddHt8WWZVw00MHkpQ1lQSl4pXVy98vRm2fK fx7KJjkC8P1/a5E4aTYR9A4WdqnL7P6mfDXvfy2lwcAXo8uRgGEBFBjQpdSuJRXuIi MmKef5LelBwVw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B4FC3180553 for ; Wed, 25 Feb 2026 14:41:36 +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,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-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (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, 25 Feb 2026 14:41:26 +0000 (UTC) Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-8954a050c19so84986966d6.3 for ; Wed, 25 Feb 2026 06:41:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772030481; cv=none; d=google.com; s=arc-20240605; b=gzkXa7uHlzWUpNJLkt/KHEagxVTkeWlHPAHtJIAmt2sRSyCuu7IB91ImnXzflc4Aob A3o2loYsBPZq7uk4hXbyo53AGS3RS4CYGbdMqFoF6Tn1anIrlrmshHcdrVktrofUiteO fUxBKTjBNiKcR4p6AtdnGZvBwNESnNHQ/zeyCntfPcbeVncZL5NcwB81RCG9LaudqeOO JGjKkdZ8okQxFBXs2gShs608NKeq4yGbXrBD3HXVr3zf6asRCRwCdcDKxvx0k2hEz6T/ Rizrib9vBfq5pPqXVwuQWrhVfeWz0f8zAFop70h95+3VT71LrxicN+lhmYMq9FClxBzx hhVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=idoV/EK2xN0engXSfoAdPeTNITZ0hJVnjlINWtlFNmo=; fh=PwvV1jWZOR90rDIG/6XexqaHJyAFBTdnFVhsS64qdEQ=; b=HTBxi7IUvK6l4IUpxI9fXYOVLmXzktpBCn2de/XGSs6PDEuf0EUY8LhtnFi1N+1eGq lxNCSfZsgACVnR0TScPmUDL0e/7qZbnpAJIvGDfaCFrabswaNG5zZgRyzsa+99+3KYow My3hqNtoyLUQpDUaVvKoKHR4XmCDEg6HHhs+ai/ljJr7SLSOEquCP1jqlnkpqpLDzNph Z/ePnb3vQNfr4GHeDuipOReQwCkt2ZHD+2CCoYKNN3d1NFjzKswkE1lyuY6GJW6VXVeP 4RAKnIdlhqNdQbhlO2LPH0kJpCK2Pnbb7X/7VOkmcQ/MH6STmavT4IVRRzVtuFoA1RQ1 womQ==; 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=1772030481; x=1772635281; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=idoV/EK2xN0engXSfoAdPeTNITZ0hJVnjlINWtlFNmo=; b=CGJt3XvYVyHu9jrmSdhMCgolHjzDCsa/fbdVFLjqFm1csNEiUZIiPQVU6090+GEwXD u4xVlzzjdcVuVhstA6RWiLcQK1RVZkm1JriAMYdwUhy2v8jTVbi30Qk/H+dJNuc3ayG6 g3K0at2w4oTUNYhYG6GFZU8MgqPflmLj1d/J4N0a6U3gt1ZRMkTayf1RmQSS/jS6oX15 gLp0aG0eDBS6nzpymEvj1i/P9cQJ+ep6PXQQfm1FDxz0tWF9yI3Aeiz6+VH+ADbvpQ58 L6aFpDFxE/t8QT4fmNk21fAoLlao20632E5cRnS4GErdNz4wBqA7XeAZEAE5sexG12dv nE2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772030481; x=1772635281; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=idoV/EK2xN0engXSfoAdPeTNITZ0hJVnjlINWtlFNmo=; b=VJV7X8s0+yNaaEjtOnTffXrV772DjxXzr/EsCYMRF2epvvlEYsHEe6pazo58G/h/Wb Usc71RW7t/y383ZY0zEk9U0xz20ME0F6/sBRyEjZLdRJY+SUWF2dg2lOMOb19vzC+cvK xJ84BbuBds2J+ei2vhBON9+zl8vte3RbWOi4WYBaj8DLqql7MX7SrUIr0ryaitb5iRNe juwB5y9ebT8qgBZY1hy5aZzOf+zu6G33obRBv75Qv4WP5B1suw2kKutXe7tKYOSJfAsS BlPNO09oO/8zby59s86MmJyH9h5Hkm1hqh/WblhZKUP688gjwtPNs0Ug/WKdYiuGi347 fzNQ== X-Gm-Message-State: AOJu0Yzb5uBf4mHOGr/yoKHOjhNvPd1xnA9Ax4MjQpoYKkxnSvc26S4y HPZ0ttSBqLi8mJFvuy3fvroAeDiHToOnf+HoNFaBVYusMnnbMuPeK6g/d3VIzg0UARAzRxT053U sTiqiszoSHtfTKNVO157U5qXSL+2Z48Eskb9sAts= X-Gm-Gg: ATEYQzw4maGKcGr4g0cQzFoPv8hCWYxOct0gyZ5QMqTZ+RyG7beGj7ysH50Lba4DmjW FdX5yWr9s3TaOpJttcANam4w9pCIwivMku7YYQ4dXZGBZ9HJhNmFy1g7y5GScALmgMDABx/luMw VszCeQuhJURjOcVKfbSE1iRbA68rwYIwKnSefO/Egzz1kEumT97fIv+R2lNpL+03mcdgsIAGtR0 RhqAD0k04SWyAGKS8CUwfopqRfllMAQEbv0JfA7ly4doeWXA96mT1Kh5ybHKiiFsgdY3jkLPuT3 JKI2w6P6areVohU2VaEv5CdomDJmgHuovoNmLdQ4vg== X-Received: by 2002:a05:6214:416:b0:896:f73b:c887 with SMTP id 6a1803df08f44-89979e31ccemr226741156d6.4.1772030480564; Wed, 25 Feb 2026 06:41:20 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Date: Wed, 25 Feb 2026 15:41:09 +0100 X-Gm-Features: AaiRm52n8sfMHchpjnZkFqhQSi9dc9Oe7avrw6nQl0thEdlZ5ERyN2OUjFbRx0s Message-ID: Subject: [PHP-DEV] Re: [RFC] Readonly Variables To: PHP internals Content-Type: text/plain; charset="UTF-8" From: tovilo.ilija@gmail.com (Ilija Tovilo) Hi Joshua On Mon, 23 Feb 2026 21:29:19 +0000, josh@wcflabs.de wrote: > https://wiki.php.net/rfc/readonly-variables First of all, thank you for your proposal and the effort you've put into the implementation. I'm skeptical about the usefulness of local immutability as a whole. I personally don't recognize local mutability as a significant source of bugs, contrary to action at a distance. Putting that aside: I understand your implementation is a proof-of-concept, but the approach looks wrong to me. I think if local immutability is added, it should mostly be a compile-time concept. The implementation currently add a new opcode for readonly assignment, and touches all existing assignments to add immutability checks. This seems mostly unnecessary with few exceptions (those being var-vars, globals, extract, pass-by-reference reference promotion, etc.), as the compiler can assert that the variable being assigned to isn't marked as readonly. The implementation shows an instruction count increase of 5.2%, 1.3% and 2.1% for Zend/bench.php, Symfony Demo and Wordpress, respectively. That should mostly go away with a compile time approach. There are likely also some limitations to the compile-time approach: - Without runtime tracking of readonly (and the concept of block scoping) every variable name could only be declared once in a function. - Disallowing `$readonly['foo'] = 'bar';` at compile-time will incorrectly restrict ArrayOffset, which I personally find acceptable. - Similar to the above, compile-time checks are insufficient for future value types. [1] `$readonly->foo = 'bar';` should fail if $readonly is a value type, which will necessarily require additional runtime checks. This is further complicated by `$readonly->foo->bar = 'baz';`, which should fail _only_ if $readonly->foo itself is also a value type. Given this issue applies to arbitrarily long chains, I don't know how this could be solved. For the reasons mentioned, I don't think I'd support this RFC in any form. Nonetheless, I appreciate the care that has gone both into the RFC and implementation. Ilija [1] https://wiki.php.net/rfc/structs-v2