Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128381 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 70AE91A00BC for ; Sun, 3 Aug 2025 10:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754215474; bh=+NE+B1Xqy79z4zvDbeT0GwXdXNGerdTUdHOJ4XV/2VQ=; h=Date:From:To:Subject:In-Reply-To:References:From; b=b0yzWVickkNB6cnyx2tCrjkBiC3EBzYpdkYnTPW4dh4EVPwOpX+gL/67uNICd3lfT nZxeIB56iDpKo918nbwXqFqbRVmchzmgELV9LaXsocsZwrT4hPMvUCeG4wvnWEX4eS 9tLgtc8f0xmFsYamG/q/4aYF1xCscUmmXWl0dvFz55sDk0NRkbM6DuJg+eH3tCmLtG APgf+DozaZx7ms/CPTgS7sx1w6BQPJXaEn79Ohg6PlmZplEmFsnSzkqEul40BjGyzY ZAs6lP3m0bh3lgjc3iy3pZClqOpDKIR7y60XULbFahjZucJzN7CiHJoO9rl90qT4/T vggjqEt7rYe/Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB77B180341 for ; Sun, 3 Aug 2025 10:04:31 +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 fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (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 ; Sun, 3 Aug 2025 10:04:31 +0000 (UTC) Received: from phl-compute-06.internal (phl-compute-06.phl.internal [10.202.2.46]) by mailfout.phl.internal (Postfix) with ESMTP id D95FAEC1537 for ; Sun, 3 Aug 2025 06:06:11 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Sun, 03 Aug 2025 06:06:11 -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=1754215571; x=1754301971; bh=v9JUrQ+5B+fuvuJ9RyxoXeOdryFxe5IHSs5ThBE2xjA=; b= TSfPSdvyQ3b0z25D4CeseFaTDjKhvyoWpHG2JohCxd1mH5Httj3Pf2aS8mqICY5z gbU+EqsSsX528IgEkYzLCu4sqjZvoxyBjmOvcyntmgVOT4NJ529fJcQ+0gvwv584 cjHO2oPnYaquDdFFa+jflSiLu+CIXvKVytfzrEG1ia4owTOP2yDO3NQglTpjDBU7 mxUc78q53/mnd/bGiktMMGsnjF3FQC7Rsh6pJr9CI1wo+DR1RxhfokgRD/WAo1jv K6RvVMZiq+yw9Z9uj/rQSI6WJhGhcXwE6R8GSno2JDJ/Bdc71OA/fCVJ2DaMmY8g sznPxM6wcpOVqRwWat3e0Q== 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=1754215571; x=1754301971; bh=v 9JUrQ+5B+fuvuJ9RyxoXeOdryFxe5IHSs5ThBE2xjA=; b=i2uV9iGomc5EX3i2Y Iagkz1+EBjCOODaVufFSsx2xos+DwGgWEizMw9mDBoW9DJdilof2Wzj25CvzfJzv xfe8u6NWo/tPL5ouUA8eiwdzbZv9zfuHvTAssa13kL9KqlikwQQ7x+cgxyaYwMOB l2DSL3sxis+rDuMZaAZnB4nk47mUUkjfD+q3ho+6lk5gGiYxv84uoAqeJFQ3Cmrr E6pRKl1j/NuXQnJ7kXTOk214yyO/w/4I8tAONJqhcNmfWFw4vW4hcKEMGjBoL0LB qZvx7NBF+uXgHF0u9gkEKuxmCWYTQKvxYXucf3X0LWZ1oS/j4sxruXB9OdrvUZqc ynyGg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddutdeludejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgoufhushhpvggtthffohhmrghinhculdegledmnecujf gurhepfffhvffufggjfhfkgggtgfesthhqmhdttderjeenucfhrhhomhepfdftohifrghn ucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtg hordhukheqnecuggftrfgrthhtvghrnhepueevleffieefgefhhfeujeduteeigeetteeg ffegledvhffhleevvdeijedugeeunecuffhomhgrihhnpeefvheglhdrohhrghenucevlh hushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhp hhhpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtph houhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 3 Aug 2025 06:06:11 -0400 (EDT) Date: Sun, 03 Aug 2025 11:06:09 +0100 To: internals@lists.php.net Subject: Re: [PHP-DEV] Protected inheritance hierarchies User-Agent: K-9 Mail for Android In-Reply-To: References: <2d516e15-2fc7-4ac4-b9c2-7146ac01cfb1@app.fastmail.com> <8c60c0b8-8826-49a4-80ba-973ff833fff7@app.fastmail.com> <900d2936-6afd-4eed-b08a-1540d124273a@app.fastmail.com> <43428CE0-2D9C-485C-969B-5529850614BE@rwec.co.uk> <86af366e-5a31-4f0b-9440-a1d052b97331@app.fastmail.com> <5C752175-C3ED-406C-B40A-84639358C24B@rwec.co.uk> Message-ID: <559EE2D0-71FE-4321-B35E-A18468FEC364@rwec.co.uk> Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 3 August 2025 10:30:13 BST, Rob Landers wrote: >I'm not sure that this is a bug=2E You can redeclare the same type and ad= d hooks (or change them), which breaks all assumptions about substitutabili= ty=2E If substitutability was the problem, access to the re-declared property sh= ould be forbidden to the parent class as well, but it's not: https://3v4l= =2Eorg/OEadK In fact, there's no break in the *contract* of the property there, only th= e *implementation*, just like a method can be redefined to have completely = different behaviour=2E If anything, refusing access to a sibling class is a break in contact: in = the original example, class C is written with the expectation that property= $v will be visible to it, for any instance of P it receives=2E class P { protected $v =3D 1; } class C extends P { public function test(P $i) { return $i->v; } } This expectation holds, and appears to be a valid contract, regardless of = whether the object given is an instance of P itself or of a subclass=2E=20 But, a completely unrelated class can create an object which satisfies ins= tanceof P, but forbids access to property $v: class C2 extends P { protected $v =3D 2; } Why should C2 have the right to break the expectation of C in that way? Rowan Tommins [IMSoP]