Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115452 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 20842 invoked from network); 17 Jul 2021 11:22:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Jul 2021 11:22:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A2BD418033A for ; Sat, 17 Jul 2021 04:47:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 17 Jul 2021 04:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1626522446; bh=MMZtHE4TPfMmM2ngWrZrQdbu3HilM114IhycNYWt88o=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=AaokhbleuncKrMKbIDlHqxZ60oqFksKHn/kwoxgXxwQg67XinUos9l2jkpQX38hMo c0G21kUkbcWyN6bsDNQyugWCXdKKmlEWL8uWJ2Mybsrq3y/K7BK6o7Ql+h8QlINNoU WP2kzge2vkITE7o8esqX5jhJXHJACNK6pQMtZdxg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.120] ([24.134.51.41]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MzyuS-1l9t960Z5K-00x4y3 for ; Sat, 17 Jul 2021 13:47:26 +0200 To: internals@lists.php.net References: Message-ID: <2edb4a2e-b337-14c7-c453-591eaa806668@gmx.net> Date: Sat, 17 Jul 2021 13:47:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:mtPoLkdHdttXYUF5wZy/ESQReG+w/szmJst8kWDVFWECTcnb0ZD QHV+ovn6FMEAI5boaVSIHubx4ebmZD2Sx3g7vkthNNx4XFUJPmQeVwFd0TkFH2jIrrdG2Rs Ed+6bPKaDNLOONqJmcW+TDT7UvaKXeA8Km+4OSasVSfM/7Vc7l6DTKZ3wJYaZRmnWZ56Dlj RfeupJH9PP6blQcbxuTjw== X-UI-Out-Filterresults: notjunk:1;V03:K0:85oP1a/13/Q=:zBM2nqf6ToL7s7rAehqPIF GNymLzYZWpFrR/cuOko1ruNqzpaplx3XKQP4/Yc7lLwHG535ymDURyM9UTk9MH4N5qEAz/C5R VOiYMTQ8dTnHJkR1MLimAjfBDdzLkGZlItYYQzYiDnKZwOxM231Sc0U6cBT1Iv1NBKLHOLTpL kbAKBO9MOqg+dnTEzuaDTEmHAMW2rO5XfdZlWauwzYepDKDJinLIJiolQAkAQ5oABMq7T5q2s EwF4n74EhReJ+eLV+my7S1mTDMRc9hGJoGepNSAB8rB6ocqMMIZ2Q0u+KF24b5D7ZuCXRXHFy PzGgQuSimA//62nkTNggPKdOlZ0l165clKesnlWCb5vFowydab93524RvjxfXqfuK1BEBDUJq pdjysMJJSthebBWb2Wz4rj9BqFcbI2hvDHEIY0Kg2KughTH02/kl6fhTTt6STxs1AZJjxn1AC /y9/Hrr3HU1E6OKr9XLTLGXcEiqxoLxlX5aYHxubJLPmMm32c8QD8On3Xvi5uuY2CZS/WUIEp +K2crA8k+Xp4TtnnlKsCLNRi4CGlg85EZlkeTMFfY+W++9FhTR05djx/EI2inLVqa4tFVcBT1 hBgow7PdsjgQFUgLVy3a2vaCDUtV5A0byvvF9VkgRB0QJncS+ZWcivY5ZSDOEGI4iV9rTHEs8 g8QzKvIPGUY9PDnGe4jOSUaVDCUNzAbXdTl+qERCeME3ykLekK7teFsmadcV/8PUBMogXCLSQ 79ja7YPLxdMElogo08r+1ysjh1hvHcuAsJhybecgQqrXRcPgW2osRsk5lwma3fKhFbI3691jS mAQ7zGMZ/4w52ajjQOf/MXD2ULTUYM474Hzg8jcG6kouQ9QwQ0DGjYpjsaFB1+ud5pQT3DOMU v597PacCPfMnetosNei34/LBfOex9wNRYKpL24r0Ow9EcPu1ZsGNdX37sfP5SJmu/xgAYH49h sV2YIOM6fwKGUiWblARPVaj8FVtcCyMFNtl2GT3x4hkkRHZF/hYVrLkUiSi/AhJZoq61F4arn qTis4W5G4TsHQoLKx8KueHOGf7lEApMsU0NRDRnsUtPZl1FEkdyTXs+jFqKRBhQyqS6ZKObJB ql+1hSWGPW24ZWog0eKPvJi2kk49dOdcIEy Subject: Re: [PHP-DEV] Readonly properties - immutability by default From: a.leathley@gmx.net (Andreas Leathley) On 16.07.21 09:06, Nikita Popov wrote: > We cannot make properties readonly by default, because that would be a > major backwards compatibility break. > > If you're going for brevity, something you can do is omit the visibility > specifier, as it is public by default. "readonly int $prop" works. Would it be possible to adapt constructor property promotion to support this (as far as I tell, it currently does not)? Namely: class A { =C2=A0=C2=A0=C2=A0 public function __construct( =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 readonly int $id, =C2=A0=C2=A0=C2=A0 ) { =C2=A0=C2=A0=C2=A0 } } According to the constructor property promotion RFC, the promotion only happens when public, private and protected is used for an constructor parameter. With the readonly RFC accepted, it would make sense to also do constructor property promotion when readonly is used, to avoid the explicit public, because readonly would also clearly define the parameter as not-only-a-parameter.