is_digits() and digits type
| From: | Yasuo Ohgaki | Date: | Tue, 12 May 2015 00:56:52 +0000 |
| Subject: | is_digits() and digits type | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-86161@lists.php.net to get a copy of this message | ||
Hi all,
Firstly, I don't intend this for PHP 7.0 strictly.
PHP is made for Web. It means PHP is made for interacting other
systems/data. Currently, we only have "int" and "float" strictly bounded
to native "unsigned int" and "IEEE 754 double". This causes problems
for interacting other systems/data.
Conversion to native data type causes problem like RFC 7159 "6 Numbers"
points out.
https://tools.ietf.org/html/rfc7159
PHP's "int" is more limited because safe value is least common and it's
signed 32 bit integer.
To resolve this issue, how about to have
- is_digits() and digits type for digits only inputs(integer like string)
- is_numeric() and numeric type for float like string
These check if variable contains only digits or float like string.
It's pseudo type, but it prevents developers to specify "int"/"float" type
wrongly.
These may be extended to allow GMP int/float.
Having these make sense for a language made for interaction and make basic
type hint use intuitive. IMO.
I wouldn't like to write too long mail. My thoughts and concerns are in my
blog
mostly.
http://blog.ohgaki.net/php7-is-going-to-be-strictly-typed-language-will-this-work
http://blog.ohgaki.net/dont-use-php7-type-hint-for-external-data
Any comments?
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net