Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118611 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 55030 invoked from network); 12 Sep 2022 19:58:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 12 Sep 2022 19:58:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 3A7FC1804A7 for ; Mon, 12 Sep 2022 12:58:46 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,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-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) (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 ; Mon, 12 Sep 2022 12:58:45 -0700 (PDT) Received: by mail-yb1-f169.google.com with SMTP id e187so8256092ybh.10 for ; Mon, 12 Sep 2022 12:58:45 -0700 (PDT) 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; bh=I+kdOSEAVWooMUFylt1JOa/iJ7T0TkklQHFGpK8He64=; b=UxCIvZOh5PT/V3o9fHgM/S8BhU+ffcgRs8Ez3t1eAxledEXhz1nNS0InX8RUA9vdXP 3DfafA9jCDMPIQLmJKEa9qZ8qXou0XOb322Ilemu+SnKUJf6v1xteLtStoctmjORsp3T G0ENJKertX5/AcrczMexkf1fVA4wEHNjY//UhhPwLV71i3unG1PfZqvUOTSzutl6X2xQ m8Vy49Os9I5e/5YDM1KxCA9mZtHor7eZVN+fOn8z9/tGvHttxtjxkA4Eg7dITFZw1Zek loHGbnpv13KdlIt8zTlBqa4bn6NNrBTTFnWYa0sogomn+74j70vYYjmbq9MUH6ARbvHK fhlQ== 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; bh=I+kdOSEAVWooMUFylt1JOa/iJ7T0TkklQHFGpK8He64=; b=KatvEKy48RJsWSForlZSziiLEVu1D0l5Q30/oTaw3Ccx8YfpgaOwVynTP3UEACJd8z ln1k/Ran2YlUArRpxXt5ZwpWNVyhVrsa3eVSqpoKPOL2hpVbn4g/ohsccX0qHNMqJIOq THKn46Q8dMB3zMwkE5Jl2cqAHnBYeOQtaZ1San4J1BjVa/RY+HNHu8eIr7UXN/zmR+30 jUvkFNvvUBt4Yx5h6OkZL+8sY15P94eSL6jRaNJRrIRuNj3K1RJseY0oLz5IOZcC4fgg +VQZLfpH4nLC3R0JR2/MerAUsZVATaSobrxZX/tXoQFzNdpNqZq3VCiAasQpNxi51n+U wabQ== X-Gm-Message-State: ACgBeo2PmTJ3fFTWkqoxxaC53t3th5guw7Bo2ymYfZFllAsXkeKiljxb htN/su3y1l2wrRLKe0z6M21ie1qqKBUjQPDL2Q9UZsQHdhM= X-Google-Smtp-Source: AA6agR5fKHEkF+op6oYNkmE4g+wf8or+AWq+TB9hl8HNVfg/anZHYW8tdBspAFgucQ162LnSRYQgFjp1io8k2p5+AT0= X-Received: by 2002:a25:d70f:0:b0:6af:2866:dbad with SMTP id o15-20020a25d70f000000b006af2866dbadmr5323132ybg.95.1663012724995; Mon, 12 Sep 2022 12:58:44 -0700 (PDT) MIME-Version: 1.0 References: <7930779c-1782-4ecd-8e3d-42ba9e199bdc@www.fastmail.com> In-Reply-To: <7930779c-1782-4ecd-8e3d-42ba9e199bdc@www.fastmail.com> Date: Mon, 12 Sep 2022 21:58:32 +0200 Message-ID: To: Larry Garfield , =?UTF-8?B?TcOhdMOpIEtvY3Npcw==?= Cc: php internals Content-Type: multipart/alternative; boundary="000000000000bafc4a05e88052f5" Subject: Re: [PHP-DEV] Re: Issues with readonly classes From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --000000000000bafc4a05e88052f5 Content-Type: text/plain; charset="UTF-8" > >> Personally I'm undecided at the moment whether or not it should be > >> allowed. I'm sympathetic to the "it's easier to disallow and allow > later > >> than vice versa" argument, but still not sure where I stand. The above > at > >> least gives a concrete example of where the problem would be. > >> > > > > If we want the safety you describe, we might want a stronger version of > it. > > Let's name it immutable. An immutable property/class would be like a > > readonly property with the additional restriction that only an immutable > > value could be assigned to it (scalars + array + immutable classes.) But > > that's another topic. > > > > Your example made me doubt for a moment, but without any convincing > > purpose, this should help decide that child classes shouldn't have to be > > readonly. > > > > Nicolas > > Another question I think is pertinent to ask: What kinds of objects > generally would be proxied in this way, and are those the kinds of objects > where a readonly object would make sense? > > Off hand, I'd expect this kind of proxying to be used mainly on services, > whereas readonly classes would be mostly value objects. So the problem > space may be smaller than it initially appears. > It's very difficult to anticipate this. Here is a counter argument: About services: the best ones are of the functional sort; they don't hold any states and their dependencies are also pure functional units. Aka they're immutable and they're good candidates for readonly classes. About entities: e.g. Doctrine proxies them all. So no, I wouldn't say that services are the most common things to proxy, and that entities are the most common things to use readonly on... I hope this discussion illustrated why we should remove propagating readonly to child classes: it serves no purpose and it breaks a universal design pattern. There is no rationale that supports the current behavior. Mate, WDYT? Cheers, Nicolas --000000000000bafc4a05e88052f5--