rfc:zpp-conversion-rules

This is an old revision of the document!


Current :

Zval type
ZPP type IS_NULL IS_FALSE IS_TRUE IS_LONG IS_DOUBLE IS_STRING
bool Yes (-> false) Native Native Yes (1) Yes (1) Yes (2)
long Yes (-> 0) Yes (-> 0) Yes (-> 1) Native Yes (3)
double Yes (-> 0.0) Yes (-> 0.0) Yes (-> 1.0) Yes Native (4)
string Yes (-> “”) Yes (-> “”) Yes (-> “1”) Yes Yes Native
  • (1) false if null, true if non null
  • (2) “” and “0” -> false, other values -> true
  • (3) Run string through is_numeric_str_function() and detect error. If double returned, convert it to long
  • (4) Run string through is_numeric_str_function() and detect error. If int returned, convert it to double

is_numeric_str_function() behavior :

  • Skip leading spaces
  • Stop conversion at first non digit character with no error

Proposed changes:

* error if non null fractional part * if string contains float, reject non null fractional part * 3/4 Accept trailing blanks, error if non-blank trailing chars

Result :

Zval type
ZPP type IS_NULL IS_FALSE IS_TRUE IS_LONG IS_DOUBLE IS_STRING
null Yes No No No No No
bool No Native Native Yes (1) Yes (1) No
strict_bool No Native Native No No No
long No No No Native (2) (3)
strict_long No No No Native No No
double No No No Yes Native (4)
strict_double No No No No Native No
string No No No Yes Yes Native
strict_string No No No No No Native
  • (1) false if null, true if non null
  • (2) error if fractional part is non null
  • (3) Run string through is_numeric_str_function() and detect error. If double with null fractional part returned, convert to long, else error
  • (4) Run string through is_numeric_str_function() and detect error. If int returned, convert to double

is_numeric_str_function() behavior :

  • Skip leading spaces
  • Ignore trailing spaces
  • Error on non-blank trailing chars
rfc/zpp-conversion-rules.1424287239.txt.gz · Last modified: 2017/09/22 13:28 (external edit)