spl.php 32 KB

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