]> granicus.if.org Git - php/commitdiff
- New parameter parsing API
authorFelipe Pena <felipe@php.net>
Fri, 20 Jun 2008 13:02:33 +0000 (13:02 +0000)
committerFelipe Pena <felipe@php.net>
Fri, 20 Jun 2008 13:02:33 +0000 (13:02 +0000)
ext/standard/tests/general_functions/is_array.phpt
ext/standard/tests/general_functions/is_bool.phpt
ext/standard/tests/general_functions/is_float.phpt
ext/standard/tests/general_functions/is_int.phpt
ext/standard/tests/general_functions/is_null.phpt
ext/standard/tests/general_functions/is_numeric.phpt
ext/standard/tests/general_functions/is_object.phpt
ext/standard/tests/general_functions/is_scalar.phpt
ext/standard/tests/general_functions/is_string.phpt
ext/standard/type.c

index bb240518c3b93b044dc9fd0c652c7361304e285a..68b1b089dadfe082fa0c8167ebb9e21679282db9 100644 (file)
@@ -207,9 +207,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_array(): Only one argument expected in %s on line %d
+Warning: is_array() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_array(): Only one argument expected in %s on line %d
+Warning: is_array() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index 9ef60d4b4ee27e2abea9fa9c800a1f73c4a8677e..dc1c21660a951211b123fa939e4089c1704ec58f 100644 (file)
@@ -287,9 +287,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_bool(): Only one argument expected in %s on line %d
+Warning: is_bool() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_bool(): Only one argument expected in %s on line %d
+Warning: is_bool() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index d72a22a5c64b088a64a558490dad8644625edd64..1c610165d8cb099125cc3524a2e0693961fb8043 100644 (file)
@@ -421,21 +421,21 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_float(): Only one argument expected in %s on line %d
+Warning: is_float() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_double(): Only one argument expected in %s on line %d
+Warning: is_double() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_real(): Only one argument expected in %s on line %d
+Warning: is_real() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_float(): Only one argument expected in %s on line %d
+Warning: is_float() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 
-Warning: is_double(): Only one argument expected in %s on line %d
+Warning: is_double() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 
-Warning: is_real(): Only one argument expected in %s on line %d
+Warning: is_real() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index 2158bcc08b3c78a1be9824bc7b48fd28e4fcd950..57a3c04da9a4e460ccd46ff372240bd04a627737 100644 (file)
@@ -446,21 +446,21 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_int(): Only one argument expected in %s on line %d
+Warning: is_int() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_integer(): Only one argument expected in %s on line %d
+Warning: is_integer() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_long(): Only one argument expected in %s on line %d
+Warning: is_long() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_int(): Only one argument expected in %s on line %d
+Warning: is_int() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 
-Warning: is_integer(): Only one argument expected in %s on line %d
+Warning: is_integer() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 
-Warning: is_long(): Only one argument expected in %s on line %d
+Warning: is_long() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index 261385b85537e20ab6147a7d58253a29ee7af6e7..f39ada28ebf1ec3d45b226fd594a15dea288c709 100644 (file)
@@ -289,9 +289,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_null(): Only one argument expected in %s on line %d
+Warning: is_null() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_null(): Only one argument expected in %s on line %d
+Warning: is_null() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index 8121402661299a8550e853d48a6c0f51dcf96543..1b682014857774cadad271ab2ade94fd9435c938 100644 (file)
@@ -380,9 +380,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: Wrong parameter count for is_numeric() in %s on line %d
+Warning: is_numeric() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for is_numeric() in %s on line %d
+Warning: is_numeric() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 Done
index 9916c9e32a239ce618641687db6cd340fbcc1c53..5b7719202ca86024072361016e4a7fa9e23e319a 100644 (file)
@@ -220,9 +220,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_object(): Only one argument expected in %s on line %d
+Warning: is_object() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_object(): Only one argument expected in %s on line %d
+Warning: is_object() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index f7f142a16ac73b6174945dbc5ab3c6f749eaa122..699057db9c3f6ec79b36794a1a936dc959e324cd 100644 (file)
@@ -230,12 +230,12 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: Wrong parameter count for is_scalar() in %s on line %d
+Warning: is_scalar() expects exactly 1 parameter, 0 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for is_scalar() in %s on line %d
+Warning: is_scalar() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 
-Warning: Wrong parameter count for is_scalar() in %s on line %d
+Warning: is_scalar() expects exactly 1 parameter, 2 given in %s on line %d
 NULL
 Done
index 92bca6673ae2e8c8eac7e8ee9d174f0bd20c75c7..f7a8185d0acb838bde31840dae79c0170ca1efc7 100644 (file)
@@ -296,9 +296,9 @@ bool(false)
 
 *** Testing error conditions ***
 
-Warning: is_string(): Only one argument expected in %s on line %d
+Warning: is_string() expects exactly 1 parameter, 0 given in %s on line %d
 bool(false)
 
