Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115699 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 46079 invoked from network); 12 Aug 2021 18:45:08 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Aug 2021 18:45:08 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 335121804B3 for ; Thu, 12 Aug 2021 12:16:10 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS35329 80.237.132.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wp160.webpack.hosteurope.de (wp160.webpack.hosteurope.de [80.237.132.167]) (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 ; Thu, 12 Aug 2021 12:16:09 -0700 (PDT) Received: from [2a02:8109:9d40:1d44:40b6:f5d3:c567:d46c] (helo=nas.fritz.box); authenticated by wp160.webpack.hosteurope.de running ExIM with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) id 1mEGBT-0003Mj-64; Thu, 12 Aug 2021 21:16:07 +0200 To: internals@lists.php.net Message-ID: <42b262eb-0d9b-8feb-cc3d-da3e36e14d1e@mabe.berlin> Date: Thu, 12 Aug 2021 21:16:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-bounce-key: webpack.hosteurope.de;marc@mabe.berlin;1628795770;9ea64a52; X-HE-SMSGID: 1mEGBT-0003Mj-64 Subject: readonly properties From: marc@mabe.berlin (Marc) Hi, As 8.1 adds readonly properties I wonder which build-in properties should be defined readonly. Currently I could find build-in readonly properties only on PDO and DOM. Very incomplete list where readonly properties could make sense: 1. Enum properties: enum Test:string {     case TEST = 'test'; } $case = TEST::TEST; $refl = (new ReflectionObject($case))->getProperty('value'); var_dump($refl->isReadOnly());  // false var_dump($refl->isPublic());  // true $case->value = 'foo'; // Fatal error: Uncaught Error: Enum properties are immutable 2. DateInterval->days $interval = (new DateTime())->diff(new DateTime()); var_dump($interval->days); // 0 $refl = (new ReflectionObject($interval))->getProperty('days'); var_dump($refl->isReadOnly()); // false var_dump($refl->isPublic()); // true $interval->days = 2; var_dump($interval->days);  // 0 3. Exception properties Exception properties are protected but does it really make sense to be able to modify an exception property after initialization? I know this would be a BC break :( Thanks for all the excellent work - Can't wait for 8.1 :) Marc