Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118372 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 10085 invoked from network); 7 Aug 2022 18:38:59 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Aug 2022 18:38:59 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 4E0F9180544 for ; Sun, 7 Aug 2022 13:40:05 -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,HTML_MESSAGE,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS,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 out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) (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 ; Sun, 7 Aug 2022 13:40:04 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 501CF5C0040 for ; Sun, 7 Aug 2022 16:40:04 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute2.internal (MEProxy); Sun, 07 Aug 2022 16:40:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ollie.codes; h= cc: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=1659904804; x=1659991204; bh=F8BpoKIFzU qjIrDgXh7vn6fXoZKCSpSf21TCiO8Y3Tk=; b=mzURkDXD4VItZ4LHXpYvvgQABA R4MnrYio/6Ser0GepAOmaChatX3pcFFkwnvtpZcqQdzQTq6wN/VxywOZOYuyJlX2 /0C++0//xCf6uhYo/jhXDr7sFZ+VUJ762VHAucEP+uCySSh+3qpYZZCI3HzDDrdx mJrQ9Nn6Ary8o9HIfn+Dnm8y1V3Gp2gOPQvFp5QHcH9TifYWubDi9xHxQ/5B+sZE nbi6r5ZxkGwqKKXLAOx/khJnjnSdSS4AWd4IE4JEQR9iAXWTJoQx9wlj2OYRmae0 6Nr2KtazdnxczR7ictxTBd1a4QAs2eNyV1wC3q7e0MyYYTNXJuoLKRQ9c+tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=1659904804; x=1659991204; bh=F8BpoKIFzUqjIrDgXh7vn6fXoZKC SpSf21TCiO8Y3Tk=; b=S22NMj5YRnGgELcWn4UBW8XfrVtpS+3kwGLLj9xJYwDy qiNcZxjnOjlSzCRqhVvszv4Z3zDurGvXTFHsmdG8t4E8mXdtDv+Umh0HzSw/fP+w DwcYi2UcsnyADEaL8IJhR5ww62iaY0YoMbc8sakmwFWnMkm1ybOLU8xPOd0SNWNb hvAenw87Rtl5MaKSbB36TQt3Jlrwrg4b503Q3cxj5IIm52jq5VVZcVtVW3o51Quh uO94pcbxuCPLqIuI43aomwaBVKuTPplVSwhy1DEOoEEFceQh/EZZq1gmG2aW/fa4 jJtWg0bIffGFJTm9cAbsyLeprGs82uSain6lzaFc+Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdefiedgudehhecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesrg dtreerreertdenucfhrhhomhepfdfqlhhlihgvucftvggrugdfuceophhhphesohhllhhi vgdrtghouggvsheqnecuggftrfgrthhtvghrnhepvddtjefgteelueelveekvdevueduke efgfehteeujedvudffjeffvdduvdegleeunecuvehluhhsthgvrhfuihiivgeptdenucfr rghrrghmpehmrghilhhfrhhomhepphhhphesohhllhhivgdrtghouggvsh X-ME-Proxy: Feedback-ID: i835c46d5:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F35A236A0071; Sun, 7 Aug 2022 16:40:03 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-758-ge0d20a54e1-fm-20220729.001-ge0d20a54 Mime-Version: 1.0 Message-ID: <1404a189-f5ab-403f-b4a5-cc3789c6cc96@www.fastmail.com> In-Reply-To: <6a5c06d3-3816-4d1b-8c9b-6884346812eb@www.fastmail.com> References: <14237a5f-0522-48b4-8d3f-8dc346dd0870@www.fastmail.com> <6a5c06d3-3816-4d1b-8c9b-6884346812eb@www.fastmail.com> Date: Sun, 07 Aug 2022 21:39:43 +0100 To: =?UTF-8?Q?Bj=C3=B6rn_Larsson?= Content-Type: multipart/alternative; boundary=72b7111962e4444cb2c671bef1d03572 Subject: Re: [PHP-DEV] RFC Idea: Introducing a ReflectionWithAttributes interface - Looking for feedback From: php@ollie.codes ("Ollie Read") --72b7111962e4444cb2c671bef1d03572 Content-Type: text/plain On Sun, Aug 7, 2022, at 7:56 PM, Larry Garfield wrote: > So I'm all for adding a proper interface here. However, I am unclear why it needs to be separate from Reflector. Reflector is already used by all the same classes that can have attributes, no? Wouldn't just adding the attribute methods to that interface be sufficient? Sadly the Reflector interface is implemented by ReflectionExtension, which does not support attributes. It's also because adding those methods to Reflector now prevents any future implementation of that method for something that doesn't have attributes. Keep it simple, keep it separate. > I'm mixed on the new methods. The current equivalent of getAttribute() is: > > $r->getAttributes($attrClass, \ReflectionAttribute::IS_INSTANCEOF)[0] ?? null; > > Which I don't mind. My main concern there would be how it interacts with repeating/non-repeating attributes. Can you call getAttribute() on a repeating attribute? Can you call getAttributes() on a non-repeating? Do they behave any differently? There's likely answers to these questions, but they would need to be asked. The methods would behave the same in terms of how it retrieves and returns the results, with the exception that getAttribute will only return one attribute or null. The main idea I have is that calling getAttribute for an attribute that is present more than once should throw an exception. > Would hasAttribute() and getNumberOfAttributes() have any performance benefit over calling count() on getAttributes()? Again, this isn't a pain point I've had with attributes yet. If so, I'd combine them into an attributeCount() method that returns an int, and if it returns 0 you know it wasn't defined. I'm afraid I couldn't say for certain, though it's highly likely that any performance increase would be negligible and not worth worrying about. I appreciate that they are easy to do in userland, but the same could be said for ReflectionFunctionAbstract::getNumberOfParameters and ReflectionClass::hasMethod. The idea behind these two is to provide a nice API with sensible actions, while trying to maintain consistency, something we sorely need in the core. I think the cost of having these methods is nothing compared to the nicer interface and API provided by having them as part of an interface. --- Best Regards, *Ollie Read* --72b7111962e4444cb2c671bef1d03572--