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.

1149 lines
32 KiB

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