Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111822 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 12997 invoked from network); 3 Sep 2020 16:06:20 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 3 Sep 2020 16:06:20 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id F1C66180538 for ; Thu, 3 Sep 2020 08:11:31 -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-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.47]) (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 ; Thu, 3 Sep 2020 08:11:31 -0700 (PDT) Received: by mail-ej1-f47.google.com with SMTP id j11so4432841ejk.0 for ; Thu, 03 Sep 2020 08:11:31 -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-language:content-transfer-encoding; bh=ploorQ4Yz8QrTwXHEJbKW+c4XkEJpOn5M44bOvB5oHo=; b=gr1XyA+F3xKbRbIB5mvFufPIxSZTSSTmGhgJHFmqBz2bFbYm1XRe84RNIAg5gPqysF yNFzMDJUai5Jri7zTx4dMnSXP6tc/4STEtuK/nZSglPRWixL5uS6aSFFb/gJE4vh/KYd fDEn58iSsdUturdz2yAP4E9bnAgYXSrTIhQqY8aUn2nxv83AgnNFAcOKC8XnIkVoVQ8J aPh8QGp63q6krOB1fIXxOZ30FAK5S/z2paJpxAl/pLlRp4Lt8tSzX5nl8AJ5kiywSTnb ZVLF9SR98z8arWnGPWBeHNwKrs7jF9chVXxJvx8ExWuaJ2dY8yQNje3Wz+CYcMhbG2yx tVYg== 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-language :content-transfer-encoding; bh=ploorQ4Yz8QrTwXHEJbKW+c4XkEJpOn5M44bOvB5oHo=; b=stFgqmjUi/v+awKQd1ul04x0P1kxTdctQxZAaJi/3ZyKuiGhNp0aV9jjynnEb9Xir4 GlqFYuDbfgwzwovYg93cXrjLyPn2qoGKIpZ7fnei0x2qHOSnM2UQtOyJkYr7A79Zw/5h YE0AjPv+WwalHsWdcf/nD5BD+9cDaKNNpSKTkChWE+OJESXHKzWvLy+DGILhhx26FfVD HPF/S+GnuDll7q1FY5kPwNYhu88MQzsN70KlV7tVxRgox2+4tNWkqf/0nzC80VA2G2J/ aGPvYUVcd1wJif1o0efytm9D7UO0uL3G/viACebjow9eEjCAC679U9YDuXo7K9d9o66D UpQg== X-Gm-Message-State: AOAM532tNMBCwRjLF25sxieWpSePBt6qRrv5y4xuiFkfJEvyhEj6R3p1 9NE/k5eIa4pQs54i2S8vxeXfEA3ps++kYg== X-Google-Smtp-Source: ABdhPJylRsBPH5Qr9biJefvkLsmrdWn3bnHXWpxQtibKmyk0pADRKYHFPMilLsKEmADhM5wTsuzdqg== X-Received: by 2002:a17:906:6884:: with SMTP id n4mr2771444ejr.50.1599145889240; Thu, 03 Sep 2020 08:11:29 -0700 (PDT) Received: from ?IPv6:2001:983:6fc5:1:49c7:735:8c90:b4f5? ([2001:983:6fc5:1:49c7:735:8c90:b4f5]) by smtp.gmail.com with ESMTPSA id n20sm3351677ejg.65.2020.09.03.08.11.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 08:11:28 -0700 (PDT) To: Larry Garfield , php internals References: <89FF9360-609A-439F-BDBE-B3B4C141E00F@newclarity.net> <95eddd89-9915-14fc-7649-9de0e8dd349d@gmail.com> <306f190e-efd8-0db8-a9c3-aff3c90aa1c6@gmail.com> <53FF7328-F05C-496E-8F57-5A81B899CED1@stitcher.io> Message-ID: <2f0bcc8f-c2c2-5764-a782-8cd9c0390040@gmail.com> Date: Thu, 3 Sep 2020 17:11:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Draft RFC: foreach iteration of keys without values From: dik.takken@gmail.com (Dik Takken) On 03-09-2020 15:07, Larry Garfield wrote: > > I agree here. _ is already a common pattern in other languages for a placeholder ignored variable. It's not a big jump for PHP static analyzers to start ignoring unused $_ variables, and it requires no language changes or formal standards. > Technically that will work. However, this needs to rely on some unwritten undocumented convention that all of the user community agrees on and is aware of. Such a convention can be established and documented of course, it worked for doc comments as well. Apparently the PHPMD project considered a change to recognize $_ as an ignored variable. It was declined: https://github.com/phpmd/phpmd/issues/326 In stead, configuration was added to allow specifying a variable name that is to be ignored. Still, every individual user needs to manually configure it and pick a name for ignored variables. For one use case, using $_ simply does not appear to be an option, while using void is. This is the use case of ignoring an argument that is passed to a function: function foo($_) {} This can work but it changes the name of the parameter. That is not the intent at all. It breaks in inheritance scenarios. When it is called and the parameter name is specified as the parent defines it, a fatal error results. What I like about using void is that it has clear intent, it requires no configuration of static analyzers and it provides a single syntax that works for all use cases: foreach, destructuring and function parameters. Regards, Dik Takken