Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120447 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 94741 invoked from network); 30 May 2023 02:22:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 May 2023 02:22:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id EC04E180538 for ; Mon, 29 May 2023 19:22:20 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 ; Mon, 29 May 2023 19:22:20 -0700 (PDT) Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-b9daef8681fso3038633276.1 for ; Mon, 29 May 2023 19:22:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dqxtech-net.20221208.gappssmtp.com; s=20221208; t=1685413340; x=1688005340; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=vsYYvXbUJu2X5xuUbIYV4rHH7bUmJjwmgvE9Cwd1Ft8=; b=hZEGjP/mur28IhYjUfX04FgOUWSzxOALsNwoxF0SW2C8nMSidpGMdn70HDao4bPI2t e+RNUubr4CTBxhRKWcpB92ikXrbsah/6bAqxd5UJ1zY9MOHwSter7i5CcRtbBxwoHXBK FaIy1ZRhgmketBTMz4DTv4guvfN+I4kNaYMtudBQCSPV11JqKT/ov+vsNmEgK9aRC/Dt akOH3+KJJGibMq9u4mto43Ux76f90CJUZfArv1F5AqHMqoHSepWeM9s+KugVSs6EoDKQ 2XLqaeMZ4wEL7t8RDiXlu8WuUn3Ti2NHkrTpQxYoso1eJsSll9KDNETlRq9nRRDtU1e+ mIyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685413340; x=1688005340; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vsYYvXbUJu2X5xuUbIYV4rHH7bUmJjwmgvE9Cwd1Ft8=; b=TKAoFZ8criPVIXk1T7NsUftmE4oIYV0R7Ml5Utfv+t6mz4kbv9S7JSTkMPdnbtdJxd ILI3teDlwUchVSTsuuYgM9SJLGXlGmTzDPYPZdZiPkHMDXfmQbXH2M6gqkOGalzgVQCO jDSQOmzyrmokEVZ+nboSojJIiQvgDwHMFOKjEwIaO9MVEKQN82Tag132jPX9p0hlISWc TifZYnCwzpG1U7B0YPBFxKsW+eomHdHd2jsUQKxpj/M7FCs9UExe/9DkOkAMoey65Fc/ MTmnO/Da5hWn/JjnGGnnyDP1aJvxVz5Wu0MYTkWhn1BFRaLHS3Sa7h3QI2XJz1Qs+J/o YcYw== X-Gm-Message-State: AC+VfDxUCJMQkDJMA8fztSPQMmKKkqSbtDyOlpRdantdiE8ClGR6K1yS HXqCBQb8BsacUDbkczh6pb87sv+1/EAl1gecK5x4L0v+fWg1StSvSp8= X-Google-Smtp-Source: ACHHUZ5l6h4mKax9qGiihddjSkygIWcLX6i5whci4/ez75ZJcoaQd+IjQsI0jioZoBxLIdne5ttDIjaFJZojLJggzUU= X-Received: by 2002:a0d:dd47:0:b0:561:79af:f7dd with SMTP id g68-20020a0ddd47000000b0056179aff7ddmr820773ywe.5.1685413339895; Mon, 29 May 2023 19:22:19 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 30 May 2023 04:22:09 +0200 Message-ID: To: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: Declaration-aware attributes From: andreas@dqxtech.net (Andreas Hennings) I just notice a flaw in my thinking. On Tue, 30 May 2023 at 02:48, Andreas Hennings wrote: > > Note that for methods, we typically need to know the method reflector > _and_ the class reflector, because the method could be defined in a > base class. This is true when doing a discovery using attributes. However, PHP does not know the original class when we call (new ReflectionClass('C'))->getMethod('f')->getAttributes(). So it cannot pass the original class into the attribute constructor. Currently, only the userland code that does the discovery knows the original class. We would need a type of method reflector that keeps track of the original class. This could well be its own separate RFC. Once this is done, we no longer need to pass the class as a separate argument. So to keep this RFC independent, we should only pass the reflector object where ->getAttributes()[*]->newInstance() was called on. Then if in a separate RFC we keep track of the original class in ReflectionMethod, the same information will be available when the method reflector is injected into an attributes. This also means that the ReflectionAttribute object needs to keep a reference of the original reflector. And if it does that, we can as well provide a method to return it. assert((new ReflectionClass('C'))->getAttributes()[0]->getReflector()->getName() === 'C');