Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128382 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 228561A00BC for ; Sun, 3 Aug 2025 10:17:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1754216177; bh=DCTuxmsHLlP24bdMEd4YCLriNiYk+XFCXsCYgl0AJto=; h=Date:Subject:To:References:Cc:From:In-Reply-To:From; b=AaFaxBp7fDu8XYHLKP1hfh/QU6due6Mo4/kgd+iCwg4JiIciZuWrQNcem2qfK3Obw YKeIwFgCkbgd3FZjniXCZNEoYUNYeC3CPMm+XgxVIBBGMkfYy5T+cT17TJnKmhTSnM 6YLMYu2vPWo3fcZlb6kx/BbrPdKFsuoNayJNf97UQQwC3uf5L6cPcYPBTMGikbFXe/ Dw98ZNVVFIBHzcbVaNQdRFB45fVnqRGs51XK2n2TyE6RfPyQkhUOGkIjDkpEsLhpI7 PGQYtZ81f2GXrV8+xPT6LfwJK0NnUKuOyN+D1791WCr4/yk4iw5nK8KOWW7Zu3xwcx xzGue+UdhgAVw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 19512180081 for ; Sun, 3 Aug 2025 10:16:16 +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: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from filter102.mijn.host (filter102.mijn.host [109.163.225.52]) (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:16:15 +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 1uiVml-003WZL-P8; Sun, 03 Aug 2025 06:17:54 -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:From:Cc: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=FdmfozSDIGPWqfRXsBO5jgl5nmVpB3fjqLbHhDGz9ZE=; b=y+g5x7P3xGIz+VuVUhaQLrFbYp Kp8MQeDaeSd3MXM78CGgV4/4SkZbNm2OIRMhke1hclMzV8BHBLm78WUISaaoIfgUB+C/VE2NkTLvO m1iTksDJdsVSEOiSPUbQ5BFYxRLPrv2b1Z/NoLXzaWyd1QHo1hjak3z2XkdBHpY19048pVT3wqNUI R+LItnmj3XV8m3pVSGsyqR+34/sWUWsUl2aMJ+LNuE3RdvUKG/NwjmyaMQK6emKJCMHKLbmPO7Ynm xNq+Op0e+QtDDEvROI0C3bx0f50qC8ulXSYp6FZAEZf2+6LcDieJpJibSFffwaBCVvuUvWWv7OdY4 RcAOiJmw==; Received: from 2001-1c00-2a02-0700-f335-5acc-fd4e-0eed.cable.dynamic.v6.ziggo.nl ([2001:1c00:2a02:700:f335:5acc:fd4e:eed]) by h26.mijn.host with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1uiVml-000000005fa-1ZgQ; Sun, 03 Aug 2025 12:17:47 +0200 Message-ID: <3978fc99-e084-49bf-9735-f3030a1f829e@jnvsor.net> Date: Sun, 3 Aug 2025 12:17:46 +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: Rob Landers 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> Content-Language: en-US Cc: internals@lists.php.net In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.21) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuVsW8zkSyewBjp5wHC6WRPq0GAkY1YCgECm VCylXeohtSu2SmbhJN1U9FKs8X3+Nt2sdENNz0Ob5Mcg8HV4NYhqYDYiFl9huZCsZDn+LUJsU8LO nvy35IgnJri7nm2QcgsEybI1sOftHmSKUCHCvcq0VvcCA1Qa9BGdQX4vJy9/H5JVRKyFCRrxWkR6 oZhlSr2IwdrR6MCRf9fSYHlHvEpziFKfD1jKgYfH+6S5qDVYoOmeRt7qHd5fQGuXWoplKlc1R6Pa oqS3DNVMIxswrKXjmTmYf9felIf8Q0lvYJANy1im26jqdSLearSSTVIJyNKROUzReCS8EpKh0It9 L25JS816nuiE0t5pG6MLXGczodD6n5G6jw4mRNxot7VM8k9eU13R5GRisKd7Cpd4JJuGILIejoSc poot5WKwlo2dbdgFRynr5duqaiP+JtZKoQPGLwTIQNNPqNOPF/so6xWnbVcVWzkLtkIUbefa3NbH Kpc59lzUzvTEK+Uqw6PE/u7KuzDY+5x77+RY9BSYyht4On02JTRNJesPXaFd0pgPtOq9wtkIM3Ps UTmXxp6BN+taHHderbgAXsu5dIYoVN3LtixBzAFls8HrYidi62+42jPwg3Ran/r0gMtgqwZZbpQW cd4uIqrR42CrbJrta6KPbApLgBUyIj2H/TXjHI7MkORJtN5zslZJjVg4uQ5LNiaVgKvRorzkOtuL czKRagNP0tyfRa+7DFCbefWZabhQvvTMJKNSKuIt29tfB+vdNqtuQlK+ymUmkYRGmTQkTzoTMxAf otCGzDZkl4QlI5v1Yx2lpgkVq+xP9tumT5Y5PbjMdMnLl3/hVAgywsv1hKtMPLbkDqY2eXk4bkT8 PiChGeBzKcGxNEYncqhHSrGAUNpijDB/D67yHAkHIT0LTRqSUV8ShebT8U8Xw9HTDfreWUB3Q2fy s6PCXt4asqvGFMrBqnrW+DYb+TAXVZsivwKCr3vxjsH0GFZEcJqbKICEJtWxSVd/lsDmmMOY1jgp WTtKcIOSajb4SwOJeYoaS0vLgeY3tKetbIaB909lctYg6sddcUgxA7YvlbL81yrRuBH10tfqoGlb dTkTLaWCAXLaltNBJJmzUi3BRF4p6e8zRQ== X-Report-Abuse-To: spam@filter101.mijn.host X-Complaints-To: abuse@filter101.mijn.host From: jnv@jnvsor.net (Jonathan Vollebregt) On 8/3/25 11:30 AM, Rob Landers wrote: > I'm not sure that this is a bug. You can redeclare the same type and add > hooks (or change them), which breaks all assumptions about substitutability. No it doesn't, read the "Property type variance" section on the property hooks RFC: > Normal properties are neither covariant nor contravariant; their type may not change in a subclass. The reason for that is “get” operations MUST be covariant, and “set” operations MUST be contravariant. The only way for a property to satisfy both requirements is to be invariant. > > With abstract properties (on an interface or abstract class) or virtual properties, it is possible to declare a property that has only a get or set operation. As a result, abstract properties or virtual properties that have only a get operation required MAY be covariant. Similarly, an abstract property or virtual property that has only a set operation required MAY be contravariant. > > Once a property has both a get and set operation, however, it is no longer covariant or contravariant for further extension. That is, it is now invariant (as all properties are in 8.3 and earlier). Your example code _does_ fail but this isn't because of the hooks (The getter from A->$v is inherited in C) it's because you've redeclared it without a default value and it's trying to access an uninitialized property: https://3v4l.org/pv39f#v8.4.11 vs https://3v4l.org/VD6ZK#v8.4.11