php-src/ext/spl/spl.php

1161 lines
32 KiB
PHP
Raw Normal View History

2003-05-01 23:28:28 +00:00
<?php
2004-11-01 17:05:45 +00:00
/** @file spl.php
* @ingroup SPL
* @brief Documentation of internal classes and interfaces
*
* SPL - Standard PHP Library
*
2008-07-23 06:08:07 +00:00
* (c) Marcus Boerger, 2003 - 2008
*/
2004-11-01 17:05:45 +00:00
/** @mainpage SPL - Standard PHP Library
2004-05-06 22:55:25 +00:00
*
* SPL - Standard PHP Library
2003-05-01 23:28:28 +00:00
*
2008-02-04 20:40:47 +00:00
* 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
2004-11-01 18:01:06 +00:00
* examples subdirectory there are also some .php files to experiment with.
2008-02-04 20:40:47 +00:00
*
* 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
2004-11-01 18:01:06 +00:00
* you have to point your ini setting auto_prepend_file to that file.
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* Below is a list of interfaces/classes already availabel natively through
* the SPL extension grouped by category.
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* 1) Iterators
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* SPL offers some advanced iterator algorithms:
2008-02-04 20:40:47 +00:00
*
* - interface RecursiveIterator extends Iterator
2004-11-01 18:01:06 +00:00
* - interface OuterIterator extends Iterator
* - class RecursiveIteratorIterator implements OuterIterator
2008-07-19 15:49:21 +00:00
* - class RecursiveTreeIterator extends RecursiveIteratorIterator
2004-11-01 18:01:06 +00:00
* - abstract class FilterIterator implements OuterIterator
* - class ParentIterator extends FilterIterator implements RecursiveIterator
* - interface SeekableIterator extends Iterator
2004-11-01 18:01:06 +00:00
* - class LimitIterator implements OuterIterator
* - class CachingIterator implements OuterIterator
* - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
2004-11-01 18:01:06 +00:00
* - class IteratorIterator implements OuterIterator
* - class NoRewindIterator implements OuterIterator
* - class EmptyIterator implements Iterator
* - class InfiniteIterator extends IteratorIterator
* - class AppendIterator implements OuterIterator
* - class RegexIterator extends FilterIterator
2006-07-16 23:48:34 +00:00
* - class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
2008-07-23 06:08:07 +00:00
* - class MultipleIterator extends Iterator
2008-02-04 20:40:47 +00:00
*
* 2) Directories and Files
2008-02-04 20:40:47 +00:00
*
* SPL offers two advanced directory and file handling classes:
2008-02-04 20:40:47 +00:00
*
2006-01-14 20:21:10 +00:00
* - class SplFileInfo
* - class DirectoryIterator extends SplFileInfo implements Iterator
2008-07-19 15:49:21 +00:00
* - class FilesystemIterator extends DirectoryIterator
2008-02-04 20:40:47 +00:00
* - class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
* - class GlobIterator extends FilesystemIterator implements Countable
2006-01-14 20:21:10 +00:00
* - class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
2008-02-04 20:40:47 +00:00
* - class SplTempFileObject extends SplFileObject
*
2004-11-01 18:01:06 +00:00
* 3) XML
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* SPL offers an advanced XML handling class:
2008-02-04 20:40:47 +00:00
*
* - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* 4) Array Overloading
2008-02-04 20:40:47 +00:00
*
2004-11-01 18:01:06 +00:00
* SPL offers advanced Array overloading:
2008-02-04 20:40:47 +00:00
*
* - class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
* - class ArrayIterator implements Iterator, ArrayAccess, Countable, SeekableIterator
2005-09-18 17:39:54 +00:00
* - class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
2008-07-23 06:08:07 +00:00
* - class SplFixedArray implements Iterator, ArrayAccess, Countable
2008-02-04 20:40:47 +00:00
*
2005-02-08 20:42:48 +00:00
* As the above suggest an ArrayObject creates an ArrayIterator when it comes to
2008-02-04 20:40:47 +00:00
* iteration (e.g. ArrayObject instance used inside foreach).
2004-11-01 18:01:06 +00:00
*
* 5) Counting
*
2005-02-08 19:05:25 +00:00
* - interface Countable allows to hook into the standard array function count().
2004-11-01 18:01:06 +00:00
*
2005-05-03 12:09:26 +00:00
* 6) Exception%s
2004-11-01 18:01:06 +00:00
*
2008-02-04 20:40:47 +00:00
* SPL provides a set of standard Exception classes each meant to indicate a
2004-11-01 18:01:06 +00:00
* certain problem type.
*
* - class LogicException extends Exception
* - class BadFunctionCallException extends LogicException
* - class BadMethodCallException extends BadFunctionCallException
* - class DomainException extends LogicException
* - class InvalidArgumentException extends LogicException
* - class LengthException extends LogicException
* - class OutOfRangeException extends LogicException
* - class RuntimeException extends Exception
* - class OutOfBoundsException extends RuntimeException
* - class OverflowException extends RuntimeException
* - class RangeException extends RuntimeException
* - class UnderflowException extends RuntimeException
2005-02-08 20:42:48 +00:00
*
* 7) Observer
*
* SPL suggests a standard way of implementing the observer pattern.
*
* - interface SplObserver
* - interface SplSubject
* - class SplObjectStorage
2006-02-20 22:21:54 +00:00
*
* 8) Datastructures
*
* SPL proposes a set of datastructures implemented internally.
*
* - class SplDoublyLinkedList
* - class SplStack extends SplDoublyLinkedList
* - class SplQueue extends SplDoublyLinkedList
*
* 9) @ref Examples
2006-02-20 22:21:54 +00:00
*
2008-02-04 20:40:47 +00:00
* The classes and interfaces in this group are contained as PHP code in the
2006-02-20 22:21:54 +00:00
* examples subdirectory of ext/SPL. Sooner or later they will be moved to
* c-code.
2008-02-04 20:40:47 +00:00
*
* 10) Some articles about SPL:
2006-08-13 10:37:57 +00:00
* - <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>
2005-05-03 12:09:26 +00:00
* - <a href="http://www.ramikayyali.com/archives/2005/02/25/iterators">Iterators in PHP5</a>
* - <a href="http://www.phpriot.com/d/articles/php/oop/oop-with-spl-php-5-1/index.html">Advanced OOP with SPL in PHP 5</a>
* - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-1/">The Standard PHP Library, Part 1</a>
2005-05-03 12:09:26 +00:00
* - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-2/">The Standard PHP Library, Part 2</a>
* - <a href="http://www.professionelle-softwareentwicklung-mit-php5.de/erste_auflage/oop.iterators.spl.html">Die Standard PHP Library (SPL) [german]</a>
*
* 11) Talks on SPL:
2007-04-22 17:13:52 +00:00
* - SPL Update <a href="http://talks.somabo.de/200702_vancouver_spl_update.pps">[pps]</a>, <a href="http://talks.somabo.de/200702_vancouver_spl_update.pdf">[pdf]</a>
* - Happy SPLing <a href="http://talks.somabo.de/200509_toronto_happy_spling.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_happy_spling.pdf">[pdf]</a>
* - From engine overloading to SPL <a href="http://talks.somabo.de/200505_cancun_from_engine_overloading_to_spl.pps">[pps]</a>, <a href="http://talks.somabo.de/200505_cancun_from_engine_overloading_to_spl.pdf">[pdf]</a>
* - SPL for the masses <a href="http://talks.somabo.de/200504_php_quebec_spl_for_the_masses.pps">[pps]</a>, <a href="http://talks.somabo.de/200504_php_quebec_spl_for_the_masses.pdf">[pdf]</a>
*
* 12) Debug sessions:
2007-04-22 17:13:52 +00:00
* - Debug session 1 <a href="200407_oscon_introduction_to_iterators_debug.pps">[pps]</a>, <a href="200407_oscon_introduction_to_iterators_debug.pdf">[pdf]</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>
2004-11-01 15:50:25 +00:00
*
2007-04-22 17:13:52 +00:00
* (c) Marcus Boerger, 2003 - 2007
2003-05-01 23:28:28 +00:00
*/
2004-11-01 15:50:25 +00:00
/** @defgroup ZendEngine Zend engine classes
*
2008-02-04 20:40:47 +00:00
* The classes and interfaces in this group are contained in the c-code of
2004-11-01 15:50:25 +00:00
* PHP's Zend engine.
*/
/** @defgroup SPL Internal classes
2004-05-08 12:26:28 +00:00
*
2008-02-04 20:40:47 +00:00
* The classes and interfaces in this group are contained in the c-code of
2004-05-08 12:26:28 +00:00
* ext/SPL.
*/
2004-11-01 15:50:25 +00:00
/** @defgroup Examples Example classes
2004-05-08 12:26:28 +00:00
*
2008-02-04 20:40:47 +00:00
* The classes and interfaces in this group are contained as PHP code in the
2004-05-08 12:26:28 +00:00
* examples subdirectory of ext/SPL. Sooner or later they will be moved to
* c-code.
*/
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Default implementation for __autoload()
* @since PHP 5.1
*
* @param class_name name of class to load
* @param file_extensions file extensions (use defaults if NULL)
*/
function spl_autoload(string $class_name, string $file_extensions = NULL) {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Manual invocation of all registerd autoload functions
* @since PHP 5.1
*
* @param class_name name of class to load
*/
function spl_autoload_call(string $class_name) {/**/};
2005-11-01 21:48:25 +00:00
2008-02-04 20:40:47 +00:00
/** @ingroup SPL
2005-11-01 21:48:25 +00:00
* @brief Register and return default file extensions for spl_autoload
* @since PHP 5.1
*
2008-02-04 20:40:47 +00:00
* @param file_extensions optional comma separated list of extensions to use in
2005-11-01 21:48:25 +00:00
* default autoload function. If not given just return the current list.
2008-02-04 20:40:47 +00:00
* @return comma separated list of file extensions to use in default autoload
2005-11-01 21:48:25 +00:00
* function.
*/
function spl_autoload_extensions($file_extensions) {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Return all registered autoload functionns
* @since PHP 5.1
*
* @return array of all registered autoload functions or false
*/
function spl_autoload_functions() {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Register given function as autoload implementation
* @since PHP 5.1
*
2008-02-04 20:40:47 +00:00
* @param autoload_function name of function or array of object/class and
2005-11-01 21:48:25 +00:00
* function name to register as autoload function.
* @param throw whether to throw or issue an error on failure.
*/
function spl_autoload_register(string $autoload_function = "spl_autoload", $throw = true) {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Unregister given function as autoload implementation
* @since PHP 5.1
*
2008-02-04 20:40:47 +00:00
* @param autoload_function name of function or array of object/class and
2005-11-01 21:48:25 +00:00
* function name to unregister as autoload function.
*/
function spl_autoload_unregister(string $autoload_function = "spl_autoload") {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Return an array of classes and interfaces in SPL
*
2008-02-04 20:40:47 +00:00
* @return array containing the names of all clsses and interfaces defined in
2005-11-01 21:48:25 +00:00
* extension SPL
*/
function spl_classes() {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Count the elements in an iterator
* @since PHP 5.1
*
* @return number of elements in an iterator
*/
function iterator_count(Traversable $it) {/**/};
2005-11-01 21:48:25 +00:00
/** @ingroup SPL
* @brief Copy iterator elements into an array
* @since PHP 5.1
*
* @param it iterator to copy
2006-11-20 19:58:01 +00:00
* @param use_keys whether touse the keys
2005-11-01 21:48:25 +00:00
* @return array with elements copied from the iterator
*/
2006-11-20 19:58:01 +00:00
function iterator_to_array(Traversable $it, $use_keys = true) {/**/};
2005-11-01 21:48:25 +00:00
2004-11-01 15:50:25 +00:00
/** @ingroup ZendEngine
* @brief Basic Exception class.
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-11-01 15:50:25 +00:00
*/
class Exception
{
/** The exception message */
2008-02-04 20:40:47 +00:00
protected $message;
2013-07-23 23:55:43 +00:00
/** The string representations as generated during construction */
2008-02-04 20:40:47 +00:00
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;
2004-11-01 15:50:25 +00:00
/** Prevent clone
*/
2008-02-04 20:40:47 +00:00
final private function __clone() {}
2004-11-01 15:50:25 +00:00
2004-11-01 16:31:19 +00:00
/** Construct an exception
*
* @param $message Some text describing the exception
* @param $code Some code describing the exception
2004-11-01 15:50:25 +00:00
*/
2004-11-01 16:31:19 +00:00
function __construct($message = NULL, $code = 0) {
if (func_num_args()) {
$this->message = $message;
}
$this->code = $code;
$this->file = __FILE__; // of throw clause
$this->line = __LINE__; // of throw clause
$this->trace = debug_backtrace();
$this->string = StringFormat($this);
2008-02-04 20:40:47 +00:00
}
2004-11-01 15:50:25 +00:00
/** @return the message passed to the constructor
*/
2008-02-04 20:40:47 +00:00
final public function getMessage()
{
return $this->message;
}
2004-11-01 15:50:25 +00:00
/** @return the code passed to the constructor
*/
2008-02-04 20:40:47 +00:00
final public function getCode()
{
return $this->code;
}
2004-11-01 15:50:25 +00:00
/** @return the name of the file where the exception was thrown
*/
2008-02-04 20:40:47 +00:00
final public function getFile()
{
return $this->file;
}
2004-11-01 15:50:25 +00:00
/** @return the line number where the exception was thrown
*/
2008-02-04 20:40:47 +00:00
final public function getLine()
{
return $this->line;
}
2004-11-01 15:50:25 +00:00
/** @return the stack trace as array
*/
2008-02-04 20:40:47 +00:00
final public function getTrace()
{
return $this->trace;
}
2004-11-01 15:50:25 +00:00
/** @return the stack trace as string
*/
2008-02-04 20:40:47 +00:00
final public function getTraceAsString()
{
}
2004-11-01 15:50:25 +00:00
2013-07-23 23:55:43 +00:00
/** @return string representation of exception
2004-11-01 15:50:25 +00:00
*/
2008-02-04 20:40:47 +00:00
public function __toString()
{
return $this->string;
}
2004-11-01 15:50:25 +00:00
}
/** @ingroup SPL
* @brief Exception that represents error in the program logic.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
* This kind of exceptions should directly leed to a fix in your code.
*/
class LogicException extends Exception
{
}
/** @ingroup SPL
* @brief Exception thrown when a function call was illegal.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
*/
class BadFunctionCallException extends LogicException
{
}
/** @ingroup SPL
* @brief Exception thrown when a method call was illegal.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
*/
class BadMethodCallException extends BadFunctionCallException
{
}
2004-11-01 15:50:25 +00:00
/** @ingroup SPL
* @brief Exception that denotes a value not in the valid domain was used.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
2008-02-04 20:40:47 +00:00
* This kind of exception should be used to inform about domain erors in
2004-11-01 15:50:25 +00:00
* mathematical sense.
*
* @see RangeException
2004-11-01 15:50:25 +00:00
*/
class DomainException extends LogicException
{
}
/** @ingroup SPL
* @brief Exception that denotes invalid arguments were passed.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
*
* @see UnexpectedValueException
2004-11-01 15:50:25 +00:00
*/
class InvalidArgumentException extends LogicException
{
}
/** @ingroup SPL
* @brief Exception thrown when a parameter exceeds the allowed length.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
2008-02-04 20:40:47 +00:00
* This can be used for strings length, array size, file size, number of
2004-11-01 15:50:25 +00:00
* elements read from an Iterator and so on.
*/
class LengthException extends LogicException
{
}
/** @ingroup SPL
* @brief Exception thrown when an illegal index was requested.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
* This represents errors that should be detected at compile time.
*
* @see OutOfBoundsException
*/
class OutOfRangeException extends LogicException
{
}
/** @ingroup SPL
2008-02-04 20:40:47 +00:00
* @brief Exception thrown for errors that are only detectable at runtime.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*/
class RuntimeException extends Exception
{
}
/** @ingroup SPL
* @brief Exception thrown when an illegal index was requested.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
* This represents errors that cannot be detected at compile time.
*
* @see OutOfRangeException
*/
2004-11-01 16:31:19 +00:00
class OutOfBoundsException extends RuntimeException
2004-11-01 15:50:25 +00:00
{
}
/** @ingroup SPL
* @brief Exception thrown to indicate arithmetic/buffer overflow.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*/
class OverflowException extends RuntimeException
{
}
/** @ingroup SPL
* @brief Exception thrown to indicate range errors during program execution.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*
* Normally this means there was an arithmetic error other than under/overflow.
* This is the runtime version of DomainException.
*
* @see DomainException
2004-11-01 15:50:25 +00:00
*/
class RangeException extends RuntimeException
{
}
/** @ingroup SPL
* @brief Exception thrown to indicate arithmetic/buffer underflow.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2004-11-01 15:50:25 +00:00
*/
class UnderflowException extends RuntimeException
{
}
/** @ingroup SPL
* @brief Exception thrown to indicate an unexpected value.
* @since PHP 5.1
*
* 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
2008-02-04 20:40:47 +00:00
* or buffer related errors.
*
* @see InvalidArgumentException
*/
class UnexpectedValueException extends RuntimeException
{
}
2004-11-01 17:05:45 +00:00
/** @ingroup ZendEngine
* @brief Interface to override array access of objects.
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-05-06 22:55:25 +00:00
*/
interface ArrayAccess
{
2004-11-01 17:05:45 +00:00
/** @param $offset to modify
* @param $value new value
2004-05-06 22:55:25 +00:00
*/
function offsetSet($offset, $value);
2004-11-01 17:05:45 +00:00
/** @param $offset to retrieve
* @return value at given offset
2004-05-06 22:55:25 +00:00
*/
function offsetGet($offset);
2004-11-01 17:05:45 +00:00
/** @param $offset to delete
2004-05-06 22:55:25 +00:00
*/
function offsetUnset($offset);
2004-11-01 17:05:45 +00:00
/** @param $offset to check
* @return whether the offset exists.
2004-05-06 22:55:25 +00:00
*/
function offsetExists($offset);
}
2004-11-01 17:05:45 +00:00
/** @ingroup ZendEngine
* @brief Interface to detect a class is traversable using foreach.
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-05-08 12:26:28 +00:00
*
* Abstract base interface that cannot be implemented alone. Instead it
2008-02-04 20:40:47 +00:00
* must be implemented by either IteratorAggregate or Iterator.
2003-06-09 16:58:51 +00:00
*
2008-02-04 20:40:47 +00:00
* @note Internal classes that implement this interface can be used in a
2003-12-04 19:39:46 +00:00
* foreach construct and do not need to implement IteratorAggregate or
* Iterator.
2004-01-29 00:10:33 +00:00
*
2004-11-01 17:05:45 +00:00
* @note This is an engine internal interface which cannot be implemented
2008-02-04 20:40:47 +00:00
* in PHP scripts. Either IteratorAggregate or Iterator must be used
2004-05-06 21:20:50 +00:00
* instead.
2003-06-09 16:58:51 +00:00
*/
2004-01-29 00:10:33 +00:00
interface Traversable
{
2003-06-09 16:58:51 +00:00
}
2003-05-01 23:28:28 +00:00
2004-11-01 17:05:45 +00:00
/** @ingroup ZendEngine
* @brief Interface to create an external Iterator.
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-01-29 00:10:33 +00:00
*
2004-11-01 17:05:45 +00:00
* @note This is an engine internal interface.
2008-02-04 20:40:47 +00:00
*/
interface IteratorAggregate extends Traversable
2004-01-29 00:10:33 +00:00
{
2004-11-01 17:05:45 +00:00
/** @return an Iterator for the implementing object.
2003-06-09 16:58:51 +00:00
*/
2003-12-04 19:39:46 +00:00
function getIterator();
2003-06-09 16:58:51 +00:00
}
2003-05-01 23:28:28 +00:00
2004-11-01 17:05:45 +00:00
/** @ingroup ZendEngine
* @brief Basic iterator
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-05-08 12:26:28 +00:00
*
2008-02-04 20:40:47 +00:00
* Interface for external iterators or objects that can be iterated
2003-12-04 19:39:46 +00:00
* themselves internally.
2004-01-29 00:10:33 +00:00
*
2004-11-01 17:05:45 +00:00
* @note This is an engine internal interface.
2003-06-09 16:58:51 +00:00
*/
interface Iterator extends Traversable
2004-01-29 00:10:33 +00:00
{
2003-12-04 19:39:46 +00:00
/** Rewind the Iterator to the first element.
2003-06-09 16:58:51 +00:00
*/
function rewind();
2003-12-04 19:39:46 +00:00
/** Return the current element.
*/
function current();
/** Return the key of the current element.
2003-05-01 23:28:28 +00:00
*/
2003-06-09 16:58:51 +00:00
function key();
2003-05-01 23:28:28 +00:00
2003-12-04 19:39:46 +00:00
/** Move forward to next element.
*/
function next();
2003-05-01 23:28:28 +00:00
2003-12-04 19:39:46 +00:00
/** Check if there is a current element after calls to rewind() or next().
*/
function valid();
2003-06-09 16:58:51 +00:00
}
/** @ingroup SPL
* @brief This Interface allows to hook into the global count() function.
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
*/
interface Countable
{
/** @return the number the global function count() should show
*/
function count();
}
/** @ingroup ZendEngine
* @brief Interface for customized serializing
* @since 5.1
2008-02-04 20:40:47 +00:00
*
* 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
* the class is known and the appropriate unserialize() method is called as a
* constructor instead of calling __construct(). If you need to execute the
* standard constructor you may do so in the method.
*/
interface Serializable
{
/**
* @return string representation of the instance
*/
function serialize();
2008-02-04 20:40:47 +00:00
/**
* @note This is a constructor
2008-02-04 20:40:47 +00:00
*
* @param $serialized data read from stream to construct the instance
*/
function unserialize($serialized);
}
2004-11-01 17:05:45 +00:00
/** @ingroup SPL
* @brief An Array wrapper
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2006-01-14 20:21:10 +00:00
* @version 1.2
*
2008-02-04 20:40:47 +00:00
* This array wrapper allows to recursively iterate over Arrays and public
2004-04-26 21:34:45 +00:00
* Object properties.
*
2004-11-01 17:05:45 +00:00
* @see ArrayIterator
*/
class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
2004-01-29 00:10:33 +00:00
{
/** Properties of the object have their normal functionality
* when accessed as list (var_dump, foreach, etc.) */
2005-09-18 17:39:54 +00:00
const STD_PROP_LIST = 0x00000001;
/** Array indices can be accessed as properties in read/write */
2005-09-18 17:39:54 +00:00
const ARRAY_AS_PROPS = 0x00000002;
2003-12-04 19:39:46 +00:00
/** Construct a new array iterator from anything that has a hash table.
* That is any Array or Object.
*
2004-11-01 17:05:45 +00:00
* @param $array the array to use.
2005-09-02 19:11:10 +00:00
* @param $flags see setFlags().
2005-09-18 17:39:54 +00:00
* @param $iterator_class class used in getIterator()
*/
function __construct($array, $flags = 0, $iterator_class = "ArrayIterator") {/**/}
2005-09-02 19:11:10 +00:00
/** Set behavior flags.
2008-02-04 20:40:47 +00:00
*
2005-09-02 19:11:10 +00:00
* @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) {/**/}
2008-02-04 20:40:47 +00:00
/** @return current flags
2005-09-02 19:11:10 +00:00
*/
function getFlags() {/**/}
2005-09-02 19:11:10 +00:00
/** Sort the entries by values.
*/
function asort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by key.
2005-09-02 19:11:10 +00:00
*/
function ksort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using user defined function.
*/
function uasort(mixed cmp_function) {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by key using user defined function.
*/
function uksort(mixed cmp_function) {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using "natural order" algorithm.
*/
function natsort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using case insensitive "natural order" algorithm.
*/
function natcasesort() {/**/}
2008-02-04 20:40:47 +00:00
/** @param $array new array or object
*/
function exchangeArray($array) {/**/}
2004-11-01 17:05:45 +00:00
/** @return the iterator which is an ArrayIterator object connected to
2004-04-26 21:34:45 +00:00
* this object.
*/
function getIterator() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to inspect
* @return whetehr offset $index esists
2008-02-04 20:40:47 +00:00
*/
function offsetExists($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to return value for
* @return value at offset $index
2008-02-04 20:40:47 +00:00
*/
function offsetGet($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index index to set
* @param $newval new value to store at offset $index
2008-02-04 20:40:47 +00:00
*/
function offsetSet($index, $newval) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to unset
2008-02-04 20:40:47 +00:00
*/
function offsetUnset($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $value is appended as last element
2008-02-04 20:40:47 +00:00
* @warning this method cannot be called when the ArrayObject refers to
* an object.
2008-02-04 20:40:47 +00:00
*/
function append($value) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return a \b copy of the array
2008-02-04 20:40:47 +00:00
* @note when the ArrayObject refers to an object then this method
* returns an array of the public properties.
2008-02-04 20:40:47 +00:00
*/
function getArrayCopy() {/**/}
2004-05-06 21:20:50 +00:00
2004-11-01 17:05:45 +00:00
/** @return the number of elements in the array or the number of public
2004-05-06 21:20:50 +00:00
* properties in the object.
*/
function count() {/**/}
2008-02-04 20:40:47 +00:00
2005-09-18 17:39:54 +00:00
/* @param $iterator_class new class used in getIterator()
*/
function setIteratorClass($itertor_class) {/**/}
2008-02-04 20:40:47 +00:00
2005-09-18 17:39:54 +00:00
/* @return class used in getIterator()
*/
function getIteratorClass() {/**/}
}
2004-11-01 17:05:45 +00:00
/** @ingroup SPL
* @brief An Array iterator
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
* @version 1.2
*
* This iterator allows to unset and modify values and keys while iterating
* over Arrays and Objects.
*
2008-02-04 20:40:47 +00:00
* 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()
2004-04-26 21:34:45 +00:00
* method manually.
*/
2004-11-01 17:05:45 +00:00
class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
2004-01-29 00:10:33 +00:00
{
/** Properties of the object have their normal functionality
* when accessed as list (var_dump, foreach, etc.) */
const STD_PROP_LIST = 0x00000001;
/** Array indices can be accessed as properties in read/write */
const ARRAY_AS_PROPS = 0x00000002;
2003-12-04 19:39:46 +00:00
/** Construct a new array iterator from anything that has a hash table.
* That is any Array or Object.
*
2004-11-01 17:05:45 +00:00
* @param $array the array to use.
2005-09-02 19:11:10 +00:00
* @param $flags see setFlags().
*/
function __construct($array, $flags = 0) {/**/}
2005-09-02 19:11:10 +00:00
/** Set behavior flags.
2008-02-04 20:40:47 +00:00
*
2005-09-02 19:11:10 +00:00
* @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) {/**/}
2006-01-14 20:21:10 +00:00
2005-09-02 19:11:10 +00:00
/**
* @return current flags
*/
function getFlags() {/**/}
2004-04-26 21:34:45 +00:00
/** Sort the entries by values.
*/
function asort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by key.
*/
function ksort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using user defined function.
*/
function uasort(mixed cmp_function) {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by key using user defined function.
*/
function uksort(mixed cmp_function) {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using "natural order" algorithm.
*/
function natsort() {/**/}
2008-02-04 20:40:47 +00:00
/** Sort the entries by values using case insensitive "natural order" algorithm.
*/
function natcasesort() {/**/}
2008-02-04 20:40:47 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to inspect
* @return whetehr offset $index esists
2008-02-04 20:40:47 +00:00
*/
function offsetExists($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to return value for
* @return value at offset $index
2008-02-04 20:40:47 +00:00
*/
function offsetGet($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index index to set
* @param $newval new value to store at offset $index
2008-02-04 20:40:47 +00:00
*/
function offsetSet($index, $newval) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $index offset to unset
2008-02-04 20:40:47 +00:00
*/
function offsetUnset($index) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $value is appended as last element
2008-02-04 20:40:47 +00:00
* @warning this method cannot be called when the ArrayIterator refers to
* an object.
2008-02-04 20:40:47 +00:00
*/
function append($value) {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return a \b copy of the array
2008-02-04 20:40:47 +00:00
* @note when the ArrayIterator refers to an object then this method
* returns an array of the public properties.
2008-02-04 20:40:47 +00:00
*/
function getArrayCopy() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @param $position offset to seek to
2005-03-01 23:44:05 +00:00
* @throw OutOfBoundsException if $position is invalid
2004-04-26 21:34:45 +00:00
*/
function seek($position) {/**/}
2003-12-04 19:39:46 +00:00
2004-11-01 17:05:45 +00:00
/** @return the number of elements in the array or the number of public
2004-05-06 21:20:50 +00:00
* properties in the object.
*/
function count() {/**/}
/** @copydoc Iterator::rewind */
function rewind() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::valid */
function valid() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::current */
function current() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::key */
function key() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::next */
function next() {/**/}
2004-05-06 21:20:50 +00:00
}
2004-11-01 17:05:45 +00:00
/** @ingroup SPL
2006-01-14 20:21:10 +00:00
* @brief File info class
* @since PHP 5.1.3
*/
2008-02-04 20:40:47 +00:00
class SplFileInfo
2004-01-29 00:10:33 +00:00
{
2006-01-14 20:21:10 +00:00
/** Construct a file info object
*
2006-01-14 20:21:10 +00:00
* @param $file_name path or file name
*/
function __construct($file_name) {/**/}
2006-01-14 20:21:10 +00:00
/** @return the path part only.
2003-12-04 19:39:46 +00:00
*/
2008-02-04 20:40:47 +00:00
function getPath() {/**/}
2003-12-04 19:39:46 +00:00
2006-01-14 20:21:10 +00:00
/** @return the filename only.
2003-12-04 19:39:46 +00:00
*/
2008-02-04 20:40:47 +00:00
function getFilename() {/**/}
2003-12-04 19:39:46 +00:00
2006-01-14 20:21:10 +00:00
/** @return SplFileInfo created for the file
* @param class_name name of class to instantiate
* @see SplFileInfo::setInfoClass()
*/
function getFileInfo(string class_name = NULL) {/**/}
2006-01-14 20:21:10 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entries path and file name.
*/
2008-02-04 20:40:47 +00:00
function getPathname() {/**/}
2003-12-04 19:39:46 +00:00
2006-01-14 20:21:10 +00:00
/** @return SplFileInfo created for the path
* @param class_name name of class to instantiate
* @see SplFileInfo::setInfoClass()
*/
function getPathInfo(string class_name = NULL) {/**/}
2006-01-14 20:21:10 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's permissions.
2004-04-26 21:34:45 +00:00
*/
function getPerms() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's inode.
2004-04-26 21:34:45 +00:00
*/
function getInode() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's size in bytes .
2004-04-26 21:34:45 +00:00
*/
function getSize() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's owner name.
2004-04-26 21:34:45 +00:00
*/
function getOwner() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's group name.
2004-04-26 21:34:45 +00:00
*/
function getGroup() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's last access time.
2004-04-26 21:34:45 +00:00
*/
function getATime() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's last modification time.
2004-04-26 21:34:45 +00:00
*/
function getMTime() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return The current entry's last change time.
2004-04-26 21:34:45 +00:00
*/
function getCTime() {/**/}
2004-04-26 21:34:45 +00:00
/** @return The current entry's file type.
2004-04-26 21:34:45 +00:00
*/
function getType() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return Whether the current entry is writeable.
2004-04-26 21:34:45 +00:00
*/
function isWritable() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return Whether the current entry is readable.
2004-04-26 21:34:45 +00:00
*/
function isReadable() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return Whether the current entry is executable.
2004-04-26 21:34:45 +00:00
*/
function isExecutable() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return Whether the current entry is .
2004-04-26 21:34:45 +00:00
*/
function isFile() {/**/}
2004-04-26 21:34:45 +00:00
2004-11-01 17:05:45 +00:00
/** @return Whether the current entry is a directory.
2003-12-04 19:39:46 +00:00
*/
2008-02-04 20:40:47 +00:00
function isDir() {/**/}
2003-12-04 19:39:46 +00:00
2004-11-01 17:05:45 +00:00
/** @return whether the current entry is a link.
2004-04-26 21:34:45 +00:00
*/
function isLink() {/**/}
2004-04-26 21:34:45 +00:00
2007-04-22 17:13:52 +00:00
/** @return target of link.
*/
function getLinkTarget() {/**/}
/** @return The resolved path
*/
function getRealPath() {/**/}
2008-02-04 20:40:47 +00:00
2006-01-14 20:21:10 +00:00
/** @return getPathname()
2004-04-26 21:34:45 +00:00
*/
function __toString() {/**/}
/** Open the current file as a SplFileObject instance
*
* @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
2008-02-04 20:40:47 +00:00
* @throw RuntimeException if file cannot be opened (e.g. insufficient
* access rights).
* @return The opened file as a SplFileObject instance
*
* @see SplFileObject
2006-01-14 20:21:10 +00:00
* @see SplFileInfo::setFileClass()
* @see file()
*/
function openFile($mode = 'r', $use_include_path = false, $context = NULL) {/**/}
2006-01-14 20:21:10 +00:00
2008-02-04 20:40:47 +00:00
/** @param class_name name of class used with openFile(). Must be derived
2006-01-14 20:21:10 +00:00
* from SPLFileObject.
*/
function setFileClass(string class_name = "SplFileObject") {/**/}
2006-01-14 20:21:10 +00:00
/** @param class_name name of class used with getFileInfo(), getPathInfo().
* Must be derived from SplFileInfo.
2006-01-14 20:21:10 +00:00
*/
function setInfoClass(string class_name = "SplFileInfo") {/**/}
2006-01-14 20:21:10 +00:00
}
/** @ingroup SPL
* @brief Directory iterator
* @version 1.1
* @since PHP 5.0
*/
class DirectoryIterator extends SplFileInfo implements Iterator
{
/** Construct a directory iterator from a path-string.
*
* @param $path directory to iterate.
*/
function __construct($path) {/**/}
2006-01-14 20:21:10 +00:00
/** @copydoc Iterator::rewind */
function rewind() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::valid */
function valid() {/**/}
2008-02-04 20:40:47 +00:00
2006-01-14 20:21:10 +00:00
/** @return index of entry
*/
function key() {/**/}
2006-01-14 20:21:10 +00:00
/** @return $this
*/
function current() {/**/}
/** @copydoc Iterator::next */
function next() {/**/}
2006-01-14 20:21:10 +00:00
/** @return Whether the current entry is either '.' or '..'.
*/
2008-02-04 20:40:47 +00:00
function isDot() {/**/}
2006-01-14 20:21:10 +00:00
/** @return whether the current entry is a link.
*/
function isLink() {/**/}
2006-01-14 20:21:10 +00:00
/** @return getFilename()
*/
function __toString() {/**/}
}
2003-12-04 19:39:46 +00:00
2004-11-01 17:05:45 +00:00
/** @ingroup SPL
* @brief recursive directory iterator
2006-01-14 20:21:10 +00:00
* @version 1.1
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2003-12-04 19:39:46 +00:00
*/
2004-01-29 00:10:33 +00:00
class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
{
const CURRENT_AS_FILEINFO 0x00000000; /* make RecursiveDirectoryTree::current() return SplFileInfo */
const CURRENT_AS_SELF 0x00000010; /* make RecursiveDirectoryTree::current() return getSelf() */
2008-02-04 20:40:47 +00:00
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 */
2006-01-14 20:21:10 +00:00
/** Construct a directory iterator from a path-string.
*
* @param $path directory to iterate.
* @param $flags open flags
* - CURRENT_AS_FILEINFO
2008-02-04 20:40:47 +00:00
* - CURRENT_AS_SELF
* - CURRENT_AS_PATHNAME
* - KEY_AS_PATHNAME
2006-01-14 20:21:10 +00:00
* - KEY_AS_FILENAME
2008-02-04 20:40:47 +00:00
* - NEW_CURRENT_AND_KEY
2006-01-14 20:21:10 +00:00
*/
function __construct($path, $flags = 0) {/**/}
2006-01-14 20:21:10 +00:00
/** @return getPathname() or getFilename() depending on flags
*/
function key() {/**/}
2006-01-14 20:21:10 +00:00
/** @return getFilename() or getFileInfo() depending on flags
*/
function current() {/**/}
2006-01-14 20:21:10 +00:00
2004-11-01 17:05:45 +00:00
/** @return whether the current is a directory (not '.' or '..').
2003-12-04 19:39:46 +00:00
*/
2008-02-04 20:40:47 +00:00
function hasChildren() {/**/}
2003-12-04 19:39:46 +00:00
2004-11-01 17:05:45 +00:00
/** @return a RecursiveDirectoryIterator for the current entry.
2003-12-04 19:39:46 +00:00
*/
2008-02-04 20:40:47 +00:00
function getChildren() {/**/}
2006-01-14 20:21:10 +00:00
/** @return sub path only (without main path)
*/
function getSubPath() {/**/}
2006-01-14 20:21:10 +00:00
/** @return the current sub path
*/
function getSubPathname() {/**/}
2004-01-29 00:10:33 +00:00
}
2004-11-01 17:05:45 +00:00
/** @ingroup SPL
* @brief recursive SimpleXML_Element iterator
2005-02-17 00:24:57 +00:00
* @since PHP 5.0
2004-08-29 10:33:24 +00:00
*
2008-02-04 20:40:47 +00:00
* 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
* has subelements, hasChildren() returns true. This will trigger a call to
* getChildren() which returns the iterator for that sub element.
2004-01-29 00:10:33 +00:00
*/
class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, Countable
2004-01-29 00:10:33 +00:00
{
2004-11-01 17:05:45 +00:00
/** @return whether the current node has sub nodes.
2004-01-29 00:10:33 +00:00
*/
2008-02-04 20:40:47 +00:00
function hasChildren() {/**/}
2004-01-29 00:10:33 +00:00
2004-11-01 17:05:45 +00:00
/** @return a SimpleXMLIterator for the current node.
2004-01-29 00:10:33 +00:00
*/
2008-02-04 20:40:47 +00:00
function getChildren() {/**/}
/** @return number of elements/attributes seen with foreach()
*/
function count() {/**/}
/** @copydoc Iterator::rewind */
function rewind() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::valid */
function valid() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::current */
function current() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::key */
function key() {/**/}
2008-02-04 20:40:47 +00:00
/** @copydoc Iterator::next */
function next() {/**/}
2003-12-04 19:39:46 +00:00
}
2005-02-08 20:42:48 +00:00
/** @ingroup SPL
2005-09-18 17:52:09 +00:00
* @brief Observer of the observer pattern
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2005-02-08 20:42:48 +00:00
*
* For a detailed explanation see Observer pattern in
* <em>
* Gamma, Helm, Johnson, Vlissides<br />
* Design Patterns
* </em>
*/
2005-09-18 17:52:09 +00:00
interface SplObserver
2005-02-08 20:42:48 +00:00
{
/** Called from the subject (i.e. when it's value has changed).
* @param $subject the callee
2008-07-19 15:49:21 +00:00
*/
2005-09-18 17:52:09 +00:00
function update(SplSubject $subject);
2005-02-08 20:42:48 +00:00
}
/** @ingroup SPL
2005-09-18 17:52:09 +00:00
* @brief Subject to the observer pattern
2005-02-17 00:24:57 +00:00
* @since PHP 5.1
2005-02-08 20:42:48 +00:00
* @see Observer
*/
2005-09-18 17:52:09 +00:00
interface SplSubject
2005-02-08 20:42:48 +00:00
{
/** @param $observer new observer to attach
*/
2008-02-04 20:40:47 +00:00
function attach(SplObserver $observer);
2005-02-08 20:42:48 +00:00
/** @param $observer existing observer to detach
* @note a non attached observer shouldn't result in a warning or similar
*/
2008-02-04 20:40:47 +00:00
function detach(SplObserver $observer);
2005-02-08 20:42:48 +00:00
2005-02-17 00:16:00 +00:00
/** Notify all observers
2005-02-08 20:42:48 +00:00
*/
2008-02-04 20:40:47 +00:00
function notify();
2005-02-08 20:42:48 +00:00
}
?>