Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:85883 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79697 invoked from network); 22 Apr 2015 08:42:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Apr 2015 08:42:05 -0000 Authentication-Results: pb1.pair.com smtp.mail=dgoosens@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=dgoosens@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.174 as permitted sender) X-PHP-List-Original-Sender: dgoosens@gmail.com X-Host-Fingerprint: 209.85.212.174 mail-wi0-f174.google.com Received: from [209.85.212.174] ([209.85.212.174:36357] helo=mail-wi0-f174.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 75/E1-56941-CDE57355 for ; Wed, 22 Apr 2015 04:42:05 -0400 Received: by wizk4 with SMTP id k4so168799695wiz.1 for ; Wed, 22 Apr 2015 01:42:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=wEUVVUU/3k3NXZkJOkzwgeoFagikJGPWcSEb1XFxvPA=; b=A7t0CBB0q4hRcxj/p8HTM88fqZoLKc4pHKjvWlTIllbtqUslyG9zResTRSLEu9VA3Q FsaEhr/8YoBhQJu/OTutC4KXuz3Q4NrKb0AzuqVfn7O7/G1nX2DxLqG3awUf+FiuSQMa e46lBRQ3Al+KCWkGpV9bx3T+tCj4feOGc8e5fOwaMBpbA6/qOdrP30H+ckRbUXspMCz9 nmALmFa4djOQAEc748KKMJk48oDYBKCQW1Kiv+tqVOolo3/0Rhvs0puhJnZ0ldPwus42 Iv8veWD1DcgIAE9b814ukdDsUPNGKHS8YTvgUKGlFf9ccFuR3D9jA8dsEbOCf3hXHC5b jYUg== MIME-Version: 1.0 X-Received: by 10.194.222.135 with SMTP id qm7mr50115027wjc.14.1429692120023; Wed, 22 Apr 2015 01:42:00 -0700 (PDT) Received: by 10.194.236.42 with HTTP; Wed, 22 Apr 2015 01:41:59 -0700 (PDT) Date: Wed, 22 Apr 2015 10:41:59 +0200 Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a11c3aed6f3cad005144c22fd Subject: request priviledges to create an RFC or at least submit a suggestion From: dgoosens@gmail.com (Dmitri Goosens) --001a11c3aed6f3cad005144c22fd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi PHP-fellows or whoever reads this=E2=80=A6 I=E2=80=99m a Belgian PHP addict and feel I=E2=80=99ve got a suggestion tha= t might be of interest for PHP7. I=E2=80=99d more than glad to write it down completely in an RFC if you gra= nt 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=E2=80=A6 That means, not the array itself, obviously, but the items that are in the array. Right now we have array $foo =3D array(); What I=E2=80=99d like to see is something like this: string[] $foo =3D array(); // an array that can only contain stringsarray[string[]] $foo =3D array(); // an array that can only contain arrays that contain stringsBar[] $foo =3D array(); // an array that can only contain instances of Bar There probably are some side effects to this and maybe I=E2=80=99m not awar= e enough about PHP=E2=80=99s internals, but I think this implementation would have a= series of benefits=E2=80=A6 *1. function attributes type hinting* public function bar(string[] $foo =3D 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 =3D string[]; } $bar =3D new foo();$bar->foo[] =3D 'only strings are allowed here'; etc. etc. I feel this would be a very nice improvement in PHP=E2=80=A6 Thanks dgoosens --001a11c3aed6f3cad005144c22fd--