summaryrefslogtreecommitdiff
path: root/ext/spl/spl.php
blob: 1f4735b3f6d3ebb22aba76d612137bc4600743a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
<?php

/** @file spl.php
 * @ingroup SPL
 * @brief Documentation of internal classes and interfaces
 *
 * SPL - Standard PHP Library
 *
 * (c) Marcus Boerger, 2003 - 2005
 */

/** @mainpage SPL - Standard PHP Library
 *
 * SPL - Standard PHP Library
 *
 * SPL is a collection of interfaces and classes that are meant to solve 
 * standard problems and implements some efficient data access interfaces 
 * and classes. You'll find the classes documented using php code in the 
 * file spl.php or in corresponding .inc files in subdirectories examples 
 * and internal. Based on the internal implementations or the files in the 
 * examples subdirectory there are also some .php files to experiment with.
 * 
 * The .inc files are not included automatically because they are sooner or 
 * later integrated into the extension. That means that you either need to 
 * put the code of examples/autoload.inc into your autoprepend file or that 
 * you have to point your ini setting auto_prepend_file to that file.
 * 
 * Below is a list of interfaces/classes already availabel natively through
 * the SPL extension grouped by category.
 * 
 * 1) Iterators
 * 
 * SPL offers some advanced iterator algorithms:
 * 
 * - interface RecursiveIterator implements Iterator
 * - interface OuterIterator extends Iterator
 * - class RecursiveIteratorIterator implements OuterIterator
 * - abstract class FilterIterator implements OuterIterator
 * - class ParentIterator extends FilterIterator implements RecursiveIterator
 * - interface SeekableIterator implements Iterator
 * - class LimitIterator implements OuterIterator
 * - class CachingIterator implements OuterIterator
 * - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
 * - class IteratorIterator implements OuterIterator
 * - class NoRewindIterator implements OuterIterator
 * - class EmptyIterator implements Iterator
 * - class InfiniteIterator extends IteratorIterator
 * - class AppendIterator implements OuterIterator
 * 
 * 2) Directories and Files
 * 
 * SPL offers two advanced directory and file handling classes:
 * 
 * - class DirectoryIterator implements Iterator
 * - class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
 * - class SplFileObject implements RecursiveIterator, SeekableIterator
 * 
 * 3) XML
 * 
 * SPL offers an advanced XML handling class:
 * 
 * - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
 * 
 * 4) Array Overloading
 * 
 * SPL offers advanced Array overloading:
 * 
 * - class ArrayObject implements IteratorAggregate
 * - class ArrayIterator implements Iterator
 * 
 * As the above suggest an ArrayObject creates an ArrayIterator when it comes to
 * iteration (e.g. ArrayObject instance used inside foreach). 
 *
 * 5) Counting
 *
 * - interface Countable allows to hook into the standard array function count().
 *
 * 6) Exception%s
 *
 * SPL provides a set of standard Exception classes each meant to indicate a 
 * certain problem type.
 *
 * - class LogicException           extends Exception
 * - class BadFunctionCallException extends LogicException
 * - class BadMethodCallException   extends BadFunctionCallException
 * - class DomainException          extends LogicException
 * - class InvalidArgumentException extends LogicException
 * - class LengthException          extends LogicException
 * - class OutOfRangeException      extends LogicException
 * - class RuntimeException         extends Exception
 * - class OutOfBoundsException     extends RuntimeException
 * - class OverflowException        extends RuntimeException
 * - class RangeException           extends RuntimeException
 * - class UnderflowException       extends RuntimeException
 *
 * 7) Observer
 *
 * SPL suggests a standard way of implementing the observer pattern.
 *
 * - interface SplObserver
 * - interface SplSubject
 * - class SplObjectStorage
 * 
 * Some articles about SPL:
 * - <a href="http://www.sitepoint.com/article/php5-standard-library/1">Introducing PHP 5's Standard Library</a>
 * - <a href="http://www.ramikayyali.com/archives/2005/02/25/iterators">Iterators in PHP5</a>
 * - <a href="http://www.phpriot.com/d/articles/php/oop/oop-with-spl-php-5-1/index.html">Advanced OOP with SPL in PHP 5</a>
 * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-1/">The Standard PHP Library, Part 1</a>
 * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-2/">The Standard PHP Library, Part 2</a>
 * - <a href="http://www.wiki.cc/php/SPL">SPL on PHP Wiki</a>
 * - <a href="http://www.professionelle-softwareentwicklung-mit-php5.de/erste_auflage/oop.iterators.spl.html">Die Standard PHP Library (SPL) [german]</a>
 *
 * Talks on SPL:
 * - SPL for the masses <a href="http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pps">[pps]</a>, <a href="http://somabo.de/talks/200504_php_quebec_spl_for_the_masses.pdf">[pdf]</a>
 * - Debug session 1 <a href="http://somabo.de/talks/200504_php_quebec_iterator_debug_session_1.pps">[pps]</a>, <a href="http://somabo.de/talks/200504_php_quebec_iterator_debug_session_1.pdf">[pdf]</a>
 * - Debug session 2 <a href="http://somabo.de/talks/200504_php_quebec_iterator_debug_session_2.pps">[pps]</a>, <a href="http://somabo.de/talks/200504_php_quebec_iterator_debug_session_2.pdf">[pdf]</a>
 * - From engine overloading to SPL <a href="http://somabo.de/talks/200505_cancun_from_engine_overloading_to_spl.pps">[pps]</a>, <a href="http://somabo.de/talks/200505_cancun_from_engine_overloading_to_spl.pdf">[pdf]</a>
 *
 * You can download this documentation as a chm file 
 * <a href="http://php.net/~helly/php/ext/spl/spl.chm">here</a>.
 *
 * (c) Marcus Boerger, 2003 - 2005
 */

