[PHP] PHP5 Type Hints
Im unable to find documentation on this. Does one exist? If so can you point me to it. Thanks... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Type Hints
* 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Type Hints
Curt Zirzow wrote: * 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. Thanks. I could have sworn, I saw something somewhere, that led me to believe that arguments can be casted. I.E. function foo(int $foo) { // $foo will be casted as an integer } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Type Hints
Hi Gerald, If you did see something like that, it was a mistake in our manual :) I've documented typehinting now, though it will take a while to show up in the manual. http://php.net/language.oop5.typehinting Kind Regards, Aidan Gerard Samuel [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Curt Zirzow wrote: * 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. Thanks. I could have sworn, I saw something somewhere, that led me to believe that arguments can be casted. I.E. function foo(int $foo) { // $foo will be casted as an integer } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 Type Hints
Aidan Lister wrote: Hi Gerald, If you did see something like that, it was a mistake in our manual :) I've documented typehinting now, though it will take a while to show up in the manual. http://php.net/language.oop5.typehinting It may have been Example 18-23 at http://us2.php.net/manual/en/language.oop5.exceptions.php Thanks for updating the manual... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php