]> granicus.if.org Git - php/commitdiff
- MFH Flag handling and documentation
authorMarcus Boerger <helly@php.net>
Mon, 4 Feb 2008 20:43:50 +0000 (20:43 +0000)
committerMarcus Boerger <helly@php.net>
Mon, 4 Feb 2008 20:43:50 +0000 (20:43 +0000)
ext/spl/spl.php
ext/spl/spl_directory.c
ext/spl/spl_directory.h

index bb6af7e050f7d62d1cc469b6927f0eb25e4fd4dd..43c29e987744fcf175a1ee12a42301d5ff48964c 100755 (executable)
  *
  * SPL - Standard PHP Library
  *
- * SPL is a collection of interfaces and classes that are meant to solve 
- * standard problems and implements some efficient data access interfaces 
- * and classes. You'll find the classes documented using php code in the 
- * file spl.php or in corresponding .inc files in subdirectories examples 
- * and internal. Based on the internal implementations or the files in the 
+ * SPL is a collection of interfaces and classes that are meant to solve
+ * standard problems and implements some efficient data access interfaces
+ * and classes. You'll find the classes documented using php code in the
+ * file spl.php or in corresponding .inc files in subdirectories examples
+ * and internal. Based on the internal implementations or the files in the
  * examples subdirectory there are also some .php files to experiment with.
- * 
- * The .inc files are not included automatically because they are sooner or 
- * later integrated into the extension. That means that you either need to 
- * put the code of examples/autoload.inc into your autoprepend file or that 
+ *
+ * The .inc files are not included automatically because they are sooner or
+ * later integrated into the extension. That means that you either need to
+ * put the code of examples/autoload.inc into your autoprepend file or that
  * you have to point your ini setting auto_prepend_file to that file.
- * 
+ *
  * Below is a list of interfaces/classes already availabel natively through
  * the SPL extension grouped by category.
- * 
+ *
  * 1) Iterators
- * 
+ *
  * SPL offers some advanced iterator algorithms:
- * 
+ *
  * - interface RecursiveIterator extends Iterator
  * - interface OuterIterator extends Iterator
  * - class RecursiveIteratorIterator implements OuterIterator
  * - class AppendIterator implements OuterIterator
  * - class RegexIterator extends FilterIterator
  * - class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
- * 
+ *
  * 2) Directories and Files
- * 
+ *
  * SPL offers two advanced directory and file handling classes:
- * 
+ *
  * - class SplFileInfo
  * - class DirectoryIterator extends SplFileInfo implements Iterator
  * - class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
  * - class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
- * 
+ *
  * 3) XML
- * 
+ *
  * SPL offers an advanced XML handling class:
- * 
+ *
  * - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
- * 
+ *
  * 4) Array Overloading
- * 
+ *
  * SPL offers advanced Array overloading:
- * 
+ *
  * - class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
  * - class ArrayIterator implements Iterator, ArrayAccess, Countable, SeekableIterator
  * - class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
- * 
+ *
  * As the above suggest an ArrayObject creates an ArrayIterator when it comes to
- * iteration (e.g. ArrayObject instance used inside foreach). 
+ * iteration (e.g. ArrayObject instance used inside foreach).
  *
  * 5) Counting
  *
@@ -81,7 +81,7 @@
  *
  * 6) Exception%s
  *
- * SPL provides a set of standard Exception classes each meant to indicate a 
+ * SPL provides a set of standard Exception classes each meant to indicate a
  * certain problem type.
  *
  * - class LogicException           extends Exception
  *
  * 8) @ref Examples
  *
- * The classes and interfaces in this group are contained as PHP code in the 
+ * The classes and interfaces in this group are contained as PHP code in the
  * examples subdirectory of ext/SPL. Sooner or later they will be moved to
  * c-code.
- * 
+ *
  * 9) Some articles about SPL:
  * - <a href="http://www.phpro.org/tutorials/Introduction-to-SPL.html">Introduction to Standard PHP Library (SPL)</a>
  * - <a href="http://www.sitepoint.com/article/php5-standard-library/1">Introducing PHP 5's Standard Library</a>
  * - Debug session 2 <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_1.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_1.pdf">[pdf]</a>, <a href="http://taks.somabo.de/200411_php_conference_frankfrurt_iterator_debug_session.swf">[swf]</a>
  * - Debug session 3 <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_2.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_2.pdf">[pdf]</a>
  *
