Hi!

Are you suggesting not allowing null to be returned, or provide an
indicator within the syntax that it may return null?  PHP would be the
first language I'm aware of that would do so in either case.

No I am not suggesting that. I'm just pointing out the problems with the concept of strict typing in PHP and this particular instance of it. One of them is that many functions do not actually return one type but multiple types depending on the result. It is a very common pattern.

BTW, which languages you are talking about? PHP peers - Python, Ruby, Perl, Javascript (to some measure), etc. don't have typing as far as I know. Comparing PHP to statically compiled strictly typed languages does not seem very useful to me. So could you clarify what do you mean?

The point isn't to restrict a type hint to always be returned. The
goal is to guarantee that if a value is returned, it will be of type
X. In the event it is inappropriate to return the value back, would

All functions in PHP return values, so it is not possible that no value would be returned (yes, if you don't return anything it actually will return null). So ensuring something is an object of type X prevents you from returning anything else, false/null included. If you make exceptions for null, then why not for false? If for false, then why not for true? Etc.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to