Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111700 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 65686 invoked from network); 27 Aug 2020 11:11:25 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 27 Aug 2020 11:11:25 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5F6901804DA for ; Thu, 27 Aug 2020 03:14:46 -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-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.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 ; Thu, 27 Aug 2020 03:14:45 -0700 (PDT) Received: by mail-io1-f51.google.com with SMTP id j2so2962408ioj.7 for ; Thu, 27 Aug 2020 03:14:45 -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 :cc:content-transfer-encoding; bh=ySed/G5xZJuuXD/udhaGOp4VX6NnGXhfDjABgojX3aU=; b=clcVB7eJAZDHgtW7HPuVmubhqZg/wcqTDFSgFOF+GSRE1ZGaUccTtxE3dTU3WLwmIB yMgRAOyzsp7U5+kAC902wAeRHlWs76P4MKLuqvulOH4FzKozz1tsP2Vh/Bvm9Z6TLu7X fo181sEoyJpWWtbHj9a+f7WRXq8knzn7Xoo7Ruo/b4YYcR0VgxtmpmVqaN9V1ELbpkoK 3b2GB4oo9NGkVZ31j2uPfEC3GJSD7dc7nO2ZLvhfPOYhUAIxmyUzVGYK3I+esetCXf02 tIQV765TiKpcbvC6FWeEI2telkkDr5GWvUC2Gf1dqGQP9SBc+XmF5SltFugct3Sl+fVV QSAA== 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:content-transfer-encoding; bh=ySed/G5xZJuuXD/udhaGOp4VX6NnGXhfDjABgojX3aU=; b=lpYyveB42DVnjFKGh/DH9W+UajRDfyVosllDy/vOpAuAZo66ubpUKvgI+IDQc5BFs9 JIkqECRCh4Q4Cyd9hRC4jOPnXB2xgRBAzpTmVJOYjBAWw4MQ3ZJdeFE/1h/NTCqtEDln RD8QMgdJqS+QDnO+0UtPEspMixzWM3IXJUmX+Mjw9hjlewNekA+gJb8cpk4Nie0cu3wj ouWCoryQ3SklffCxcnA7W32aIrpJ1n6kg1ZmMC+p0KDU/J2H7RDpZr7biJZQbu7PWPpV FM7w2YliEfRYVVfJ3vgkrABIc9gGwuDShIQpfT3VxPZFoKugcTBGyFQT7GYWMn/pqB14 ELbw== X-Gm-Message-State: AOAM530zU2Dc2WFibbyHMlN7dyciJsd4iqdaHyAUTzFJyV1s3kf5xdCZ 5xO1tFMy36zqmQ83GCu9X7XV9A0nBHPWfqUyIRI= X-Google-Smtp-Source: ABdhPJwrhTYqNSZPpNLiSLbS19F7uoku0CfktoGOWQ3XUPWiI4s2cJZ8vEOQZO4pQCL1weitc9ELhQjqdmQhB4Z/VVM= X-Received: by 2002:a05:6638:2a3:: with SMTP id d3mr5418690jaq.0.1598523284660; Thu, 27 Aug 2020 03:14:44 -0700 (PDT) MIME-Version: 1.0 References: <73403328efaefb3141bf59dcab66d4859ee264fd691801fc7c23111c03ac02a7@mahalux.com> In-Reply-To: Date: Thu, 27 Aug 2020 13:14:29 +0300 Message-ID: To: Rowan Tommins Cc: PHP Internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Array map with reset function From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) On Wed, Aug 26, 2020 at 11:16 AM Rowan Tommins wr= ote: > > 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=8C= VUT 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_fir= st > 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, > -- > Rowan Tommins > [IMSoP] array_map(fn($x)=3D>reset($x), $rows) would work as well Alex