Re: [RFC][DISCUSSION] Collection Inspection

From: Date: Thu, 25 Jan 2018 16:31:00 +0000
Subject: Re: [RFC][DISCUSSION] Collection Inspection
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to internals+get-101668@lists.php.net to get a copy of this message
On Thu, Jan 25, 2018 at 9:21 AM, Derick Rethans <derick@php.net> wrote: > On Thu, 25 Jan 2018, Ryan Pallas wrote: > > > On Thu, Jan 25, 2018 at 7:52 AM, Derick Rethans <derick@php.net> 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 And yet, it's a point of contention that every proposal adding to the root namespace has faced. > > > 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 >

« previous php.internals (#101668) next »