request priviledges to create an RFC or at least submit a suggestion

From: Date: Wed, 22 Apr 2015 08:41:59 +0000
Subject: request priviledges to create an RFC or at least submit a suggestion
Groups: php.internals 
Request: Send a blank email to internals+get-85883@lists.php.net to get a copy of this message
Hi PHP-fellows or whoever reads this… I’m a Belgian PHP addict and feel I’ve got a suggestion that might be of interest for PHP7. I’d more than glad to write it down completely in an RFC if you grant me access, otherwise, maybe someone can do it. My username is *dgoosens*. I feel, a natural evolution of the scalar type hinting would be the possibility to type hint arrays as well… That means, not the array itself, obviously, but the items that are in the array. Right now we have array $foo = array(); What I’d like to see is something like this: string[] $foo = array(); // an array that can only contain stringsarray[string[]] $foo = array(); // an array that can only contain arrays that contain stringsBar[] $foo = array(); // an array that can only contain instances of Bar There probably are some side effects to this and maybe I’m not aware enough about PHP’s internals, but I think this implementation would have a series of benefits… *1. function attributes type hinting* public function bar(string[] $foo = array()){ /* No need to validate the data in $foo as we already know that it will only contain strings */} *2. class attributes* class foo { public $foo = string[]; } $bar = new foo();$bar->foo[] = 'only strings are allowed here'; etc. etc. I feel this would be a very nice improvement in PHP… Thanks dgoosens

« previous php.internals (#85883) next »