]> granicus.if.org Git - php/commitdiff
Add array type hinting
authorHannes Magnusson <bjori@php.net>
Thu, 15 Jun 2006 16:25:12 +0000 (16:25 +0000)
committerHannes Magnusson <bjori@php.net>
Thu, 15 Jun 2006 16:25:12 +0000 (16:25 +0000)
Remove unnecessary array checkes

ext/curl/interface.c
ext/dbase/dbase.c
ext/gd/gd.c

index 048c079eca7ed932e02bd14deea8551c98749de5..b58d8ff98fda9100e470789dda737e344c712dfe 100644 (file)
@@ -205,7 +205,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_curl_setopt_array, 0)
        ZEND_ARG_INFO(0, ch)
-       ZEND_ARG_INFO(0, options)/* ARRAY_INFO(0, options, 0) */
+       ZEND_ARG_ARRAY_INFO(0, options, 0)
 ZEND_END_ARG_INFO()
 
 static
index f4357858aa2380f05182cbe64a879512f6a08acd..eb0e2e6e9436d4c4328b9e6e67933522021e43e1 100644 (file)
@@ -261,10 +261,6 @@ PHP_FUNCTION(dbase_add_record)
                WRONG_PARAM_COUNT;
        }
        convert_to_long_ex(dbh_id);
-       if (Z_TYPE_PP(fields) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
-               RETURN_FALSE;
-       }
 
        dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
        if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
@@ -332,10 +328,6 @@ PHP_FUNCTION(dbase_replace_record)
        }
        convert_to_long_ex(dbh_id);
        convert_to_long_ex(recnum);
-       if (Z_TYPE_PP(fields) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
-               RETURN_FALSE;
-       }
 
        dbh = zend_list_find(Z_LVAL_PP(dbh_id), &dbh_type);
        if (!dbh || dbh_type != DBase_GLOBAL(le_dbhead)) {
@@ -581,11 +573,6 @@ PHP_FUNCTION(dbase_create)
        }
        convert_to_string_ex(filename);
 
-       if (Z_TYPE_PP(fields) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expected array as second parameter");
-               RETURN_FALSE;
-       }
-       
        if (php_check_open_basedir(Z_STRVAL_PP(filename) TSRMLS_CC)) {
                RETURN_FALSE;
        }
@@ -638,12 +625,6 @@ PHP_FUNCTION(dbase_create)
                        RETURN_FALSE;
                }
 
-               if (Z_TYPE_PP (field) != IS_ARRAY) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "second parameter must be array of arrays");
-                       free_dbf_head(dbh);
-                       RETURN_FALSE;
-               }
-
                /* field name */
                if (zend_hash_index_find(Z_ARRVAL_PP(field), 0, (void **)&value) == FAILURE) {
                        php_error_docref(NULL TSRMLS_CC, E_WARNING, "expected field name as first element of list in field %d", i);
@@ -749,13 +730,13 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_dbase_add_record, 0)
        ZEND_ARG_INFO(0, identifier)
-       ZEND_ARG_INFO(0, data) /* ARRAY_INFO(0, data, 0) */
+       ZEND_ARG_ARRAY_INFO(0, data, 0)
 ZEND_END_ARG_INFO()
 
 static
 ZEND_BEGIN_ARG_INFO(arginfo_dbase_replace_record, 0)
        ZEND_ARG_INFO(0, identifier)
-       ZEND_ARG_INFO(0, data) /* ARRAY_INFO(0, data, 0) */
+       ZEND_ARG_ARRAY_INFO(0, data, 0)
        ZEND_ARG_INFO(0, recnum)
 ZEND_END_ARG_INFO()
 
@@ -780,7 +761,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_dbase_create, 0)
        ZEND_ARG_INFO(0, filename)
-       ZEND_ARG_INFO(0, fields) /* ARRAY_INFO(0, fields, 0) */
+       ZEND_ARG_ARRAY_INFO(0, fields, 0)
 ZEND_END_ARG_INFO()
 
 static
