Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:10568 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 29742 invoked by uid 1010); 17 Jun 2004 13:18:50 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 29710 invoked from network); 17 Jun 2004 13:18:50 -0000 Received: from unknown (HELO nexus.n0de.net) (66.139.78.117) by pb1.pair.com with SMTP; 17 Jun 2004 13:18:50 -0000 Received: by nexus.n0de.net with esmtp (TLSv1:RC4-MD5:128) (Exim) Message ID '1Bax8M-00039f-LW' ; Thu, 17 Jun 2004 08:40:51 -0500 Message-ID: <40D19B3E.4030802@memefeeder.com> Date: Thu, 17 Jun 2004 14:23:10 +0100 User-Agent: Mozilla Thunderbird 0.6 (Windows/20040502) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Marcus Boerger CC: Christian Schneider , mike@php.net, internals@lists.php.net References: <20040615112747.27402.qmail@pb1.pair.com> <40CEDECA.9040600@cschneid.com> <40D05892.6090804@memefeeder.com> <913185304.20040616211716@marcus-boerger.de> In-Reply-To: <913185304.20040616211716@marcus-boerger.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "nexus.n0de.net", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or block similar future email. If you have any questions, see the administrator of that system for details. Content preview: I understand your point, however, this is the way that other languages behave and its a feature that i consider to be very necessary and timesaving. My understanding was that Typehinting exists to save having to do such if-else clauses all the time, since 99.9% of the time, you will expect an object of a certain class or nothing at all. The problem here is that i need only to know that an argument is either an instance of a class or null, nothing else, but removing the typehinting effectively means any argument can be passed, and its not longer enforced at a PHP level, but within my own code... and since this is something that happens a lot, it seems a shame to loose this handy, timesaving functionality. [...] Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- Subject: Re: [PHP-DEV] Re: ClassHints and NULL From: ray.hilton@memefeeder.com (Ray Hilton) I understand your point, however, this is the way that other languages behave and its a feature that i consider to be very necessary and timesaving. My understanding was that Typehinting exists to save having to do such if-else clauses all the time, since 99.9% of the time, you will expect an object of a certain class or nothing at all. The problem here is that i need only to know that an argument is either an instance of a class or null, nothing else, but removing the typehinting effectively means any argument can be passed, and its not longer enforced at a PHP level, but within my own code... and since this is something that happens a lot, it seems a shame to loose this handy, timesaving functionality. Ray and Marcus Boerger wrote: >Hello Ray, > >Wednesday, June 16, 2004, 4:26:26 PM, you wrote: > > > >>Hi all, >> >> > >[....] > > - NOTHING stops you from passing NULL to functions. > - Typhints are a shortcut for an 'instanceof'`test > > - now try NULL instanceof stdclass: > >php-cvs $ php -r 'var_dump(NULL instanceof stdclass);' >bool(false) > >- what you probablywant is >function bla($x) { > if (is_null($x)) { > // handle null > } else if ($x instanceof whatever) { > // handle instance > } else { > // handle error > } >} > >- if you look again you'll see that you are doing *three different* > things in your code. Typehints have a different usage! > >best regards >marcus > > >