Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101679 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98232 invoked from network); 25 Jan 2018 22:11:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2018 22:11:07 -0000 Authentication-Results: pb1.pair.com header.from=morrison.levi@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=morrison.levi@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.45 as permitted sender) X-PHP-List-Original-Sender: morrison.levi@gmail.com X-Host-Fingerprint: 74.125.82.45 mail-wm0-f45.google.com Received: from [74.125.82.45] ([74.125.82.45:40344] helo=mail-wm0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 0C/66-61119-AF55A6A5 for ; Thu, 25 Jan 2018 17:11:07 -0500 Received: by mail-wm0-f45.google.com with SMTP id v123so17706308wmd.5 for ; Thu, 25 Jan 2018 14:11:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=IPg1xYZ3aVDDQ4zJxy3A0yT7Hb0jdf4fc6ekO8oLQ/Q=; b=WETZAUVlMkqh+2NeK5H2AqCqpw0wlRL+k9Ys+Y5HArD+E8ofmuSCNLG28v+g+SxKtM XX+9NJ6EQ9umTcqxVSD1cElWf5Kpx5WQrE8CXzv5SnGmvoVrD/THTd6JqGI6b9nYXfaF opmV+KlV873TPiIeDfOO8blfzaKEW71iLuYorz7jO64CLrZVabp1EqFfOi4al86kZZkJ RyjvsZXtK2X/8ZKsTzn6DTSlGrJz6uP77a6231Pxd9r3Yiix9F1Jlozh24Ca+zrySQpm jAgV0LopyGGrOCozpkyQe6DnkHY34xI1N9uyvmprgOg2WtHHFgSE4xuuk2aq3jAjRO+O cnCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=IPg1xYZ3aVDDQ4zJxy3A0yT7Hb0jdf4fc6ekO8oLQ/Q=; b=VC20yggcwfgKuqEjWPcZcskIzLwDq1A9FZJjTvzK0AeVxOqU5IZa4NEJWyL7sjudRg BrbzIHxewQjLz2WdQ+Lbc0Kf0z13KMB5hzEJOUKguIywR0wOFdS9uYGqMsx303nOxVqJ sUvvVRG1XAKg9rdeCnoA+nSvA6vwT2kvei8HzeyB/4wUmnnxcit6QbYyFVWfefFoE4yw 7C+ccCZFVlzT1bIcByURmakls74706VHI+bzw8QMWB6h2yAhANBlG8d5TGnWdvJeA7+o E3kaaX9xB4dZyYiu95v6mEBlu6vv4qqVRmR2wPHnBtuluZS80FaxSrkiOEtQbLEkTY9W mhxw== X-Gm-Message-State: AKwxytec1fxYYWn7ehoGh598XI6ToK/ZliSR1XrUtXdcXNOvXlNmmcHD +qFYVlncTftwNfcgnTcOcnPu6C0WWW/Kfytr6Tw= X-Google-Smtp-Source: AH8x225yykOHbacPYptVkBBOOBC+5H4y7ba4P6ehuvWfnMxqPBY5A2aBoJ8MIHWjTqRkheEYRUWxnXh3wl5xzFcoN5U= X-Received: by 10.28.147.196 with SMTP id v187mr9915165wmd.128.1516918263616; Thu, 25 Jan 2018 14:11:03 -0800 (PST) MIME-Version: 1.0 Sender: morrison.levi@gmail.com Received: by 10.28.56.3 with HTTP; Thu, 25 Jan 2018 14:11:02 -0800 (PST) In-Reply-To: References: Date: Thu, 25 Jan 2018 15:11:02 -0700 X-Google-Sender-Auth: K29uIfqXBRdML2F5Mla_qnwS1GY Message-ID: To: Michael Morris Cc: PHP internals Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Collection Inspection From: levim@php.net (Levi Morrison) > IMPLEMENTATION STYLE #1: collectionof operator > The style of implementation I like the most is a collectionof operator in > parallel to the instance_of operator. It would be instanceof's plural > brother, so > > $arg collectionof \SomeClass > > To pass the check $arg must be of the iterable psuedotype with all its > values being a \SomeClass object. > > This is all well and good, but collection integrity checks are usually > going to be looking to see if all the members are the same scalar. > > $arg collectionof string > > For language consistency we would need to allow instance_of to do the same, > which it currently does not. > > $arg instanceof string > > This does create duplication with the is_* family of functions, but > instanceof already overlaps is_a heavily. I see no value to this operator being applied to non-array traversables. Our iterators cannot always be reliably rewound, such as when using generators. Checking that the generator returns only strings would consume all the input and would therefore be useless.