Re: Re: ClassHints and NULL

From: Date: Wed, 16 Jun 2004 19:17:16 +0000
Subject: Re: Re: ClassHints and NULL
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-10541@lists.php.net to get a copy of this message
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

« previous php.internals (#10541) next »