Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101676 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 90085 invoked from network); 25 Jan 2018 20:48:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2018 20:48:24 -0000 Authentication-Results: pb1.pair.com header.from=tendoaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tendoaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.48 as permitted sender) X-PHP-List-Original-Sender: tendoaki@gmail.com X-Host-Fingerprint: 209.85.213.48 mail-vk0-f48.google.com Received: from [209.85.213.48] ([209.85.213.48:43939] helo=mail-vk0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/F4-61119-6924A6A5 for ; Thu, 25 Jan 2018 15:48:24 -0500 Received: by mail-vk0-f48.google.com with SMTP id x203so5703518vkx.10 for ; Thu, 25 Jan 2018 12:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=k7QipWyAPBNBmMg6+UtxTlVgpl0j99TsnMAJGDPCtco=; b=gnFOruoWLIQKv5/xxDh452DiMNlLjHW3pgV4bdWaDHz6jogDb55+u8vQskLr6nF1qh 9Em8F9IwH22FSMSnmPC43NI9XdkH4SSclxchNSG6eCJ84Gn8Z++DSjlVamFNom4dogIE ooQqxtQMFuLZ8hazsUqXpzQPY/CnjrOKgBuytk5Gf9+bufU170UJhEFjqcCWBjSUDAFc AMX8DeZRhF97lGaCLB8sQIvaA3Pw0vNqfpRRldaagCkVfiMco6VUDD7fQQUgyyXtK1Sn sl262KVDjX015Z8fHJ/rUIUK7KoGBHLrCL0bWjHlSYCZY7KHDv2pL4ytZ/Y717HymdkF ZWtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=k7QipWyAPBNBmMg6+UtxTlVgpl0j99TsnMAJGDPCtco=; b=jtgbECusYCNLdb19PINryK2ek8ASoney+TBpCKi6G262ErEKBFyWwvAmOdXIXAoOfl a6vcxRA3qOlZBCOghqO3EdY+Ng993yuDgYADubI8hMRtTctjxyAiVynEAODA+P6lFgYk 1/hXfXNif5Pf1nFjNw/TPBAUdXeoQ+hC2Af9W8dCo72H9UVtGbhhg6qCL/dsMXYdEXki 1tsZlwODOHUqL9PgJcMMxZND+txjEUOCnkkzoZ6hoitDrwv/XGYn/vnVfunVdXVsdIP1 H5S7aGj8i4tX6D25Nvkn163lrwieM8vHx0n9t4XV3hv2tQzB1M+pCJA39+9CVO0lJh/4 pcNQ== X-Gm-Message-State: AKwxytdxiUpjO5VgNwj6wz6lJs3pLfBux6vunQzM64dVsSPsUebelU6V vZmN1xK7A4JqpNhZMwLqaq4OeKHGzMNcRwedLDA= X-Google-Smtp-Source: AH8x2256yWGqiBxG1ZAzLH91hrrpMq7Y0kd/ZZqQZvoCLmXX+KF2kqECSUFE8Nid7f5OtKmL+awfcWwt7ThC8RgT/BM= X-Received: by 10.31.41.10 with SMTP id p10mr8565033vkp.110.1516913299517; Thu, 25 Jan 2018 12:48:19 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.199.3 with HTTP; Thu, 25 Jan 2018 12:48:19 -0800 (PST) In-Reply-To: References: <9b12b0e2-185e-86fb-0e0b-c4f24bfbd661@gmail.com> Date: Thu, 25 Jan 2018 14:48:19 -0600 Message-ID: To: Niklas Keller Cc: PHP internals Content-Type: multipart/alternative; boundary="001a113ef3685f781005639fe6c3" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Collection Inspection From: tendoaki@gmail.com (Michael Morris) --001a113ef3685f781005639fe6c3 Content-Type: text/plain; charset="UTF-8" On Thu, Jan 25, 2018 at 2:39 PM, Niklas Keller wrote: > > So, given `$a collectionof string` the operator returns whether or not $a >> is, at that time, a collection of strings (be it an array or other >> iterable). It doesn't insure $a will stay that way - it's just a check of >> the variables status at a given moment, which is the best that can be >> hoped >> for in PHP. >> > > That should be a function, not an operator, unless you can bring up very > good arguments to make it an operator. > Consistency with instanceof. Hmm, it might be possible to just pile this all onto instanceof - following Derrick's mention of how Java does things, so here's a third implementation approach. It would look like this: $a instanceof array Returns true if $a is an array (or implements array access) and that all it's members are strings. $b instanceof SomeClass Returns true if SomeClass can be iterated and contains only strings. The question is can the token parser handle that pattern? Or does the current usage of < and > in their boolean form block this? If this third approach is accepted then we have no BC breaks at all since there's no new keyword or function. We just have a *very* expanded instanceof operator. --001a113ef3685f781005639fe6c3--