You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1163 lines
32 KiB

23 years ago
22 years ago
22 years ago
22 years ago
23 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
20 years ago
18 years ago
18 years ago
18 years ago
20 years ago
18 years ago
20 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
18 years ago
22 years ago
18 years ago
22 years ago
18 years ago
18 years ago
18 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
20 years ago
20 years ago
18 years ago
20 years ago
18 years ago
20 years ago
19 years ago
19 years ago
18 years ago
19 years ago
23 years ago
18 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
21 years ago
21 years ago
21 years ago
18 years ago
21 years ago
18 years ago
21 years ago
18 years ago
21 years ago
21 years ago
21 years ago
18 years ago
21 years ago
21 years ago
18 years ago
21 years ago
21 years ago
18 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
18 years ago
18 years ago
22 years ago
22 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
18 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
23 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
23 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
23 years ago
23 years ago
23 years ago
18 years ago
18 years ago
18 years ago
22 years ago
20 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
21 years ago
21 years ago
18 years ago
21 years ago
18 years ago
21 years ago
21 years ago
18 years ago
21 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
18 years ago
22 years ago
22 years ago
18 years ago
18 years ago
22 years ago
18 years ago
18 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
21 years ago
21 years ago
18 years ago
21 years ago
20 years ago
21 years ago
22 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
18 years ago
18 years ago
22 years ago
22 years ago
18 years ago
18 years ago
22 years ago
22 years ago
21 years ago
22 years ago
22 years ago
18 years ago
18 years ago
18 years ago
18 years ago
22 years ago
20 years ago
18 years ago
22 years ago
20 years ago
20 years ago
20 years ago
18 years ago
20 years ago
18 years ago
20 years ago
20 years ago
22 years ago
18 years ago
20 years ago
20 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
19 years ago
18 years ago
20 years ago
22 years ago
18 years ago
20 years ago
20 years ago
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
20 years ago
18 years ago
18 years ago
20 years ago
20 years ago
20 years ago
18 years ago
20 years ago
20 years ago
22 years ago
20 years ago
22 years ago
18 years ago
20 years ago
18 years ago
20 years ago
18 years ago
20 years ago
20 years ago
20 years ago
20 years ago
22 years ago
18 years ago
22 years ago
18 years ago
20 years ago
20 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
22 years ago
18 years ago
22 years ago
22 years ago
22 years ago
18 years ago
18 years ago
18 years ago
18 years ago
18 years ago
21 years ago
21 years ago
21 years ago
21 years ago
21 years ago
18 years ago
18 years ago
18 years ago
  1. <?php
  2. /** @file spl.php
  3. * @ingroup SPL
  4. * @brief Documentation of internal classes and interfaces
  5. *
  6. * SPL - Standard PHP Library
  7. *
  8. * (c) Marcus Boerger, 2003 - 2008
  9. */
  10. /** @mainpage SPL - Standard PHP Library
  11. *
  12. * SPL - Standard PHP Library
  13. *
  14. * SPL is a collection of interfaces and classes that are meant to solve
  15. * standard problems and implements some efficient data access interfaces
  16. * and classes. You'll find the classes documented using php code in the
  17. * file spl.php or in corresponding .inc files in subdirectories examples
  18. * and internal. Based on the internal implementations or the files in the
  19. * examples subdirectory there are also some .php files to experiment with.
  20. *
  21. * The .inc files are not included automatically because they are sooner or
  22. * later integrated into the extension. That means that you either need to
  23. * put the code of examples/autoload.inc into your autoprepend file or that
  24. * you have to point your ini setting auto_prepend_file to that file.
  25. *
  26. * Below is a list of interfaces/classes already availabel natively through
  27. * the SPL extension grouped by category.
  28. *
  29. * 1) Iterators
  30. *
  31. * SPL offers some advanced iterator algorithms:
  32. *
  33. * - interface RecursiveIterator extends Iterator
  34. * - interface OuterIterator extends Iterator
  35. * - class RecursiveIteratorIterator implements OuterIterator
  36. * - class RecursiveTreeIterator extends RecursiveIteratorIterator
  37. * - abstract class FilterIterator implements OuterIterator
  38. * - class ParentIterator extends FilterIterator implements RecursiveIterator
  39. * - interface SeekableIterator extends Iterator
  40. * - class LimitIterator implements OuterIterator
  41. * - class CachingIterator implements OuterIterator
  42. * - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
  43. * - class IteratorIterator implements OuterIterator
  44. * - class NoRewindIterator implements OuterIterator
  45. * - class EmptyIterator implements Iterator
  46. * - class InfiniteIterator extends IteratorIterator
  47. * - class AppendIterator implements OuterIterator
  48. * - class RegexIterator extends FilterIterator
  49. * - class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
  50. * - class MultipleIterator extends Iterator
  51. *
  52. * 2) Directories and Files
  53. *
  54. * SPL offers two advanced directory and file handling classes:
  55. *
  56. * - class SplFileInfo
  57. * - class DirectoryIterator extends SplFileInfo implements Iterator
  58. * - class FilesystemIterator extends DirectoryIterator
  59. * - class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
  60. * - class GlobIterator extends FilesystemIterator implements Countable
  61. * - class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
  62. * - class SplTempFileObject extends SplFileObject
  63. *
  64. * 3) XML
  65. *
  66. * SPL offers an advanced XML handling class:
  67. *
  68. * - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
  69. *
  70. * 4) Array Overloading
  71. *
  72. * SPL offers advanced Array overloading:
  73. *
  74. * - class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
  75. * - class ArrayIterator implements Iterator, ArrayAccess, Countable, SeekableIterator
  76. * - class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
  77. * - class SplFixedArray implements Iterator, ArrayAccess, Countable
  78. *
  79. * As the above suggest an ArrayObject creates an ArrayIterator when it comes to
  80. * iteration (e.g. ArrayObject instance used inside foreach).
  81. *
  82. * 5) Counting
  83. *
  84. * - interface Countable allows to hook into the standard array function count().
  85. *
  86. * 6) Exception%s
  87. *
  88. * SPL provides a set of standard Exception classes each meant to indicate a
  89. * certain problem type.
  90. *
  91. * - class LogicException extends Exception
  92. * - class BadFunctionCallException extends LogicException
  93. * - class BadMethodCallException extends BadFunctionCallException
  94. * - class DomainException extends LogicException
  95. * - class InvalidArgumentException extends LogicException
  96. * - class LengthException extends LogicException
  97. * - class OutOfRangeException extends LogicException
  98. * - class RuntimeException extends Exception
  99. * - class OutOfBoundsException extends RuntimeException
  100. * - class OverflowException extends RuntimeException
  101. * - class RangeException extends RuntimeException
  102. * - class UnderflowException extends RuntimeException
  103. *
  104. * 7) Observer
  105. *
  106. * SPL suggests a standard way of implementing the observer pattern.
  107. *
  108. * - interface SplObserver
  109. * - interface SplSubject
  110. * - class SplObjectStorage
  111. *
  112. * 8) Datastructures
  113. *
  114. * SPL proposes a set of datastructures implemented internally.
  115. *
  116. * - class SplDoublyLinkedList
  117. * - class SplStack extends SplDoublyLinkedList
  118. * - class SplQueue extends SplDoublyLinkedList
  119. *
  120. * 9) @ref Examples
  121. *
  122. * The classes and interfaces in this group are contained as PHP code in the
  123. * examples subdirectory of ext/SPL. Sooner or later they will be moved to
  124. * c-code.
  125. *
  126. * 10) Some articles about SPL:
  127. * - <a href="http://www.phpro.org/tutorials/Introduction-to-SPL.html">Introduction to Standard PHP Library (SPL)</a>
  128. * - <a href="http://www.sitepoint.com/article/php5-standard-library/1">Introducing PHP 5's Standard Library</a>
  129. * - <a href="http://www.ramikayyali.com/archives/2005/02/25/iterators">Iterators in PHP5</a>
  130. * - <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>
  131. * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-1/">The Standard PHP Library, Part 1</a>
  132. * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-2/">The Standard PHP Library, Part 2</a>
  133. * - <a href="http://www.professionelle-softwareentwicklung-mit-php5.de/erste_auflage/oop.iterators.spl.html">Die Standard PHP Library (SPL) [german]</a>
  134. *
  135. * 11) Talks on SPL:
  136. * - 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>
  137. * - 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>
  138. * - 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>
  139. * - 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>
  140. *
  141. * 12) Debug sessions:
  142. * - 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>
  143. * - 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>
  144. * - 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>
  145. *
  146. * You can download this documentation as a chm file
  147. * <a href="http://php.net/~helly/php/ext/spl/spl.chm">here</a>.
  148. *
  149. * (c) Marcus Boerger, 2003 - 2007
  150. */
  151. /** @defgroup ZendEngine Zend engine classes
  152. *
  153. * The classes and interfaces in this group are contained in the c-code of
  154. * PHP's Zend engine.
  155. */
  156. /** @defgroup SPL Internal classes
  157. *
  158. * The classes and interfaces in this group are contained in the c-code of
  159. * ext/SPL.
  160. */
  161. /** @defgroup Examples Example classes
  162. *
  163. * The classes and interfaces in this group are contained as PHP code in the
  164. * examples subdirectory of ext/SPL. Sooner or later they will be moved to
  165. * c-code.
  166. */
  167. /** @ingroup SPL
  168. * @brief Default implementation for __autoload()
  169. * @since PHP 5.1
  170. *
  171. * @param class_name name of class to load
  172. * @param file_extensions file extensions (use defaults if NULL)
  173. */
  174. function spl_autoload(string $class_name, string $file_extensions = NULL) {/**/};
  175. /** @ingroup SPL
  176. * @brief Manual invocation of all registerd autoload functions
  177. * @since PHP 5.1
  178. *
  179. * @param class_name name of class to load
  180. */
  181. function spl_autoload_call(string $class_name) {/**/};
  182. /** @ingroup SPL
  183. * @brief Register and return default file extensions for spl_autoload
  184. * @since PHP 5.1
  185. *
  186. * @param file_extensions optional comma separated list of extensions to use in
  187. * default autoload function. If not given just return the current list.
  188. * @return comma separated list of file extensions to use in default autoload
  189. * function.
  190. */
  191. function spl_autoload_extensions($file_extensions) {/**/};
  192. /** @ingroup SPL
  193. * @brief Return all registered autoload functionns
  194. * @since PHP 5.1
  195. *
  196. * @return array of all registered autoload functions or false
  197. */
  198. function spl_autoload_functions() {/**/};
  199. /** @ingroup SPL
  200. * @brief Register given function as autoload implementation
  201. * @since PHP 5.1
  202. *
  203. * @param autoload_function name of function or array of object/class and
  204. * function name to register as autoload function.
  205. * @param throw whether to throw or issue an error on failure.
  206. */
  207. function spl_autoload_register(string $autoload_function = "spl_autoload", $throw = true) {/**/};
  208. /** @ingroup SPL
  209. * @brief Unregister given function as autoload implementation
  210. * @since PHP 5.1
  211. *
  212. * @param autoload_function name of function or array of object/class and
  213. * function name to unregister as autoload function.
  214. */
  215. function spl_autoload_unregister(string $autoload_function = "spl_autoload") {/**/};
  216. /** @ingroup SPL
  217. * @brief Return an array of classes and interfaces in SPL
  218. *
  219. * @return array containing the names of all clsses and interfaces defined in
  220. * extension SPL
  221. */
  222. function spl_classes() {/**/};
  223. /** @ingroup SPL
  224. * @brief Count the elements in an iterator
  225. * @since PHP 5.1
  226. *
  227. * @return number of elements in an iterator
  228. */
  229. function iterator_count(Traversable $it) {/**/};
  230. /** @ingroup SPL
  231. * @brief Copy iterator elements into an array
  232. * @since PHP 5.1
  233. *
  234. * @param it iterator to copy
  235. * @param use_keys whether touse the keys
  236. * @return array with elements copied from the iterator
  237. */
  238. function iterator_to_array(Traversable $it, $use_keys = true) {/**/};
  239. /** @ingroup ZendEngine
  240. * @brief Basic Exception class.
  241. * @since PHP 5.0
  242. */
  243. class Exception
  244. {
  245. /** The exception message */
  246. protected $message;
  247. /** The string represenations as generated during construction */
  248. private $string;
  249. /** The code passed to the constructor */
  250. protected $code;
  251. /** The file name where the exception was instantiated */
  252. protected $file;
  253. /** The line number where the exception was instantiated */
  254. protected $line;
  255. /** The stack trace */
  256. private $trace;
  257. /** Prevent clone
  258. */
  259. final private function __clone() {}
  260. /** Construct an exception
  261. *
  262. * @param $message Some text describing the exception
  263. * @param $code Some code describing the exception
  264. */
  265. function __construct($message = NULL, $code = 0) {
  266. if (func_num_args()) {
  267. $this->message = $message;
  268. }
  269. $this->code = $code;
  270. $this->file = __FILE__; // of throw clause
  271. $this->line = __LINE__; // of throw clause
  272. $this->trace = debug_backtrace();
  273. $this->string = StringFormat($this);
  274. }
  275. /** @return the message passed to the constructor
  276. */
  277. final public function getMessage()
  278. {
  279. return $this->message;
  280. }
  281. /** @return the code passed to the constructor
  282. */
  283. final public function getCode()
  284. {
  285. return $this->code;
  286. }
  287. /** @return the name of the file where the exception was thrown
  288. */
  289. final public function getFile()
  290. {
  291. return $this->file;
  292. }
  293. /** @return the line number where the exception was thrown
  294. */
  295. final public function getLine()
  296. {
  297. return $this->line;
  298. }
  299. /** @return the stack trace as array
  300. */
  301. final public function getTrace()
  302. {
  303. return $this->trace;
  304. }
  305. /** @return the stack trace as string
  306. */
  307. final public function getTraceAsString()
  308. {
  309. }
  310. /** @return string represenation of exception
  311. */
  312. public function __toString()
  313. {
  314. return $this->string;
  315. }
  316. }
  317. /** @ingroup SPL
  318. * @brief Exception that represents error in the program logic.
  319. * @since PHP 5.1
  320. *
  321. * This kind of exceptions should directly leed to a fix in your code.
  322. */
  323. class LogicException extends Exception
  324. {
  325. }
  326. /** @ingroup SPL
  327. * @brief Exception thrown when a function call was illegal.
  328. * @since PHP 5.1
  329. */
  330. class BadFunctionCallException extends LogicException
  331. {
  332. }
  333. /** @ingroup SPL
  334. * @brief Exception thrown when a method call was illegal.
  335. * @since PHP 5.1
  336. */
  337. class BadMethodCallException extends BadFunctionCallException
  338. {
  339. }
  340. /** @ingroup SPL
  341. * @brief Exception that denotes a value not in the valid domain was used.
  342. * @since PHP 5.1
  343. *
  344. * This kind of exception should be used to inform about domain erors in
  345. * mathematical sense.
  346. *
  347. * @see RangeException
  348. */
  349. class DomainException extends LogicException
  350. {
  351. }
  352. /** @ingroup SPL
  353. * @brief Exception that denotes invalid arguments were passed.
  354. * @since PHP 5.1
  355. *
  356. * @see UnexpectedValueException
  357. */
  358. class InvalidArgumentException extends LogicException
  359. {
  360. }
  361. /** @ingroup SPL
  362. * @brief Exception thrown when a parameter exceeds the allowed length.
  363. * @since PHP 5.1
  364. *
  365. * This can be used for strings length, array size, file size, number of
  366. * elements read from an Iterator and so on.
  367. */
  368. class LengthException extends LogicException
  369. {
  370. }
  371. /** @ingroup SPL
  372. * @brief Exception thrown when an illegal index was requested.
  373. * @since PHP 5.1
  374. *
  375. * This represents errors that should be detected at compile time.
  376. *
  377. * @see OutOfBoundsException
  378. */
  379. class OutOfRangeException extends LogicException
  380. {
  381. }
  382. /** @ingroup SPL
  383. * @brief Exception thrown for errors that are only detectable at runtime.
  384. * @since PHP 5.1
  385. */
  386. class RuntimeException extends Exception
  387. {
  388. }
  389. /** @ingroup SPL
  390. * @brief Exception thrown when an illegal index was requested.
  391. * @since PHP 5.1
  392. *
  393. * This represents errors that cannot be detected at compile time.
  394. *
  395. * @see OutOfRangeException
  396. */
  397. class OutOfBoundsException extends RuntimeException
  398. {
  399. }
  400. /** @ingroup SPL
  401. * @brief Exception thrown to indicate arithmetic/buffer overflow.
  402. * @since PHP 5.1
  403. */
  404. class OverflowException extends RuntimeException
  405. {
  406. }
  407. /** @ingroup SPL
  408. * @brief Exception thrown to indicate range errors during program execution.
  409. * @since PHP 5.1
  410. *
  411. * Normally this means there was an arithmetic error other than under/overflow.
  412. * This is the runtime version of DomainException.
  413. *
  414. * @see DomainException
  415. */
  416. class RangeException extends RuntimeException
  417. {
  418. }
  419. /** @ingroup SPL
  420. * @brief Exception thrown to indicate arithmetic/buffer underflow.
  421. * @since PHP 5.1
  422. */
  423. class UnderflowException extends RuntimeException
  424. {
  425. }
  426. /** @ingroup SPL
  427. * @brief Exception thrown to indicate an unexpected value.
  428. * @since PHP 5.1
  429. *
  430. * Typically this happens when a function calls another function and espects
  431. * the return value to be of a certain type or value not including arithmetic
  432. * or buffer related errors.
  433. *
  434. * @see InvalidArgumentException
  435. */
  436. class UnexpectedValueException extends RuntimeException
  437. {
  438. }
  439. /** @ingroup ZendEngine
  440. * @brief Interface to override array access of objects.
  441. * @since PHP 5.0
  442. */
  443. interface ArrayAccess
  444. {
  445. /** @param $offset to modify
  446. * @param $value new value
  447. */
  448. function offsetSet($offset, $value);
  449. /** @param $offset to retrieve
  450. * @return value at given offset
  451. */
  452. function offsetGet($offset);
  453. /** @param $offset to delete
  454. */
  455. function offsetUnset($offset);
  456. /** @param $offset to check
  457. * @return whether the offset exists.
  458. */
  459. function offsetExists($offset);
  460. }
  461. /** @ingroup ZendEngine
  462. * @brief Interface to detect a class is traversable using foreach.
  463. * @since PHP 5.0
  464. *
  465. * Abstract base interface that cannot be implemented alone. Instead it
  466. * must be implemented by either IteratorAggregate or Iterator.
  467. *
  468. * @note Internal classes that implement this interface can be used in a
  469. * foreach construct and do not need to implement IteratorAggregate or
  470. * Iterator.
  471. *
  472. * @note This is an engine internal interface which cannot be implemented
  473. * in PHP scripts. Either IteratorAggregate or Iterator must be used
  474. * instead.
  475. */
  476. interface Traversable
  477. {
  478. }
  479. /** @ingroup ZendEngine
  480. * @brief Interface to create an external Iterator.
  481. * @since PHP 5.0
  482. *
  483. * @note This is an engine internal interface.
  484. */
  485. interface IteratorAggregate extends Traversable
  486. {
  487. /** @return an Iterator for the implementing object.
  488. */
  489. function getIterator();
  490. }
  491. /** @ingroup ZendEngine
  492. * @brief Basic iterator
  493. * @since PHP 5.0
  494. *
  495. * Interface for external iterators or objects that can be iterated
  496. * themselves internally.
  497. *
  498. * @note This is an engine internal interface.
  499. */
  500. interface Iterator extends Traversable
  501. {
  502. /** Rewind the Iterator to the first element.
  503. */
  504. function rewind();
  505. /** Return the current element.
  506. */
  507. function current();
  508. /** Return the key of the current element.
  509. */
  510. function key();
  511. /** Move forward to next element.
  512. */
  513. function next();
  514. /** Check if there is a current element after calls to rewind() or next().
  515. */
  516. function valid();
  517. }
  518. /** @ingroup SPL
  519. * @brief This Interface allows to hook into the global count() function.
  520. * @since PHP 5.1
  521. */
  522. interface Countable
  523. {
  524. /** @return the number the global function count() should show
  525. */
  526. function count();
  527. }
  528. /** @ingroup ZendEngine
  529. * @brief Interface for customized serializing
  530. * @since 5.1
  531. *
  532. * Classes that implement this interface no longer support __sleep() and
  533. * __wakeup(). The method serialized is called whenever an instance needs to
  534. * be serialized. This does not invoke __destruct() or has any other side
  535. * effect unless programmed inside the method. When the data is unserialized
  536. * the class is known and the appropriate unserialize() method is called as a
  537. * constructor instead of calling __construct(). If you need to execute the
  538. * standard constructor you may do so in the method.
  539. */
  540. interface Serializable
  541. {
  542. /**
  543. * @return string representation of the instance
  544. */
  545. function serialize();
  546. /**
  547. * @note This is a constructor
  548. *
  549. * @param $serialized data read from stream to construct the instance
  550. */
  551. function unserialize($serialized);
  552. }
  553. /** @ingroup SPL
  554. * @brief An Array wrapper
  555. * @since PHP 5.0
  556. * @version 1.2
  557. *
  558. * This array wrapper allows to recursively iterate over Arrays and public
  559. * Object properties.
  560. *
  561. * @see ArrayIterator
  562. */
  563. class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
  564. {
  565. /** Properties of the object have their normal functionality
  566. * when accessed as list (var_dump, foreach, etc.) */
  567. const STD_PROP_LIST = 0x00000001;
  568. /** Array indices can be accessed as properties in read/write */
  569. const ARRAY_AS_PROPS = 0x00000002;
  570. /** Construct a new array iterator from anything that has a hash table.
  571. * That is any Array or Object.
  572. *
  573. * @param $array the array to use.
  574. * @param $flags see setFlags().
  575. * @param $iterator_class class used in getIterator()
  576. */
  577. function __construct($array, $flags = 0, $iterator_class = "ArrayIterator") {/**/}
  578. /** Set behavior flags.
  579. *
  580. * @param $flags bitmask as follows:
  581. * 0 set: properties of the object have their normal functionality
  582. * when accessed as list (var_dump, foreach, etc.)
  583. * 1 set: array indices can be accessed as properties in read/write
  584. */
  585. function setFlags($flags) {/**/}
  586. /** @return current flags
  587. */
  588. function getFlags() {/**/}
  589. /** Sort the entries by values.
  590. */
  591. function asort() {/**/}
  592. /** Sort the entries by key.
  593. */
  594. function ksort() {/**/}
  595. /** Sort the entries by values using user defined function.
  596. */
  597. function uasort(mixed cmp_function) {/**/}
  598. /** Sort the entries by key using user defined function.
  599. */
  600. function uksort(mixed cmp_function) {/**/}
  601. /** Sort the entries by values using "natural order" algorithm.
  602. */
  603. function natsort() {/**/}
  604. /** Sort the entries by values using case insensitive "natural order" algorithm.
  605. */
  606. function natcasesort() {/**/}
  607. /** @param $array new array or object
  608. */
  609. function exchangeArray($array) {/**/}
  610. /** @return the iterator which is an ArrayIterator object connected to
  611. * this object.
  612. */
  613. function getIterator() {/**/}
  614. /** @param $index offset to inspect
  615. * @return whetehr offset $index esists
  616. */
  617. function offsetExists($index) {/**/}
  618. /** @param $index offset to return value for
  619. * @return value at offset $index
  620. */
  621. function offsetGet($index) {/**/}
  622. /** @param $index index to set
  623. * @param $newval new value to store at offset $index
  624. */
  625. function offsetSet($index, $newval) {/**/}
  626. /** @param $index offset to unset
  627. */
  628. function offsetUnset($index) {/**/}
  629. /** @param $value is appended as last element
  630. * @warning this method cannot be called when the ArrayObject refers to
  631. * an object.
  632. */
  633. function append($value) {/**/}
  634. /** @return a \b copy of the array
  635. * @note when the ArrayObject refers to an object then this method
  636. * returns an array of the public properties.
  637. */
  638. function getArrayCopy() {/**/}
  639. /** @return the number of elements in the array or the number of public
  640. * properties in the object.
  641. */
  642. function count() {/**/}
  643. /* @param $iterator_class new class used in getIterator()
  644. */
  645. function setIteratorClass($itertor_class) {/**/}
  646. /* @return class used in getIterator()
  647. */
  648. function getIteratorClass() {/**/}
  649. }
  650. /** @ingroup SPL
  651. * @brief An Array iterator
  652. * @since PHP 5.0
  653. * @version 1.2
  654. *
  655. * This iterator allows to unset and modify values and keys while iterating
  656. * over Arrays and Objects.
  657. *
  658. * When you want to iterate over the same array multiple times you need to
  659. * instanciate ArrayObject and let it create ArrayIterator instances that
  660. * refer to it either by using foreach or by calling its getIterator()
  661. * method manually.
  662. */
  663. class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
  664. {
  665. /** Properties of the object have their normal functionality
  666. * when accessed as list (var_dump, foreach, etc.) */
  667. const STD_PROP_LIST = 0x00000001;
  668. /** Array indices can be accessed as properties in read/write */
  669. const ARRAY_AS_PROPS = 0x00000002;
  670. /** Construct a new array iterator from anything that has a hash table.
  671. * That is any Array or Object.
  672. *
  673. * @param $array the array to use.
  674. * @param $flags see setFlags().
  675. */
  676. function __construct($array, $flags = 0) {/**/}
  677. /** Set behavior flags.
  678. *
  679. * @param $flags bitmask as follows:
  680. * 0 set: properties of the object have their normal functionality
  681. * when accessed as list (var_dump, foreach, etc.)
  682. * 1 set: array indices can be accessed as properties in read/write
  683. */
  684. function setFlags($flags) {/**/}
  685. /**
  686. * @return current flags
  687. */
  688. function getFlags() {/**/}
  689. /** Sort the entries by values.
  690. */
  691. function asort() {/**/}
  692. /** Sort the entries by key.
  693. */
  694. function ksort() {/**/}
  695. /** Sort the entries by values using user defined function.
  696. */
  697. function uasort(mixed cmp_function) {/**/}
  698. /** Sort the entries by key using user defined function.
  699. */
  700. function uksort(mixed cmp_function) {/**/}
  701. /** Sort the entries by values using "natural order" algorithm.
  702. */
  703. function natsort() {/**/}
  704. /** Sort the entries by values using case insensitive "natural order" algorithm.
  705. */
  706. function natcasesort() {/**/}
  707. /** @param $index offset to inspect
  708. * @return whetehr offset $index esists
  709. */
  710. function offsetExists($index) {/**/}
  711. /** @param $index offset to return value for
  712. * @return value at offset $index
  713. */
  714. function offsetGet($index) {/**/}
  715. /** @param $index index to set
  716. * @param $newval new value to store at offset $index
  717. */
  718. function offsetSet($index, $newval) {/**/}
  719. /** @param $index offset to unset
  720. */
  721. function offsetUnset($index) {/**/}
  722. /** @param $value is appended as last element
  723. * @warning this method cannot be called when the ArrayIterator refers to
  724. * an object.
  725. */
  726. function append($value) {/**/}
  727. /** @return a \b copy of the array
  728. * @note when the ArrayIterator refers to an object then this method
  729. * returns an array of the public properties.
  730. */
  731. function getArrayCopy() {/**/}
  732. /** @param $position offset to seek to
  733. * @throw OutOfBoundsException if $position is invalid
  734. */
  735. function seek($position) {/**/}
  736. /** @return the number of elements in the array or the number of public
  737. * properties in the object.
  738. */
  739. function count() {/**/}
  740. /** @copydoc Iterator::rewind */
  741. function rewind() {/**/}
  742. /** @copydoc Iterator::valid */
  743. function valid() {/**/}
  744. /** @copydoc Iterator::current */
  745. function current() {/**/}
  746. /** @copydoc Iterator::key */
  747. function key() {/**/}
  748. /** @copydoc Iterator::next */
  749. function next() {/**/}
  750. }
  751. /** @ingroup SPL
  752. * @brief File info class
  753. * @since PHP 5.1.3
  754. */
  755. class SplFileInfo
  756. {
  757. /** Construct a file info object
  758. *
  759. * @param $file_name path or file name
  760. */
  761. function __construct($file_name) {/**/}
  762. /** @return the path part only.
  763. */
  764. function getPath() {/**/}
  765. /** @return the filename only.
  766. */
  767. function getFilename() {/**/}
  768. /** @return SplFileInfo created for the file
  769. * @param class_name name of class to instantiate
  770. * @see SplFileInfo::setInfoClass()
  771. */
  772. function getFileInfo(string class_name = NULL) {/**/}
  773. /** @return The current entries path and file name.
  774. */
  775. function getPathname() {/**/}
  776. /** @return SplFileInfo created for the path
  777. * @param class_name name of class to instantiate
  778. * @see SplFileInfo::setInfoClass()
  779. */
  780. function getPathInfo(string class_name = NULL) {/**/}
  781. /** @return The current entry's permissions.
  782. */
  783. function getPerms() {/**/}
  784. /** @return The current entry's inode.
  785. */
  786. function getInode() {/**/}
  787. /** @return The current entry's size in bytes .
  788. */
  789. function getSize() {/**/}
  790. /** @return The current entry's owner name.
  791. */
  792. function getOwner() {/**/}
  793. /** @return The current entry's group name.
  794. */
  795. function getGroup() {/**/}
  796. /** @return The current entry's last access time.
  797. */
  798. function getATime() {/**/}
  799. /** @return The current entry's last modification time.
  800. */
  801. function getMTime() {/**/}
  802. /** @return The current entry's last change time.
  803. */
  804. function getCTime() {/**/}
  805. /** @return The current entry's file type.
  806. */
  807. function getType() {/**/}
  808. /** @return Whether the current entry is writeable.
  809. */
  810. function isWritable() {/**/}
  811. /** @return Whether the current entry is readable.
  812. */
  813. function isReadable() {/**/}
  814. /** @return Whether the current entry is executable.
  815. */
  816. function isExecutable() {/**/}
  817. /** @return Whether the current entry is .
  818. */
  819. function isFile() {/**/}
  820. /** @return Whether the current entry is a directory.
  821. */
  822. function isDir() {/**/}
  823. /** @return whether the current entry is a link.
  824. */
  825. function isLink() {/**/}
  826. /** @return target of link.
  827. */
  828. function getLinkTarget() {/**/}
  829. /** @return The resolved path
  830. */
  831. function getRealPath() {/**/}
  832. /** @return getPathname()
  833. */
  834. function __toString() {/**/}
  835. /** Open the current file as a SplFileObject instance
  836. *
  837. * @param mode open mode
  838. * @param use_include_path whether to search include paths (don't use)
  839. * @param context resource context to pased to open function
  840. * @throw RuntimeException if file cannot be opened (e.g. insufficient
  841. * access rights).
  842. * @return The opened file as a SplFileObject instance
  843. *
  844. * @see SplFileObject
  845. * @see SplFileInfo::setFileClass()
  846. * @see file()
  847. */
  848. function openFile($mode = 'r', $use_include_path = false, $context = NULL) {/**/}
  849. /** @param class_name name of class used with openFile(). Must be derived
  850. * from SPLFileObject.
  851. */
  852. function setFileClass(string class_name = "SplFileObject") {/**/}
  853. /** @param class_name name of class used with getFileInfo(), getPathInfo().
  854. * Must be derived from SplFileInfo.
  855. */
  856. function setInfoClass(string class_name = "SplFileInfo") {/**/}
  857. }
  858. /** @ingroup SPL
  859. * @brief Directory iterator
  860. * @version 1.1
  861. * @since PHP 5.0
  862. */
  863. class DirectoryIterator extends SplFileInfo implements Iterator
  864. {
  865. /** Construct a directory iterator from a path-string.
  866. *
  867. * @param $path directory to iterate.
  868. */
  869. function __construct($path) {/**/}
  870. /** @copydoc Iterator::rewind */
  871. function rewind() {/**/}
  872. /** @copydoc Iterator::valid */
  873. function valid() {/**/}
  874. /** @return index of entry
  875. */
  876. function key() {/**/}
  877. /** @return $this
  878. */
  879. function current() {/**/}
  880. /** @copydoc Iterator::next */
  881. function next() {/**/}
  882. /** @return Whether the current entry is either '.' or '..'.
  883. */
  884. function isDot() {/**/}
  885. /** @return whether the current entry is a link.
  886. */
  887. function isLink() {/**/}
  888. /** @return getFilename()
  889. */
  890. function __toString() {/**/}
  891. }
  892. /** @ingroup SPL
  893. * @brief recursive directory iterator
  894. * @version 1.1
  895. * @since PHP 5.0
  896. */
  897. class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
  898. {
  899. const CURRENT_AS_FILEINFO 0x00000000; /* make RecursiveDirectoryTree::current() return SplFileInfo */
  900. const CURRENT_AS_SELF 0x00000010; /* make RecursiveDirectoryTree::current() return getSelf() */
  901. const CURRENT_AS_PATHNAME 0x00000020; /* make RecursiveDirectoryTree::current() return getPathname() */
  902. const KEY_AS_PATHNAME 0x00000000; /* make RecursiveDirectoryTree::key() return getPathname() */
  903. const KEY_AS_FILENAME 0x00000100; /* make RecursiveDirectoryTree::key() return getFilename() */
  904. const NEW_CURRENT_AND_KEY 0x00000100; /* CURRENT_AS_FILEINFO + KEY_AS_FILENAME */
  905. /** Construct a directory iterator from a path-string.
  906. *
  907. * @param $path directory to iterate.
  908. * @param $flags open flags
  909. * - CURRENT_AS_FILEINFO
  910. * - CURRENT_AS_SELF
  911. * - CURRENT_AS_PATHNAME
  912. * - KEY_AS_PATHNAME
  913. * - KEY_AS_FILENAME
  914. * - NEW_CURRENT_AND_KEY
  915. */
  916. function __construct($path, $flags = 0) {/**/}
  917. /** @return getPathname() or getFilename() depending on flags
  918. */
  919. function key() {/**/}
  920. /** @return getFilename() or getFileInfo() depending on flags
  921. */
  922. function current() {/**/}
  923. /** @return whether the current is a directory (not '.' or '..').
  924. */
  925. function hasChildren() {/**/}
  926. /** @return a RecursiveDirectoryIterator for the current entry.
  927. */
  928. function getChildren() {/**/}
  929. /** @return sub path only (without main path)
  930. */
  931. function getSubPath() {/**/}
  932. /** @return the current sub path
  933. */
  934. function getSubPathname() {/**/}
  935. }
  936. /** @ingroup SPL
  937. * @brief recursive SimpleXML_Element iterator
  938. * @since PHP 5.0
  939. *
  940. * The SimpleXMLIterator implements the RecursiveIterator interface. This
  941. * allows iteration over all elements using foreach or an appropriate while
  942. * construct, just like SimpleXMLElement does. When using the foreach construct,
  943. * you will also iterate over the subelements. For every element which
  944. * has subelements, hasChildren() returns true. This will trigger a call to
  945. * getChildren() which returns the iterator for that sub element.
  946. */
  947. class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, Countable
  948. {
  949. /** @return whether the current node has sub nodes.
  950. */
  951. function hasChildren() {/**/}
  952. /** @return a SimpleXMLIterator for the current node.
  953. */
  954. function getChildren() {/**/}
  955. /** @return number of elements/attributes seen with foreach()
  956. */
  957. function count() {/**/}
  958. /** @copydoc Iterator::rewind */
  959. function rewind() {/**/}
  960. /** @copydoc Iterator::valid */
  961. function valid() {/**/}
  962. /** @copydoc Iterator::current */
  963. function current() {/**/}
  964. /** @copydoc Iterator::key */
  965. function key() {/**/}
  966. /** @copydoc Iterator::next */
  967. function next() {/**/}
  968. }
  969. /** @ingroup SPL
  970. * @brief Observer of the observer pattern
  971. * @since PHP 5.1
  972. *
  973. * For a detailed explanation see Observer pattern in
  974. * <em>
  975. * Gamma, Helm, Johnson, Vlissides<br />
  976. * Design Patterns
  977. * </em>
  978. */
  979. interface SplObserver
  980. {
  981. /** Called from the subject (i.e. when it's value has changed).
  982. * @param $subject the callee
  983. */
  984. function update(SplSubject $subject);
  985. }
  986. /** @ingroup SPL
  987. * @brief Subject to the observer pattern
  988. * @since PHP 5.1
  989. * @see Observer
  990. */
  991. interface SplSubject
  992. {
  993. /** @param $observer new observer to attach
  994. */
  995. function attach(SplObserver $observer);
  996. /** @param $observer existing observer to detach
  997. * @note a non attached observer shouldn't result in a warning or similar
  998. */
  999. function detach(SplObserver $observer);
  1000. /** Notify all observers
  1001. */
  1002. function notify();
  1003. }
  1004. ?>