Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111692 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 24547 invoked from network); 26 Aug 2020 09:13:19 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 26 Aug 2020 09:13:19 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7684C1804D9 for ; Wed, 26 Aug 2020 01:16:25 -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,HTML_MESSAGE, 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-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 ; Wed, 26 Aug 2020 01:16:25 -0700 (PDT) Received: by mail-il1-f182.google.com with SMTP id t4so1045653iln.1 for ; Wed, 26 Aug 2020 01:16:25 -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=oM1fKbW87Yvja2u15h6xa+G7M3sxNAkb/wqk81xVaaI=; b=Efzi55DppTfr9CCj+xrvDYmt59vifzXBKX6JCeVYh/qXUJgC2dnD82aQjybIfNFekM KfTcz6BMrMfPzCJmYCVqz+EfL5YdkDJ+X0Fpma1vqSa//hyekENyQ0o/9ebCCmozNgWe 8wI5d1sAgNlpluE1ufQyIY4cAA9MXg/N1ofD2twR5Kt8FYeCTVnzq8sfEx8EN/7621Pb Tg4J1Q/YtZ0gU7ViNnbK/vAN9xCz8+NsvorSF4WWk7+zEKw/APx3/6kBoJQoVh+Nqkez qtjR0xrfM73uGU6tKpO/81rpauM+b82YtjJYUpPRMLCOVbI360jSj6wkAxQO23dxRvE6 Kz6Q== 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=oM1fKbW87Yvja2u15h6xa+G7M3sxNAkb/wqk81xVaaI=; b=HrIyyKolcjaqJZ0rKPFgGPYHM97k/sP0O+60ZmufqgeIzq9Pqk93myQjCTnAQdZ7tY CbNsy7j0NxzgWretvLdiWEp8gVuTbANl2xBRYZfraWuUI64VU1En874jISYZ/BKxxIaL f7vgMNPHhlQkQA4StxHS5H7ZZkvAQ91yheM2cLCRtMGlc810VtET2uuAZq5QF88CDnQe UqtmVbFvV5HNIALP/aKkhotwSrQTT1iCnElTR+TQuQdVY5d1H9FTseyTRcCepI7fOzSk R2NQ48OqbE/yOyCu5Gc309bRGjJnD7zdr5KzwERf4MtgnTt2YptqS/jEgol/9bnPX0aN lESw== X-Gm-Message-State: AOAM5301f/y68npakW1TchVaWv5NkQeo1frE2SYv121V69fHBQTJA2so uxzOC4Pl5yIx5mVSR6cHp5jEtRoYE1rd998wt4wbwcJ1yfY= X-Google-Smtp-Source: ABdhPJzug8+l6Eydlw4BtCbDMz/pRC6phCr31Bougc4my0c5yReZ0PJ8Q07D2BcUp/e+x4sAn/JYh87uCThJXUgVYls= X-Received: by 2002:a05:6e02:dee:: with SMTP id m14mr12139540ilj.207.1598429784125; Wed, 26 Aug 2020 01:16:24 -0700 (PDT) MIME-Version: 1.0 References: <73403328efaefb3141bf59dcab66d4859ee264fd691801fc7c23111c03ac02a7@mahalux.com> In-Reply-To: Date: Wed, 26 Aug 2020 09:16:12 +0100 Message-ID: To: PHP Internals Content-Type: multipart/alternative; boundary="0000000000007b34f405adc36f9f" Subject: Re: [PHP-DEV] Array map with reset function From: rowan.collins@gmail.com (Rowan Tommins) --0000000000007b34f405adc36f9f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 25 Aug 2020 at 20:08, Nikita Popov wrote: > On Tue, Aug 25, 2020 at 7:47 PM Michael Vo=C5=99=C3=AD=C5=A1ek - =C4=8CVU= T FEL < > vorismi3@fel.cvut.cz> wrote: > > > The following code stopped working in PHP 8: > > > > https://3v4l.org/UlIE3 To be pedantic: it didn't stop working, it just started raising Warnings. The return value of array_map remains the same. > > > > > is it a bug or a feature? > > > > This is an intentional change, if that's what you're asking. array_map() = is > not spec'd to pass by reference, so it doesn't. > As with many uses of reset(), this one doesn't really need to be by reference, it's being used for its output. Unfortunately, array_value_first failed at RFC [https://wiki.php.net/rfc/array_key_first_last#vote], so I presume the recommended replacement code in the general case is this: array_map(fn($x)=3D>$x[array_key_first($x)], $rows) Of course for a list-style array like the example shown, it can be a lot simpler: array_map(fn($x)=3D>$x[0], $rows) Regards, --=20 Rowan Tommins [IMSoP] --0000000000007b34f405adc36f9f--