Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128372 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 949411A00BC for ; Sat, 2 Aug 2025 17:19:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754155046; bh=EaQnoRLRIXBM1Jx7ufhGUiyYZDjgSiexU8P+hRCYWhQ=; h=Date:Subject:To:References:From:In-Reply-To:From; b=j6Yg+RFx0slnNyCq5Fms9Z4hKor91ZS5auFaopX7wAwx3YDxK+iPV04ajwjzIIwwG AJKmdD2XO/PawsK1fpHQ1scTpQ+b4mNpSKlFSvV3jkEAOOqYuLSKWzukbC14yPyel7 8EpX64bCD8yC+7MCjgQGVuDzUlLJtCbt2BCBHgqOCsYkhXjSK96agicYkjl/lAuibX n970bvW8BOURXtlLkvOL/9AU0x6A8WP9LwYsftfc57oZGNs17yaL2Ib1AESLiyJPaT Hpi8KYkm10y4Zi4dD0HN3Bh9qnEbDNVg0/NFMZdNGobrSPepGLj7dVPXUz0uJQeyMU 2mEMiQeWlx6RA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 59424180079 for ; Sat, 2 Aug 2025 17:17:25 +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=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,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 fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 17:17:24 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.stl.internal (Postfix) with ESMTP id 963157A089F for ; Sat, 2 Aug 2025 13:19:05 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Sat, 02 Aug 2025 13:19:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1754155145; x=1754241545; bh=hZyUGf/YLkjlpf2PA7uw0z0BL6E9x7ZxhkerHv//nVE=; b= SPSSof/ueeXtJn8rO+3anynwk4vMOpZN9sxtzNzRzdx2MuEUhW9jd5Y1u0YhZ0I/ QeJ/41YptYuNPMoiaXNWvOFL/Y9VCoSDm4wLUq9OTyXUayIvKSyIcd2HZh1qoT0/ SHdg13+XXE/bAUT8fDyhTLYhwP2G1uen2ZmawIdBoTYcBS0GRvWD+Zwh/Kq29WZx yyZoX4IxDo9EvGQ5zB9GPaR/Wx9Z+RWY4MQZIFNRmJrB3suKPYo2WBZOFJ03Dckq Zwmc29tyoG5VfqbMCfKvOD4UEBvnOv3ujeKix5dqhPCK0dNZftTGoIiy14LQj/+k eDLKsQ7nbsd/CY77qbZ9hQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1754155145; x=1754241545; bh=h ZyUGf/YLkjlpf2PA7uw0z0BL6E9x7ZxhkerHv//nVE=; b=FlAYbXfbHxBJucUtV Ac1cc69V/ftSjcAP5nkQoYriUIpZ/Dl/hJlYt6L0fH842Oqh9K2QYqBQYQsUIEjE yl/TIp6Y0XLiPKfXywhcUlkNJ5gcJ3qT+z+So95pUsGMaFUb6buSSv5h2XlmFlXM k/HMRdVvadCsm8kHwMjiCKo4jru5VQ5L78VH1GQKR8L2GhU1fw+0Z3OTMLYm8v+y qihADwUxFZi4VYvUMRAenYL6z7EmLyDvAgig8s7kvo1w6C1aeWXyhJIBYxTSudfV QtrCORG9YpT8x647kMNSeKim5JtASmq7YR3x6+4cRz8FsDqAM4e0KOEvO9x57LA0 Gs2KA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddutdejudehucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgoufhushhpvggtthffohhmrghinhculdegledmnecujf gurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomhepfdftohifrghn ucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtg hordhukheqnecuggftrfgrthhtvghrnhepteduueegleffffevuddvhfekudffkeeiieeu heduveevjeegieelfeeuueduiefgnecuffhomhgrihhnpeefvheglhdrohhrghdphhgvrg hprdhsphgrtggvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhope dupdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhs thhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sat, 2 Aug 2025 13:19:04 -0400 (EDT) Message-ID: <069c2d28-9171-4c03-a8e4-687e517226d6@rwec.co.uk> Date: Sat, 2 Aug 2025 18:19:03 +0100 Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Protected inheritance hierarchies Content-Language: en-GB To: internals@lists.php.net References: <2d516e15-2fc7-4ac4-b9c2-7146ac01cfb1@app.fastmail.com> <8c60c0b8-8826-49a4-80ba-973ff833fff7@app.fastmail.com> In-Reply-To: <8c60c0b8-8826-49a4-80ba-973ff833fff7@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 02/08/2025 15:09, Rob Landers wrote: > I’m not sure what you mean? https://3v4l.org/WKILh#v8.4.10 > > There is clearly shadowing going on. There's a lot of confusing code in that example, so I'm not really sure what it's illustrating. This example seems more to the point: https://3v4l.org/FVhXa Regardless of whether you look up the reflection property on the parent or the child, it points to the same slot for property 'v' In contrast, the same reflection code for a private property finds both values stored in the object: https://3v4l.org/S7GmM You can see the same result with var_dump (and serialize, and debug_zval_dump, ...): https://3v4l.org/FqecC I think the relevant code is this, in zend_declare_typed_property: https://heap.space/xref/php-src/Zend/zend_API.c?r=78d96e94fa8e05dd59d03aa4891fa843ebc93ef8#4661 if (access_type & ZEND_ACC_PUBLIC) {     property_info->name = zend_string_copy(name); } else if (access_type & ZEND_ACC_PRIVATE) {     property_info->name = zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce)); } else {     ZEND_ASSERT(access_type & ZEND_ACC_PROTECTED);     property_info->name = zend_mangle_property_name("*", 1, ZSTR_VAL(name), ZSTR_LEN(name), is_persistent_class(ce)); } For a private name, the mangled name includes the class where it's defined, which is where the shadowing comes from: the final merged symbol table has two differently named slots. But for a protected name, the prefix is just "*", so it's the same slot no matter how many times it appears in the hierarchy, just like for public properties (whose names aren't mangled at all). How this relates back to the original example in the thread, I'm not sure, but it's definitely not "shadowing" in the same sense as a private property. -- Rowan Tommins [IMSoP]