helly           Wed Feb 13 12:23:26 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/spl/tests      dit_002.phpt 

  Modified files:              
    /php-src/ext/spl    spl.php spl_directory.c spl_directory.h 
  Log:
  - MFH Make this behave like in <= 5.2.5 and test for it
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl.php?r1=1.49.2.11.2.9&r2=1.49.2.11.2.10&diff_format=u
Index: php-src/ext/spl/spl.php
diff -u php-src/ext/spl/spl.php:1.49.2.11.2.9 
php-src/ext/spl/spl.php:1.49.2.11.2.10
--- php-src/ext/spl/spl.php:1.49.2.11.2.9       Mon Feb  4 21:37:55 2008
+++ php-src/ext/spl/spl.php     Wed Feb 13 12:23:26 2008
@@ -1019,8 +1019,8 @@
  */
 class RecursiveDirectoryIterator extends DirectoryIterator implements 
RecursiveIterator
 {
-       const CURRENT_AS_SELF       0x00000000; /* make 
RecursiveDirectoryTree::current() return getSelf() */
-       const CURRENT_AS_FILEINFO   0x00000010; /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+       const CURRENT_AS_FILEINFO   0x00000000; /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+       const CURRENT_AS_SELF       0x00000010; /* make 
RecursiveDirectoryTree::current() return getSelf() */
        const CURRENT_AS_PATHNAME   0x00000020; /* make 
RecursiveDirectoryTree::current() return getPathname() */
 
        const KEY_AS_PATHNAME       0x00000000; /* make 
RecursiveDirectoryTree::key() return getPathname() */
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.c?r1=1.45.2.27.2.25&r2=1.45.2.27.2.26&diff_format=u
Index: php-src/ext/spl/spl_directory.c
diff -u php-src/ext/spl/spl_directory.c:1.45.2.27.2.25 
php-src/ext/spl/spl_directory.c:1.45.2.27.2.26
--- php-src/ext/spl/spl_directory.c:1.45.2.27.2.25      Mon Feb  4 20:43:50 2008
+++ php-src/ext/spl/spl_directory.c     Wed Feb 13 12:23:26 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.c,v 1.45.2.27.2.25 2008/02/04 20:43:50 helly Exp $ */
+/* $Id: spl_directory.c,v 1.45.2.27.2.26 2008/02/13 12:23:26 helly Exp $ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
@@ -962,7 +962,7 @@
        spl_filesystem_object *intern;
        char *path;
        int len;
-       long flags = 0;
+       long flags = 
SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
 
        php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException 
TSRMLS_CC);
 
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_directory.h?r1=1.12.2.5.2.9&r2=1.12.2.5.2.10&diff_format=u
Index: php-src/ext/spl/spl_directory.h
diff -u php-src/ext/spl/spl_directory.h:1.12.2.5.2.9 
php-src/ext/spl/spl_directory.h:1.12.2.5.2.10
--- php-src/ext/spl/spl_directory.h:1.12.2.5.2.9        Mon Feb  4 21:49:44 2008
+++ php-src/ext/spl/spl_directory.h     Wed Feb 13 12:23:26 2008
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: spl_directory.h,v 1.12.2.5.2.9 2008/02/04 21:49:44 helly Exp $ */
+/* $Id: spl_directory.h,v 1.12.2.5.2.10 2008/02/13 12:23:26 helly Exp $ */
 
 #ifndef SPL_DIRECTORY_H
 #define SPL_DIRECTORY_H
@@ -93,8 +93,8 @@
 #define SPL_FILE_OBJECT_SKIP_EMPTY         0x00000006 /* skip empty lines */
 #define SPL_FILE_OBJECT_READ_CSV           0x00000008 /* read via fgetcsv */
 
-#define SPL_FILE_DIR_CURRENT_AS_SELF       0x00000000 /* make 
RecursiveDirectoryTree::current() return getSelf() */
-#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000010 /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+#define SPL_FILE_DIR_CURRENT_AS_FILEINFO   0x00000000 /* make 
RecursiveDirectoryTree::current() return SplFileInfo */
+#define SPL_FILE_DIR_CURRENT_AS_SELF       0x00000010 /* make 
RecursiveDirectoryTree::current() return getSelf() */
 #define SPL_FILE_DIR_CURRENT_AS_PATHNAME   0x00000020 /* make 
RecursiveDirectoryTree::current() return getPathname() */
 #define SPL_FILE_DIR_CURRENT_MODE_MASK     0x000000F0 /* mask 
RecursiveDirectoryTree::current() */
 #define SPL_FILE_DIR_CURRENT(intern,mode)  
((intern->flags&SPL_FILE_DIR_CURRENT_MODE_MASK)==mode)

http://cvs.php.net/viewvc.cgi/php-src/ext/spl/tests/dit_002.phpt?view=markup&rev=1.1
Index: php-src/ext/spl/tests/dit_002.phpt
+++ php-src/ext/spl/tests/dit_002.phpt
--TEST--
SPL: DirectoryIterator defaults
--SKIPIF--
<?php if (!extension_loaded("spl")) print "skip"; ?>
--FILE--
<?php

$classes = array(
        'DirectoryIterator' => 0,
        'FilesystemIterator' => 1,
        'RecursiveDirectoryIterator' => 1,
        'GlobIterator' => 1,
);

foreach ($classes as $class => $flags) {
        echo "===$class===\n";
        $ref = new ReflectionClass($class);
        $obj = $ref->newInstance('glob://*');
        echo get_class($obj->current()) . "\n";
        if ($flags)
        {
                var_dump($obj->getFlags());
                $flags = array(
                        FilesystemIterator::CURRENT_AS_FILEINFO => 0,
                        FilesystemIterator::CURRENT_AS_SELF     => 0,
                        FilesystemIterator::CURRENT_AS_PATHNAME => 1,
                );
                foreach($flags as $flag => $isstring) {
                        $obj->setFlags($flag);
                        $obj->rewind();
                        var_dump($obj->getFlags());
                        if ($isstring) {
                                $val = $obj->current();
                                if (is_string($val) || is_unicode($val)) {
                                        var_dump(true);
                                } else {
                                        var_dump($val);
                                }
                        } else {
                                echo get_class($obj->current()) . "\n";
                        }
                }
        }
}
?>
===DONE===
--EXPECT--
===DirectoryIterator===
DirectoryIterator
===FilesystemIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
FilesystemIterator
int(32)
bool(true)
===RecursiveDirectoryIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
RecursiveDirectoryIterator
int(32)
bool(true)
===GlobIterator===
SplFileInfo
int(0)
int(0)
SplFileInfo
int(16)
GlobIterator
int(32)
bool(true)
===DONE===

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to