/** @defgroup ZendEngine Zend engine classes
 *
 * The classes and interfaces in this group are contained in the c-code of 
 * PHP's Zend engine.
 */

/** @defgroup SPL Internal classes
 *
 * The classes and interfaces in this group are contained in the c-code of 
 * ext/SPL.
 */

/** @defgroup Examples Example classes
 *
 * The classes and interfaces in this group are contained as PHP code in the 
 * examples subdirectory of ext/SPL. Sooner or later they will be moved to
 * c-code.
 */

/** @ingroup ZendEngine
 * @brief Basic Exception class.
 * @since PHP 5.0
 */
class Exception
{
	/** The exception message */
    protected $message;
    
    /** The string represenations as generated during construction */
    private $string;
    
    /** The code passed to the constructor */
    protected $code;
    
    /** The file name where the exception was instantiated */
    protected $file;
    
    /** The line number where the exception was instantiated */
    protected $line;
    
    /** The stack trace */
    private $trace;

	/** Prevent clone
	 */
    final private function __clone() {}

	/** Construct an exception
	 *
	 * @param $message Some text describing the exception
	 * @param $code    Some code describing the exception
	 */
	function __construct($message = NULL, $code = 0) {
		if (func_num_args()) {
			$this->message = $message;
		}
		$this->code = $code;
		$this->file = __FILE__; // of throw clause
		$this->line = __LINE__; // of throw clause
		$this->trace = debug_backtrace();
		$this->string = StringFormat($this);
	} 

	/** @return the message passed to the constructor
	 */
    final public function getMessage()
    {
    	return $this->message;
    }

	/** @return the code passed to the constructor
	 */
    final public function getCode()
    {
    	return $this->code;
    }

	/** @return the name of the file where the exception was thrown
	 */
    final public function getFile()
    {
    	return $this->file;
    }

	/** @return the line number where the exception was thrown
	 */
    final public function getLine()
    {
    	return $this->line;
    }

	/** @return the stack trace as array
	 */
    final public function getTrace()
    {
    	return $this->trace;
    }

	/** @return the stack trace as string
	 */
    final public function getTraceAsString()
    {
    }

	/** @return string represenation of exception
	 */
    public function __toString()
    {
    	return $this->string;
    }
}

/** @ingroup SPL
 * @brief Exception that represents error in the program logic.
 * @since PHP 5.1
 *
 * This kind of exceptions should directly leed to a fix in your code.
 */
class LogicException extends Exception
{
}

/** @ingroup SPL
 * @brief Exception thrown when a function call was illegal.
 * @since PHP 5.1
 */
class BadFunctionCallException extends LogicException
{
}

/** @ingroup SPL
 * @brief Exception thrown when a method call was illegal.
 * @since PHP 5.1
 */
class BadMethodCallException extends BadFunctionCallException
{
}

/** @ingroup SPL
 * @brief Exception that denotes a value not in the valid domain was used.
 * @since PHP 5.1
 *
 * This kind of exception should be used to inform about domain erors in 
 * mathematical sense.
 *
 * @see RangeException
 */
class DomainException extends LogicException
{
}

/** @ingroup SPL
 * @brief Exception that denotes invalid arguments were passed.
 * @since PHP 5.1
 *
 * @see UnexpectedValueException
 */
