Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:106952 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 13611 invoked from network); 12 Sep 2019 16:35:12 -0000 Received: from unknown (HELO php-smtp3.php.net) (208.43.231.12) by pb1.pair.com with SMTP; 12 Sep 2019 16:35:12 -0000 Received: from php-smtp3.php.net (localhost [127.0.0.1]) by php-smtp3.php.net (Postfix) with ESMTP id 4CB7A2D19C4 for ; Thu, 12 Sep 2019 07:11:07 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp3.php.net X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Virus: No Received: from mail-io1-xd30.google.com (mail-io1-xd30.google.com [IPv6:2607:f8b0:4864:20::d30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp3.php.net (Postfix) with ESMTPS for ; Thu, 12 Sep 2019 07:11:06 -0700 (PDT) Received: by mail-io1-xd30.google.com with SMTP id r26so54778757ioh.8 for ; Thu, 12 Sep 2019 07:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=U7KPmRCvlfgLFrv58XDKhg90IhcwrUrBDDhgWl5jrLY=; b=bfG6b6r1kcjSvX9f02HXmHcsqCsczucutbRq4cW0uRMcrNK2Bt2b3uyEnWpU/1tQQ1 gRN/hozU3GO9EyTvrSVQP10gxXEzqVViXa9PZPG71hh772hw6UHhb11Ja75GY22U2dgE CjNx8fya2oQpwrRXnxx3w2FB0cm5zsO80KTyAW6MjsJWwGsCq7uqnSwL39j0LazH5kkQ PmYYsm/f5jdqqo1LiNwTkSvKnGBZ2mzxyZmrfaMES1QmHac+/oaniAKeEXszvKTFEMm9 gYIOjH6zMmHgwvdWFpGhHaVPS1rglGWBTcV4P7nhN5M9OLEJwCdibsAyUEUWMm1OneXW Jqpg== 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; bh=U7KPmRCvlfgLFrv58XDKhg90IhcwrUrBDDhgWl5jrLY=; b=RDWGUMsnTyVcL5dc4vZNxAz6HJbPTAzTpA/3OVC/gYZXYHoDdGMkcJbdy+lY8XNoTc APofjCz9Z1lEVCy3d+mhkNWFidDvhXr3lh7l7lZDJestl76U6D7WRlIxYQq/UEhgyPXo 61y8S+ZO5/F7WTMeZ1lYMu8JxURS4CwcvOeMugkt9xAclTfpA7oGmRGvyhicoG6q0PCS moDzW5yQEKF6uERqjPXHOQxMTNZUe5H8N8Gzfbdd+o7lWIBAxg29LThjthigRTIiLBdm CM1/SlLtPhN+IMBExNZ7MID3l/p9SBa7IwSpvtTRndtJxc1sP7gw+YlR0rUS1KTAS3AB YTBw== X-Gm-Message-State: APjAAAXfM2ra6qrQIpUBrF2SAUjENPEfpSdlQX6wddH3Sb/OrvpE2wH5 ap+MmQBRuA89bo+/GCiL8SzqS9TLoKdhaRjIGUUympod X-Google-Smtp-Source: APXvYqxo4gH/DRImuZgSzSVorOFWQX02RCeXKJHDXlJJKaz4vEls1kFklip8m3oLPVjso8oW9oZhZX0VWQwkkezCZu8= X-Received: by 2002:a5d:87ca:: with SMTP id q10mr4444844ios.305.1568297465984; Thu, 12 Sep 2019 07:11:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 12 Sep 2019 15:10:54 +0100 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary="0000000000005cbe2f05925bb597" X-Envelope-From: Subject: Re: [PHP-DEV] [RFC] Reclassifying engine warnings From: rowan.collins@gmail.com (Rowan Tommins) --0000000000005cbe2f05925bb597 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 12 Sep 2019 at 14:55, Claude Pache wrote: > Le 12 sept. 2019 =C3=A0 15:33, Marco Pivetta a =C3= =A9crit : > > $foo[$key1][$key2] =3D ($foo[$key1][$key2] ?? 0) + 1; > > Marco Pivetta > > > That violates blatantly DRY (twice the exact same lengthy expression > `$foo[$key1][$key2]`), so it is not a satisfactory solution. > Agreed; it's certainly neater than all the isset() checks, but it's definitely a bit ugly. To clarify my point, the reason why people write this: $foo[$key1][$key2]++; Is not because they're lazy, it's because *it expresses their intent*. The ?key syntax was one suggestion for how to express the intent safely in that particular scenario. Another way might be that the array is initialised a different way; completely off the top of my head, something like this: $foo =3D new Dictionary>; That could express the intent of "this variable is going to be used as an accumulator with these dimensions". The "if isset" lines, in my opinion, don't express any intent, and they don't protect against any real errors; they're just noise to work around a short-coming in the language. Regards, --=20 Rowan Tommins [IMSoP] --0000000000005cbe2f05925bb597--