Re: [phpng] naming

From: Date: Wed, 07 May 2014 19:29:47 +0000
Subject: Re: [phpng] naming
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-74032@lists.php.net to get a copy of this message
Andrea Faulds wrote (on 07/05/2014): > > On 7 May 2014, at 19:11, Rowan Collins <rowan.collins@gmail.com > <mailto:rowan.collins@gmail.com>> wrote: > >> Ooh, that reminds me of something I've been meaning to file a bug >> for, and maybe even attempt a patch, if I can understand where it >> comes from: the message shown *to the user* when an internal function >> is passed an invalid value uses "double" and "long" instead of >> "float" and "int". > > …that’s probably from zend_parse_parameters, no? Following the code by eye, I think the patch would just be the attached - I haven't actually got a build environment to test it in, though, I'm just killing time while a colleague tests something. Using "integer" rather than "int" matches zend_get_type_by_const, which is is used for the "given" part of the message; floats are "double" in that function, which is documented behaviour of gettype [http://php.net/gettype]. The only downside I can think of of this change is that since error messages have no machine-readable form, people may be relying on matching the original text. Everything's a breaking change to someone I guess... [http://xkcd.com/1172/] Regards, -- Rowan Collins [IMSoP]

--- Zend/zend_API.c Wed May 7 20:16:52 2014 +++ Zend/zend_API.c Wed May 7 20:16:55 2014 @@ -338,7 +338,7 @@ int type; if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), p, &d, -1)) == 0) { - return "long"; + return "integer"; } else if (type == IS_DOUBLE) { if (c == 'L') { if (d > LONG_MAX) { @@ -376,7 +376,7 @@ case IS_OBJECT: case IS_RESOURCE: default: - return "long"; + return "integer"; } } break; @@ -397,7 +397,7 @@ int type; if ((type = is_numeric_string(Z_STRVAL_PP(arg), Z_STRLEN_PP(arg), &l, p, -1)) == 0) { - return "double"; + return "float"; } else if (type == IS_LONG) { *p = (double) l; } @@ -416,7 +416,7 @@ case IS_OBJECT: case IS_RESOURCE: default: - return "double"; + return "float"; } } break;
« previous php.internals (#74032) next »