class InvalidArgumentException extends LogicException
{
}

/** @ingroup SPL
 * @brief Exception thrown when a parameter exceeds the allowed length.
 * @since PHP 5.1
 *
 * This can be used for strings length, array size, file size, number of 
 * elements read from an Iterator and so on.
 */
class LengthException extends LogicException
{
}

/** @ingroup SPL
 * @brief Exception thrown when an illegal index was requested.
 * @since PHP 5.1
 *
 * This represents errors that should be detected at compile time.
 *
 * @see OutOfBoundsException
 */
class OutOfRangeException extends LogicException
{
}

/** @ingroup SPL
 * @brief Exception thrown for errors that are only detectable at runtime. 
 * @since PHP 5.1
 */
class RuntimeException extends Exception
{
}

/** @ingroup SPL
 * @brief Exception thrown when an illegal index was requested.
 * @since PHP 5.1
 *
 * This represents errors that cannot be detected at compile time.
 *
 * @see OutOfRangeException
 */
class OutOfBoundsException extends RuntimeException
{
}

/** @ingroup SPL
 * @brief Exception thrown to indicate arithmetic/buffer overflow.
 * @since PHP 5.1
 */
class OverflowException extends RuntimeException
{
}

/** @ingroup SPL
 * @brief Exception thrown to indicate range errors during program execution.
 * @since PHP 5.1
 *
 * Normally this means there was an arithmetic error other than under/overflow.
 * This is the runtime version of DomainException.
 *
 * @see DomainException
 */
class RangeException extends RuntimeException
{
}

/** @ingroup SPL
 * @brief Exception thrown to indicate arithmetic/buffer underflow.
 * @since PHP 5.1
 */
class UnderflowException extends RuntimeException
{
}

/** @ingroup SPL
 * @brief Exception thrown to indicate an unexpected value.
 * @since PHP 5.1
 *
 * Typically this happens when a function calls another function and espects
 * the return value to be of a certain type or value not including arithmetic
 * or buffer related errors. 
 *
 * @see InvalidArgumentException
 */
class UnexpectedValueException extends RuntimeException
{
}

/** @ingroup ZendEngine
 * @brief Interface to override array access of objects.
 * @since PHP 5.0
 */
interface ArrayAccess
{
	/** @param $offset to modify
	 * @param $value new value
	 */
	function offsetSet($offset, $value);

	/** @param $offset to retrieve
	 * @return value at given offset
	 */
	function offsetGet($offset);

	/** @param $offset to delete
	 */
	function offsetUnset($offset);

	/** @param $offset to check
	 * @return whether the offset exists.
	 */
	function offsetExists($offset);
}

/** @ingroup ZendEngine
 * @brief Interface to detect a class is traversable using foreach.
 * @since PHP 5.0
 *
 * Abstract base interface that cannot be implemented alone. Instead it
 * must be implemented by either IteratorAggregate or Iterator. 
 *
 * @note Internal classes that implement this interface can be used in a 
 * foreach construct and do not need to implement IteratorAggregate or
 * Iterator.
 *
 * @note This is an engine internal interface which cannot be implemented
 * in PHP scripts. Either IteratorAggregate or Iterator must be used 
 * instead.
 */
interface Traversable
{
}

/** @ingroup ZendEngine
 * @brief Interface to create an external Iterator.
 * @since PHP 5.0
 *
 * @note This is an engine internal interface.
 */ 
interface IteratorAggregate extends Traversable
{
	/** @return an Iterator for the implementing object.
	 */
	function getIterator();
}

/** @ingroup ZendEngine
 * @brief Basic iterator
 * @since PHP 5.0
 *
 * Interface for external iterators or objects that can be iterated 
 * themselves internally.
 *
 * @note This is an engine internal interface.
 */
interface Iterator extends Traversable
{
	/** Rewind the Iterator to the first element.
	 */
	function rewind();

	/** Return the current element.
	 */
	function current();

	/** Return the key of the current element.
	 */
	function key();

	/** Move forward to next element.
	 */
	function next();

	/** Check if there is a current element after calls to rewind() or next().
	 */
	function valid();
}

/** @ingroup SPL
 * @brief This Interface allows to hook into the global count() function.
 * @since PHP 5.1
 */
interface Countable
{
	/** @return the number the global function count() should show
	 */
	function count();
}

