Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:111732 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 5699 invoked from network); 30 Aug 2020 21:46:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 30 Aug 2020 21:46:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AE33F1804C0 for ; Sun, 30 Aug 2020 13:51:06 -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=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2017.outbound.protection.outlook.com [40.92.21.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 30 Aug 2020 13:51:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eoyKy1aciLQWbREaO6r0MY6Dp+qZ+n44oYZqa/D1F0mgafSDTF/lGGc5prPMnAVEJAPqgklVgyqaTRb0s6ZNqiZ/Coi9NjcdNQTpHk2QchTmNRsQ9n3YkksC+K8agqEnUKo53JUmwpTNQWyq0gOItdpjIQMdedjvvCrCwtzdR+SdIde0DYDIIFw7SN9KocpDJ8grEAhEv8WpPKj3bayNuJOQtWV6fB9ec3P1FSPcx4JXrS5VMIqI0FCYq+dyommBcdb1COnrwQmEHDSDm/sJZiBYAFNnyswu4GeANGZ8i2m0WxVvlu3RT7S2OQx3GDvKtwJrIELotKSWZyEwAnWYlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pdNGAqq5HvZJG87FU3xP6++XdzEZpGkbA410DdGkRSY=; b=c3m3H/I2f5crhwSxQ65HPnh+lGRqUaKcgVUWW7LC7YPeuMLsNjsw7EiPM6N5qucrZIDm4ONJinqjIyzGBRDxWSto5tVyKjOuj7nYpQf+XkVvNfXhy8Lah14ZKOk4qJB/GdFyG9mT01Ow5FIH6skyc5NYKjwhvxgpOI12e4HKL+AACISTQf1e6+ieCdCf1zjHhkE8VhDv075tUmn5/n07cqMR5uxoAswW0MQ/HLst5s3XFAf/pPHflkxYVhJW+CgahoA8fFwtUxbtATS4/hl//n7TtCMyXzCV3r+/pgEcG2+6DLQRxbRv8PHyMBtLyDPMjQuOpeIwETpk/WjpeUJWVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pdNGAqq5HvZJG87FU3xP6++XdzEZpGkbA410DdGkRSY=; b=cng1QEIKsd1jtSjJ/J3HwdvKrAYxww46v2iykFmoCair8FqYYU8EcoAK4WfJoCRyYCWnihkKOTLddg9ZrDZeXYLD6YSFQR7aOZC7VzPXpkxP3PX8VuHDSDipscWAeeR4reXwAMhMLJK5WrUaldEN7wICfmaK8oDV9M1l2hqg1WTb3wW5wy6vqG/IwgnTp43IK70KAFN0VmabX4+nD2wu5ac6zOsmdwFnRLwzO6yu6Lu/i3JZQxIFErODHSLNpR4I7V56KivWppyvIATXg9kLNhFMT02uxgaKEnnQB44iMQv5LATPks7GpddeYBmV1VoRlXJbB0DWLRHg6QFP1YkIaw== Received: from BN8NAM12FT005.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::49) by BN8NAM12HT256.eop-nam12.prod.protection.outlook.com (2a01:111:e400:fc66::97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.7; Sun, 30 Aug 2020 20:51:04 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com (2a01:111:e400:fc66::52) by BN8NAM12FT005.mail.protection.outlook.com (2a01:111:e400:fc66::167) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3348.7 via Frontend Transport; Sun, 30 Aug 2020 20:51:04 +0000 Received: from DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f9d1:ed5b:8625:bfb4]) by DM6PR07MB6618.namprd07.prod.outlook.com ([fe80::f9d1:ed5b:8625:bfb4%7]) with mapi id 15.20.3326.025; Sun, 30 Aug 2020 20:51:04 +0000 To: Bruce Weirdan CC: Larry Garfield , php internals Thread-Topic: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...) Thread-Index: AQHWfj2/bRooGr39CkeRSgZBGY4s+alQvQSAgAAChTuAAC99AIAAA7kAgAAtNrM= Date: Sun, 30 Aug 2020 20:51:04 +0000 Message-ID: References: <7d91bd8f-9ca0-4e62-886b-f89bc8edd3e9@www.fastmail.com> , In-Reply-To: Accept-Language: en-CA, en-US Content-Language: en-CA X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:D9C169461AA07D2B524979A850FFECE8F106C961C7A5AA8F81C1DBAF6D4BC9CB;UpperCasedChecksum:86B80DE620168EF191378B2182EA147BA2A1D6197B794A3BCF39ADDBFEC7466A;SizeAsReceived:7568;Count:45 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [kDBqy+X5rT+/yyerMgx5Sxqz7xBE72uJ+CON9iyyRAmSAQ/BeqXPSPJUZME0wudD] x-ms-publictraffictype: Email x-incomingheadercount: 45 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: fa4d532d-c7f3-431a-b01c-08d84d266989 x-ms-traffictypediagnostic: BN8NAM12HT256: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 8ePuucEpmmIgJpBruNF+ARK/IktbvrSi8caJ4IIFgbsyhe/XUe3/ijBNrETx3YhzIdVImhWeYUyA6UVKHXEchCcSMKx89dmf5PV+kk98jvt9m16sdPC7F9Kc2P4rgpiev6dIxxwee7e/7GgqoryS6OsupUle8Iu+u5VTV2xeNo2kdt1QzJk11kO4mQGhxrC3YqRkksrpU3sxV4r7ChXf4A== x-ms-exchange-antispam-messagedata: mLGe8qyUGhsx92hxYTfJYqmql9ZllGfiIt4QZtMx4a1WkixkEH4nox1hpSvZyeCucsXZTaoDm7H4hvDJCFw2eR5jmv7MeuWp+wOXGkNibONz1cm+E5idpXf8EaG9aNK/ItBPKRGMSPD+NP1VNU9MF5qgI4FWV2LTA/QlWONzAeLmTu6yi7zwYK048e4rUVSjW4nq1AqAEjFvj+k0Y6YFRA== x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: hotmail.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN8NAM12FT005.eop-nam12.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: fa4d532d-c7f3-431a-b01c-08d84d266989 X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Aug 2020 20:51:04.6573 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN8NAM12HT256 Subject: Re: [PHP-DEV] Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...) From: tysonandre775@hotmail.com (tyson andre) Hi Bruce Weirdan,=0A= =0A= > If it took the default value as well it could return that. While it's use= ful in itself it also would enable you to pass > a marker object and check = the identity of that to know if no matches have been found:=0A= > =0A= > $none =3D new stdClass;=0A= > $element =3D first($collection, fn($elt) =3D> ..., $none);=0A= > if ($element =3D=3D=3D $none) {=0A= > // nothing found=0A= > }=0A= =0A= Oh, right, I'd forgotten about that option - that would work.=0A= =0A= There's still the question of what it would do without a predicate.=0A= Making the predicate mandatory in the initial proposal would help avoid the= confusion of whether `first() should behave like array_filter() and any() = and filter for the first truthy value.=0A= =0A= Calling it [iterable_]search_callback() or first_matching() or find() might= help distinguish this from the reset()/end()/next()/prev() family of funct= ions - not happy with any of my naming ideas=0A= =0A= Thanks,=0A= - Tyson=