*
* 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
*
*
* 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.
*/
*/
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) {/**/};
* @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.
*/
* @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") {/**/};
/** @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() {/**/};
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
*
$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
* @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
* @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
}
/** @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
*
* 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
*/
* @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
* @since PHP 5.0
*
* @note This is an engine internal interface.
- */
+ */
interface IteratorAggregate extends Traversable
{
/** @return an Iterator for the implementing object.
* @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.
/** @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
* @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);
* @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
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() {/**/}
/** 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) {/**/}
/** @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() {/**/}
* 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
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.)
/** 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
/** @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() {/**/}
}
* @brief File info class
* @since PHP 5.1.3
*/
-class SplFileInfo
+class SplFileInfo
{
/** Construct a file info object
*
/** @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
/** @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
/** @return Whether the current entry is a directory.
*/
- function isDir() {/**/}
+ function isDir() {/**/}
/** @return whether the current entry is a link.
*/
/** @return The resolved path
*/
function getRealPath() {/**/}
-
+
/** @return getPathname()
*/
function __toString() {/**/}
* @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
*
*/
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") {/**/}
/** @copydoc Iterator::rewind */
function rewind() {/**/}
-
+
/** @copydoc Iterator::valid */
function valid() {/**/}
-
+
/** @return index of entry
*/
function key() {/**/}
/** @return Whether the current entry is either '.' or '..'.
*/
- function isDot() {/**/}
+ function isDot() {/**/}
/** @return whether the current entry is a link.
*/
*/
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) {/**/}
/** @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)
*/
* @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
{
/** @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()
*/
/** @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() {/**/}
}
{
/** @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();
}
?>
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);
}
{
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);
{
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 {
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);
}
/* }}} */
-/* define an overloaded iterator structure */
+/* {{{ define an overloaded iterator structure */
typedef struct {
zend_object_iterator intern;
zval *current;
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)
efree(iterator);
}
/* }}} */
-
+
/* {{{ spl_filesystem_dir_it_valid */
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)
{
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);
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 {
}
/* }}} */
-/* 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,
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)
}
/* }}} */
-/* declare method parameters */
+/* {{{ declare method parameters */
/* supply a name and default to call by parameter */
static
ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0)
};
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()
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) /* {{{ */
{
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) /* {{{ */
{
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;
RETURN_BOOL(!php_stream_flush(intern->u.file.stream));
} /* }}} */
-
/* {{{ proto int SplFileObject::ftell()
Return current file position */
SPL_METHOD(SplFileObject, ftell)
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()
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);
}
/* }}} */
-
/*
* Local variables:
* tab-width: 4