]> granicus.if.org Git - php/commitdiff
- New parameter parsing API
authorFelipe Pena <felipe@php.net>
Thu, 24 Jul 2008 12:48:47 +0000 (12:48 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 24 Jul 2008 12:48:47 +0000 (12:48 +0000)
ext/standard/dir.c
ext/standard/tests/dir/closedir_error.phpt
ext/standard/tests/dir/closedir_variation1.phpt
ext/standard/tests/dir/readdir_error.phpt
ext/standard/tests/dir/readdir_variation1.phpt
ext/standard/tests/dir/rewinddir_error.phpt
ext/standard/tests/dir/rewinddir_variation1.phpt

index 7d33aa264eaeb61c9898d58c0fb7073a00f27cc1..9b161ed35aa2c721a841672eb73dc66734b9af3d 100644 (file)
@@ -74,6 +74,9 @@ static int le_dirp;
 static zend_class_entry *dir_class_entry_ptr;
 
 #define FETCH_DIRP() \
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|r", &id) == FAILURE) { \
+               return; \
+       } \
        if (ZEND_NUM_ARGS() == 0) { \
                myself = getThis(); \
                if (myself) { \
@@ -85,10 +88,8 @@ static zend_class_entry *dir_class_entry_ptr;
                } else { \
                        ZEND_FETCH_RESOURCE(dirp, php_stream *, 0, DIRG(default_dir), "Directory", php_file_le_stream()); \
                } \
-       } else if ((ZEND_NUM_ARGS() != 1) || zend_get_parameters_ex(1, &id) == FAILURE) { \
-               WRONG_PARAM_COUNT; \
        } else { \
-               dirp = (php_stream *) zend_fetch_resource(id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
+               dirp = (php_stream *) zend_fetch_resource(&id TSRMLS_CC, -1, "Directory", NULL, 1, php_file_le_stream()); \
                if (!dirp) \
                        RETURN_FALSE; \
        } 
@@ -278,7 +279,7 @@ PHP_FUNCTION(getdir)
    Close directory connection identified by the dir_handle */
 PHP_FUNCTION(closedir)
 {
-       zval **id, **tmp, *myself;
+       zval *id = NULL, **tmp, *myself;
        php_stream *dirp;
        int rsrc_id;
 
@@ -386,7 +387,7 @@ PHP_FUNCTION(getcwd)
    Rewind dir_handle back to the start */
 PHP_FUNCTION(rewinddir)
 {
-       zval **id, **tmp, *myself;
+       zval *id = NULL, **tmp, *myself;
        php_stream *dirp;
        
        FETCH_DIRP();
@@ -404,7 +405,7 @@ PHP_FUNCTION(rewinddir)
    Read directory entry from dir_handle */
 PHP_NAMED_FUNCTION(php_if_readdir)
 {
-       zval **id, **tmp, *myself;
+       zval *id = NULL, **tmp, *myself;
        php_stream *dirp;
        php_stream_dirent entry;
 
index 1a8a043d0ae24f3a76cadbe8038dab218388e4ee..c2f7647ff94f752b77eec4de709f92d313f7ec6b 100644 (file)
@@ -40,6 +40,6 @@ rmdir($dir_path);
 
 -- Testing closedir() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for closedir() in %s on line %d
+Warning: closedir() expects at most 1 parameter, 2 given in %s on line %d
 NULL
 ===DONE===
index d5c843996d0e05556d015ad961c90f8c410d402b..0edbe19284d1690f42e25633c887b3cda4f881d5 100644 (file)
@@ -92,121 +92,121 @@ foreach($inputs as $input) {
 
 -- Iteration 1 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 2 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 3 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 4 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 5 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 6 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 7 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 8 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 9 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 10 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 11 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 12 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 13 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 14 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 15 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 16 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 17 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 18 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, array given in %s on line %d
+NULL
 
 -- Iteration 19 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 20 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 21 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 22 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, object given in %s on line %d
+NULL
 
 -- Iteration 23 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 24 --
 
-Warning: closedir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: closedir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 ===DONE===
index 4b4011a136a8ea3e22a5a74eb10d40706dc926eb..23ba3dfa63c7fa4f1ee42b177b6a234b24cde239 100644 (file)
@@ -38,6 +38,6 @@ rmdir($path);
 
 -- Testing readdir() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for readdir() in %s on line %d
+Warning: readdir() expects at most 1 parameter, 2 given in %s on line %d
 NULL
 ===DONE===
index b9cd85b2887dbaeb2e8a3a0ee2c368c64688cfb3..edfbf71538ab6b1b2b98cf73a8153bb08e804fb2 100644 (file)
@@ -90,121 +90,121 @@ foreach($inputs as $input) {
 
 -- Iteration 1 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 2 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 3 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 4 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 5 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 6 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 7 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 8 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 9 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 10 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 11 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 12 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 13 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 14 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 15 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 16 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 17 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 18 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, array given in %s on line %d
+NULL
 
 -- Iteration 19 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 20 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 21 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 22 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, object given in %s on line %d
+NULL
 
 -- Iteration 23 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 24 --
 
-Warning: readdir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: readdir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 ===DONE===
index d66b24b9398ca293b191740118e059b3c54f72a3..b3bb02bca398264ce93b84ab834e2437e8d8845d 100644 (file)
@@ -37,6 +37,6 @@ rmdir($dir_path);
 
 -- Testing rewinddir() function with more than expected no. of arguments --
 
-Warning: Wrong parameter count for rewinddir() in %s on line %d
+Warning: rewinddir() expects at most 1 parameter, 2 given in %s on line %d
 NULL
 ===DONE===
index e1fa002c147e2594451a208a6880f1e211bd3304..be915ad09eec1b9407bb7451133ad45108c12ab2 100644 (file)
@@ -26,7 +26,7 @@ class classA
   }
 }
 
-// heredoc string
+// heredoc Unicode string
 $heredoc = <<<EOT
 hello world
 EOT;
@@ -62,9 +62,9 @@ $inputs = array(
        '',
        array(),
 
-       // string data
-/*19*/ "string",
-       'string',
+       // Unicode string data
+/*19*/ "Unicode string",
+       'Unicode string',
        $heredoc,
        
        // object data
@@ -91,121 +91,121 @@ foreach($inputs as $input) {
 
 -- Iteration 1 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 2 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 3 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 4 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, integer given in %s on line %d
+NULL
 
 -- Iteration 5 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 6 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 7 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 8 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 9 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, double given in %s on line %d
+NULL
 
 -- Iteration 10 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 11 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 12 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 13 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 14 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 15 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, boolean given in %s on line %d
+NULL
 
 -- Iteration 16 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 17 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 18 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, array given in %s on line %d
+NULL
 
 -- Iteration 19 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 20 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 21 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, Unicode string given in %s on line %d
+NULL
 
 -- Iteration 22 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, object given in %s on line %d
+NULL
 
 -- Iteration 23 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 
 -- Iteration 24 --
 
-Warning: rewinddir(): supplied argument is not a valid Directory resource in %s on line %d
-bool(false)
+Warning: rewinddir() expects parameter 1 to be resource, null given in %s on line %d
+NULL
 ===DONE===