Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82682 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 8245 invoked from network); 14 Feb 2015 12:33:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 14 Feb 2015 12:33:33 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.200 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.200 imap1-2.ox.privateemail.com Received: from [192.64.116.200] ([192.64.116.200:53751] helo=imap1-2.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 56/70-03565-D904FD45 for ; Sat, 14 Feb 2015 07:33:33 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 25DACB0007B; Sat, 14 Feb 2015 07:33:30 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap1.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap1.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id R-Yk8zScgXA3; Sat, 14 Feb 2015 07:33:30 -0500 (EST) Received: from [137.50.28.190] (oa-res-28-190.wireless.abdn.ac.uk [137.50.28.190]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 3F7A3B0008E; Sat, 14 Feb 2015 07:33:27 -0500 (EST) References: <680FB44D-B42D-4898-A28B-FA1C6E4D4D1A@ajf.me> Mime-Version: 1.0 (1.0) In-Reply-To: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Message-ID: <58F62ED2-562E-4851-B2FB-2D973732D9DA@ajf.me> Cc: PHP Internals X-Mailer: iPhone Mail (12B466) Date: Sat, 14 Feb 2015 12:33:23 +0000 To: Xinchen Hui Subject: Re: [PHP-DEV] [RFC] Void Return Type From: ajf@ajf.me (Andrea Faulds) Hi, > On 14 Feb 2015, at 05:03, Xinchen Hui wrote: >=20 > Hey: > be honest, I think it's only part of the idea is implemented. >=20 > which make it useless. >=20 > in PHP, even if you don't return anything, NULL is returned implicitly. >=20 > even if a function is declared return nothing(void). >=20 > like: >=20 > function a() : void {}; >=20 > following codes still works: >=20 > $b =3D a(); >=20 > so, if you want a void return type, and if you want it to be a useful feat= ure.. >=20 > above expr should be invalid with an error " a() return nothing" I'm not sure about this. PHP has always made functions valid rvalues, for be= tter or for worse. This RFC could make void functions "truly" void, but that= would be a massive change to support value-less function returns. It would a= lso break existing code which assumes all functions return a value, which is= n't good. I think this RFC is enough: it would let you enforce that a function doesn't= return anything and makes code more self-documenting. It doesn't affect any= thing trying to use the function's implicit return value of NULL, but IDEs a= nd code linters would surely pick up on it for you. It's still useful even i= f it doesn't bind the caller. Thanks.