Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128424 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 7F5CE1A00BC for ; Thu, 7 Aug 2025 18:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754591746; bh=wcbPYA0lGcbQ5GRbO2VdGph+op68ChEO3V+tpQ2kM6o=; h=Date:Subject:To:References:From:Cc:In-Reply-To:From; b=H8ZLtWcG4ZS3Uckw1frhowspyZNt6cXUOpAOK6Vt6qtWOTLlOXikPv97ynZmeLokD 3Y97SiTye1hFgURtQ74UQAfEE39NORUAHdqsN1QJYUIjs2CNP8jByPx1P5a83hhuc8 +TlapgmKPFGwv5sAUBtAdLCSPT4nxkWfkaU3sLaFk4+MNX93PkJpxewqJkOWLowH7Z Og4kkqqE9/y3ltq4ZYYZ9/RwDOfbyCTP3ueYcHHoQC+bfRfaCgW3roXt9khWibH3s3 dFT3KTYVJ2io5Bw8L9bERLL+CbVnv3XQdNM8xBT/jCT8HvxfWvuTszdqBXCqMoWfpB Rt/0X5+fWJWpw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 2085F180081 for ; Thu, 7 Aug 2025 18:35:44 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from filter102.mijn.host (filter102.mijn.host [5.254.117.163]) (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 ; Thu, 7 Aug 2025 18:35:43 +0000 (UTC) Received: from h26.mijn.host ([2a03:5180:7:2:f264:726d:beae:1]) by filter102.mijn.host with esmtps (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uk5UN-00CJn5-6v; Thu, 07 Aug 2025 14:37:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=jnvsor.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:Cc:From:References: To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=qpEOOEHPf0UU9duO0JV6xJI1orziwrmFzw+zOqgKGBc=; b=3mCKo5DEEtwMsq/JsJ7uUavwWm rm0AGQkPO2Q1J9f7gdpmZWULlh/UAoJyI4RBbmmINiwvlXVgY19dfNaJYHyb1alAw935LkzLqD0lo t7ZQ7fi/RXphe5EKORSAaJ19dbUdxD8yOvVIUrTV97Qgt+Y7y4oXz6zBku+eeXgulVNkvKrMIvame fo3GpEgNEc1Rmt1YVko6lNbsAy97xcSRRDZ2Z/5WK+85RUxasrCPFJDw8JFG55TvpZMi7jS3xCEln ROW5QRgcE8hZyqltijpl4BqW7KVU6vtibzyrhJxK/z6aQg1Lzt5gx7ChwJAPTpwDqsgtbKMSVvbeL +3EOKhEw==; Received: from 2001-1c00-2a02-0700-40b5-bd17-682b-8cb3.cable.dynamic.v6.ziggo.nl ([2001:1c00:2a02:700:40b5:bd17:682b:8cb3]) by h26.mijn.host with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uk5UN-00000005I8P-0d4d; Thu, 07 Aug 2025 20:37:19 +0200 Message-ID: Date: Thu, 7 Aug 2025 20:37:18 +0200 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 To: Hans Krentel References: <1754480697189.440122623.4156562731@yahoo.de> Content-Language: en-US Cc: internals@lists.php.net In-Reply-To: <1754480697189.440122623.4156562731@yahoo.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AuthUser: jnv@jnvsor.net X-Authenticated-Id: jnv@jnvsor.net X-Originating-IP: 2a03:5180:7:2:f264:726d:beae:1 X-mijn.host-Spamfilter-Domain: mijn.host X-mijn.host-Spamfilter-Username: 2a03:5180:7:2:f264:726d:beae:1/112 Authentication-Results: mijn.host; auth=pass smtp.auth=2a03:5180:7:2:f264:726d:beae:1/112@mijn.host X-mijn.host-Spamfilter-Outgoing-Class: ham X-mijn.host-Spamfilter-Outgoing-Evidence: Combined (0.28) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuWsmSYk1QtGq8DOur+6+9dyegA3Uks29tGA X4LiG6Gb9Cu2SmbhJN1U9FKs8X3+Nt2sdENNz0Ob5Mcg8HV4NYhqYDYiFl9huZCsZDn+LUJsU+20 xtEXt/kSRjovy84YpcAEybI1sOftHmSKUCHCvcq0VvcCA1Qa9BGdQX4vJy9/H5JVRKyFCRrxWkR6 oZhlSr27jIIUCA+rBO/vL0gUFL32iFKfD1jKgYfH+6S5qDVYoOmeRt7qHd5fQGuXWoplKlc1R6Pa oqS3DNVMIxswrKXjmTmYf9felIf8Q0lvYJANy1im26jqdSLearSSTVIJyNKROUzReCS8EpKh0It9 L25JS816nuiE0t5pG6MLXGczofgXbS3qE61+OyR3Gc3nPUAkegH8AGg21BffYc5vZTkUwH34Upjg oeqgIDrFIrvO7+0aRbZk85NvEefkoSA+zXcvJuwl5fjKNe9yZBtrjaM9xEJYeWfJSk21pH43sUC7 1lktQNYXmRiLO5LZeh8LNb/h5rz7DLGg45GiUflDl8Pj2akSwD/pSEmvxWvR3fDzkLJ2UFyRsw29 tR4/IrseQC/4hO6RFjmINtYHMzaX33L/tiUbuNooEA7vZpGZDzmDZgIrBW1POd3o/7DSQTTj6s9Y TPEQFtK83f11FvBEWMEBI7CwI3bS1vgQJo6x+DddptN1fsCPigxM7SJUfln/JfEUkbqD/uIH8xTd WUhclVOYEsPvSCTlfM5Y80pDXX9tTiwVgrK/7QwfJv1RRuxwcLuEvz2n1rNwe171zTv0+4jIReiC tmFn0ADLIXPKDNedc4zsBDjH9DHvNgD+hPJh6YgIBGH410FLO/EAYb3GPEo8iJqDgs6RAwpb87Vf b9Iz0TXdlYAq6UjIxP1xMwYPoGLExzWxWyPSMeXzqo8Q4inxctgzcDoFd+96Xw4QUNtTneOQTU3U jDF2OBsHCKzGTYiz8VlyFBlXkWhIz+XlKI6Osb3p8YGPqdx9YesYZ2kEPVt51XbultM4HiyNgPp2 q0tR4oPERYWp9aw199O5emhHusUwx3A/VWW7RJdlrDgzR+tjKjwx6m43vUn7qqn63AQBupGDLZdC L3LKbw2iVCYOWXejn1PsqQY/5pHqdKO0/TEvuGslKTrRIXcXpFg5ivY= X-Report-Abuse-To: spam@filter101.mijn.host X-Complaints-To: abuse@filter101.mijn.host From: jnv@jnvsor.net (Jonathan Vollebregt) On 8/7/25 12:38 AM, Hans Krentel wrote: > > > From a child class's perspective, the "public interface" is both > protected + public of the parent. If you change or misuse a parent's > implementation or invariants, it violates LSP, even if it doesn't affect > external clients immediately. > > Ah okay, that part is not in my book, this explains to me why in your > example it violates substitutability for you, and with that thinking it > also prevents or degrades implementability for me so to say, as > otherwise I could not make use of visibility in classes - it would take > away that tool from me or I would not treat it well, potentially leading > to defects in the program. Don't believe everything you read on the internet. If you weren't allowed to change a parent's implementation, then you wouldn't be permitted to override methods at all, at which point inheritance is pointless. It's funny that he's starting to talk about invariants here. Seems he doesn't realize every example he's given so far is covariant (Besides the one at the beginning of the thread where he confused static and non-static properties) He's trying to argue that LSP is about implementation when it's not. This is an interface with a function signature: interface I { function f(): string; } See a fruit anywhere? Me neither. That's because there isn't one. It's not part of the signature. It's not part of the interface. It's not part of the definition. It's not part of the contract. This is a class with _the same function signature_: class C { function f(): string { return "fruit"; } } In fact, this class could implement that interface without any problems, because the signature is identical. The types are identical. There is no LSP violation. There is also no contract that implies C::f() returns "fruit". If you made that assumption I'd call it a lack of error handling from someone who only considered the happy path. Static analysis tools exist to stop you from making these mistakes. Once more, just to drive the point home. This is an interface with a function signature: interface I { public int $p { get; } } This is a class with the same function signature (And one more for good measure, because I::$p is covariant!): class C { public int $p; } In fact, this class could implement that interface without any problems, because the signature is identical. The types are identical. There is no LSP violation. There is no contract that implies that getting C->p will return a certain value, other than that the value will be an int. --- Back to the original issue: I'm going to open a github issue on this since it's clearly a bug and I don't see fixing it breaking any existing code.