Re: type hinting

From: Date: Fri, 04 Jan 2008 18:59:58 +0000
Subject: Re: type hinting
References: 1 2 3 4 5 6 7 8 9 10  Groups: php.internals 
Request: Send a blank email to internals+get-34448@lists.php.net to get a copy of this message
Not necessarily, if you have a function that performs a generic operation on any object. As for resources you are right, it might be
Like what? I don't know many operations that are good for any object and only object and need special function to perform them. Actually, excluding scenarios like serialization and RPC (which should take care of other types too so irrelevant here) I can't think of any right now.
ideal to have "mysql resource" rather than just "resource", but just having the "resource" type hint is better than having no type hint.
No, it's not better. Having GD image instead of mysql connection is not better than having integer in any way. It would just produce different error message, so what?
This is one that I find very useful, much more than it may seem. I use scalar for any type of post/get input, printed output, or DB interaction, as objects/arrays/resources cannot be printed or stored in a database in a standardized way.
If you need serialization/printing, you have serialize() and __toString() with respective handlers. If you reimplementing them and using scalar restrictions, you most probably do it wrong. -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#34448) next »