Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:119034 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13598 invoked from network); 26 Nov 2022 19:45:23 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Nov 2022 19:45:23 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 980EF1804A9 for ; Sat, 26 Nov 2022 11:45:22 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-oo1-f41.google.com (mail-oo1-f41.google.com [209.85.161.41]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 26 Nov 2022 11:45:22 -0800 (PST) Received: by mail-oo1-f41.google.com with SMTP id r10-20020a4aa2ca000000b0049dd7ad4128so1097618ool.13 for ; Sat, 26 Nov 2022 11:45:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=kigT2M8ieHxRN+2NRT3j/j244XNHdeM3+VTOdo6MHDI=; b=cYP5yTxWl6Kk7SZjwjTqpv8G4/p5qL3emVj8WD3Qgm0YCUtQy5H3XoCkM6Cni8xX0r vxaaV6favmo0I3NATvaNJ0Oj+Ru/xc31spObnxVP5kLwaK8V3M8zUpVng7xmVMg6QzmK s1TmCV2Xk+BeRYGLvBd1rutvbpYJCC/WfkdkSF8W7pnnD/1jBxk2Yx6iJqgSF9EQj9mI +BUqltZ/ZDKloJcgdxa3iFrzKsoOiJhle4MFZJhHzPApvGpsilnO4uQpvnne3JkTHvHT lmL4dtOeccqupIIH9U9urb7lIMqF979EZbW3kLb2w8AvHELoeEpve1qfSpDce7Z17EkZ YsQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kigT2M8ieHxRN+2NRT3j/j244XNHdeM3+VTOdo6MHDI=; b=WS2wZGZkEo42T5MOlPiyVxssh7Q/B8AFI+YB2rFf3FnFdIx3GFDKmBHv0ZmVA2TECd zK0e0wT86KlPRaz5nHzv4kcNOWCH8moerJwBz5MVOiMAL8ayWl7edcxZP9XVKcAMq36B A40ATcI5uoNLIqo65OgBfJpNmIkIjnbVJ8j5TM2QFsCjCGvtDfMt7D9pqepF4vAAVIB6 CJp06lNittDGFnS4GLZIePv88wLns6B+EJwoTd86xjQJqtQNNtZ2rVfFatWK43b9BHGM dV0o2oi9eh5EjghE/DAai1ialM9AcAZcc56SBBZXwwcH2bDThkpsOp4cMpru8k/0N4KC TEZw== X-Gm-Message-State: ANoB5pmr/9zBvhsD7vVbK+LdM1EtQVX88S61esqGexzJ9plyoTpee6+H v5zpdlak1zhSVoHiNmjC8GnZMszTS+S5+TtfNtaPYQrm4d0= X-Google-Smtp-Source: AA0mqf7CbUEZpQw3Ny1get9onfND/d0KCnlMGi0naK4Xug3WTl7XQaUmWS6R/3/0Q4LLRFPvnzQ07rrIlv5BmVXLb2I= X-Received: by 2002:a4a:2a57:0:b0:49a:6eb0:735a with SMTP id x23-20020a4a2a57000000b0049a6eb0735amr10143586oox.34.1669491921288; Sat, 26 Nov 2022 11:45:21 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Sat, 26 Nov 2022 20:45:10 +0100 Message-ID: To: Marco Pivetta Cc: PHP Internals List Content-Type: multipart/alternative; boundary="000000000000ec831d05ee64e0c5" Subject: Re: [PHP-DEV] [RFC] [Discussion] Readonly class amendments From: kocsismate90@gmail.com (=?UTF-8?B?TcOhdMOpIEtvY3Npcw==?=) --000000000000ec831d05ee64e0c5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Marco, Sorry for the very late reply! As explained in > https://github.com/lcobucci/jwt/pull/979#discussion_r1025280053, a > consumer relying on a `readonly` > implementation of a class probably also expects replacement implementations > as read-only. > I am aware that we lack the `readonly` marker at interface level (would b= e > really neat), but the practical example is as follows: > Regarding readonly interfaces: it would be a good idea given properties were be able to be declared in interfaces. Then readonly interfaces could adopt the same semantics as readonly classes have, so that all *declared* properties become readonly. Regarding the LSP violation: your example is about immutability (as the name of the classes also suggest), but the readonly keyword doesn't guarantee immutability. This is basically what Nicolas answered not long ago to Larry: https://externals.io/message/118554#118604 readonly class FancyPerson extends Person { > private readonly stdClass $middle; > public function setMiddle(string $mid) { > $this->middle ??=3D new stdClass; > $this->middle->name =3D $mid; > } > public function fullName() { > return "$this->first $this-middle $this->last"; > } > } We proposed this change because it wouldn't break anything that's already not "broken". Regards: M=C3=A1t=C3=A9 --000000000000ec831d05ee64e0c5--