- * You can download this documentation as a chm file 
+ * You can download this documentation as a chm file
  * <a href="http://php.net/~helly/php/ext/spl/spl.chm">here</a>.
  *
  * (c) Marcus Boerger, 2003 - 2007
 
 /** @defgroup ZendEngine Zend engine classes
  *
- * The classes and interfaces in this group are contained in the c-code of 
+ * The classes and interfaces in this group are contained in the c-code of
  * PHP's Zend engine.
  */
 
 /** @defgroup SPL Internal classes
  *
- * The classes and interfaces in this group are contained in the c-code of 
+ * The classes and interfaces in this group are contained in the c-code of
  * ext/SPL.
  */
 
 /** @defgroup Examples Example classes
  *
- * The classes and interfaces in this group are contained as PHP code in the 
+ * The classes and interfaces in this group are contained as PHP code in the
  * examples subdirectory of ext/SPL. Sooner or later they will be moved to
  * c-code.
  */
@@ -173,13 +173,13 @@ function spl_autoload(string $class_name, string $file_extensions = NULL) {/**/}
  */
 function spl_autoload_call(string $class_name) {/**/};
 
-/** @ingroup SPL 
+/** @ingroup SPL
  * @brief Register and return default file extensions for spl_autoload
  * @since PHP 5.1
  *
- * @param file_extensions optional comma separated list of extensions to use in 
+ * @param file_extensions optional comma separated list of extensions to use in
  *        default autoload function. If not given just return the current list.
- * @return comma separated list of file extensions to use in default autoload 
+ * @return comma separated list of file extensions to use in default autoload
  *        function.
  */
 function spl_autoload_extensions($file_extensions) {/**/};
@@ -196,7 +196,7 @@ function spl_autoload_functions() {/**/};
  * @brief Register given function as autoload implementation
  * @since PHP 5.1
  *
- * @param autoload_function  name of function or array of object/class and 
+ * @param autoload_function  name of function or array of object/class and
  *                           function name to register as autoload function.
  * @param throw              whether to throw or issue an error on failure.
  */
