From 899cc40f7da5c6265a288e43e07e0d249b3d38b4 Mon Sep 17 00:00:00 2001 From: Peter Cowburn Date: Sat, 27 Jun 2009 12:54:54 +0000 Subject: [PATCH] Padded out SPL FilesystemIterator skeleton docs git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@282867 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/spl/filesystemiterator.xml | 132 +++++++++++++++++- .../spl/filesystemiterator/construct.xml | 54 ++++++- reference/spl/filesystemiterator/current.xml | 40 +++++- reference/spl/filesystemiterator/getflags.xml | 9 +- reference/spl/filesystemiterator/key.xml | 43 +++++- reference/spl/filesystemiterator/next.xml | 40 +++++- reference/spl/filesystemiterator/rewind.xml | 39 +++++- reference/spl/filesystemiterator/setflags.xml | 52 ++++++- 8 files changed, 370 insertions(+), 39 deletions(-) diff --git a/reference/spl/filesystemiterator.xml b/reference/spl/filesystemiterator.xml index 8dbc3cfc7c..13b1f70ad1 100644 --- a/reference/spl/filesystemiterator.xml +++ b/reference/spl/filesystemiterator.xml @@ -1,5 +1,5 @@ - + @@ -48,6 +48,68 @@ + + Constants + + const + integer + FilesystemIterator::CURRENT_AS_PATHNAME + 32 + + + const + integer + FilesystemIterator::CURRENT_AS_FILEINFO + 0 + + + const + integer + FilesystemIterator::CURRENT_AS_SELF + 16 + + + const + integer + FilesystemIterator::CURRENT_MODE_MASK + 240 + + + const + integer + FilesystemIterator::KEY_AS_PATHNAME + 0 + + + const + integer + FilesystemIterator::KEY_AS_FILENAME + 256 + + + const + integer + FilesystemIterator::KEY_MODE_MASK + 3840 + + + const + integer + FilesystemIterator::NEW_CURRENT_AND_KEY + 256 + + + const + integer + FilesystemIterator::SKIP_DOTS + 4096 + + + const + integer + FilesystemIterator::UNIX_PATHS + 8192 + Methods @@ -59,6 +121,74 @@ + + +
+ &reftitle.constants; + + + FilesystemIterator::CURRENT_AS_PATHNAME + + Makes FilesystemIterator::current return the pathname. + + + + FilesystemIterator::CURRENT_AS_FILEINFO + + Makes FilesystemIterator::current return an SplFileInfo instance. + + + + FilesystemIterator::CURRENT_AS_SELF + + Makes FilesystemIterator::current return $this (the FilesystemIterator). + + + + FilesystemIterator::CURRENT_MODE_MASK + + Masks FilesystemIterator::current + + + + FilesystemIterator::KEY_AS_PATHNAME + + Makes FilesystemIterator::key return the pathname. + + + + FilesystemIterator::KEY_AS_FILENAME + + Makes FilesystemIterator::key return the filename. + + + + FilesystemIterator::KEY_MODE_MASK + + Masks FilesystemIterator::key + + + + FilesystemIterator::NEW_CURRENT_AND_KEY + + Same as FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::CURRENT_AS_FILEINFO. + + + + FilesystemIterator::SKIP_DOTS + + Skips dot files (. and ..). + + + + FilesystemIterator::UNIX_PATHS + + Makes paths use Unix-style forward slash irrespective of system default. + + + +
+ diff --git a/reference/spl/filesystemiterator/construct.xml b/reference/spl/filesystemiterator/construct.xml index fa3b7c7a93..d3413f89e6 100644 --- a/reference/spl/filesystemiterator/construct.xml +++ b/reference/spl/filesystemiterator/construct.xml @@ -1,5 +1,5 @@ - + @@ -12,14 +12,12 @@ FilesystemIterator::__construct stringpath - stringflags + intflagsFilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::SKIP_DOTS Constructs a new filesystem iterator from the path. - &warn.undocumented.func; - @@ -30,7 +28,7 @@ path - The path. + The path of the filesystem item to be iterated over. @@ -38,7 +36,9 @@ flags - The desired flags. + Flags may be provided which will affect the behavior of some methods. + A list of the flags can found under FilesystemIterator predefined constants. + They can also be set later with FilesystemIterator::setFlags @@ -46,6 +46,48 @@ + + &reftitle.returnvalues; + + &return.void; + + + + + &reftitle.errors; + + Throws an UnexpectedValueException + if the path cannot be found. + + + + + &reftitle.examples; + + + <function>FilesystemIterator::__construct</function> example + +getFilename() . "\n"; +} +?> +]]> + + &example.outputs; + + + + + + + &reftitle.seealso; diff --git a/reference/spl/filesystemiterator/current.xml b/reference/spl/filesystemiterator/current.xml index 1d2f071abf..83cc873fb0 100644 --- a/reference/spl/filesystemiterator/current.xml +++ b/reference/spl/filesystemiterator/current.xml @@ -1,5 +1,5 @@ - + @@ -10,14 +10,12 @@ &reftitle.description; - mixed FilesystemIterator::current + public mixedFilesystemIterator::current Get file information of the current element. - - &warn.undocumented.func; @@ -29,7 +27,38 @@ &reftitle.returnvalues; - The Filename, File information, or $this depending on the set flags. + The filename, file information, or $this depending on the set flags. + See the FilesystemIterator constants. + + + + + &reftitle.examples; + + + <methodname>FilesystemIterator::current</methodname> example + + This example will list the contents of the directory containing the script. + + +current() . "\n"; +} +?> +]]> + + &example.outputs.similar; + + + + @@ -37,6 +66,7 @@ &reftitle.seealso; + FilesystemIterator constants DirectoryIterator::current DirectoryIterator::getFileName diff --git a/reference/spl/filesystemiterator/getflags.xml b/reference/spl/filesystemiterator/getflags.xml index e33e48d409..e55a91986e 100644 --- a/reference/spl/filesystemiterator/getflags.xml +++ b/reference/spl/filesystemiterator/getflags.xml @@ -1,5 +1,5 @@ - + @@ -14,11 +14,9 @@ - Gets the handling flags, as set in FilesystemIterator::__construct. + Gets the handling flags, as set in FilesystemIterator::__construct or FilesystemIterator::setFlags. - &warn.undocumented.func; - @@ -29,7 +27,7 @@ &reftitle.returnvalues; - The value of the set flags. + The integer value of the set flags. @@ -38,6 +36,7 @@ FilesystemIterator::__construct + FilesystemIterator::setFlags diff --git a/reference/spl/filesystemiterator/key.xml b/reference/spl/filesystemiterator/key.xml index aec77141e9..e9f5d070cb 100644 --- a/reference/spl/filesystemiterator/key.xml +++ b/reference/spl/filesystemiterator/key.xml @@ -1,21 +1,18 @@ - + FilesystemIterator::key - Retrieve the file name + Retrieve the key for the current file &reftitle.description; - stringFilesystemIterator::key + public stringFilesystemIterator::key - - &warn.undocumented.func; - @@ -26,7 +23,38 @@ &reftitle.returnvalues; - Returns the Pathname or Filename depending on the set flags. + Returns the pathname or filename depending on the set flags. + See the FilesystemIterator constants. + + + + + &reftitle.examples; + + + <methodname>FilesystemIterator::key</methodname> example + + This example will list the contents of the directory containing the script. + + +key() . "\n"; +} +?> +]]> + + &example.outputs.similar; + + + + @@ -34,6 +62,7 @@ &reftitle.seealso; + FilesystemIterator constants DirectoryIterator::key DirectoryIterator::getFilename DirectoryIterator::getPathname diff --git a/reference/spl/filesystemiterator/next.xml b/reference/spl/filesystemiterator/next.xml index 331fd71e31..87fef1ae01 100644 --- a/reference/spl/filesystemiterator/next.xml +++ b/reference/spl/filesystemiterator/next.xml @@ -1,10 +1,10 @@ - + FilesystemIterator::next - Move to the next entry + Move to the next file @@ -14,11 +14,8 @@ - Move to the next entry. + Move to the next file. - - &warn.undocumented.func; - @@ -33,6 +30,37 @@ + + &reftitle.examples; + + + <methodname>FilesystemIterator::next</methodname> example + + List the contents of a directory using a while loop. + + +valid()) { + echo $iterator->getFilename() . "\n"; + $iterator->next(); +} +?> +]]> + + &example.outputs.similar; + + + + + + + &reftitle.seealso; diff --git a/reference/spl/filesystemiterator/rewind.xml b/reference/spl/filesystemiterator/rewind.xml index 2f8043c4cc..c7b5803758 100644 --- a/reference/spl/filesystemiterator/rewind.xml +++ b/reference/spl/filesystemiterator/rewind.xml @@ -1,10 +1,10 @@ - + FilesystemIterator::rewind - Rewinds dir + Rewinds back to the beginning @@ -16,9 +16,6 @@ Rewinds the directory back to the start. - - &warn.undocumented.func; - @@ -33,6 +30,38 @@ + + &reftitle.examples; + + + <methodname>FilesystemIterator::rewind</methodname> example + +key() . "\n"; + +$iterator->next(); +echo $iterator->key() . "\n"; + +$iterator->rewind(); +echo $iterator->key() . "\n"; +?> +]]> + + &example.outputs.similar; + + + + + + + &reftitle.seealso; diff --git a/reference/spl/filesystemiterator/setflags.xml b/reference/spl/filesystemiterator/setflags.xml index a04b5d9a91..0c90fecdd7 100644 --- a/reference/spl/filesystemiterator/setflags.xml +++ b/reference/spl/filesystemiterator/setflags.xml @@ -1,5 +1,5 @@ - + @@ -11,14 +11,12 @@ &reftitle.description; public voidFilesystemIterator::setFlags - stringflags + intflags Sets handling flags. - &warn.undocumented.func; - @@ -30,6 +28,7 @@ The handling flags to set. + See the FilesystemIterator constants. @@ -44,6 +43,51 @@ + + &reftitle.examples; + + + <methodname>FilesystemIterator::key</methodname> example + + This example demonstrates the difference between the + FilesystemIterator::KEY_AS_PATHNAME and + FilesystemIterator::KEY_AS_FILENAME flags. + + + $fileinfo) { + echo $key . "\n"; +} + +$iterator->setFlags(FilesystemIterator::KEY_AS_FILENAME); +echo "\nKey as Filename:\n"; +foreach ($iterator as $key => $fileinfo) { + echo $key . "\n"; +} +?> +]]> + + &example.outputs.similar; + + + + + + + &reftitle.seealso;