Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67900 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80818 invoked from network); 26 Jun 2013 16:33:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Jun 2013 16:33:43 -0000 Authentication-Results: pb1.pair.com header.from=patrick.allaert@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=patrick.allaert@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.182 as permitted sender) X-PHP-List-Original-Sender: patrick.allaert@gmail.com X-Host-Fingerprint: 209.85.214.182 mail-ob0-f182.google.com Received: from [209.85.214.182] ([209.85.214.182:52493] helo=mail-ob0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 03/3B-29746-6E71BC15 for ; Wed, 26 Jun 2013 12:33:42 -0400 Received: by mail-ob0-f182.google.com with SMTP id va7so13496073obc.41 for ; Wed, 26 Jun 2013 09:33:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=9Thb5Y17VC/4N90dX7Pgzr81hiA0ha1vrnGYUpOplNI=; b=CBJcEBUOue2yKzwORwz4/FemVfHP2qCwBDcioE5V6jsJ923NCnK5rmGFWIRTnc57Br gHmiyqTPMjnZchae/WkkHkxuWul9grCOoT46kjPxJyV7CDF+32pwATWWAF57R2MD1ErB uRrFwFc9CZYZ/sOgIqvbqHy0kKvJHicFwd7pfKwcBOk/a+YOBshO5SM4nIAlbZSOxQ+a eRDUjflFn7+SuMS23ff62IOm5KBNKZwVRltU1EJ9R7Cy/7ZCwd8Tqx5KrYXhYTEqb9j4 WpeZJcBCAR2NpuRXrjj4dbTPRdm7ocYYP+HJkzu24Mvd8DqgE4+UxlNDUxjMLH+MA2GJ c3fg== MIME-Version: 1.0 X-Received: by 10.60.178.136 with SMTP id cy8mr878944oec.58.1372264419055; Wed, 26 Jun 2013 09:33:39 -0700 (PDT) Sender: patrick.allaert@gmail.com Received: by 10.76.7.169 with HTTP; Wed, 26 Jun 2013 09:33:38 -0700 (PDT) In-Reply-To: <1372258135.2410.22.camel@guybrush> References: <1372258135.2410.22.camel@guybrush> Date: Wed, 26 Jun 2013 18:33:38 +0200 X-Google-Sender-Auth: 0vKJ2IXQd3JV22olV_uiIwok1n4 Message-ID: To: =?UTF-8?Q?Johannes_Schl=C3=BCter?= Cc: Ferenc Kovacs , Julien Pauli , Maxwell , Sherif Ramadan , Florin Patan , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Request for comments - new PHP feature: return typing From: patrickallaert@php.net (Patrick ALLAERT) Johannes, 2013/6/26 Johannes Schl=C3=BCter : > So a function author doesn't trust himself and therefore we change the > language syntax? In the following example: class Foo { public function bar($input) { $return =3D Baz::foo($input); if (!$return instanceof ReturnType) trigger_error("Cannot divide by zero", E_USER_ERROR); // or throwing some RuntimeException return $return; } } Baz class can be from a 3rd party software and I may want to enforce the fact that my Foo::bar() method returns an instance of ReturnType or throw an exception or trigger an error. This is moez easily written with this proposition: class Foo { public function bar($input) { return Baz::foo($input); } } With the same reasoning you had, you would avoid using parameter type hinting and interfaces for your own project if there's no other people using it.