Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128435 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 16C2A1A00BC for ; Fri, 8 Aug 2025 13:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754658622; bh=RDXLxkMzRux6vPfXHiaoLE8tO4bnIh9xJ9MyVB1T7os=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SObw3pss5T65QXWVLTqvMXgmUxouR1YS3iz+r1fP5kJQCcNq7PZVTbFhM9s7fxRoO JYwIp4MQdBIKZX6WkRy4WwPOUe3HUh5YamRkRSfMVgMwpX9Pywu9eDjyisYR1ktKES 4Y9uAxpVxSaQq8tGVtKJzxScUx4Anj2GqTSvHDmEMK1ehhT6DSykvCDeKc/pfr6m21 Ew8ocIAwnL2WC6Qt9aRvFmaMaG30lPTbZrLOi2zA/JKZXzIjNTCedjKGqjTB+wxTYw SC0vdBLCC6QXKK/ukhnkIiuL75s0o2hfAgKTuuNHN1od764FGld2xckiW47J7bBUaM 9aAXGjKgIkT8w== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B2DAE18007E for ; Fri, 8 Aug 2025 13:10:21 +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.4 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, 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: No X-Envelope-From: Received: from sonic309-24.consmr.mail.ir2.yahoo.com (sonic309-24.consmr.mail.ir2.yahoo.com [77.238.179.82]) (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 ; Fri, 8 Aug 2025 13:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1754658718; bh=OuFVYaZLSGPzSuraa/0SRKPrygnRjacz7xO2h+l9lqs=; h=From:To:Subject:Date:In-Reply-To:References:From:Subject:Reply-To; b=mmtpgtqISYdeyzXr2hLwaOzwW7xPA3aIH8pMvd05mziys0sNSCUKCIOVM5vIx2Xzg4V1318rD4DTjSSJqx8HdhOrZWBZ5isKKZvlqv6xWuf03Kn2UORYDyHQKBoOPDwnHgYRCqL7JIidmZHXId7O9c8gj4AJmHyuduCsKANX1Q4dYpn2rCXkB2yUn68+SFuSSl3X2YTodGZaAsLOfv88L+ynJje2ga1k9JCImoeQtaQNXfb4dks1usr6aQc1kPkkmMMPDryDf9pOL2TFR9f288b2PJr6/4rWyZs5cs33XBgrLaQjVeBBZ6zJmz/+s1qC/i/zxbxdjilzJk7AH2xxFg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1754658718; bh=fQFfnoaDpB3zRcwyNzzZm8ErMaeDU+YjhSEkW606Jfp=; h=X-Sonic-MF:From:To:Subject:Date:From:Subject; b=ks4aijeC2jOvSwgbFGLTm5ug+BE9xcwQO2lKjZiVf8Tm1/DdG8ZcsT1hhv6+Mlj7J/T3/leTlBpiFm3EAvyZ8MlCN4BYdbE1gajZQYkxn9d8EQz50FzaQbt+bnho0A8kJEFmWN/om92DPJ9Jv+pV7xGxk6fni4Lu/drm9sCJzD1TLGTj8Wax2C9kPqMiTrEKX37BzOQ/a1uLgItwyPw+3pyxBlXgE7NsVYZkP0ZW2Ppu5PAmOmrI3yk1vW6pxk1Zw6BU7YueaGslyVNEmaybSz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Fee_9B6I.42gz0AkW24nA._xk9hwL7uwDFUQYklNObBePsDWwhNSr_oKbgqU4Ap6ZfU3 VucwmhNn.ays7N4x0n2qz_P9UKRvddfwUgN1AQA1T93ruQtycD0qB5POdtasGz7WPB7UxsDQUu7d EC1__IJVYzw37cCAFXRyv1gwpzBvj0qzMlzvEPppHloZq9QKE.I6OB0i2hXkOqgdlN5bDRIU197C SWQoCAET2VPphnvcpe_pXQ7S7Kgiyqf0UmTSqKCSlNmL_.9MNyAdDrq35EDAUOawUwkBu X-Sonic-MF: X-Sonic-ID: 63e87057-b492-4e72-a82a-84765efbbd32 Received: from sonic.gate.mail.ne1.yahoo.com by sonic309.consmr.mail.ir2.yahoo.com with HTTP; Fri, 8 Aug 2025 13:11:58 +0000 Received: by hermes--production-ir2-858bd4ff7b-v2qb6 (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID c3086620f949ee564a13b97c6f76cac8; Fri, 08 Aug 2025 13:11:54 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Message-ID: <1754655377927.1104458686.3594147701@yahoo.de> To: weedpacket@varteg.nz, internals@lists.php.net Subject: Re: [PHP-DEV] Protected inheritance hierarchies Date: Fri, 08 Aug 2025 13:11:53 +0000 In-Reply-To: <2d2cc2d2-5e62-41da-b697-cd752e48b1f2@varteg.nz> References: <2d2cc2d2-5e62-41da-b697-cd752e48b1f2@varteg.nz> X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.5.3735.58 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 From: hanskrentel@yahoo.de (Hans Krentel) On Friday 08 August 2025 00:49:27 (+02:00), Morgan wrote: > On 2025-08-08 10:01, Rob Landers wrote: > > For example, if |A::foo(): int| promises to always return a non-zero = integer, and a subclass overrides |foo()| to only return zero, that = violates the contract=E2=80=94even though the type signatures match = perfectly. This is the sort of semantic guarantee that LSP is about, and it= is discussed in nearly every reputable textbook and conference talk on OO = design. Languages like PHP can=E2=80=99t enforce these contracts, but the /= principle/ is what helps prevent subtle design bugs and behavioural = =E2=80=9Csurprises.=E2=80=9D > > Indeed. Those contracts only become enforceable in the type signature = when your type system is robust enough to be able to express them. If you = could declare |A::foo(): NonzeroInt| then the signature could prevent an = overriding subclass C from returning zero from that function (while still = allowing |C::foo(): PositiveInt|, say); the compiler can verify that the = type of the expression C::foo() is written to return is of type NonzeroInt = (or PositiveInt). >=20 > In the absence of being able to declare such constraints in the type = system, one has to fall back on other documentation about what behaviour is= and isn't acceptable. >=20 That is certainly always useful, especially when it was written down, as it= allows to read both, the fine-print, and between the lines. As you have = just quoted Rob's suggestion while replying to it, allow me the opportunity= to highlight a key sentence for me under the pretext of the earlier quote,= and the much appreciated association with documentation of yours to = illustrate that: > [...] the / principle/ [here, LSP,] is what helps prevent subtle design = bugs and behavioural =E2=80=9Csurprises.=E2=80=9D Documentation, e.g. of pre- and postconditions, loop (in)variants, class = invariants, etc, we can already make use of those corner-stones of the LSP = to reason about sub-types, the LSP can inspire us of what or how we = document. And that's what I've learned these days from Rob: Without = reasoning about the LSP. I knew already for what I love Liskov for, but the= LSP is so much a loaded thing in discussions, I had to get a couple of = things out of the way first to only understand Robs reasoning. I came here = by the error message, and was looking for what I was missing with it. "Oh the types in PHP must do that for us, otherwise my scripts are doomed.= " No. The compiler can only handle the type but not the sub-type, because of the = halting problem. And while my programs can be doomed because of the halting problem (4. = Every program is a part of some other program and rarely fits.), I as human= am still able to reason about the correctness of my program. Just my 2 cents -- hakre