Type Hints can only be of the object and array (since PHP 5.1) type. Traditional type hinting with int and string isn't supported. referer
We will not provide typehints for primitive types as PHP has automatic typeconversion for them Also we are not adding any checks for primitive types since that would either slow down the compile step or would require new keywords. (by helly@php.net)
user comment里面提供了利用set_error_handler解决php对int/string类型type hint报fatal error的方法, 但是set_error_handler..这个合适吗? 罢了,php type hint不支持interface, 却支持数组,quick and dirty, 这或许就是php philosophy吧


Leave a comment