Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:102320 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 67529 invoked from network); 20 Jun 2018 12:20:42 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jun 2018 12:20:42 -0000 Authentication-Results: pb1.pair.com smtp.mail=carusogabriel34@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=carusogabriel34@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.46 as permitted sender) X-PHP-List-Original-Sender: carusogabriel34@gmail.com X-Host-Fingerprint: 74.125.82.46 mail-wm0-f46.google.com Received: from [74.125.82.46] ([74.125.82.46:52034] helo=mail-wm0-f46.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CB/73-32156-7964A2B5 for ; Wed, 20 Jun 2018 08:20:40 -0400 Received: by mail-wm0-f46.google.com with SMTP id r15-v6so5662711wmc.1 for ; Wed, 20 Jun 2018 05:20:39 -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; bh=Qr4FdcHn5B5U0lBQ5cpgOAcJnlkju6ImFXK1OwANQ8k=; b=ajbr/I+OdUGe/iFsvjjGrtMabKweptzsuH5hf8a5qkMXEPklS32T9FwJZJX7epbGfF a7hgS/N3lSdzU7uc/DbXW6VUKbHJeLnJRJfXVhb4q1EUdO9hcUH/WOsgaJP06QSg823G SKpDLLPJT1tAXUEQuWpOFBPMVBrAmaj0PyKXpQAL0MuWHF8isNtgnqMIBGGikBfKHHMV 0KiEZAjPvFdsuWc6IW6zHUoFxm5Ne9h+jdImULl4a2VAyPsuwDjz+ooL1mnH5VpZrjXV RY45HyNJ98Q8HjQ3ctxpSTvTpsuxjKwqpzW0MEkE56J46GvY5w54vgEjwWM3NAPcw6AE ZmOA== 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; bh=Qr4FdcHn5B5U0lBQ5cpgOAcJnlkju6ImFXK1OwANQ8k=; b=gEVGepjVRPEdOoWixmCcGKGblJEdFHOkIoHFN6j/NTRPjTsFb4rnEDxAW18VpBdKxd SS8tPnhWX/MUH1as2ZACxUkfbuIO7hRIBOkJ+i0fAS04hn+KHCFg8bzLOIohNHgEaN9i soOLGpEXtAQSyEfnct5IUc09KQvrSqns4FvMUZvUZQoDwpekCKtzGQlPzcpBk+UmBAND nWN8SLpzJtzSfjeqdKnfb7ewDEBhe4dQtH4wQ5jvo8Ujyqhx+XNl197bUNPp95Q67ypI T35vqtDtlFvA2xEY/wWdt0dpR3+rT/H6SGQzf4FdI3rWunII8qXS5fjnm9wEC6iPgsAP eBhQ== X-Gm-Message-State: APt69E0j1HgUPYJBME59tHhsiBmR3FrLNDUXt/xtYD0xZU80leiZy+Js 5J9LdjrzWILBOzoCTZ1FB2u0zpTEZrptOcAmTio= X-Google-Smtp-Source: ADUXVKI2jQE/LbIMLYw8maJKCz5a9eRVYGIDHR1yLWJkb0leSklomo2VBkecy4PVEuIxw7+JugervrhKxNA22bNFRvA= X-Received: by 2002:a1c:e48a:: with SMTP id b132-v6mr1568375wmh.129.1529497236556; Wed, 20 Jun 2018 05:20:36 -0700 (PDT) MIME-Version: 1.0 References: <75db877c-ef0b-7d3b-48a8-9879d90352b0@web.de> <76e4744f-6722-ee49-0325-e4433236f1b1@web.de> <73ac8914-8c9f-e74b-a4f5-f6e39cd96f8f@gmx.de> <3242366.BL9MUqXe46@vulcan> In-Reply-To: Date: Wed, 20 Jun 2018 09:20:24 -0300 Message-ID: To: Levi Morrison Cc: Larry Garfield , internals Content-Type: multipart/alternative; boundary="000000000000785ec0056f11d334" Subject: Re: [PHP-DEV] [RFC][Under Discussion] Add functions array_key_first()and array_key_last() From: carusogabriel34@gmail.com (Gabriel Caruso) --000000000000785ec0056f11d334 Content-Type: text/plain; charset="UTF-8" > > don't think I'm getting all the mail I am supposed to. I hope this gets > seen. > > I propose 2 functions *only* which I believe covers the use-cases that > all 4 of these do and more, with shorter names, and the ability to > discern whether the call succeeded or not. > > list($key, $value) = array_first($input); > // $key will be null if the call failed > > list($key, $value) = array_last($input); > // $key will be null if the call failed > > I have tested it with user-land functions and seems to work as > intended in all success and failure conditions. Verification that it > works as intended with internal functions is necessary but this seems > a much better proposal to me. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php Hi Levi. I have plans to bring an `array_find_first` and `array_find_last` to the next PHP 7.x. It will basically work: $firstUserWithUsername = array_find_first(function (User $user): bool { return $user->username !== null; }, $users); Just wanted to point that to alert that someone is working on that :) -- Gabriel Caruso --000000000000785ec0056f11d334--