Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101677 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92619 invoked from network); 25 Jan 2018 21:04:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2018 21:04:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=me@kelunik.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=me@kelunik.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain kelunik.com from 81.169.146.221 cause and error) X-PHP-List-Original-Sender: me@kelunik.com X-Host-Fingerprint: 81.169.146.221 mo4-p00-ob.smtp.rzone.de Received: from [81.169.146.221] ([81.169.146.221:30912] helo=mo4-p00-ob.smtp.rzone.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 72/75-61119-2664A6A5 for ; Thu, 25 Jan 2018 16:04:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1516914271; s=strato-dkim-0002; d=kelunik.com; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:References: In-Reply-To:X-RZG-CLASS-ID:X-RZG-AUTH; bh=DLUAxSUF7R8fSuVJO8rlWNX2x1/DqPmcmGcMwTJ49ro=; b=XB9nHIvBf9r05qU+vdXSqNV/VG9evHi+9CO19/N0flsSgWgtIuLV7Xbf8c9GTDGlRK TocPrafZZKIoCuOiTDmHuEnsugXQv8TatZvPaJlxEwtWcRPTnl4fFiYM5loMnU+LzWS2 3Ww2XnTZmu9NpfjR6fczXKskvLXbu55anrzLgsjmpatZV95DQ38Vu1hGk2mmgO1ZVlP7 jXF+Gp6BDjZukLcDn3Q6R+JdXAJ/5DeEQ/wsJvsuhAASV+SgAx/YFLKnVmx0+JofI3zl BI6gR8yQ1XqKUa3A9b8mQICZ3r6ZWMdlIyrwfu4bI6PnvDIY7vUN/LDw5nAUc69+RXfu lMVQ== X-RZG-AUTH: :IWkkfkWkbvHsXQGmRYmUo9mlsGbEv0XHBzMIJSS+jKTzde5mDb8Db2nURiuzcA== X-RZG-CLASS-ID: mo00 Received: by mail-yw0-f174.google.com with SMTP id x62so3472627ywg.11 for ; Thu, 25 Jan 2018 13:04:31 -0800 (PST) X-Gm-Message-State: AKwxytdyPIgNQax+U+Tr7FKI8M6Jzh2FB7oMz86euk7LP/IHJIMK4jWv 7y0L9VCmQFr+/i3kFWN5CWX82oP1yceWJOVntfk= X-Google-Smtp-Source: AH8x225YblSAqkwKHPLm1mvOn3aigUeIE7q/W0F+Ss2Oz6L3cvdmbtNJMoqwHHB9CXE+TaNPVW+bAW2srC5KP6MvI5k= X-Received: by 10.129.179.7 with SMTP id r7mr9353139ywh.191.1516914270634; Thu, 25 Jan 2018 13:04:30 -0800 (PST) MIME-Version: 1.0 Received: by 10.37.160.100 with HTTP; Thu, 25 Jan 2018 13:04:30 -0800 (PST) In-Reply-To: References: <9b12b0e2-185e-86fb-0e0b-c4f24bfbd661@gmail.com> Date: Thu, 25 Jan 2018 22:04:30 +0100 X-Gmail-Original-Message-ID: Message-ID: To: Michael Morris Cc: PHP internals Content-Type: multipart/alternative; boundary="94eb2c146be2418ba50563a02027" Subject: Re: [PHP-DEV][RFC][DISCUSSION] Collection Inspection From: me@kelunik.com (Niklas Keller) --94eb2c146be2418ba50563a02027 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 > That might work, but array should only return true if it's an array, not for anything that implements ArrayAccess. > 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. > This would block generics with that syntax then. > 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. > Regards, Niklas --94eb2c146be2418ba50563a02027--