Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78577 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 44973 invoked from network); 3 Nov 2014 15:07:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Nov 2014 15:07:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@tutteli.ch; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@tutteli.ch; sender-id=pass Received-SPF: pass (pb1.pair.com: domain tutteli.ch designates 80.74.154.78 as permitted sender) X-PHP-List-Original-Sender: php@tutteli.ch X-Host-Fingerprint: 80.74.154.78 ns73.kreativmedia.ch Linux 2.6 Received: from [80.74.154.78] ([80.74.154.78:46048] helo=hyperion.kreativmedia.ch) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 93/C4-08476-24A97545 for ; Mon, 03 Nov 2014 10:07:48 -0500 Received: (qmail 17616 invoked from network); 3 Nov 2014 16:07:43 +0100 Received: from cm56-129-238.liwest.at (HELO RoLaptop) (86.56.129.238) by ns73.kreativmedia.ch with ESMTPSA (AES128-SHA encrypted, authenticated); 3 Nov 2014 16:07:43 +0100 To: "'PHP Internals'" Date: Mon, 3 Nov 2014 16:07:41 +0100 Message-ID: <002601cff777$eb923430$c2b69c90$@tutteli.ch> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-Index: Ac/3dQUEpqAhs/iXT52Nr+O2Bvaveg== Content-Language: de-ch Subject: Types on the right or on the left From: php@tutteli.ch ("Robert Stoll") Heya, Its seems to me that more and more RFC are proposed to augment PHP's syntax with some form of additional type hints. The following RFC proposes to add a type hint for the return type of a function/method: https://wiki.php.net/rfc/returntypehinting It adds the type hint on the right hand side of the function (of the identifier). In contrast to parameters where the type hint is placed on the left hand side of the identifier. Mixing both, having some types on the left and others on the right, seems like another inconsistency in the language design to me. I think now is the time where we should decide what convention we want to stick to in the future (either left or right). PHP 7 is the perfect time to make a change. I do not want to take sides because I am not yet sure what I prefer but following some examples for both conventions: function foo($a : Foo, $b : array) : void {} // types on the right function void foo(Foo $a, array $b){} // types on the left Assuming PHP will introduce type hints for properties at some point class A{ private $f : Foo; //types on the right private Foo $f; //types on the left } Assuming PHP will introduce type hints for variables at some point $a : int = 1; //types on the right int $a = 1; // types on the left Assuming PHP will introduce generics and typed arrays at some point. function foo($a : T, $b : array, $c : Foo[]) : callable {} // types on the right function callable foo(T $a, array $b, Foo[] $c){} // types on the left Thoughts? Cheers, Robert