Hi. I've been trying to get a sensible understanding of the for's and against's of the optional scalar type hinting question.
With that I have a few points and a question. 1 - In the main, PHP is used to create web pages and to deal with data coming from the user. 2 - In the main, the data coming in is strings. 3 - In the main, the data must be validated and often this involves converting the submitted strings into another type (date, integer, boolean, float, maybe arrays of these) as casting the data to another type is the simplest way to guarantee that the string holding a number for use in, say a DB query, doesn't contain nasties to force the query to misbehave. I would say, that in the main, most data, once received, remains typed. Whilst the above is not how everyone will work, I hope you all agree that this is a strong general case. Internally generated data is also normally always typed. You add integers to produce integers. You test boolean variables. About the only time I __RELY__ on the auto conversion is for string concatenation. This is immensely useful (except booleans don't convert to True/False which would be GREAT!!!!) If I want to set a boolean, I set it to True or False. Not "0", 0, "1", Null, etc - which can all be converted to a boolean sure, but for reading the code, seeing true and false is quite clearly showing that this is a boolean test and not an integer test. In the comments that have been raised about scalar type hinting, those against say it moves you towards a strictly typed language. I would argue that whilst PHP is not a strictly typed language, in the main it is used as such and that __OPTIONAL__ scalar type hinting has a benefit for those that would like to use it. function x([untyped] $m_Mixed, string $s_String, bool $b_Flag) This is understandable and readable. If you try to pass the wrong sort of object or you don't pass an array, the code fails in its way. Increasing the capability of failing (with maybe an option to force conversion of scalar types) would seem to be a suitable way to go. Regards, Richard Quadling. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php