Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25673 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53742 invoked by uid 1010); 13 Sep 2006 19:12:18 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53727 invoked from network); 13 Sep 2006 19:12:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2006 19:12:18 -0000 Authentication-Results: pb1.pair.com header.from=tslettebo@broadpark.no; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=tslettebo@broadpark.no; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain broadpark.no from 80.202.4.58 cause and error) X-PHP-List-Original-Sender: tslettebo@broadpark.no X-Host-Fingerprint: 80.202.4.58 osl1smout1.broadpark.no Solaris 9 Received: from [80.202.4.58] ([80.202.4.58:64084] helo=osl1smout1.broadpark.no) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/61-45066-FE758054 for ; Wed, 13 Sep 2006 15:12:18 -0400 Received: from osl1sminn1.broadpark.no ([80.202.4.59]) by osl1smout1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with ESMTP id <0J5J000MFPBH5E30@osl1smout1.broadpark.no> for internals@lists.php.net; Wed, 13 Sep 2006 21:11:41 +0200 (CEST) Received: from pc ([80.203.129.59]) by osl1sminn1.broadpark.no (Sun Java System Messaging Server 6.1 HotFix 0.05 (built Oct 21 2004)) with SMTP id <0J5J000QRPBGHAG2@osl1sminn1.broadpark.no> for internals@lists.php.net; Wed, 13 Sep 2006 21:11:41 +0200 (CEST) Date: Wed, 13 Sep 2006 21:11:55 +0200 To: Brian Moon Cc: RQuadling@GoogleMail.com, Marcus Boerger , internals@lists.php.net Message-ID: <005301c6d768$7a5fb0e0$9a02a8c0@pc> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 X-Mailer: Microsoft Outlook Express 6.00.2800.1807 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8BIT X-Priority: 3 X-MSMail-priority: Normal References: <0a1301c6d64f$8af01c70$a900000a@adstate.local> <74293252.20060912230042@marcus-boerger.de> <00b501c6d6b4$632b7e90$9a02a8c0@pc> <10845a340609130053n395632f4ka5bbed3e49ce6ad2@mail.gmail.com> <0d4001c6d71a$fa124260$a900000a@adstate.local> <45081ABF.2020804@dealnews.com> Subject: Re: [PHP-DEV] Return type hints From: tslettebo@broadpark.no (=?UTF-8?Q?Terje_Sletteb=C3=B8?=) > Terje Slettebø wrote: > > I'd say that's debatable. :) Yes, it can make it more convenient to handle > > data coming from outside the script (such as forms), but it can also hide > > bugs. While it can be argued that conversions between, say, arithmetic types > > (int and floats) may be useful, allowing conversion from something like NULL > > to empty string, integer 0, etc. (as PHP does) may be going a little over > > board, as an uninitialised variable (such as a member variable) may not be > > easily discovered. > > IMHO, that is covered by === and the NOTICE error level. Scenario: --- Start --- class Something { public function __construct() { // Oops, forgot to initialise $this->something... } public function f() { return $this->something; } private $something; } error_reporting(E_ALL); $something=new Something; echo $something->f()+10; // Prints "10". --- End --- This will run without any notices, warnings or errors. If we meant to initialise Something::something to a value, then there's no way to detect that in f() (other than manual type-checking), since we can't specify the type for Something::f()'s return type. Had we been able to specify e.g. "int" as the return type, the call to Something::f() would give us an error message, alerting us to the problem. As the program stands, it has a silent bug... How would you solve this with === or E_ALL? Regards, Terje