Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120468 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 66949 invoked from network); 30 May 2023 16:47:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 May 2023 16:47:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 0787A1804D7 for ; Tue, 30 May 2023 09:47:57 -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,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS29838 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 30 May 2023 09:47:56 -0700 (PDT) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id DDA3C320091B for ; Tue, 30 May 2023 12:47:55 -0400 (EDT) Received: from imap50 ([10.202.2.100]) by compute4.internal (MEProxy); Tue, 30 May 2023 12:47:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; h=cc: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=1685465275; x= 1685551675; bh=f/whPN4vnv4MsTNkiTxUM3pgBQ8vBh1Q6SytQxoE5lc=; b=H kcSEG2OtOWUbA5bXB6hJ813xIqjW/GkvPmMbQ7gcEXbOlzh8VFVKPaIF06uC8nRG 7rFcH4HTQNN2dp6bU3AhP6SAcVQsMvzFY/Xtq22i3OX3dNWeh7eCyGgYjY3oFhmr Y5dalCxmBaRgTUzkSrAUVtNH/u4c+RMgkUprX9LspiRFxo5QAGIJzNmaYnAojEtc 7yL+qiBmNCzQFBDDznq5jW9ttcd/gCWczUoYIqUMBnV0mfEKBkKo1CGNi22ypshH DYYX44j/MiViklsvOkuKgUlP2Y8Jq/08ksABijP+rzpcZ9PxljMPxb5tur+R64/z VzhgTrzNKop579ud1uXMg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1685465275; x=1685551675; bh=f/whPN4vnv4Ms TNkiTxUM3pgBQ8vBh1Q6SytQxoE5lc=; b=eQY2GF6hm3JfD6ATxQr4hjvGC4J5q I5O2yrbTndAu/Ul6qYtyaDw56ATGgwFvQvXrb6gzYli6/wW1gv6V2IIHyJRtsN7B mXQwGNVBgP4m8bOJ38ROW1FkWsiixJBc1GKquffWfyXojV3iAQvHfnW7+BfYLKSP kBDQQ6+enDT0ilDw6Y6KhOFiYE7rmc5OY/+DsCIEeMU97jZYlKRIkG/DD2mkacjR oPTI9MHWTGJBoev4KWADWLuamMZsrjwXm8kKjWCdwAM8RIpJw1Z6o+h0TmOW3Vez p4vfZP51KuoXwfn9zZLKeprH1zZ33JqTwINlARpQBB6O3iUs9/Y9l8xLg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeekjedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgr rhhrhicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtg homheqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefg ffekudevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 2A8AD1700093; Tue, 30 May 2023 12:47:55 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-447-ge2460e13b3-fm-20230525.001-ge2460e13 Mime-Version: 1.0 Message-ID: In-Reply-To: References: Date: Tue, 30 May 2023 16:47:31 +0000 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Let ReflectionMethod keep track of original class From: larry@garfieldtech.com ("Larry Garfield") -- Larry Garfield larry@garfieldtech.com On Tue, May 30, 2023, at 2:42 AM, Andreas Hennings wrote: > Hello list, > this proposal will be useful in combination with "Declaration-aware attributes" > > > Problem > ======== > Currently, ReflectionMethod is not aware of the original class, if the > method is declared in a parent class. > Methods that are called during a discovery algorithm that need to > process a method with its original class typically need two > parameters: > > function processMethod(\ReflectionClass $class, \ReflectionMethod $method) {..} > > > Proposal > ======== > Let a ReflectionMethod object keep track of the original class. > Introduce a new method ReflectionMethod->getOriginalClass() to retrieve it. > > class B { > function f($x) {} > } > class C extends B {} > > foreach ([ > // There are different ways to get a reflection method object, all > of them track the original class. > new ReflectionMethod('C', 'f'), > (new ReflectionClass('C'))->getMethod('f'), > (new ReflectionMethod('C', 'f'))->getParameters()[0]->getDeclaringFunction(), > ] as $rm) { > // The following won't change: > assert($rm->class === 'B'); > assert($rm->getDeclaringClass()->getName() === 'B'); > // New method: > assert($rm->getOriginalClass()->getName() === 'C'); > > > Alternatives > ========== > > At first I thought we might introduce a new class like > "VirtualReflectionMethod" which behaves as if the method was declared > on the child class. But this is awkward. > > I think the ->getOriginalClass() is much simpler. I would not be opposed to this. I don't know that I have any use cases for it, but I'd be open to it. --Larry Garfield