/** @ingroup ZendEngine
 * @brief Interface for customized serializing
 * @since 5.1
 * 
 * Classes that implement this interface no longer support __sleep() and 
 * __wakeup(). The method serialized is called whenever an instance needs to
 * be serialized. This does not invoke __destruct() or has any other side
 * effect unless programmed inside the method. When the data is unserialized
 * the class is known and the appropriate unserialize() method is called as a
 * constructor instead of calling __construct(). If you need to execute the
 * standard constructor you may do so in the method.
 */
interface Serializeable
{
	/**
	 * @return string representation of the instance
	 */
	function serialize();
	
	/**
	 * @note This is a constructor
	 * 
	 * @param $serialized data read from stream to construct the instance
	 */
	function unserialize($serialized);
}

/** @ingroup SPL
 * @brief An Array wrapper
 * @since PHP 5.0
 * @version 1.1
 *
 * This array wrapper allows to recursively iterate over Arrays and public 
 * Object properties.
 *
 * @see ArrayIterator
 */
class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
{
	/** Properties of the object have their normal functionality
	 * when accessed as list (var_dump, foreach, etc.) */
	const STD_PROP_LIST  = 0x00000001;
	/** Array indices can be accessed as properties in read/write */
	const ARRAY_AS_PROPS = 0x00000002;

	/** Construct a new array iterator from anything that has a hash table.
	 * That is any Array or Object.
	 *
	 * @param $array the array to use.
	 * @param $flags see setFlags().
	 */
	function __construct($array, $flags = 0);

	/** Set behavior flags.
	 *	
	 * @param $flags bitmask as follows:
	 *        0 set: properties of the object have their normal functionality
	 *               when accessed as list (var_dump, foreach, etc.)
	 *        1 set: array indices can be accessed as properties in read/write
	 */
	function setFlags($flags);
	                    
	/**
	 * @ return current flags
	 */
	function getFlags();

	/**
	 * @param $array new array or object
	 */
	function exchangeArray($array);

	/** @return the iterator which is an ArrayIterator object connected to
	 * this object.
	 */
	function getIterator();

	/** @param $index offset to inspect
	 * @return whetehr offset $index esists
	 */	
	function offsetExists($index);

	/** @param $index offset to return value for
	 * @return value at offset $index
	 */	
	function offsetGet($index);

	/** @param $index index to set
	 * @param $newval new value to store at offset $index
	 */	
	function offsetSet($index, $newval);

	/** @param $index offset to unset
	 */	
	function offsetUnset($index);

	/** @param $value is appended as last element
	 * @warning this method cannot be called when the ArrayObject refers to 
	 *          an object.
	 */	
	function append($value);

	/** @return a \b copy of the array
	 * @note when the ArrayObject refers to an object then this method 
	 *       returns an array of the public properties.
	 */	
	function getArrayCopy();

	/** @return the number of elements in the array or the number of public
	 * properties in the object.
	 */
	function count();
}

/** @ingroup SPL
 * @brief An Array iterator
 * @since PHP 5.0
 * @version 1.1
 *
 * This iterator allows to unset and modify values and keys while iterating
 * over Arrays and Objects.
 *
 * When you want to iterate over the same array multiple times you need to 
 * instanciate ArrayObject and let it create ArrayIterator instances that 
 * refer to it either by using foreach or by calling its getIterator() 
 * method manually.
 */
class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
{
	/** Properties of the object have their normal functionality
	 * when accessed as list (var_dump, foreach, etc.) */
	const STD_PROP_LIST  = 0x00000001;
	/** Array indices can be accessed as properties in read/write */
	const ARRAY_AS_PROPS = 0x00000002;

	/** Construct a new array iterator from anything that has a hash table.
	 * That is any Array or Object.
	 *
	 * @param $array the array to use.
	 * @param $flags see setFlags().
	 */
	function __construct($array, $flags = 0);

	/** Set behavior flags.
	 *	
	 * @param $flags bitmask as follows:
	 *        0 set: properties of the object have their normal functionality
	 *               when accessed as list (var_dump, foreach, etc.)
	 *        1 set: array indices can be accessed as properties in read/write
	 */
	function setFlags($flags);
	                    
	/**
	 * @ return current flags
	 */
	function getFlags();

	/** @param $index offset to inspect
	 * @return whetehr offset $index esists
	 */	
	function offsetExists($index);

	/** @param $index offset to return value for
	 * @return value at offset $index
	 */	
	function offsetGet($index);

	/** @param $index index to set
	 * @param $newval new value to store at offset $index
	 */	
	function offsetSet($index, $newval);

	/** @param $index offset to unset
	 */	
	function offsetUnset($index);

