Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:101666 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 65706 invoked from network); 25 Jan 2018 16:21:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Jan 2018 16:21:58 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.113.146.227 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.113.146.227 xdebug.org Received: from [82.113.146.227] ([82.113.146.227:44072] helo=xdebug.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7C/D0-61119-0240A6A5 for ; Thu, 25 Jan 2018 11:21:55 -0500 Received: from localhost (localhost [IPv6:::1]) by xdebug.org (Postfix) with ESMTPS id 0F5CADE44A; Thu, 25 Jan 2018 16:21:50 +0000 (GMT) Date: Thu, 25 Jan 2018 16:21:49 +0000 (GMT) X-X-Sender: derick@singlemalt.home.derickrethans.nl To: Ryan Pallas cc: Michael Morris , PHP internals In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [PHP-DEV][RFC][DISCUSSION] Collection Inspection From: derick@php.net (Derick Rethans) On Thu, 25 Jan 2018, Ryan Pallas wrote: > On Thu, Jan 25, 2018 at 7:52 AM, Derick Rethans wrote: > > > On Wed, 24 Jan 2018, Michael Morris wrote: > > > > > Ok, here's another idea I've been mulling over. This I know is possible > > > because I've done it using user land code, specifically Drupal 8's > > > Assertion\Inspector class. > > > > > > https://api.drupal.org/api/drupal/core%21lib%21Drupal% > > 21Component%21Assertion%21Inspector.php/class/Inspector/8.5.x > > > > > > These methods provide a means to inspect collections - arrays usually but > > > also Traversables. They fill a hole in the PHP library - the ability to > > > check collection integrity. > > > > IMO, it makes a lot more sense to check integrity when creating the > > "array" structure. Instead, I would suggest to add a native Collection > > type, that takes a "type" as argument. They aren't quite full generics, > > but it does 1. fix something; 2. isn't really complicated. > > > > What I am suggesting is to add a new syntax "Collection<$type>", > > mimicking a class, but having a type as "argument": > > > > > Just like to point out if it's considered a class, or takes the same space > there is likely collisions. While most collection classes on github look to > be in a namespace, there are lots that aren't. Of course github only gives > us a view of open source projects that happen to be on github. PHP owns the top-level namespace. It has always done that. It's even documented: http://docs.php.net/manual/en/userlandnaming.rules.php cheers, Derick -- https://derickrethans.nl | https://xdebug.org | https://dram.io Like Xdebug? Consider a donation: https://xdebug.org/donate.php, or become my Patron: https://www.patreon.com/derickr twitter: @derickr and @xdebug