hhvm / type-assert

Hack library for converting untyped data to typed data.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative numbers don't coerce to ints

ssandler opened this issue · comments

=hphpd> =Facebook\TypeCoerce\int('100');
=Facebook\TypeCoerce\int('100');
100
hphpd> =Facebook\TypeCoerce\int('-100');
=Facebook\TypeCoerce\int('-100');
Hit a php exception : exception 'Facebook\TypeAssert\TypeCoercionException' with message 'Could not coerce string to type int' ...

This is due to the use of ctype_digit() which returns false for negative numbers.