Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112109 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45193 invoked from network); 23 Oct 2020 18:48:31 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 23 Oct 2020 18:48:31 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 222F01804AA for ; Fri, 23 Oct 2020 11:06:11 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 ; Fri, 23 Oct 2020 11:06:10 -0700 (PDT) Received: by mail-wr1-f48.google.com with SMTP id t9so3063351wrq.11 for ; Fri, 23 Oct 2020 11:06:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=NLyB20ElmzHghysZTb5EGnP9wF4Qq2H83Fux4VtTw7o=; b=ozRV7W1f0YNuioLK9oCUM4YCZplZF7kK3gzXecOOGpX9rgyCP/B3ndD4wR2Prmrgq6 P04lD9kiYPoAi1ZhJ0dCwBRTvRLX1wMRf455iYIZsjyt2zxmoG7iqnCuMH3nInHspYuu ZPbIZ+i6YHYDIgmtcEx6bR+pnpeuZGYYwXpCPBQ3fmdsm9ZPd7PJE6Enq3AutCFuIRYd 7WzxGCj/ltepsSmRiR+/3uq/iB/mIZz+KxqL5DfTUvAiiBsk/0+G4/ER7x+og/4aIk8n BRxZ/KhPJ384iDUVVNzkupfHhITz4Yf6W68KR91nMleQ9wvZFLUqTEsEwj/TmJjHRNfm vBjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=NLyB20ElmzHghysZTb5EGnP9wF4Qq2H83Fux4VtTw7o=; b=ZwVXAOVNAHRMWxkEtdjRMeP9jaRX/rTtojyHS/+LaS+kUabjMtCjrK1aeOJ4XT5hii 9vq61C+16RPKm3mSlD5IXOo1F2TPmdrqhrC5h+TaWF3/3tgkbpoAb0uJgAflMNXIx6wu 21ncisr1KnzDgihpEiSPrdu3V7knljbkdRb/DzUJYAwEt39y4DKEKef7vcUMgs52lOe9 JJcKdrblnCYxmg+OjANdTPtmhmoBF6d6HWz4SBTRWe0jYM4tQvLiFtrZ4WzUrY6Iq0VR zACUyClM5WJkqFtZMitIMN1qQwekN+h0p007B+37W3M05BDVhNoS1rGK1eOKrLsjRkpL tPRw== X-Gm-Message-State: AOAM532aKGVsjyI50zVyhuBc9qZW9UAfliWMG7wa1Ck7YTp6xcDOlGI9 vNJYNZiQmzwp+OO/BruP76+MIR9MTVo= X-Google-Smtp-Source: ABdhPJyKDRo9p3YGltfJlOSxaI374HeDd/1rNiA9jEH9acTZwEe8EAo+Nnv43ugIHtL8DtSrjO9gUA== X-Received: by 2002:a5d:6ac6:: with SMTP id u6mr3876265wrw.65.1603476366360; Fri, 23 Oct 2020 11:06:06 -0700 (PDT) Received: from [192.168.0.22] (cpc104104-brig22-2-0-cust548.3-3.cable.virginm.net. [82.10.58.37]) by smtp.googlemail.com with ESMTPSA id j7sm5101822wrn.81.2020.10.23.11.06.05 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 11:06:05 -0700 (PDT) To: PHP Internals List References: Message-ID: Date: Fri, 23 Oct 2020 19:06:04 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB Subject: Re: [PHP-DEV] List of attributes From: rowan.collins@gmail.com (Rowan Tommins) On 23/10/2020 16:52, Theodore Brown wrote: > The problem with this is that it results in inconsistent semantics, > where the number of items in an attribute group results in a > different type of value being passed. I.e. if you remove two of the > three attributes from the list, suddenly the code will break since > the `Assert\All` attribute is no longer being passed an array. That's a fair point. Perhaps nested attributes could *always* be considered a list? That may sound odd, but it's actually quite consistent with "normal" attributes: #[Foo] class C {} var_dump( (new ReflectionClass('C'))->getAttributes() ); Gives an array with one item in it, not an object: array(1) {     [0]=> object(ReflectionAttribute)#2 (0) { } } So similarly: #[Foo( 42, #[Bar] ) class C {} var_dump( (new ReflectionClass('C'))->getAttributes()[0]->getArguments() ); Could give an array with one item in it as the argument: array(2) {     [0] => int(42),     [1] => array(1) {         [0]=> object(ReflectionAttribute)#3 (0) { }     } } This actually feels quite intuitive, because we're used to square brackets representing arrays. The only downside is a slight inconvenience for cases where you want an argument of exactly one nested attribute, but I don't know how common that is. Regards, -- Rowan Tommins (né Collins) [IMSoP]