-Warning: is_string(): Only one argument expected in %s on line %d
+Warning: is_string() expects exactly 1 parameter, 2 given in %s on line %d
 bool(false)
 Done
index 88b77844ac2bc16fc4109202cadbc7f6fdc006c6..4eb219e25f85a022192c63e16eecec366eac01c2 100644 (file)
@@ -27,8 +27,8 @@ PHP_FUNCTION(gettype)
 {
        zval **arg;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+               return;
        }
 
        switch (Z_TYPE_PP(arg)) {
@@ -90,37 +90,36 @@ PHP_FUNCTION(gettype)
    Set the type of the variable */
 PHP_FUNCTION(settype)
 {
-       zval **var, **type;
+       zval **var;
+       char *type;
        char *new_type;
+       int type_len = 0;
 
-       if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &var, &type) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zs", &var, &type, &type_len) == FAILURE) {
+               return;
        }
 
-       convert_to_string_ex(type);
-       new_type = Z_STRVAL_PP(type);
-
-       if (!strcasecmp(new_type, "integer")) {
+       if (!strcasecmp(type, "integer")) {
                convert_to_long(*var);
-       } else if (!strcasecmp(new_type, "int")) {
+       } else if (!strcasecmp(type, "int")) {
                convert_to_long(*var);
-       } else if (!strcasecmp(new_type, "float")) {
+       } else if (!strcasecmp(type, "float")) {
                convert_to_double(*var);
-       } else if (!strcasecmp(new_type, "double")) { /* deprecated */
+       } else if (!strcasecmp(type, "double")) { /* deprecated */
                convert_to_double(*var);
-       } else if (!strcasecmp(new_type, "string")) {
+       } else if (!strcasecmp(type, "string")) {
                convert_to_string(*var);
-       } else if (!strcasecmp(new_type, "array")) {
+       } else if (!strcasecmp(type, "array")) {
                convert_to_array(*var);
-       } else if (!strcasecmp(new_type, "object")) {
+       } else if (!strcasecmp(type, "object")) {
                convert_to_object(*var);
-       } else if (!strcasecmp(new_type, "bool")) {
+       } else if (!strcasecmp(type, "bool")) {
                convert_to_boolean(*var);
-       } else if (!strcasecmp(new_type, "boolean")) {
+       } else if (!strcasecmp(type, "boolean")) {
                convert_to_boolean(*var);
-       } else if (!strcasecmp(new_type, "null")) {
+       } else if (!strcasecmp(type, "null")) {
                convert_to_null(*var);
-       } else if (!strcasecmp(new_type, "resource")) {
+       } else if (!strcasecmp(type, "resource")) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot convert to resource type");
                RETURN_FALSE;
        } else {
@@ -135,23 +134,23 @@ PHP_FUNCTION(settype)
    Get the integer value of a variable using the optional base for the conversion */
 PHP_FUNCTION(intval)
 {
-       zval **num, **arg_base;
+       zval **num;
+       long arg_base;
        int base;
 
        switch (ZEND_NUM_ARGS()) {
                case 1:
-                       if (zend_get_parameters_ex(1, &num) == FAILURE) {
-                               WRONG_PARAM_COUNT;
+                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &num) == FAILURE) {
+                               return;
                        }
                        base = 10;
                        break;
 
                case 2:
-                       if (zend_get_parameters_ex(2, &num, &arg_base) == FAILURE) {
-                               WRONG_PARAM_COUNT;
+                       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Zl", &num, &arg_base) == FAILURE) {
+                               return;
                        }
-                       convert_to_long_ex(arg_base);
-                       base = Z_LVAL_PP(arg_base);
+                       base = arg_base;
                        break;
 
                default:
@@ -169,8 +168,8 @@ PHP_FUNCTION(floatval)
 {
        zval **num;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &num) == FAILURE) {
+               return;
        }
 
        RETVAL_ZVAL(*num, 1, 0);
@@ -186,8 +185,8 @@ PHP_FUNCTION(strval)
        zval expr_copy;
        int use_copy;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &num) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &num) == FAILURE) {
+               return;
        }
 
        zend_make_printable_zval(*num, &expr_copy, &use_copy);
@@ -204,8 +203,7 @@ static void php_is_type(INTERNAL_FUNCTION_PARAMETERS, int type)
 {
        zval **arg;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Only one argument expected");
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
                RETURN_FALSE;
        }
 
@@ -305,8 +303,8 @@ PHP_FUNCTION(is_numeric)
 {
        zval **arg;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+               return;
        }
 
        switch (Z_TYPE_PP(arg)) {
@@ -336,8 +334,8 @@ PHP_FUNCTION(is_scalar)
 {
        zval **arg;
 
-       if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
-               WRONG_PARAM_COUNT;
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &arg) == FAILURE) {
+               return;
        }
 
        switch (Z_TYPE_PP(arg)) {