	/** @param $value is appended as last element
	 * @warning this method cannot be called when the ArrayIterator refers to 
	 *          an object.
	 */	
	function append($value);

	/** @return a \b copy of the array
	 * @note when the ArrayIterator refers to an object then this method 
	 *       returns an array of the public properties.
	 */	
	function getArrayCopy();

	/** @param $position offset to seek to
	 * @throw OutOfBoundsException if $position is invalid
	 */
	function seek($position);

	/** @return the number of elements in the array or the number of public
	 * properties in the object.
	 */
	function count();
}

/** @ingroup SPL
 * @brief Directory iterator
 * @since PHP 5.0
 */
class DirectoryIterator implements Iterator
{
	/** Construct a directory iterator from a path-string.
	 *
	 * @param $path directory to iterate.
	 */
	function __construct($path);

	/** @return The opened path.
	 */
	function getPath();	

	/** @return The current file name.
	 */
	function getFilename();	

	/** @return The current entries path and file name.
	 */
	function getPathname();	

	/** @return The current entry's permissions.
	 */
	function getPerms();

	/** @return The current entry's inode.
	 */
	function getInode();

	/** @return The current entry's size in bytes .
	 */
	function getSize();

	/** @return The current entry's owner name.
	 */
	function getOwner();

	/** @return The current entry's group name.
	 */
	function getGroup();

	/** @return The current entry's last access time.
	 */
	function getATime();

	/** @return The current entry's last modification time.
	 */
	function getMTime();

	/** @return The current entry's last change time.
	 */
	function getCTime();

	/** @return The current entry's size in bytes .
	 */
	function getType();

	/** @return Whether the current entry is writeable.
	 */
	function isWritable();

	/** @return Whether the current entry is readable.
	 */
	function isReadable();

	/** @return Whether the current entry is executable.
	 */
	function isExecutable();

	/** @return Whether the current entry is .
	 */
	function isFile();

	/** @return Whether the current entry is a directory.
	 */
	function isDir();	

	/** @return Whether the current entry is either '.' or '..'.
	 */
	function isDot();	

	/** @return whether the current entry is a link.
	 */
	function isLink();

	/** @return getFilename()
	 */
	function __toString();

	/** Open the current file as a SplFileObject instance
	 *
	 * @param mode              open mode
	 * @param use_include_path  whether to search include paths (don't use)
	 * @param context           resource context to pased to open function
	 * @throw RuntimeException  if file cannot be opened (e.g. insufficient 
	 *                          access rights).
	 * @return The opened file as a SplFileObject instance
	 *
	 * @see SplFileObject
	 * @see file()
	 */
	function DirectoryIterator::openFile($mode = 'r', $use_include_path = false, $context = NULL);
}

/** @ingroup SPL
 * @brief recursive directory iterator
 * @since PHP 5.0
 */
class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
{
	/** @return whether the current is a directory (not '.' or '..').
	 */
	function hasChildren();	

	/** @return a RecursiveDirectoryIterator for the current entry.
	 */
	function getChildren();	
}

/** @ingroup SPL
 * @brief recursive SimpleXML_Element iterator
 * @since PHP 5.0
 *
 * The SimpleXMLIterator implements the RecursiveIterator interface. This 
 * allows iteration over all elements using foreach or an appropriate while
 * construct, just like SimpleXMLElement does. When using the foreach construct,
 * you will also iterate over the subelements. For every element which
 * has subelements, hasChildren() returns true.  This will trigger a call to
 * getChildren() which returns the iterator for that sub element.
 */
class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator
{
	/** @return whether the current node has sub nodes.
	 */
	function hasChildren();	

	/** @return a SimpleXMLIterator for the current node.
	 */
	function getChildren();	
}

/** @ingroup SPL
 * @brief observer of the observer pattern
 * @since PHP 5.1
 *
 * For a detailed explanation see Observer pattern in
 * <em>
 * Gamma, Helm, Johnson, Vlissides<br />
 * Design Patterns
 * </em>
 */
interface Observer
{
	/** Called from the subject (i.e. when it's value has changed).
	 * @param $subject the callee
	 */
	function update(Subject $subject);
}

/** @ingroup SPL
 * @brief ubject to the observer pattern
 * @since PHP 5.1
 * @see Observer
 */
interface Subject
{
	/** @param $observer new observer to attach
	 */
    function attach(Observer $observer);

	/** @param $observer existing observer to detach
	 * @note a non attached observer shouldn't result in a warning or similar
	 */
    function detach(Observer $observer);

	/** Notify all observers
	 */
    function notify();
}

?>