A few weeks ago I wrote a message on this list about my patch for scalar type hinting. I've been using it for about a month now in a large scale application im developing with no problems. It allows type hinting for the following types: int, float, string, bool (boolean), num (int or float), scalar (int, float, string, or bool), object, and resource.
All of these types have been very useful. Num has been useful for any mathematical functions, scalar has been the most useful, mostly for echoing values and interacting with the database (as a database cant store arrays or objects). The type hinting is all 100% optional and has caused no problems for me at all, I use it in most function but some functions I'll use it for one parameter and not the other, or none at all with no problems. What is the general opinion on this? Examples below: <?php function multiply(num $a, num b) { return $a * $b ; } multiply(5, 1) ; // works multiply(3.7, 8.2) // works multiply("foo", 5) ; // Catchable fatal error: Argument 1 passed to multiply() must be a number, string given function displayStuff(scalar $stuff) { echo $stuff ; } displayStuff('Hello!') ; // works displayStuff(123) ; // works displayStuff(array('a' => 'b')) ; // Catchable fatal error: Argument 1 passed to displayStuff() must be a scalar, array given ?> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php