Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:25675 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 15230 invoked by uid 1010); 13 Sep 2006 21:48:30 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 15215 invoked from network); 13 Sep 2006 21:48:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 13 Sep 2006 21:48:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=brianm@dealnews.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=brianm@dealnews.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain dealnews.com designates 129.41.69.185 as permitted sender) X-PHP-List-Original-Sender: brianm@dealnews.com X-Host-Fingerprint: 129.41.69.185 smtp.dealnews.com Linux 2.5 (sometimes 2.4) (4) Received: from [129.41.69.185] ([129.41.69.185:42055] helo=smtp.dealnews.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 64/2B-45066-B8C78054 for ; Wed, 13 Sep 2006 17:48:30 -0400 Received: (qmail 2940 invoked from network); 13 Sep 2006 17:47:52 -0400 Received: from unknown (HELO mail.dealnews.com) (10.1.1.7) by 10.1.1.24 with (DHE-RSA-AES256-SHA encrypted) SMTP; 13 Sep 2006 17:47:52 -0400 Received: (qmail 25482 invoked from network); 13 Sep 2006 17:47:54 -0400 Received: from h35.165.141.67.ip.alltel.net (HELO ?10.1.6.4?) (brianm@67.141.165.35) by 10.1.1.7 with ESMTPA; 13 Sep 2006 17:47:54 -0400 Message-ID: <45087C81.3030008@dealnews.com> Date: Wed, 13 Sep 2006 16:47:45 -0500 User-Agent: Thunderbird 1.5.0.2 (Macintosh/20060406) MIME-Version: 1.0 To: =?UTF-8?B?VGVyamUgU2xldHRlYsO4?= CC: internals@lists.php.net 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> <005301c6d768$7a5fb0e0$9a02a8c0@pc> In-Reply-To: <005301c6d768$7a5fb0e0$9a02a8c0@pc> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Return type hints From: brianm@dealnews.com (Brian Moon) > --- 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". If you can't trust the return values of your methods, I would use: $var = $something->f(); if($var!==NULL){ echo $var+10; // Prints "10". } However, its crap like this that reminds me why I don't use PHP OOP for all my code. I can find no non-OOP code that behaves this way. Even my favorite PHP trick, using settype() to initialize vars, does not set the var to NULL. -- Brian Moon ------------- http://dealnews.com/ Its good to be cheap =)