Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128369 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 8FDA11A00BC for ; Sat, 2 Aug 2025 14:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754143405; bh=S9UEBGLQBPlF9Crx7660MpQDtCyYk1TihuMUtOCekN8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gi1V4rARECmyck5hCO1UKyybtaJ3vx4KG1Wi2NHYPu4ENJCO4AcPRyfSMGXi34Pus EWWX92jFeCJb31jxbs1ayP7NyOLTZSV+4gvc+XxmmCq7OiaKv0yz87Zt0kHHrd1gmK uDzfq5uujV9CX1PY1oj0WqsbBH60y/jh+y5xZ2kxIU0Jj6yr35Q4IB2HR1ADh3dDim Ks0Rp1YBmexjSgxmG09eSdNwQuqc7F7HtZkF8GHSC5eFhNRzZO/WLZq6c8b4rllTHi uG1b38fYq4FfDzvbCvNWqaKP9WNPomCj5LME08PkazaNhnMMUMYRwoBG+AxFkYw+wZ 5ILss3iP/Klog== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2791318005D for ; Sat, 2 Aug 2025 14:03:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 2 Aug 2025 14:03:23 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e8bbb605530so3500217276.0 for ; Sat, 02 Aug 2025 07:05:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754143504; x=1754748304; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=S9UEBGLQBPlF9Crx7660MpQDtCyYk1TihuMUtOCekN8=; b=L2vlUdv5pg19aHe7E1B2IbiLxiWx9cjbkWurChM7SZOR2cfFiBOSrRYS+8bMzYoXhs DFay/RPzKePtlXvE+65Q3YSBFfbbOm/AauflP2s7I9NrkrWQCGdXTFTgnFkNZUSltfFG h6lvFzwhv6KFz0chOHdofnFVlQkVCP3+MPsukEJ3woTuXjiT0SKR5MhFE19QVHLgxZ9w OujNEqod2xwQrRdzDTsyH6Bs6QI5mnxjxkGfbjex/AppGFX28RTNnuGKTiIa9J/oXPdH 8SHzPovXyoQTHfthxvp9cVPCM8wVZvPIf6/o2G6iRL+RMVb3oqdIIOEAtnpzmnnkP3Qj Sd9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754143504; x=1754748304; 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=S9UEBGLQBPlF9Crx7660MpQDtCyYk1TihuMUtOCekN8=; b=kncfQ7nedG/NlIbD9xLoNaXAwP1aQD+d9UtE0f7/k1PUImRnfSoZJHBo4iRC4J3aI5 vI6ZlTNCcw7g69et3XUtmdh2vHUkCBt0jPK/h6SiUmSPTgsesceWuCCuhJTHQ0OY3hGQ 1zo81HbLA6pWvGrePVfIOzNOF8N0TJm660VjQVORExfaEb8c4eMWARZb+zcRjneA9SfO IJMNaKyBxc/WlzB3VraDVWKlPJ8e5J7oB4vFoBX1ajLiGj9l7vKZK9gbHDjvLgZ4evjB 8ic+i3Yu7ijpEJ9dt9cn9RWM7qTzHPFmqm808/YBbMO6OJ30GRovecFWaFWqTF5nMMuY x1bw== X-Gm-Message-State: AOJu0YwFMq/NB4hb+cRqpXO2i6yxj2L4QUnSwyQmtcpO+ffJTjYXyex2 exKLXiC9V8h9zUdWC7kkqDFs/vXYEst35w+0Rig+RdB9oOdg0+qzvhm7SaYeoobg5QPNeQY3uDz GB2BNsXKK6WI/P9ks5e34rbSsOfWbph5TtG5rnrRCD5nK X-Gm-Gg: ASbGncsagxsdIu4vnunk+71BwQG7t0qO1p8bYYls8Cm+8B0LZ+LTApZEZ2xvKcx7xF7 viBDI5hFv4HoJF/xNgBIuxpftuVwsqRFMFaWWh51yeitl5nKUXPEtoLLbsHs/mEHGCUqsD6dvDC VLqy1rWU4BvTuq94oAEvVH/eXoC7cbRYaqACaw9A5gm70Im/p2wc07fgurVg0h4GjZCOoJDnFZe OtN5irp X-Google-Smtp-Source: AGHT+IFk8fGjUAk+zeQTvA09TdcMPpJMmaqG/L3Tq2lISPrgMzvO70277W5sqXbY0zyXK4jQatQvvvKrVQ8wpoBGlBk= X-Received: by 2002:a05:690c:ed3:b0:71b:68ab:8bf9 with SMTP id 00721157ae682-71b7ed12778mr49368607b3.1.1754143504109; Sat, 02 Aug 2025 07:05:04 -0700 (PDT) Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <2d516e15-2fc7-4ac4-b9c2-7146ac01cfb1@app.fastmail.com> In-Reply-To: <2d516e15-2fc7-4ac4-b9c2-7146ac01cfb1@app.fastmail.com> Date: Sat, 2 Aug 2025 17:04:47 +0300 X-Gm-Features: Ac12FXwhbgcjXvyNPJJslOUc34qhRtkcpoSlrOldQOHHD8GrbSvWhYFRdapatM4 Message-ID: Subject: Re: [PHP-DEV] Protected inheritance hierarchies To: Rob Landers Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000729b6e063b625ca0" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000729b6e063b625ca0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Aug 2, 2025 at 12:10=E2=80=AFPM Rob Landers wro= te: > On Tue, Jul 29, 2025, at 20:11, Jonathan Vollebregt wrote: > > I came across this edge case today: > > https://3v4l.org/R3Q8D > > Both psalm and phpstan think this code is A-OK (Once you add the > requisite type hints) but it causes fatal errors way back to PHP 5.0.0 > > ...... > > > It's not an edge case, in C2, you redefine a protected variable with the > same name and shadowed the original $v. That $v is different than C's $v. > It's easiest to see this with static access: > https://3v4l.org/0SRWb#v8.4.10 > > However, I don't know of any way to unshadow a property from $this to > access the ancestor's value (other than using private access), but it > exists and takes up memory; just accessing it is the hard part. > > =E2=80=94 Rob > Hi Rob, I'm pretty sure that there is no shadowing happening in the example. When the child instance is created, there is just one slot for the property, as the child one replaces the parent one. So basically the child property overrides the parent property rather than shadowing it. True shadowing (two slots) only occurs when the parent property is declared private. It's just that when redefining, it stores the declaring class, and so there is this sibling class access issue. I'm wondering now if the access shouldn't be relaxed, in case we have the parent class that initially defined the property. Of course, we should focus on non-static properties, as static ones are different things, and there is some shadowing there. --=20 Alex --000000000000729b6e063b625ca0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Sat, Aug 2, = 2025 at 12:10=E2=80=AFPM Rob Landers <rob@bottled.codes> wrote:
On T= ue, Jul 29, 2025, at 20:11, Jonathan Vollebregt wrote:
I came across this edge case= today:


Both psalm = and phpstan think this code is A-OK (Once you add the=C2=A0
requi= site type hints) but it causes fatal errors way back to PHP 5.0.0

...<snip>...

It= 's not an edge case, in C2, you redefine a protected variable with the = same name and shadowed the original $v. That $v is different than C's $= v. It's easiest to see this with static access:=C2=A0https://3v4l.org/0SRWb#v8.4.10



--000000000000729b6e063b625ca0--