Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120394 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 33100 invoked from network); 23 May 2023 22:44:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 May 2023 22:44:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AFA4C180083 for ; Tue, 23 May 2023 15:44:51 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS19151 66.111.4.0/24 X-Spam-Virus: No X-Envelope-From: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 23 May 2023 15:44:51 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 9857D5C0125 for ; Tue, 23 May 2023 18:44:47 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 23 May 2023 18:44:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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:sender:subject :subject:to:to; s=fm1; t=1684881887; x=1684968287; bh=EvwCmH4Vhw lHVllEfKhnkR7yvNhDm7axfG9aZx3e9Zs=; b=eIizBC1rNvZewWL3v240PL6N8H 6hy418MNCqikWyZVpWRaTyspiVgFSr/PcU313mRe265AnnreuaYCFxh4jxvTAgsp Ourb1fIYyhbWnD00GPSR+d+bCNmRf20qIkuU8WgdpXBxfl5NrItJi4C5UHX2Wg/Z ZwMz3UDP7Y7ZMpnaWXWmV9fI2iX6VoYzTClH0wKIcewlhMizcUn2DJk2p5ixUsYU Hc+WDtRgItWFrjzLEdhW2bWGRhe3z+V6RKaVqqTZhqES/pgt23A3D9ZkNUW66E+H dHIKQbkuU74x5Qkb6BIZo8yX1ap+TtQGgiMniqMF95bDspnu0guQcqydSfmQ== 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:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684881887; x= 1684968287; bh=EvwCmH4VhwlHVllEfKhnkR7yvNhDm7axfG9aZx3e9Zs=; b=i LRmgoPTH+DoHkC0Hc9qPC1otLMFo4fpDbj+Khi5VepZcO1p2LWq7SXVyfq0OzYGx lP0IFSnxMJ4jO+ZCUOZ2SB6PbbGUmEFLOwCK5NsUI7VG5SEOjIsXqV7idupxkpd0 9OKLPDq8toEHvx2HCSpaHrBVG5MBjyP5oGXM3cthIyCnAbKgwcyzkqJVm30Q4OCl c6MYjUfRBPEFGHTUyELVLq0PWwX/kciRmXMXB44WZ7SQqqK/zhKBAzucAbAIfWuS HdxN1rDvcBbA1KB79pFhGqBrxyrCupfBl3zP31+kfVpEKAFWsfFRt1rThhVf4RZt u0uKp9a+79Nb/6Ei1Zg3g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejgedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgfgsehtqhertderreejnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepffffffejffdugfegvedviedttedvgfejffefffej leefjeetveehgefhhfdvgfelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4E1FC1700089; Tue, 23 May 2023 18:44:47 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-441-ga3ab13cd6d-fm-20230517.001-ga3ab13cd Mime-Version: 1.0 Message-ID: <1fd2566e-ce23-4ab5-af5e-d3e57389c327@app.fastmail.com> In-Reply-To: References: Date: Tue, 23 May 2023 17:44:23 -0500 To: "php internals" Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC [Discussion]: Marking overridden methods (#[\Override]) From: larry@garfieldtech.com ("Larry Garfield") On Tue, May 23, 2023, at 10:47 AM, Sara Golemon wrote: > On Thu, May 11, 2023 at 11:37=E2=80=AFAM Tim D=C3=BCsterhus wrote: >> >> I'm now opening discussion for the RFC "Marking overridden methods >> (#[\Override])": >> > > I 100% get the intent behind this RFC, and as someone who's used this = in > multiple other languages the benefit to defensive coding is obvious. > > Thoughts: > > I think targeting 8.3 is aggressive as we're less than a month from FF > (accounting for discussion and voting period). > > > The first argument (about not impacting callers) for "why an attribute= and > not a keyword" feels like it's tying itself into a knot to make a spec= ious > point. The second argument about FC is more defensible, though I > personally think it's not merited in this particular case. I'd person= ally > rather have a keyword here. > > > If you do go with an Attribute, then I'd go ahead and go further by > allowing to specify the name of the class being overridden and possibly > flags about intentional LSP violations. For examples: > > > // Intentional LSP violations > class A { > public function foo(): \SimpleXMLElement { return > simplexml_load_file("/tmp/file.xml"); } > } > class TestA extends A { > #[\Override(Override::IGNORE_RETURN_TYPE_VIOLATION)] > public function foo(): TestProxyClass { return TestProxy(parent::foo= ()); } > } > > LSP checks are super valuable for writing clean and well debuggable co= de, > but sometimes they get in the way of mocking or some other non-product= ion > activity. This could provide a "get out of jail free card" for those > circumstances where you just want to tell the engine, "Shut up, I know= what > I'm doing". I've been luke-warm on this RFC so far. I can sorta see the use case, b= ut I can also see the argument for "meh, the SA tools can already do thi= s, and those who would bother using it are probably already using SA too= ls." Sara's suggestion of using it for other operations, such as "yes, I'm vi= olating LSP, trust me, I know what I'm doing" has me very interested. T= hat has a number of potential uses that SA tools would not be sufficient= for. The first is testing, which is the example Sara gave. The second is when you have a wide type in an interface method parameter= , but in a given child class you know with certainty that the type is go= ing to be some subset of that. It's not typical, but I have a few cases= where I've needed that. Narrower docblock types seem to work to keep P= HPStan happy, but having a more directly-supported in the language optio= n would be nice. Making an attribute that can *control* inheritance rather than just *fla= g* inheritance seems like it would be much more compelling. --Larry Garfield