Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56995 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 81321 invoked from network); 22 Dec 2011 14:47:07 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Dec 2011 14:47:07 -0000 Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Linux 2.6 Received: from [78.32.209.33] ([78.32.209.33:63439] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C7/50-12618-8E243FE4 for ; Thu, 22 Dec 2011 09:47:06 -0500 Received: from addw by mint.phcomp.co.uk with local (Exim 4.63) (envelope-from ) id 1RdjvB-0000uh-5X for internals@lists.php.net; Thu, 22 Dec 2011 14:47:01 +0000 Date: Thu, 22 Dec 2011 14:47:01 +0000 To: 'PHP Developers Mailing List' Message-ID: <20111222144701.GX25857@phcomp.co.uk> Mail-Followup-To: 'PHP Developers Mailing List' References: <2095305E-D4E3-4D7E-8218-32EE99688E0C@GMAIL.COM> <2C90FB94-38C4-4270-8C6A-B89304BA8ED8@gmail.com> <159A7CA2-8561-40DA-9434-CAAE12304DDB@gmail.com> <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <005701ccc0b3$58c8dee0$0a5a9ca0$@alliantinternet.com> User-Agent: Mutt/1.4.2.2i Organization: Parliament Hill Computers Ltd Subject: Re: [PHP-DEV] Return Type Hinting for Methods RFC From: addw@phcomp.co.uk (Alain Williams) On Thu, Dec 22, 2011 at 09:09:40AM -0500, Dmitri Snytkine wrote: > The return type hinting is probably the biggest thing happening in php in a > long time. > Is this too good to be true? > > With return type hinting I can see a huge improvenets in php IDEs in > spotting errors. Also it will be much easier to auto generate wsdl files > when return types are known to a compiler. > These are just to name a couple of important benefits that can come out of > it. > > What I don't see is any discussion of being able to declare the type of > variable, you now, like in Java. > ie: > private \ArrayObject $customers; That looks like a namespace - I don't like that syntax. > Also, is there an implicit "void" return type? > > I hope that declaring types of variables will be added too because without > it, this feature is not all that useful. If - we do allow variable declaration to specify a type, can we also have a syntax that simply says ''this variable is declared but I am not saying what type it is''. Ie the variable can take any type - just as now. Why ? One thing that I would really like to see in PHP is the ability to force variables in a module to be declared -- AKA perl's 'use strict'. Have the compiler complain if it sees a variable that has not been declared. In a large program the occasional typeo on variable names does happen, catching them with 'use strict' is great! I have proposed this before and people did not like it. Here is to hopeing for a different sentiment. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include