summaryrefslogtreecommitdiff
path: root/ext/spl/examples
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2006-10-15 21:09:28 +0000
committerSVN Migration <svn@php.net>2006-10-15 21:09:28 +0000
commit88ec761548b66f58acc1a86cdd0fc164ca925476 (patch)
treed0af978fa00d83bb1d82c613f66477fbd6bb18aa /ext/spl/examples
parent268984b4787e797db6054313fc9ba3b9e845306e (diff)
downloadphp-git-PECL_OPENSSL.tar.gz
This commit was manufactured by cvs2svn to create branch 'PECL_OPENSSL'.PECL_OPENSSL
Diffstat (limited to 'ext/spl/examples')
-rwxr-xr-xext/spl/examples/autoload.inc50
-rw-r--r--ext/spl/examples/cachingrecursiveiterator.inc28
-rwxr-xr-xext/spl/examples/class_tree.php87
-rwxr-xr-xext/spl/examples/dba_array.php52
-rwxr-xr-xext/spl/examples/dba_dump.php42
-rwxr-xr-xext/spl/examples/dbaarray.inc98
-rwxr-xr-xext/spl/examples/dbareader.inc96
-rwxr-xr-xext/spl/examples/directoryfilterdots.inc45
-rw-r--r--ext/spl/examples/directorygraphiterator.inc34
-rwxr-xr-xext/spl/examples/directorytree.inc27
-rwxr-xr-xext/spl/examples/directorytree.php37
-rw-r--r--ext/spl/examples/directorytreeiterator.inc54
-rwxr-xr-xext/spl/examples/dualiterator.inc212
-rwxr-xr-xext/spl/examples/findfile.inc65
-rwxr-xr-xext/spl/examples/findfile.php33
-rwxr-xr-xext/spl/examples/findregex.php36
-rwxr-xr-xext/spl/examples/ini_groups.php41
-rwxr-xr-xext/spl/examples/inigroups.inc54
-rwxr-xr-xext/spl/examples/keyfilter.inc64
-rwxr-xr-xext/spl/examples/nocvsdir.php55
-rwxr-xr-xext/spl/examples/recursivedualiterator.inc72
-rwxr-xr-xext/spl/examples/recursivetreeiterator.inc113
-rwxr-xr-xext/spl/examples/regexfindfile.inc40
-rwxr-xr-xext/spl/examples/searchiterator.inc58
-rwxr-xr-xext/spl/examples/tests/dualiterator_001.phpt47
-rwxr-xr-xext/spl/examples/tests/examples.inc23
-rwxr-xr-xext/spl/examples/tree.php40
27 files changed, 0 insertions, 1603 deletions
diff --git a/ext/spl/examples/autoload.inc b/ext/spl/examples/autoload.inc
deleted file mode 100755
index 5871e7d63b..0000000000
--- a/ext/spl/examples/autoload.inc
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-/** @file autoload.inc
- * @ingroup Examples
- * @brief function __autoload
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** \internal
- * Tries to load class $classname from directory $dir.
- */
-function __load_class($classname, $dir)
-{
- $file = $dir . '/' . $classname . '.inc';
- if (file_exists($file))
- {
- require_once($file);
- return true;
- }
- return false;
-}
-
-/**
- * @brief Class loader for SPL example classes
- * @author Marcus Boerger
- * @version 1.0
- *
- * Loads classes automatically from include_path as given by ini or from
- * current directory of script or include file.
- */
-function __autoload($classname) {
- $classname = strtolower($classname);
- $inc = split(':', ini_get('include_path'));
- $inc[] = '.';
- $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
- foreach($inc as $dir)
- {
- if (__load_class($classname, $dir))
- {
- fprintf(STDERR, 'Loading class('.$classname.")\n");
- return;
- }
- }
- fprintf(STDERR, 'Class not found ('.$classname.")\n");
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/cachingrecursiveiterator.inc b/ext/spl/examples/cachingrecursiveiterator.inc
deleted file mode 100644
index 4fa6b235c3..0000000000
--- a/ext/spl/examples/cachingrecursiveiterator.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/** @file cachingrecursiveiterator.inc
- * @ingroup Examples
- * @brief class CachingRecursiveIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Compatibility to PHP 5.0
- * @author Marcus Boerger
- * @version 1.2
- * @deprecated
- *
- * Class RecursiveCachingIterator was named CachingRecursiveIterator until
- * PHP 5.0.6.
- *
- * @see RecursiveCachingIterator
- */
-
-class CachingRecursiveIterator extends RecursiveCachingIterator
-{
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/class_tree.php b/ext/spl/examples/class_tree.php
deleted file mode 100755
index 4af610835f..0000000000
--- a/ext/spl/examples/class_tree.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-/** @file class_tree.php
- * @brief Class Tree example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- * @version 1.0
- *
- * Usage: php class_tree.php \<class\>
- *
- * Simply specify the root class or interface to tree with parameter \<class\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <class>
-
-Displays a graphical tree for the given <class>.
-
-<class> The class or interface for which to generate the tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RecursiveTreeIterator", false)) require_once("recursivetreeiterator.inc");
-
-/** \brief Collects sub classes for given class or interface
- */
-class SubClasses extends RecursiveArrayIterator
-{
- /** @param base base class to collect sub classes for
- * @param check_interfaces whether we deal with interfaces
- */
- function __construct($base, $check_interfaces = false)
- {
- foreach(get_declared_classes() as $cname)
- {
- if (strcasecmp(get_parent_class($cname), $base) == 0)
- {
- $this->offsetSet($cname, new SubClasses($cname));
- }
- if ($check_interfaces)
- {
- foreach(class_implements($cname) as $iname)
- {
- if (strcasecmp($iname, $base) == 0)
- {
- $this->offsetSet($cname, new SubClasses($cname));
- }
- }
- }
- }
- if ($check_interfaces)
- {
- foreach(get_declared_interfaces() as $cname)
- {
- foreach(class_implements($cname) as $iname)
- {
- if (strcasecmp($iname, $base) == 0)
- {
- $this->offsetSet($cname, new SubClasses($cname, true));
- }
- }
- }
- }
- }
-
- /** @return key() since that is the name we need
- */
- function current()
- {
- return parent::key();
- }
-}
-
-$it = new RecursiveTreeIterator(new SubClasses($argv[1], true));
-
-echo $argv[1]."\n";
-foreach($it as $c=>$v)
-{
- echo "$v\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/dba_array.php b/ext/spl/examples/dba_array.php
deleted file mode 100755
index 346ac1f2f7..0000000000
--- a/ext/spl/examples/dba_array.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/** @file dba_array.php
- * @brief Program DBA array utility
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage php dba_array.php \<file\> \<handler\> \<key\> [\<value\>]
- *
- * If \<value\> is specified then \<key\> is set to \<value\> in \<file\>.
- * Else the value of \<key\> is printed only.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 4) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <file> <handler> <key> [<value>]
-
-If <value> is specified then <key> is set to <value> in <file>.
-Else the value of <key> is printed only.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-try {
- if ($argc > 2) {
- $dba = new DbaArray($argv[1], $argv[2]);
- if ($dba && $argc > 3) {
- if ($argc > 4) {
- $dba[$argv[3]] = $argv[4];
- }
- var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]]));
- }
- unset($dba);
- }
- else
- {
- echo "Not enough parameters\n";
- exit(1);
- }
-}
-catch (exception $err) {
- var_dump($err);
- exit(1);
-}
-?> \ No newline at end of file
diff --git a/ext/spl/examples/dba_dump.php b/ext/spl/examples/dba_dump.php
deleted file mode 100755
index 2c698d427a..0000000000
--- a/ext/spl/examples/dba_dump.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/** @file dba_dump.php
- * @brief Program DBA dump utility
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php dba_dump.php \<file\> \<handler\> [\<regex\>]
- *
- * Show all groups in the ini file specified by \<file\>.
- * The regular expression \<regex\> is used to filter the by setting name.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <file> <handler> [<regex>]
-
-Show all groups in the ini file specified by <file>.
-The regular expression <regex> is used to filter the by setting name.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-
-$db = new DbaReader($argv[1], $argv[2]);
-
-if ($argc>3) {
- $db = new KeyFilter($db, $argv[3]);
-}
-
-foreach($db as $key => $val) {
- echo "'$key' => '$val'\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/dbaarray.inc b/ext/spl/examples/dbaarray.inc
deleted file mode 100755
index fcd6bb378a..0000000000
--- a/ext/spl/examples/dbaarray.inc
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-/** @file dbaarray.inc
- * @ingroup Examples
- * @brief class DbaArray
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-/** @ingroup Examples
- * @brief This implements a DBA Array
- * @author Marcus Boerger
- * @version 1.0
- */
-class DbaArray extends DbaReader implements ArrayAccess
-{
-
- /**
- * Open database $file with $handler in read only mode.
- *
- * @param file Database file to open.
- * @param handler Handler to use for database access.
- */
- function __construct($file, $handler)
- {
- $this->db = dba_popen($file, "c", $handler);
- if (!$this->db) {
- throw new exception("Databse could not be opened");
- }
- }
-
- /**
- * Close database.
- */
- function __destruct()
- {
- parent::__destruct();
- }
-
- /**
- * Read an entry.
- *
- * @param $name key to read from
- * @return value associated with $name
- */
- function offsetGet($name)
- {
- $data = dba_fetch($name, $this->db);
- if($data) {
- if (ini_get('magic_quotes_runtime')) {
- $data = stripslashes($data);
- }
- //return unserialize($data);
- return $data;
- }
- else
- {
- return NULL;
- }
- }
-
- /**
- * Set an entry.
- *
- * @param $name key to write to
- * @param $value value to write
- */
- function offsetSet($name, $value)
- {
- //dba_replace($name, serialize($value), $this->db);
- dba_replace($name, $value, $this->db);
- return $value;
- }
-
- /**
- * @return whether key $name exists.
- */
- function offsetExists($name)
- {
- return dba_exists($name, $this->db);
- }
-
- /**
- * Delete a key/value pair.
- *
- * @param $name key to delete.
- */
- function offsetUnset($name)
- {
- return dba_delete($name, $this->db);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/dbareader.inc b/ext/spl/examples/dbareader.inc
deleted file mode 100755
index b09791239b..0000000000
--- a/ext/spl/examples/dbareader.inc
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-/** @file dbareader.inc
- * @ingroup Examples
- * @brief class DbaReader
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief This implements a DBA Iterator.
- * @author Marcus Boerger
- * @version 1.0
- */
-class DbaReader implements Iterator
-{
-
- protected $db = NULL;
- private $key = false;
- private $val = false;
-
- /**
- * Open database $file with $handler in read only mode.
- *
- * @param file Database file to open.
- * @param handler Handler to use for database access.
- */
- function __construct($file, $handler) {
- if (!$this->db = dba_open($file, 'r', $handler)) {
- throw new exception('Could not open file ' . $file);
- }
- }
-
- /**
- * Close database.
- */
- function __destruct() {
- dba_close($this->db);
- }
-
- /**
- * Rewind to first element.
- */
- function rewind() {
- $this->key = dba_firstkey($this->db);
- $this->fetch_data();
- }
-
- /**
- * Move to next element.
- *
- * @return void
- */
- function next() {
- $this->key = dba_nextkey($this->db);
- $this->fetch_data();
- }
-
- /**
- * Fetches the current data if $key is valid
- */
- private function fetch_data() {
- if ($this->key !== false) {
- $this->val = dba_fetch($this->key, $this->db);
- }
- }
-
- /**
- * @return Current data.
- */
- function current() {
- return $this->val;
- }
-
- /**
- * @return Whether more elements are available.
- */
- function valid() {
- if ($this->db && $this->key !== false) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @return Current key.
- */
- function key() {
- return $this->key;
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/directoryfilterdots.inc b/ext/spl/examples/directoryfilterdots.inc
deleted file mode 100755
index fceeda2a23..0000000000
--- a/ext/spl/examples/directoryfilterdots.inc
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/** @file directoryfilterdots.inc
- * @ingroup Examples
- * @brief class DirectoryFilterDots
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A filtered DirectoryIterator
- * @author Marcus Boerger
- * @version 1.1
- *
- * This Iteraotr takes a pathname from which it creates a DirectoryIterator
- * and makes it recursive. Further more it filters the entries '.' and '..'.
- */
-class DirectoryFilterDots extends RecursiveFilterIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(new DirectoryIterator($path));
- }
-
- /** @return whether the current entry is neither '.' nor '..'
- */
- function accept()
- {
- return !$this->getInnerIterator()->isDot();
- }
-
- /** @return the current entries path name
- */
- function key()
- {
- return $this->getInnerIterator()->getPathname();
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/directorygraphiterator.inc b/ext/spl/examples/directorygraphiterator.inc
deleted file mode 100644
index 5808e3b89e..0000000000
--- a/ext/spl/examples/directorygraphiterator.inc
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/** @file directorygraphiterator.inc
- * @ingroup Examples
- * @brief class DirectoryGraphIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A tree iterator that only shows directories.
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryGraphIterator extends DirectoryTreeIterator
-{
- function __construct($path)
- {
- RecursiveIteratorIterator::__construct(
- new RecursiveCachingIterator(
- new ParentIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- )
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/directorytree.inc b/ext/spl/examples/directorytree.inc
deleted file mode 100755
index 7bd9c2c597..0000000000
--- a/ext/spl/examples/directorytree.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-/** @file directorytree.inc
- * @ingroup Examples
- * @brief class DirectoryTree
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A directory iterator that does not show '.' and '..'.
- * @author Marcus Boerger
- * @version 1.0
- */
-class DirectoryTree extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path) {
- parent::__construct(new DirectoryFilterDots($path));
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/directorytree.php b/ext/spl/examples/directorytree.php
deleted file mode 100755
index dc26d6cc22..0000000000
--- a/ext/spl/examples/directorytree.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-/** @file directorytree.php
- * @brief Program Directory tree example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Displays a graphical directory tree for the given <path>.
-
-<path> The directory for which to generate the directory tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
-
-$length = $argc > 3 ? $argv[3] : -1;
-
-echo $argv[1]."\n";
-foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
-//foreach(new DirectoryTreeIterator($argv[1]) as $file) {
- echo $file . "\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/directorytreeiterator.inc b/ext/spl/examples/directorytreeiterator.inc
deleted file mode 100644
index 8e65d0db12..0000000000
--- a/ext/spl/examples/directorytreeiterator.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/** @file directorytreeiterator.inc
- * @ingroup Examples
- * @brief class DirectoryTreeIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief DirectoryIterator to generate ASCII graphic directory trees
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryTreeIterator extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(
- new RecursiveCachingIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-
- /** @return the current element prefixed with ASCII graphics
- */
- function current()
- {
- $tree = '';
- for ($l=0; $l < $this->getDepth(); $l++) {
- $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
- }
- return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
- . $this->getSubIterator($l)->__toString();
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/dualiterator.inc b/ext/spl/examples/dualiterator.inc
deleted file mode 100755
index 544034856a..0000000000
--- a/ext/spl/examples/dualiterator.inc
+++ /dev/null
@@ -1,212 +0,0 @@
-<?php
-
-/** @file dualiterator.inc
- * @ingroup Examples
- * @brief class DualIterator
- * @author Marcus Boerger
- * @date 2003 - 2006
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Synchronous iteration over two iterators
- * @author Marcus Boerger
- * @version 1.1
- */
-class DualIterator implements Iterator
-{
- const CURRENT_LHS = 0x01;
- const CURRENT_RHS = 0x02;
- const CURRENT_ARRAY = 0x03;
- const CURRENT_0 = 0x00;
-
- const KEY_LHS = 0x10;
- const KEY_RHS = 0x20;
- const KEY_ARRAY = 0x30;
- const KEY_0 = 0x00;
-
- const DEFAULT_FLAGS = 0x33;
-
- private $lhs;
- private $rhs;
- private $flags;
-
- /** construct iterator from two iterators
- *
- * @param lhs Left Hand Side Iterator
- * @param rhs Right Hand Side Iterator
- * @param flags iteration flags
- */
- function __construct(Iterator $lhs, Iterator $rhs,
- $flags = 0x33 /*DualIterator::DEFAULT_FLAGS*/)
- {
- $this->lhs = $lhs;
- $this->rhs = $rhs;
- $this->flags = $flags;
- }
-
- /** @return Left Hand Side Iterator
- */
- function getLHS()
- {
- return $this->lhs;
- }
-
- /** @return Right Hand Side Iterator
- */
- function getRHS()
- {
- return $this->rhs;
- }
-
- /** @param flags new flags
- */
- function setFlags($flags)
- {
- $this->flags = $flags;
- }
-
- /** @return current flags
- */
- function getFlags()
- {
- return $this->flags;
- }
-
- /** rewind both inner iterators
- */
- function rewind()
- {
- $this->lhs->rewind();
- $this->rhs->rewind();
- }
-
- /** @return whether both inner iterators are valid
- */
- function valid()
- {
- return $this->lhs->valid() && $this->rhs->valid();
- }
-
- /** @return current value depending on CURRENT_* flags
- */
- function current()
- {
- switch($this->flags & 0x0F)
- {
- default:
- case self::CURRENT_ARRAY:
- return array($this->lhs->current(), $this->rhs->current());
- case self::CURRENT_LHS:
- return $this->lhs->current();
- case self::CURRENT_RHS:
- return $this->rhs->current();
- case self::CURRENT_0:
- return NULL;
- }
- }
-
- /** @return current value depending on KEY_* flags
- */
- function key()
- {
- switch($this->flags & 0xF0)
- {
- default:
- case self::CURRENT_ARRAY:
- return array($this->lhs->key(), $this->rhs->key());
- case self::CURRENT_LHS:
- return $this->lhs->key();
- case self::CURRENT_RHS:
- return $this->rhs->key();
- case self::CURRENT_0:
- return NULL;
- }
- }
-
- /** move both inner iterators forward
- */
- function next()
- {
- $this->lhs->next();
- $this->rhs->next();
- }
-
- /** @return whether both inner iterators are valid and have identical
- * current and key values or both are non valid.
- */
- function areIdentical()
- {
- return $this->valid()
- ? $this->lhs->current() === $this->rhs->current()
- && $this->lhs->key() === $this->rhs->key()
- : $this->lhs->valid() == $this->rhs->valid();
- }
-
- /** @return whether both inner iterators are valid and have equal current
- * and key values or both are non valid.
- */
- function areEqual()
- {
- return $this->valid()
- ? $this->lhs->current() == $this->rhs->current()
- && $this->lhs->key() == $this->rhs->key()
- : $this->lhs->valid() == $this->rhs->valid();
- }
-
- /** Compare two iterators
- *
- * @param lhs Left Hand Side Iterator
- * @param rhs Right Hand Side Iterator
- * @param identical whether to use areEqual() or areIdentical()
- * @return whether both iterators are equal/identical
- *
- * @note If one implements RecursiveIterator the other must do as well.
- * And if both do then a recursive comparison is being used.
- */
- static function compareIterators(Iterator $lhs, Iterator $rhs,
- $identical = false)
- {
- if ($lhs instanceof RecursiveIterator)
- {
- if ($rhs instanceof RecursiveIterator)
- {
- $it = new RecursiveDualIterator($lhs, $rhs,
- self::CURRENT_0 | self::KEY_0);
- }
- else
- {
- return false;
- }
- }
- else
- {
- $it = new DualIterator($lhs, $rhs, self::CURRENT_0 | self::KEY_0);
- }
-
- if ($identical)
- {
- foreach(new RecursiveIteratorIterator($it) as $n)
- {
- if (!$it->areIdentical())
- {
- return false;
- }
- }
- }
- else
- {
- foreach($it as $n)
- {
- if (!$it->areEqual())
- {
- return false;
- }
- }
- }
- return $identical ? $it->areIdentical() : $it->areEqual();
- }
-}
-
-?>
diff --git a/ext/spl/examples/findfile.inc b/ext/spl/examples/findfile.inc
deleted file mode 100755
index 05d525a3fb..0000000000
--- a/ext/spl/examples/findfile.inc
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-/** @file findfile.inc
- * @ingroup Examples
- * @brief class FindFile
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("FindFile", false)) require_once("findfile.inc");
-if (!class_exists("AppendIterator", false)) require_once("appenditerator.inc");
-
-/** @ingroup Examples
- * @brief Base class to find files
- * @author Marcus Boerger
- * @version 1.1
- *
- */
-class FindFile extends FilterIterator
-{
- /** @internal filename to find */
- private $file;
-
- /** Construct from path and filename
- *
- * @param $path the directory to search in
- * If path contains ';' then this parameter is split and every
- * part of it is used as separate directory.
- * @param $file the name of the files to search fro
- */
- function __construct($path, $file)
- {
- $this->file = $file;
- $list = split(';', $path);
- if (count($list) <= 1) {
- parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
- } else {
- $it = new AppendIterator();
- foreach($list as $path) {
- $it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
- }
- parent::__construct($it);
- }
- }
-
- /** @return whether the current file matches the given filename
- */
- function accept()
- {
- return !strcmp($this->current(), $this->file);
- }
-
- /** @return the filename to search for.
- * @note This may be overloaded and contain a regular expression for an
- * extended class that uses regular expressions to search.
- */
- function getSearch()
- {
- return $this->file;
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/findfile.php b/ext/spl/examples/findfile.php
deleted file mode 100755
index 60146cbffd..0000000000
--- a/ext/spl/examples/findfile.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/** @file findfile.php
- * @brief Program Find a specific file by name.
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php findfile.php \<path\> \<name\>
- *
- * \<path\> Path to search in. You can specify multiple paths by separating
- * them with ';'.
- * \<name\> Filename to look for.
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php findfile.php <path> <name>
-
-Find a specific file by name.
-
-<path> Path to search in.
-<name> Filename to look for.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("FindFile", false)) require_once("findfile.inc");
-
-foreach(new FindFile($argv[1], $argv[2]) as $file) echo $file->getPathname()."\n";
-?> \ No newline at end of file
diff --git a/ext/spl/examples/findregex.php b/ext/spl/examples/findregex.php
deleted file mode 100755
index b43ee0cbbc..0000000000
--- a/ext/spl/examples/findregex.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/** @file findregex.php
- * @brief Program Find a specific file by name.
- * @ingroup Examples
- * @author Marcus Boerger, Adam Trachtenberg
- * @date 2004
- *
- * Usage: php findregex.php \<path\> \<name\>
- *
- * \<path\> Path to search in.
- * \<name\> Filename to look for.
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php findregex.php <file> <name>
-
-Find a specific file by name.
-
-<path> Path to search in.
-<name> Regex for filenames to look for.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RegexFindFile", false)) require_once("regexfindfile.inc");
-
-foreach(new RegexFindFile($argv[1], $argv[2]) as $file)
-{
- echo $file->getPathname()."\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/ini_groups.php b/ext/spl/examples/ini_groups.php
deleted file mode 100755
index 5136911096..0000000000
--- a/ext/spl/examples/ini_groups.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/** @file ini_groups.php
- * @brief Program List groups within an ini file
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php dba_dump.php \<file\> [\<regex\>]
- *
- * Show all groups in the ini file specified by \<file\>.
- * The regular expression \<regex\> is used to filter the result.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php dba_dump.php <file> [<regex>]
-
-Show all groups in the ini file specified by <file>.
-The regular expression <regex> is used to filter the result.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-if (!class_exists("IniGroups", false)) require_once("inigroups.inc");
-
-$it = new IniGroups($argv[1]);
-if ($argc>2) {
- $it = new KeyFilter($it, $argv[2]);
-}
-
-foreach($it as $group) {
- echo "$group\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/inigroups.inc b/ext/spl/examples/inigroups.inc
deleted file mode 100755
index 62cfa3e029..0000000000
--- a/ext/spl/examples/inigroups.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/** @file inigroups.inc
- * @ingroup Examples
- * @brief class IniGroups
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-/** @ingroup Examples
- * @brief Class to iterate all groups within an ini file.
- * @author Marcus Boerger
- * @version 1.1
- *
- * Using this class you can iterator over all groups of a ini file.
- *
- * This class uses a 'is-a' relation to KeyFilter in contrast to a 'has-a'
- * relation. Doing so both current() and key() methods must be overwritten.
- * If it would use a 'has-a' relation there would be much more to type...
- * but for puritists that would allow correctness in so far as then no
- * key() would be needed.
- */
-class IniGroups extends KeyFilter
-{
- /**
- * Construct an ini file group iterator from a filename.
- *
- * @param file Ini file to open.
- */
- function __construct($file) {
- parent::__construct(new DbaReader($file, 'inifile'), '^\[.*\]$');
- }
-
- /**
- * @return The current group.
- */
- function current() {
- return substr(parent::key(),1,-1);
- }
-
- /**
- * @return The current group.
- */
- function key() {
- return substr(parent::key(),1,-1);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/keyfilter.inc b/ext/spl/examples/keyfilter.inc
deleted file mode 100755
index eaf6b77364..0000000000
--- a/ext/spl/examples/keyfilter.inc
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-/** @file keyfilter.inc
- * @ingroup Examples
- * @brief class KeyFilter
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Regular expression filter for string iterators
- * @author Marcus Boerger
- * @version 1.1
- *
- * Instances of this class act as a filter around iterators whose elements
- * are strings. In other words you can put an iterator into the constructor
- * and the instance will only return elements which match the given regular
- * expression.
- */
-class KeyFilter extends FilterIterator
-{
- /** @internal regular exoression used as filter */
- private $regex;
-
- /**
- * Constructs a filter around an iterator whose elemnts are strings.
- * If the given iterator is of type spl_sequence then its rewind()
- * method is called.
- *
- * @param it Object that implements at least spl_forward
- * @param regex Regular expression used as a filter.
- */
- function __construct(Iterator $it, $regex)
- {
- parent::__construct($it);
- $this->regex = $regex;
- }
-
- /** \return whether the current key mathes the regular expression
- */
- function accept()
- {
- return ereg($this->regex, $this->getInnerIterator()->key());
- }
-
- /** @return regular expression used as filter
- */
- function getRegex()
- {
- return $this->regex;
- }
-
- /**
- * hidden __clone
- */
- protected function __clone()
- {
- // disallow clone
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/nocvsdir.php b/ext/spl/examples/nocvsdir.php
deleted file mode 100755
index 6993268945..0000000000
--- a/ext/spl/examples/nocvsdir.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-/** @file nocvsdir.php
- * @brief Program Dir without CVS subdirs
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2006
- * @version 1.1
- *
- * Usage: php nocvsdir.php \<path\>
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Show the directory and all it's contents without any CVS directory in <path>.
-
-<path> The directory for which to generate the directory.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RecursiveFilterIterator")) require_once("recursivefilteriterator.inc");
-
-class NoCvsDirectory extends RecursiveFilterIterator
-{
- function __construct($path)
- {
- parent::__construct(new RecursiveDirectoryIterator($path));
- }
-
- function accept()
- {
- return $this->getInnerIterator()->getFilename() != 'CVS';
- }
-
- function getChildren()
- {
- return new NoCvsDirectory($this->key());
- }
-}
-
-$it = new RecursiveIteratorIterator(new NoCvsDirectory($argv[1]));
-
-foreach($it as $pathname => $file)
-{
- echo $pathname."\n";
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/recursivedualiterator.inc b/ext/spl/examples/recursivedualiterator.inc
deleted file mode 100755
index 702e0cd745..0000000000
--- a/ext/spl/examples/recursivedualiterator.inc
+++ /dev/null
@@ -1,72 +0,0 @@
-<?php
-
-/** @file recursivedualiterator.inc
- * @ingroup Examples
- * @brief class RecursiveDualIterator
- * @author Marcus Boerger
- * @date 2003 - 2006
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Synchronous iteration over two recursive iterators
- * @author Marcus Boerger
- * @version 1.0
- */
-class RecursiveDualIterator extends DualIterator implements RecursiveIterator
-{
- private $ref;
-
- /** construct iterator from two iterators
- *
- * @param lhs Left Hand Side Iterator
- * @param rhs Right Hand Side Iterator
- * @param flags iteration flags
- */
- function __construct(RecursiveIterator $lhs, RecursiveIterator $rhs,
- $flags = 0x33 /*DualIterator::DEFAULT_FLAGS*/)
- {
- parent::__construct($lhs, $rhs, $flags);
- }
-
- /** @return whether both LHS and RHS have children
- */
- function hasChildren()
- {
- return $this->getLHS()->hasChildren() && $this->getRHS()->hasChildren();
- }
-
- /** @return new RecursiveDualIterator (late binding) for the two inner
- * iterators current children.
- */
- function getChildren()
- {
- if (empty($this->ref))
- {
- $this->ref = new ReflectionClass($this);
- }
- return $this->ref->newInstance(
- $this->getLHS()->getChildren(), $this->getRHS()->getChildren(), $this->getFlags());
- }
-
- /** @return whether both inner iterators are valid, have same hasChildren()
- * state and identical current and key values or both are non valid.
- */
- function areIdentical()
- {
- return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren()
- && parent::areIdentical();
- }
-
- /** @return whether both inner iterators are valid, have same hasChildren()
- * state and equal current and key values or both are invalid.
- */
- function areEqual()
- {
- return $this->getLHS()->hasChildren() === $this->getRHS()->hasChildren()
- && parent::areEqual();
- }
-}
-
-?>
diff --git a/ext/spl/examples/recursivetreeiterator.inc b/ext/spl/examples/recursivetreeiterator.inc
deleted file mode 100755
index 42d217fa76..0000000000
--- a/ext/spl/examples/recursivetreeiterator.inc
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-
-/** @file recursivetreeiterator.inc
- * @ingroup Examples
- * @brief class RecursiveTreeIterator
- * @author Marcus Boerger, Johannes Schlueter
- * @date 2005
- *
- * SPL - Standard PHP Library
- */
-
-
-/** @ingroup Examples
- * @brief RecursiveIteratorIterator to generate ASCII graphic trees for the
- * entries in a RecursiveIterator
- * @author Marcus Boerger, Johannes Schlueter
- * @version 1.0
- */
-class RecursiveTreeIterator extends RecursiveIteratorIterator
-{
- const BYPASS_CURRENT = 0x00000004;
- const BYPASS_KEY = 0x00000008;
-
- private $rit_flags;
-
- /**
- * @param it iterator to use as inner iterator
- * @param rit_flags flags passed to RecursiveIteratoIterator (parent)
- * @param cit_flags flags passed to RecursiveCachingIterator (for hasNext)
- * @param mode mode passed to RecursiveIteratoIterator (parent)
- */
- function __construct(RecursiveIterator $it, $rit_flags = self::BYPASS_KEY, $cit_flags = CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
- {
- parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags);
- $this->rit_flags = $rit_flags;
- }
-
- /** Prefix strings used in getPrefix()
- *
- * 0: prefix used to start elements
- * 1: prefix used if $level < depth and hasNext($level) == true
- * 2: prefix used if $level < depth and hasNext($level) == false
- * 3: prefix used if $level == depth and hasNext($level) == true
- * 4: prefix used if $level == depth and hasNext($level) == false
- * 5: prefix used right in front of the current element
- */
- public $prefix = array(0=>'', 1=>'| ', 2=>' ', 3=>'|-', 4=>'\-', 5=>'');
-
- /** @return string to place in front of current element
- */
- function getPrefix()
- {
- $tree = '';
- for ($level = 0; $level < $this->getDepth(); $level++)
- {
- $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[1] : $this->prefix[2];
- }
- $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[3] : $this->prefix[4];
-
- return $this->prefix[0] . $tree . $this->prefix[5];
- }
-
- /** @return string presentation build for current element
- */
- function getEntry()
- {
- return @(string)parent::current();
- }
-
- /** @return string to place after the current element
- */
- function getPostfix()
- {
- return '';
- }
-
- /** @return the current element prefixed and postfixed
- */
- function current()
- {
- if ($this->rit_flags & self::BYPASS_CURRENT)
- {
- return parent::current();
- }
- else
- {
- return $this->getPrefix() . $this->getEntry() . $this->getPostfix();
- }
- }
-
- /** @return the current key prefixed and postfixed
- */
- function key()
- {
- if ($this->rit_flags & self::BYPASS_KEY)
- {
- return parent::key();
- }
- else
- {
- return $this->getPrefix() . parent::key() . $this->getPostfix();
- }
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/regexfindfile.inc b/ext/spl/examples/regexfindfile.inc
deleted file mode 100755
index d5dd722536..0000000000
--- a/ext/spl/examples/regexfindfile.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/** @file regexfindfile.inc
- * @ingroup Examples
- * @brief class RegexFindFile
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Find files by regular expression
- * @author Marcus Boerger
- * @version 1.1
- *
- */
-class RegexFindFile extends FindFile
-{
- /** Construct from path and regular expression
- *
- * @param $path the directory to search in
- * If path contains ';' then this parameter is split and every
- * part of it is used as separate directory.
- * @param $regex perl style regular expression to find files with
- */
- function __construct($path, $regex)
- {
- parent::__construct($path, $regex);
- }
-
- /** @return whether the current filename matches the regular expression.
- */
- function accept()
- {
- return preg_match($this->getSearch(), $this->current());
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/searchiterator.inc b/ext/spl/examples/searchiterator.inc
deleted file mode 100755
index 944a4ac5a5..0000000000
--- a/ext/spl/examples/searchiterator.inc
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-/** @file searchiterator.inc
- * @ingroup Examples
- * @brief abstract class SearchIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Iterator to search for a specific element
- * @author Marcus Boerger
- * @version 1.0
- *
- * This extended FilterIterator stops after finding the first acceptable
- * value.
- */
-abstract class SearchIterator extends FilterIterator
-{
- /** @internal whether an entry was found already */
- private $done = false;
-
- /** Rewind and reset so that it once again searches.
- * @return void
- */
- function rewind()
- {
- parent::rewind();
- $this->done = false;
- }
-
- /** @return whether the current element is valid
- * which can only happen once per iteration.
- */
- function valid()
- {
- return !$this->done && parent::valid();
- }
-
- /** Do not move forward but instead mark as finished.
- * @return void
- */
- function next()
- {
- $this->done = true;
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getInnerIterator(), $func), $params);
- }
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/tests/dualiterator_001.phpt b/ext/spl/examples/tests/dualiterator_001.phpt
deleted file mode 100755
index 5577c4dc18..0000000000
--- a/ext/spl/examples/tests/dualiterator_001.phpt
+++ /dev/null
@@ -1,47 +0,0 @@
---TEST--
-SPL: DualIterator
---SKIPIF--
-<?php if (!extension_loaded("spl")) print "skip"; ?>
---FILE--
-<?php
-
-function spl_examples_autoload($classname)
-{
- include(dirname(__FILE__) . '/../' . strtolower($classname) . '.inc');
-}
-
-spl_autoload_register('spl_examples_autoload');
-
-function test($a, $b, $identical = false)
-{
- var_dump(DualIterator::compareIterators(
- new RecursiveArrayIterator($a),
- new RecursiveArrayIterator($b),
- $identical));
-}
-
-test(array(1,2,3), array(1,2,3));
-test(array(1,2,3), array(1,2));
-test(array(1,array(21,22),3), array(1,array(21,22),3));
-test(array(1,array(21,22),3), array(1,array(21,22,23),3));
-test(array(1,array(21,22),3), array(1,array(21,22,3)));
-test(array(1,array(21,22),3), array(1,array(21),array(22),3));
-test(array(1,2,3), array(1,"2",3), false);
-test(array(1,2,3), array(1,"2",3), true);
-test(array(1,array(21,22),3), array(1,array(21,"22"),3), false);
-test(array(1,array(21,22),3), array(1,array(21,"22"),3), true);
-
-?>
-===DONE===
---EXPECT--
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-bool(false)
-bool(false)
-bool(true)
-bool(false)
-bool(true)
-bool(false)
-===DONE===
diff --git a/ext/spl/examples/tests/examples.inc b/ext/spl/examples/tests/examples.inc
deleted file mode 100755
index feeba7db24..0000000000
--- a/ext/spl/examples/tests/examples.inc
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-class IncludeFiles extends ArrayIterator
-{
- function __construct($path, $classes)
- {
- parent::__construct();
- foreach($classes as $c)
- {
- $this->append($path . '/' . strtolower($c) . '.inc');
- }
- }
-}
-
-$classes = array(
-);
-
-foreach (new IncludeFiles(dirname(__FILE__). '/..', $classes) as $file)
-{
- require_once($file);
-}
-
-?> \ No newline at end of file
diff --git a/ext/spl/examples/tree.php b/ext/spl/examples/tree.php
deleted file mode 100755
index 5af36a673c..0000000000
--- a/ext/spl/examples/tree.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/** @file tree.php
- * @brief Program Tree view example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php tree.php \<path\>
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-// The following line only operates on classes which are converted to c already.
-// But does not generate a graphical output.
-//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Displays a graphical tree for the given <path>.
-
-<path> The directory for which to generate the tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
-if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
-
-echo $argv[1]."\n";
-foreach(new DirectoryGraphIterator($argv[1]) as $file)
-{
- echo $file . "\n";
-}
-
-?> \ No newline at end of file