Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115296 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 50487 invoked from network); 5 Jul 2021 11:34:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 5 Jul 2021 11:34:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFC741804D1 for ; Mon, 5 Jul 2021 04:56:04 -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=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,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 mail-vs1-f45.google.com (mail-vs1-f45.google.com [209.85.217.45]) (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 ; Mon, 5 Jul 2021 04:56:04 -0700 (PDT) Received: by mail-vs1-f45.google.com with SMTP id g24so2499118vsa.10 for ; Mon, 05 Jul 2021 04:56:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hvnUppQbrSLAvtyY3ku72K9w1jCOFWLJjt46VUovnyA=; b=an+9TM3shNiiBsgQWPt05UOOi93lzBsLx590fL0XfxPEq1da5YnKR9LU/2JnK4pfSv hu9bSgBAYxN2RUjPe936S725B5SMSeVVTaEFl2/5lWOSF+A71qzyXJWvndExchkvJs/U jGhLfvN5rCcsyldBJEeZP+j2h7vLns7XuxxZeztSQ44/mFXx5e4ym8Zlv08pz/BQa+wv 5nM1MUK+a+d8MufD8Jl+lN1/yeQcyeeSnPziH32Pp1W0VKkhK3JEE5zWEcftDgxMuiHd gN+Kr1o3YbX6gvOP26PZAnpV/pi8gi02n6sJiFLQPXb0DSqKkQwCyivutRukv8Nx4eml 6z4g== X-Gm-Message-State: AOAM5311G2Fc9FLqg+Setr8hTww7lWGkbZzjZE5+OJuxME8WggKs8zCR 6sDN1QyUCyP8KRVXuVqPSCGWpj7c8R9LfzYv0w== X-Google-Smtp-Source: ABdhPJxRd/jOBpFP4IesSezJNRS9zzPnDVzVrwZlE6IlRF3jGWZsQnqY05GEPCf+3rIgzMKzBsWXzfrCttorjqnQn24= X-Received: by 2002:a67:804e:: with SMTP id b75mr8472415vsd.8.1625486163492; Mon, 05 Jul 2021 04:56:03 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Mon, 5 Jul 2021 13:55:52 +0200 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000005cc34105c65efddf" Subject: Re: [PHP-DEV] [VOTE] Readonly properties From: patrickallaert@php.net (Patrick ALLAERT) --0000000000005cc34105c65efddf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Le jeu. 1 juil. 2021 =C3=A0 12:23, Nikita Popov a = =C3=A9crit : > Hi internals, > > I have opened voting on https://wiki.php.net/rfc/readonly_properties_v2. > The vote closes 2021-07-15. > > See https://externals.io/message/114729 for the discussion thread on this > proposal. I think a decent tl;dr is that readonly properties as proposed = do > not play well with clone-based withers, so some people believe we should > either improve cloning first, or introduce asymmetric property visibility > instead, which does not suffer from this issue. > > Regards, > Nikita > With the proposed implementation the following class: class A { public readonly string $name; public function __construct(string $name) { $this->setName($name); } public function setName(string $name) { $this->name =3D $name; } public function setName2(string $name) { $this->setName($name); } public function setName3(string $name) { $this->name =3D $name; } } Would behave like this: $a =3D new A("Initial name"); echo $a->name, "\n"; // echoes Initial name $a->setName("New name"); // Allowed ? echo $a->name, "\n"; // echoes New name $a->setName2("Yet another name"); // Allowed ? echo $a->name, "\n"; // echoes Yet another name $a->setName3("Yet another name"); // Not allowed, although identical to setName()? I find the word "scope" very confusing to understand in: > A readonly property can only be initialized once, and only from the scope > where it has been declared. Any other assignment or modification of the > property will result in an Error exception. Is the above behaviour an implementation bug or does the RFC implies that? Regards, Patrick --0000000000005cc34105c65efddf--