Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115314 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 40133 invoked from network); 6 Jul 2021 10:10:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Jul 2021 10:10:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5DBCA1804D8 for ; Tue, 6 Jul 2021 03:32:12 -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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Jul 2021 03:32:11 -0700 (PDT) Received: by mail-wr1-f51.google.com with SMTP id a8so13787714wrp.5 for ; Tue, 06 Jul 2021 03:32:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=beberlei-de.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qpiTb4x7WE1v6ildA+9MIUOIWqkp00v0To6xNRpobiE=; b=XVDTxbuet7+u5rMqSZW5KaBDP9WJyBr05LUdalZ0fYKeh12nLU1BkQO0qS4ligl0VJ DezOQfQlxUVZpNORZTbKfM/n3+fruPy3lEENBcM31ofI+4RUxcbhsho1q5eHp9Gis3xQ GexuJFFnH8YbgqtW50x4aYW+mWoHKFzIN06wcAkLhml0gbh1TxG91PCthLHdElks1U7w rdgerqqgSgzgspU9rbSFzK4PFO0DeXEZ8/Ad3rpCsmhvUXqFO01YaqK4AXGnB14USjOk 91wojPdBI0lq43M164qrWHqZuMH6gpv4+fXA+Uj5uHmuagHZ2ARMTjJKwmXnka4vJVn4 ikNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qpiTb4x7WE1v6ildA+9MIUOIWqkp00v0To6xNRpobiE=; b=oeiQs+CPWyyVz1rp4vt9LpjzZEuCT0Lzpj42O+8ybDqnaAry7JEYgf5qdXdGrMUrgN QZFpuUl1r1Wx5Lb4QD7U+sirIBpf6iRMRSWAjxYeE6Cdj/r6ELX9xMzdTnBSPSgm/HdL qfL7loxLHr8CT+Xz5U3mS48MFWyb+qrE85+RrY8mHR6efDKxxcOG9PcTtizAyQtGFcIc UPbgJgZ9VqPeWL1rjzuMZTZFuHMxBctF1JXGBMmJhpx5bFEgfe1n3hS6nYCdMmE88R5o ASKLa875o3J6zPw5SUvNET2SmWy/b32oGBD1dVEL5043IGvFM+HZVLkseRljEg9tkfU1 5azA== X-Gm-Message-State: AOAM530/A5iTPBHfheXegXguN8OaMlY8DGYOZKFnTW3ed0T5QgSSwDL2 H2kKfvVqRYphbPKL8PjruaXdslvhPhfl99M/bmhp3w== X-Google-Smtp-Source: ABdhPJz6yZwAGOWpUWgHQDoMndHrAU2G1QScSttTdPz3cBYCxBLUa4XXRj16dSucHGWekEhYu+ATc1+6Ifem2YjjFoo= X-Received: by 2002:adf:f110:: with SMTP id r16mr20823579wro.271.1625567529732; Tue, 06 Jul 2021 03:32:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 6 Jul 2021 12:31:58 +0200 Message-ID: To: Nicolas Grekas Cc: Nikita Popov , PHP internals Content-Type: multipart/alternative; boundary="0000000000002b1b0405c671ef1c" Subject: Re: [PHP-DEV] [Vote] New in initializers From: kontakt@beberlei.de (Benjamin Eberlei) --0000000000002b1b0405c671ef1c Content-Type: text/plain; charset="UTF-8" On Tue, Jul 6, 2021 at 9:31 AM Nicolas Grekas wrote: > Hi NIkita, > > I've opened voting on https://wiki.php.net/rfc/new_in_initializers. Voting > > will close on 2021-07-14. > > > > Note that relative to the original RFC, new support is limited to > parameter > > default values, attribute arguments, static variable initializers and > > global constant initializers, and not supported in property initializers > > and class constant initializers. The discussion thread > > https://externals.io/message/113347 has some extensive information on > how > > we got here. > > > > I voted yes and I'm happy this will come to PHP. > > I realized I still have one concern that I want to share here, related to > attributes: > The RFC breaks the possibility to parse the arguments of an attribute in a > generic and safe way. > What I mean is that right now, attributes can be inspected while the > corresponding classes are not installed, due eg to a missing optional > dependency. > This is not 100% correct, you can have an attribte #[Foo(Foo::class)] and then calling ReflectionAttribute::getArguments would also require to resolve the type Foo. So this is not different than what could happen right now already. What you can do is use `ReflectionAttribute::getName()` to filter the attributes you want to work on and only then call getArguments(). > This behavior is what makes attributes truly declarative: one can ignore > what they don't care about. Extra semantics can be carried out by classes > without making the related attributes a mandatory dependency. > > I think there is a way to preserve this behavior and that we should look > for it. > > If I may propose one: we might add a new > ReflectionAttribute::getUninitializedArguments() method, that would return > the same as ReflectionAttribute::getArguments(), except that it would put a > ReflectionAttribute (or similar) instance in place of objects in the data > structure. As a corollary, we might also want to enforce that only child > classes of the Attribute class can be nested inside another Attribute (at > least if we want to reuse ReflectionAttribute as a placeholder.) > A function like this could return all arguments that are not AST Nodes but "literals" (instances of scalar / array types). Foo::class or new Foo() are both AST Node types that are resolved the same way in `getArguments`. > > WDYT? > > Nicolas > --0000000000002b1b0405c671ef1c--