Hi!

> External data can have any form of numbers.
> Current PHP can handle them as "string". However PHP7's type hint cannot
> handle numeric data well because it only has "int" and "float" hints.

This is exactly what's wrong with strict typing in PHP. However, if you
use real numeric string and do not enable strict typing - it works just
fine. We don't need more types for this.

> There are cases that programmer want/need to handle any numeric values.

There also cases when programmer needs to handle Roman numbers, phone
numbers, valid XML strings and TCP/IP headers. But we should not add
types into the language for those.

> To avoid this problem, users must use "string" type hint and have to
> validate
> parameter by themselves. This ruins benefits of type hint. Most PHP will not

Typing is not solution for every data restriction, especially not in
PHP. If you app needs strings that can not be represented by PHP basic
types, you need custom validation code.

> but "numeric" type hint may do the job. One function with "int"/"float"
> type hint
> could break app with current type hint implementation, though. i.e. Working

If you type your parameter, then you declare "I want this to fail if the
parameter is not of this type". Then you can't complain when it fails -
that's exactly what you asked for.

-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to