@@ -206,7 +206,7 @@ function spl_autoload_register(string $autoload_function = "spl_autoload", $thro
  * @brief Unregister given function as autoload implementation
  * @since PHP 5.1
  *
- * @param autoload_function  name of function or array of object/class and 
+ * @param autoload_function  name of function or array of object/class and
  *                           function name to unregister as autoload function.
  */
 function spl_autoload_unregister(string $autoload_function = "spl_autoload") {/**/};
@@ -214,7 +214,7 @@ function spl_autoload_unregister(string $autoload_function = "spl_autoload") {/*
 /** @ingroup SPL
  * @brief Return an array of classes and interfaces in SPL
  *
- * @return array containing the names of all clsses and interfaces defined in 
+ * @return array containing the names of all clsses and interfaces defined in
  *         extension SPL
  */
 function spl_classes() {/**/};
@@ -244,26 +244,26 @@ function iterator_to_array(Traversable $it, $use_keys = true) {/**/};
 class Exception
 {
        /** The exception message */
-    protected $message;
-    
-    /** The string represenations as generated during construction */
-    private $string;
-    
-    /** The code passed to the constructor */
-    protected $code;
-    
-    /** The file name where the exception was instantiated */
-    protected $file;
-    
-    /** The line number where the exception was instantiated */
-    protected $line;
-    
-    /** The stack trace */
-    private $trace;
+       protected $message;
+
+       /** The string represenations as generated during construction */
+       private $string;
+
+       /** The code passed to the constructor */
+       protected $code;
+
+       /** The file name where the exception was instantiated */
+       protected $file;
+
+       /** The line number where the exception was instantiated */
+       protected $line;
+
+       /** The stack trace */
+       private $trace;
 
        /** Prevent clone
         */
-    final private function __clone() {}
+       final private function __clone() {}
 
        /** Construct an exception
         *
@@ -279,55 +279,55 @@ class Exception
                $this->line = __LINE__; // of throw clause
                $this->trace = debug_backtrace();
                $this->string = StringFormat($this);
-       } 
+       }
 
        /** @return the message passed to the constructor
         */
-    final public function getMessage()
-    {
-       return $this->message;
-    }
+       final public function getMessage()
+       {
+               return $this->message;
+       }
 
        /** @return the code passed to the constructor
         */
-    final public function getCode()
-    {
-       return $this->code;
-    }
+       final public function getCode()
+       {
+               return $this->code;
+       }
 
        /** @return the name of the file where the exception was thrown
         */
-    final public function getFile()
-    {
-       return $this->file;
-    }
+       final public function getFile()
+       {
+               return $this->file;
+       }
 
        /** @return the line number where the exception was thrown
         */
-    final public function getLine()
-    {
-       return $this->line;
-    }
+       final public function getLine()
+       {
+               return $this->line;
+       }
 
        /** @return the stack trace as array
         */
-    final public function getTrace()
-    {
-       return $this->trace;
-    }
+       final public function getTrace()
+       {
+               return $this->trace;
+       }
 
        /** @return the stack trace as string
         */
-    final public function getTraceAsString()
-    {
-    }
+       final public function getTraceAsString()
+       {
+       }
 
        /** @return string represenation of exception
         */
-    public function __toString()
-    {
-       return $this->string;
-    }
+       public function __toString()
+       {
+               return $this->string;
+       }
 }
 
 /** @ingroup SPL
@@ -360,7 +360,7 @@ class BadMethodCallException extends BadFunctionCallException
  * @brief Exception that denotes a value not in the valid domain was used.
  * @since PHP 5.1
  *
- * This kind of exception should be used to inform about domain erors in 
+ * This kind of exception should be used to inform about domain erors in
  * mathematical sense.
  *
  * @see RangeException
@@ -383,7 +383,7 @@ class InvalidArgumentException extends LogicException
  * @brief Exception thrown when a parameter exceeds the allowed length.
  * @since PHP 5.1
  *
- * This can be used for strings length, array size, file size, number of 
+ * This can be used for strings length, array size, file size, number of
  * elements read from an Iterator and so on.
  */
 class LengthException extends LogicException
@@ -403,7 +403,7 @@ class OutOfRangeException extends LogicException
 }
 
 /** @ingroup SPL
- * @brief Exception thrown for errors that are only detectable at runtime. 
+ * @brief Exception thrown for errors that are only detectable at runtime.
  * @since PHP 5.1
  */
 class RuntimeException extends Exception
@@ -457,7 +457,7 @@ class UnderflowException extends RuntimeException
  *
  * Typically this happens when a function calls another function and espects
  * the return value to be of a certain type or value not including arithmetic
- * or buffer related errors. 
+ * or buffer related errors.
  *
  * @see InvalidArgumentException
  */
@@ -496,14 +496,14 @@ interface ArrayAccess
  * @since PHP 5.0
  *
  * Abstract base interface that cannot be implemented alone. Instead it
- * must be implemented by either IteratorAggregate or Iterator. 
+ * must be implemented by either IteratorAggregate or Iterator.
  *
- * @note Internal classes that implement this interface can be used in a 
+ * @note Internal classes that implement this interface can be used in a
  * foreach construct and do not need to implement IteratorAggregate or
  * Iterator.
  *
  * @note This is an engine internal interface which cannot be implemented
- * in PHP scripts. Either IteratorAggregate or Iterator must be used 
+ * in PHP scripts. Either IteratorAggregate or Iterator must be used
  * instead.
  */
 interface Traversable
@@ -515,7 +515,7 @@ interface Traversable
  * @since PHP 5.0
  *
  * @note This is an engine internal interface.
- */ 
+ */
 interface IteratorAggregate extends Traversable
 {
        /** @return an Iterator for the implementing object.
@@ -527,7 +527,7 @@ interface IteratorAggregate extends Traversable
  * @brief Basic iterator
  * @since PHP 5.0
  *
- * Interface for external iterators or objects that can be iterated 
+ * Interface for external iterators or objects that can be iterated
  * themselves internally.
  *
  * @note This is an engine internal interface.
@@ -569,8 +569,8 @@ interface Countable
 /** @ingroup ZendEngine
  * @brief Interface for customized serializing
  * @since 5.1
- * 
- * Classes that implement this interface no longer support __sleep() and 
+ *
+ * Classes that implement this interface no longer support __sleep() and
  * __wakeup(). The method serialized is called whenever an instance needs to
  * be serialized. This does not invoke __destruct() or has any other side
  * effect unless programmed inside the method. When the data is unserialized
@@ -584,10 +584,10 @@ interface Serializable
         * @return string representation of the instance
         */
        function serialize();
-       
+
        /**
         * @note This is a constructor
-        * 
+        *
         * @param $serialized data read from stream to construct the instance
         */
        function unserialize($serialized);
@@ -598,7 +598,7 @@ interface Serializable
  * @since PHP 5.0
  * @version 1.2
  *
- * This array wrapper allows to recursively iterate over Arrays and public 
+ * This array wrapper allows to recursively iterate over Arrays and public
  * Object properties.
  *
  * @see ArrayIterator
@@ -621,14 +621,14 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
        function __construct($array, $flags = 0, $iterator_class = "ArrayIterator") {/**/}
 
        /** Set behavior flags.
-        *      
+        *
         * @param $flags bitmask as follows:
         *        0 set: properties of the object have their normal functionality
         *               when accessed as list (var_dump, foreach, etc.)
         *        1 set: array indices can be accessed as properties in read/write
         */
        function setFlags($flags) {/**/}
-                           
+
        /** @return current flags
         */
        function getFlags() {/**/}
@@ -636,27 +636,27 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
        /** Sort the entries by values.
         */
        function asort() {/**/}
-       
+
        /** Sort the entries by key.
         */
        function ksort() {/**/}
-       
+
        /** Sort the entries by values using user defined function.
         */
        function uasort(mixed cmp_function) {/**/}
-       
+
        /** Sort the entries by key using user defined function.
         */
        function uksort(mixed cmp_function) {/**/}
-       
+
        /** Sort the entries by values using "natural order" algorithm.
         */
        function natsort() {/**/}
-       
+
        /** Sort the entries by values using case insensitive "natural order" algorithm.
         */
        function natcasesort() {/**/}
-       
+
        /** @param $array new array or object
         */
        function exchangeArray($array) {/**/}
@@ -668,44 +668,44 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
 
        /** @param $index offset to inspect
         * @return whetehr offset $index esists
-        */     
+        */
        function offsetExists($index) {/**/}
 
        /** @param $index offset to return value for
         * @return value at offset $index
-        */     
+        */
        function offsetGet($index) {/**/}
 
        /** @param $index index to set
         * @param $newval new value to store at offset $index
-        */     
+        */
        function offsetSet($index, $newval) {/**/}
 
        /** @param $index offset to unset
-        */     
+        */
        function offsetUnset($index) {/**/}
 
        /** @param $value is appended as last element
-        * @warning this method cannot be called when the ArrayObject refers to 
+        * @warning this method cannot be called when the ArrayObject refers to
         *          an object.
-        */     
+        */
        function append($value) {/**/}
 
        /** @return a \b copy of the array
-        * @note when the ArrayObject refers to an object then this method 
+        * @note when the ArrayObject refers to an object then this method
         *       returns an array of the public properties.
-        */     
+        */
        function getArrayCopy() {/**/}
 
        /** @return the number of elements in the array or the number of public
         * properties in the object.
         */
        function count() {/**/}
-       
+
        /* @param $iterator_class new class used in getIterator()
         */
        function setIteratorClass($itertor_class) {/**/}
-       
+
        /* @return class used in getIterator()
         */
        function getIteratorClass() {/**/}
@@ -719,9 +719,9 @@ class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
  * This iterator allows to unset and modify values and keys while iterating
  * over Arrays and Objects.
  *
- * When you want to iterate over the same array multiple times you need to 
- * instanciate ArrayObject and let it create ArrayIterator instances that 
- * refer to it either by using foreach or by calling its getIterator() 
+ * When you want to iterate over the same array multiple times you need to
+ * instanciate ArrayObject and let it create ArrayIterator instances that
+ * refer to it either by using foreach or by calling its getIterator()
  * method manually.
  */
 class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
@@ -741,7 +741,7 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
        function __construct($array, $flags = 0) {/**/}
 
        /** Set behavior flags.
-        *      
+        *
         * @param $flags bitmask as follows:
         *        0 set: properties of the object have their normal functionality
         *               when accessed as list (var_dump, foreach, etc.)
@@ -757,56 +757,56 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
        /** Sort the entries by values.
         */
        function asort() {/**/}
-       
+
        /** Sort the entries by key.
         */
        function ksort() {/**/}
-       
+
        /** Sort the entries by values using user defined function.
         */
        function uasort(mixed cmp_function) {/**/}
-       
+
        /** Sort the entries by key using user defined function.
         */
        function uksort(mixed cmp_function) {/**/}
-       
+
        /** Sort the entries by values using "natural order" algorithm.
         */
        function natsort() {/**/}
-       
+
        /** Sort the entries by values using case insensitive "natural order" algorithm.
         */
        function natcasesort() {/**/}
-       
+
        /** @param $index offset to inspect
         * @return whetehr offset $index esists
-        */     
+        */
        function offsetExists($index) {/**/}
 
        /** @param $index offset to return value for
         * @return value at offset $index
-        */     
+        */
        function offsetGet($index) {/**/}
 
        /** @param $index index to set
         * @param $newval new value to store at offset $index
-        */     
+        */
        function offsetSet($index, $newval) {/**/}
 
        /** @param $index offset to unset
-        */     
+        */
        function offsetUnset($index) {/**/}
 
        /** @param $value is appended as last element
-        * @warning this method cannot be called when the ArrayIterator refers to 
+        * @warning this method cannot be called when the ArrayIterator refers to
         *          an object.
-        */     
+        */
        function append($value) {/**/}
 
        /** @return a \b copy of the array
-        * @note when the ArrayIterator refers to an object then this method 
+        * @note when the ArrayIterator refers to an object then this method
         *       returns an array of the public properties.
-        */     
+        */
        function getArrayCopy() {/**/}
 
        /** @param $position offset to seek to
@@ -821,16 +821,16 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
 
        /** @copydoc Iterator::rewind */
        function rewind() {/**/}
-       
+
        /** @copydoc Iterator::valid */
        function valid() {/**/}
-       
+
        /** @copydoc Iterator::current */
        function current() {/**/}
-       
+
        /** @copydoc Iterator::key */
        function key() {/**/}
-       
+
        /** @copydoc Iterator::next */
        function next() {/**/}
 }
@@ -839,7 +839,7 @@ class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
  * @brief File info class
  * @since PHP 5.1.3
  */
-class SplFileInfo 
+class SplFileInfo
 {
        /** Construct a file info object
         *
@@ -849,11 +849,11 @@ class SplFileInfo
 
        /** @return the path part only.
         */
-       function getPath() {/**/}       
+       function getPath() {/**/}
 
        /** @return the filename only.
         */
-       function getFilename() {/**/}   
+       function getFilename() {/**/}
 
        /** @return SplFileInfo created for the file
         * @param class_name name of class to instantiate
@@ -863,7 +863,7 @@ class SplFileInfo
 
        /** @return The current entries path and file name.
         */
-       function getPathname() {/**/}   
+       function getPathname() {/**/}
 
        /** @return SplFileInfo created for the path
         * @param class_name name of class to instantiate
@@ -925,7 +925,7 @@ class SplFileInfo
 
        /** @return Whether the current entry is a directory.
         */
-       function isDir() {/**/} 
+       function isDir() {/**/}
 
        /** @return whether the current entry is a link.
         */
@@ -938,7 +938,7 @@ class SplFileInfo
        /** @return The resolved path
         */
        function getRealPath() {/**/}
-       
+
        /** @return getPathname()
         */
        function __toString() {/**/}
@@ -948,7 +948,7 @@ class SplFileInfo
         * @param mode              open mode
         * @param use_include_path  whether to search include paths (don't use)
         * @param context           resource context to pased to open function
-        * @throw RuntimeException  if file cannot be opened (e.g. insufficient 
+        * @throw RuntimeException  if file cannot be opened (e.g. insufficient
         *                          access rights).
         * @return The opened file as a SplFileObject instance
         *
@@ -958,7 +958,7 @@ class SplFileInfo
         */
        function openFile($mode = 'r', $use_include_path = false, $context = NULL) {/**/}
 
-       /** @param class_name name of class used with openFile(). Must be derived 
+       /** @param class_name name of class used with openFile(). Must be derived
         * from SPLFileObject.
         */
        function setFileClass(string class_name = "SplFileObject") {/**/}
@@ -984,10 +984,10 @@ class DirectoryIterator extends SplFileInfo implements Iterator
 
        /** @copydoc Iterator::rewind */
        function rewind() {/**/}
-       
+
        /** @copydoc Iterator::valid */
        function valid() {/**/}
-       
+
        /** @return index of entry
         */
        function key() {/**/}
@@ -1001,7 +1001,7 @@ class DirectoryIterator extends SplFileInfo implements Iterator
 
        /** @return Whether the current entry is either '.' or '..'.
         */
-       function isDot() {/**/} 
+       function isDot() {/**/}
 
        /** @return whether the current entry is a link.
         */
@@ -1019,17 +1019,25 @@ class DirectoryIterator extends SplFileInfo implements Iterator
  */
 class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
 {
-       const CURRENT_AS_FILEINFO   0x00000010; /* make RecursiveDirectoryTree::current() return SplFileInfo */
-       const KEY_AS_FILENAME       0x00000020; /* make RecursiveDirectoryTree::key() return getFilename() */
-       const NEW_CURRENT_AND_KEY   0x00000030; /* CURRENT_AS_FILEINFO + KEY_AS_FILENAME */
+       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() */
+       const KEY_AS_FILENAME       0x00000100; /* make RecursiveDirectoryTree::key() return getFilename() */
+
+       const NEW_CURRENT_AND_KEY   0x00000100; /* CURRENT_AS_FILEINFO + KEY_AS_FILENAME */
 
        /** Construct a directory iterator from a path-string.
         *
         * @param $path   directory to iterate.
         * @param $flags  open flags
         * - CURRENT_AS_FILEINFO
+        * - CURRENT_AS_SELF
+        * - CURRENT_AS_PATHNAME
+        * - KEY_AS_PATHNAME
         * - KEY_AS_FILENAME
-        * - NEW_CURRENT_AND_KEY 
+        * - NEW_CURRENT_AND_KEY
         */
        function __construct($path, $flags = 0) {/**/}
 
@@ -1043,11 +1051,11 @@ class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveI
 
        /** @return whether the current is a directory (not '.' or '..').
         */
-       function hasChildren() {/**/}   
+       function hasChildren() {/**/}
 
        /** @return a RecursiveDirectoryIterator for the current entry.
         */
-       function getChildren() {/**/}   
+       function getChildren() {/**/}
 
        /** @return sub path only (without main path)
         */
@@ -1062,7 +1070,7 @@ class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveI
  * @brief recursive SimpleXML_Element iterator
  * @since PHP 5.0
  *
- * The SimpleXMLIterator implements the RecursiveIterator interface. This 
+ * The SimpleXMLIterator implements the RecursiveIterator interface. This
  * allows iteration over all elements using foreach or an appropriate while
  * construct, just like SimpleXMLElement does. When using the foreach construct,
  * you will also iterate over the subelements. For every element which
@@ -1073,11 +1081,11 @@ class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, C
 {
        /** @return whether the current node has sub nodes.
         */
-       function hasChildren() {/**/}   
+       function hasChildren() {/**/}
 
        /** @return a SimpleXMLIterator for the current node.
         */
-       function getChildren() {/**/}   
+       function getChildren() {/**/}
 
        /** @return number of elements/attributes seen with foreach()
         */
@@ -1085,16 +1093,16 @@ class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, C
 
        /** @copydoc Iterator::rewind */
        function rewind() {/**/}
-       
+
        /** @copydoc Iterator::valid */
        function valid() {/**/}
-       
+
        /** @copydoc Iterator::current */
        function current() {/**/}
-       
+
        /** @copydoc Iterator::key */
        function key() {/**/}
-       
+
        /** @copydoc Iterator::next */
        function next() {/**/}
 }
@@ -1126,16 +1134,16 @@ interface SplSubject
 {
        /** @param $observer new observer to attach
         */
-    function attach(SplObserver $observer);
+       function attach(SplObserver $observer);
 
        /** @param $observer existing observer to detach
         * @note a non attached observer shouldn't result in a warning or similar
         */
-    function detach(SplObserver $observer);
+       function detach(SplObserver $observer);
 
        /** Notify all observers
         */
-    function notify();
+       function notify();
 }
 
 ?>
index c9429cf4871074dc2eaf0edc849cb39311402b49..69c4a8654da3036ba24f210bcd6c24f8016fbc8d 100755 (executable)
@@ -484,7 +484,7 @@ SPL_METHOD(DirectoryIterator, __construct)
        intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
        spl_filesystem_dir_open(intern, path TSRMLS_CC);
        intern->u.dir.is_recursive = instanceof_function(intern->std.ce, spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
-       intern->flags = 0;
+       intern->flags = SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_SELF;
 
        php_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
 }
@@ -661,7 +661,7 @@ SPL_METHOD(RecursiveDirectoryIterator, key)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-       if (intern->flags & SPL_FILE_DIR_KEY_AS_FILENAME) {
+       if (SPL_FILE_DIR_KEY(intern, SPL_FILE_DIR_KEY_AS_FILENAME)) {
                RETURN_STRING(intern->u.dir.entry.d_name, 1);
        } else {
                spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -676,10 +676,10 @@ SPL_METHOD(RecursiveDirectoryIterator, current)
 {
        spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
 
-       if (intern->flags & SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+       if (SPL_FILE_DIR_CURRENT(intern, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
                spl_filesystem_object_get_file_name(intern TSRMLS_CC);
                RETURN_STRINGL(intern->file_name, intern->file_name_len, 1);
-       } else if (intern->flags & SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+       } else if (SPL_FILE_DIR_CURRENT(intern, SPL_FILE_DIR_CURRENT_AS_FILEINFO)) {
                spl_filesystem_object_get_file_name(intern TSRMLS_CC);
                spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, return_value TSRMLS_CC);
        } else {
@@ -962,7 +962,7 @@ SPL_METHOD(RecursiveDirectoryIterator, __construct)
        spl_filesystem_object *intern;
        char *path;
        int len;
-       long flags = SPL_FILE_DIR_CURRENT_AS_FILEINFO;
+       long flags = 0;
 
        php_set_error_handling(EH_THROW, spl_ce_UnexpectedValueException TSRMLS_CC);
 
@@ -1104,7 +1104,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
 }
 /* }}} */
 
-/* define an overloaded iterator structure */
+/* {{{ define an overloaded iterator structure */
 typedef struct {
        zend_object_iterator  intern;
        zval                  *current;
@@ -1128,6 +1128,7 @@ zend_object_iterator_funcs spl_filesystem_dir_it_funcs = {
        spl_filesystem_dir_it_move_forward,
        spl_filesystem_dir_it_rewind
 };
+/* }}} */
 
 /* {{{ spl_ce_dir_get_iterator */
 zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
@@ -1162,7 +1163,7 @@ static void spl_filesystem_dir_it_dtor(zend_object_iterator *iter TSRMLS_DC)
        efree(iterator);
 }
 /* }}} */
-       
+
 /* {{{ spl_filesystem_dir_it_valid */
 static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC)
 {
@@ -1173,7 +1174,6 @@ static int spl_filesystem_dir_it_valid(zend_object_iterator *iter TSRMLS_DC)
 }
 /* }}} */
 
-
 /* {{{ spl_filesystem_dir_it_current_data */
 static void spl_filesystem_dir_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
 {
@@ -1240,21 +1240,21 @@ static void spl_filesystem_tree_it_dtor(zend_object_iterator *iter TSRMLS_DC)
        efree(iterator);
 }
 /* }}} */
-       
+
 /* {{{ spl_filesystem_tree_it_current_data */
 static void spl_filesystem_tree_it_current_data(zend_object_iterator *iter, zval ***data TSRMLS_DC)
 {
        spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
        spl_filesystem_object *object   = iterator->object;
 
-       if (object->flags & SPL_FILE_DIR_CURRENT_AS_PATHNAME) {
+       if (SPL_FILE_DIR_CURRENT(object, SPL_FILE_DIR_CURRENT_AS_PATHNAME)) {
                if (!iterator->current) {
                        ALLOC_INIT_ZVAL(iterator->current);
                        spl_filesystem_object_get_file_name(object TSRMLS_CC);
                        ZVAL_STRINGL(iterator->current, object->file_name, object->file_name_len, 1);
                }
                *data = &iterator->current;
-       } else if (object->flags & SPL_FILE_DIR_CURRENT_AS_FILEINFO) {
+       } else if (SPL_FILE_DIR_CURRENT(object, SPL_FILE_DIR_CURRENT_AS_FILEINFO)) {
                if (!iterator->current) {
                        ALLOC_INIT_ZVAL(iterator->current);
                        spl_filesystem_object_get_file_name(object TSRMLS_CC);
@@ -1273,7 +1273,7 @@ static int spl_filesystem_tree_it_current_key(zend_object_iterator *iter, char *
        spl_filesystem_dir_it *iterator = (spl_filesystem_dir_it *)iter;
        spl_filesystem_object *object   = iterator->object;
        
-       if (object->flags & SPL_FILE_DIR_KEY_AS_FILENAME) {
+       if (SPL_FILE_DIR_KEY(object, SPL_FILE_DIR_KEY_AS_FILENAME)) {
                *str_key_len = strlen(object->u.dir.entry.d_name) + 1;
                *str_key = estrndup(object->u.dir.entry.d_name, *str_key_len - 1);
        } else {
@@ -1330,7 +1330,7 @@ static void spl_filesystem_tree_it_rewind(zend_object_iterator *iter TSRMLS_DC)
 }
 /* }}} */
 
-/* iterator handler table */
+/* {{{ iterator handler table */
 zend_object_iterator_funcs spl_filesystem_tree_it_funcs = {
        spl_filesystem_tree_it_dtor,
        spl_filesystem_dir_it_valid,
@@ -1339,6 +1339,7 @@ zend_object_iterator_funcs spl_filesystem_tree_it_funcs = {
        spl_filesystem_tree_it_move_forward,
        spl_filesystem_tree_it_rewind
 };
+/* }}} */
 
 /* {{{ spl_ce_dir_get_iterator */
 zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
@@ -1383,7 +1384,7 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS
 }
 /* }}} */
 
-/* declare method parameters */
+/* {{{ declare method parameters */
 /* supply a name and default to call by parameter */
 static
 ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0) 
@@ -1444,7 +1445,7 @@ static zend_function_entry spl_SplFileInfo_functions[] = {
 };
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0) 
+ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0)
        ZEND_ARG_INFO(0, path)
 ZEND_END_ARG_INFO()
 
@@ -1487,6 +1488,7 @@ static zend_function_entry spl_RecursiveDirectoryIterator_functions[] = {
        SPL_ME(RecursiveDirectoryIterator, getSubPathname,NULL, ZEND_ACC_PUBLIC)
        {NULL, NULL, NULL}
 };
+/* }}} */
 
 static int spl_filesystem_file_read(spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
 {
@@ -1582,12 +1584,12 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
        return result;
 } /* }}} */
 
-#define FileFunctionCall(func_name, pass_num_args, arg2) \
+#define FileFunctionCall(func_name, pass_num_args, arg2) /* {{{ */ \
 { \
        zend_function *func_ptr; \
        zend_hash_find(EG(function_table), #func_name, sizeof(#func_name), (void **) &func_ptr); \
        spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value, arg2 TSRMLS_CC); \
-}
+} /* }}} */
 
 static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, zval *return_value TSRMLS_DC) /* {{{ */
 {
@@ -1667,7 +1669,7 @@ static int spl_filesystem_file_is_empty_line(spl_filesystem_object *intern TSRML
                case IS_STRING:
                        return Z_STRLEN_P(intern->u.file.current_zval) == 0;
                case IS_ARRAY:
-                       if ((intern->flags & SPL_FILE_OBJECT_READ_CSV) 
+                       if ((intern->flags & SPL_FILE_OBJECT_READ_CSV)
                        && zend_hash_num_elements(Z_ARRVAL_P(intern->u.file.current_zval)) == 1) {
                                zval ** first = Z_ARRVAL_P(intern->u.file.current_zval)->pListHead->pData;
                                        
@@ -2045,7 +2047,6 @@ SPL_METHOD(SplFileObject, fflush)
        RETURN_BOOL(!php_stream_flush(intern->u.file.stream));
 } /* }}} */
 
-
 /* {{{ proto int SplFileObject::ftell()
    Return current file position */
 SPL_METHOD(SplFileObject, ftell)
@@ -2227,17 +2228,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
 ZEND_END_ARG_INFO()
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_file_object_setFlags, 0) 
+ZEND_BEGIN_ARG_INFO(arginfo_file_object_setFlags, 0)
        ZEND_ARG_INFO(0, flags)
 ZEND_END_ARG_INFO()
 
 static
-ZEND_BEGIN_ARG_INFO(arginfo_file_object_setMaxLineLen, 0) 
+ZEND_BEGIN_ARG_INFO(arginfo_file_object_setMaxLineLen, 0)
        ZEND_ARG_INFO(0, max_len)
 ZEND_END_ARG_INFO()
 
 static
-ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetcsv, 0, 0, 0) 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetcsv, 0, 0, 0)
        ZEND_ARG_INFO(0, delimiter)
        ZEND_ARG_INFO(0, enclosure)
 ZEND_END_ARG_INFO()
@@ -2347,9 +2348,9 @@ PHP_MINIT_FUNCTION(spl_directory)
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "CURRENT_MODE_MASK",   SPL_FILE_DIR_CURRENT_MODE_MASK);
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "CURRENT_AS_PATHNAME", SPL_FILE_DIR_CURRENT_AS_PATHNAME);
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "CURRENT_AS_FILEINFO", SPL_FILE_DIR_CURRENT_AS_FILEINFO);
-       REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "CURRENT_AS_SELF",     0);
+       REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "CURRENT_AS_SELF",     SPL_FILE_DIR_CURRENT_AS_SELF);
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "KEY_MODE_MASK",       SPL_FILE_DIR_KEY_MODE_MASK);
-       REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "KEY_AS_PATHNAME",     0);
+       REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "KEY_AS_PATHNAME",     SPL_FILE_DIR_KEY_AS_PATHNAME);
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "KEY_AS_FILENAME",     SPL_FILE_DIR_KEY_AS_FILENAME);
        REGISTER_SPL_CLASS_CONST_LONG(RecursiveDirectoryIterator, "NEW_CURRENT_AND_KEY", SPL_FILE_DIR_KEY_AS_FILENAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO);
 
@@ -2369,7 +2370,6 @@ PHP_MINIT_FUNCTION(spl_directory)
 }
 /* }}} */
 
-
 /*
  * Local variables:
  * tab-width: 4
index fa4d95251295ced0af34ae0b94b14da86707c3fc..07ac4062fed6056aff3468d9a7159cb8c5b48fcb 100755 (executable)
@@ -93,12 +93,16 @@ struct _spl_filesystem_object {
 #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_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)
 
+#define SPL_FILE_DIR_KEY_AS_PATHNAME       0x00000000 /* make RecursiveDirectoryTree::key() return getPathname() */
 #define SPL_FILE_DIR_KEY_AS_FILENAME       0x00000100 /* make RecursiveDirectoryTree::key() return getFilename() */
 #define SPL_FILE_DIR_KEY_MODE_MASK         0x00000F00 /* mask RecursiveDirectoryTree::key() */
+#define SPL_FILE_DIR_KEY(intern,mode)      ((intern->flags&SPL_FILE_DIR_KEY_MODE_MASK)==mode)
 
 #endif /* SPL_DIRECTORY_H */