Re: PHP5 Type Hints

From: Date: Sun, 03 Oct 2004 02:09:54 +0000
Subject: Re: PHP5 Type Hints
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-198516@lists.php.net to get a copy of this message
* Thus wrote Gerard Samuel: > Im unable to find documentation on this. > Does one exist? If so can you point me to it. I dont think anything officially exist in the manual, yet. The type hint can only be an Object, and will cause a fatal error if not the paticular object isn't passed. class Foo { }; function bar(Foo $foo) { } $a = new Foo(); foo($a); foo('a string'); // Fatal Error The most useful use with type hinting can/is used is with exceptions. The catch() requires a type hint of what class of exception to catch: try { some_code(); } catch (CustomException $e) { } catch (Exception $e) { // if CustomException isn't thrown } Curt -- The above comments may offend you. flame at will.

« previous php.general (#198516) next »