index b9eca19691ce9075b365007bdd6d6b4edb75e105..5e6f41859a4220cd9d281e2ecf1395f4f732bee7 100644 (file)
@@ -148,7 +148,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_imagesetstyle, 0)
        ZEND_ARG_INFO(0, im)
-       ZEND_ARG_INFO(0, styles) /* ARRAY_INFO(0, styles, 0) */
+       ZEND_ARG_ARRAY_INFO(0, styles, 0)
 ZEND_END_ARG_INFO()
 
 static
@@ -627,7 +627,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_imagepolygon, 0)
        ZEND_ARG_INFO(0, im)
-       ZEND_ARG_INFO(0, points) /* ARRAY_INFO(0, points, 0) */
+       ZEND_ARG_ARRAY_INFO(0, points, 0)
        ZEND_ARG_INFO(0, num_pos)
        ZEND_ARG_INFO(0, col)
 ZEND_END_ARG_INFO()
@@ -635,7 +635,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_imagefilledpolygon, 0)
        ZEND_ARG_INFO(0, im)
-       ZEND_ARG_INFO(0, points) /* ARRAY_INFO(0, points, 0) */
+       ZEND_ARG_ARRAY_INFO(0, points, 0)
        ZEND_ARG_INFO(0, num_pos)
        ZEND_ARG_INFO(0, col)
 ZEND_END_ARG_INFO()
@@ -760,7 +760,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imageftbbox, 0, 0, 4)
        ZEND_ARG_INFO(0, float angle)
        ZEND_ARG_INFO(0, font_file)
        ZEND_ARG_INFO(0, text)
-       ZEND_ARG_INFO(0, extrainfo) /* ARRAY_INFO(0, extrainfo, 0) */
+       ZEND_ARG_ARRAY_INFO(0, extrainfo, 0)
 ZEND_END_ARG_INFO()
 
 static
@@ -773,7 +773,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_imagefttext, 0, 0, 8)
        ZEND_ARG_INFO(0, col)
        ZEND_ARG_INFO(0, font_file)
        ZEND_ARG_INFO(0, text)
-       ZEND_ARG_INFO(0, extrainfo) /* ARRAY_INFO(0, extrainfo, 0) */
+       ZEND_ARG_ARRAY_INFO(0, extrainfo, 0)
 ZEND_END_ARG_INFO()
 #endif
 
@@ -903,7 +903,7 @@ ZEND_END_ARG_INFO()
 static
 ZEND_BEGIN_ARG_INFO(arginfo_imageconvolution, 0)
        ZEND_ARG_INFO(0, im)
-       ZEND_ARG_INFO(0, matrix3x3) /* ARRAY_INFO(0, matrix3x3, 0) */
+       ZEND_ARG_ARRAY_INFO(0, matrix3x3, 0)
        ZEND_ARG_INFO(0, div)
        ZEND_ARG_INFO(0, offset)
 ZEND_END_ARG_INFO()
@@ -3226,11 +3226,6 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
        npoints = Z_LVAL_PP(NPOINTS);
        col = Z_LVAL_PP(COL);
 
-       if (Z_TYPE_PP(POINTS) != IS_ARRAY) {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "2nd argument to imagepolygon not an array");
-               RETURN_FALSE;
-       }
-
        nelem = zend_hash_num_elements(Z_ARRVAL_PP(POINTS));
        if (nelem < 6) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have at least 3 points in your array");
@@ -4796,7 +4791,7 @@ PHP_FUNCTION(imageconvolution)
 
        for (i=0; i<3; i++) {
                if (zend_hash_index_find(Z_ARRVAL_P(hash_matrix), (i), (void **) &var) == SUCCESS) {
-                       if (Z_TYPE_PP(var) != IS_ARRAY || zend_hash_num_elements(Z_ARRVAL_PP(var)) != 3 ) {
+                       if (zend_hash_num_elements(Z_ARRVAL_PP(var)) != 3 ) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must have 3x3 array");
                                RETURN_FALSE;
                        }