Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67941 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36262 invoked from network); 27 Jun 2013 12:37:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Jun 2013 12:37:13 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.180 as permitted sender) X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.223.180 mail-ie0-f180.google.com Received: from [209.85.223.180] ([209.85.223.180:38304] helo=mail-ie0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/60-34034-8F13CC15 for ; Thu, 27 Jun 2013 08:37:12 -0400 Received: by mail-ie0-f180.google.com with SMTP id f4so1367893iea.39 for ; Thu, 27 Jun 2013 05:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=3dniWuhNO8Maf6b1XisDnOik8wfqi4hfhg9hEY+bxlg=; b=xZNCaigkKkfr3Wc4bvh6Ul20C0bvPiSlCCP1twToKdhWb7m6TRqfdK7UjCsQDlX+Ol 7R500DV+7Jh5e+bYMGnrP09ANzsCk61Fy9gpU71OHNFk6Ah4BIQOcqUYgjvyY0//lNkM Px7I5xRb54iDzf0aO3r8b+TEP2LtAglgjxj6I+UbvluDwPkMkG4jjFq9queoIyoiIRzA hHM73R5ZnAQTwCmhG6j8L+P98Pj6tHNWcjn1QbTlesxDFt1MlJkHk6lWENH4GsVht/6l jQlbnnCWhm7h8aIJZBtrcNiD6U7JRaABZme1p16Mh28uvBkYsSx1G1zGgIimmauZnGIa ky6A== X-Received: by 10.50.77.80 with SMTP id q16mr3959695igw.3.1372336629926; Thu, 27 Jun 2013 05:37:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.23.5 with HTTP; Thu, 27 Jun 2013 05:36:49 -0700 (PDT) Reply-To: RQuadling@GMail.com In-Reply-To: References: <1372258135.2410.22.camel@guybrush> Date: Thu, 27 Jun 2013 13:36:49 +0100 Message-ID: To: Patrick ALLAERT Cc: =?UTF-8?Q?Johannes_Schl=C3=BCter?= , Ferenc Kovacs , Julien Pauli , Maxwell , Sherif Ramadan , Florin Patan , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=047d7bdc123856d5e504e02205d1 Subject: Re: [PHP-DEV] Request for comments - new PHP feature: return typing From: rquadling@gmail.com (Richard Quadling) --047d7bdc123856d5e504e02205d1 Content-Type: text/plain; charset=UTF-8 Hi. At the moment we can type hint array, classes, interfaces, callable, etc. As PHP is loosely typed and has type juggling thinking of (or at least trying to get PHP to enforce) a particular type (string, int, float, boolean) would be the wrong way to go - too many different behaviours (block if not a suitable type, block if not a suitable castable value, nonblocking with auto juggling, etc.). But if we consider that type juggling is the domain of the type 'scalar', then this would/could act as a suitable hinter. If a method has been designed to accept a scalar, there is nothing to stop the passing in of a resource, callable, closure or object, etc. But with the type hint, in my head, it is now no different to any other type hint. scalar, callable, interface, class, array (and others I'm sure). This isn't about trying to cast the value to a type - PHP is intrinsically loosely typed and that is core to everything. But as the core can easily tell an array from a callable, then a scalar would seem to fit right in. And if we can have scalar type hinting, scalar return type hinting would/should also be possible. Is this a feasible option? -- Richard Quadling Twitter : @RQuadling EE : http://e-e.com/M_248814.html Zend : http://bit.ly/9O8vFY --047d7bdc123856d5e504e02205d1--