PageRenderTime 65ms CodeModel.GetById 56ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 1ms

/PHP/CompatInfo/Reference/spl.php

http://github.com/llaville/php-compat-info
PHP | 281 lines | 184 code | 13 blank | 84 comment | 32 complexity | 9900f7fcaba38d3ee4ccf3c653254b89 MD5 | raw file
  1<?php
  2/**
  3 * Version informations about SPL extension
  4 *
  5 * PHP version 5
  6 *
  7 * @category PHP
  8 * @package  PHP_CompatInfo
  9 * @author   Laurent Laville <pear@laurent-laville.org>
 10 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
 11 * @version  SVN: $Id$
 12 * @link     http://php5.laurent-laville.org/compatinfo/
 13 */
 14
 15/**
 16 * All interfaces, classes, functions, constants about SPL extension
 17 *
 18 * @category PHP
 19 * @package  PHP_CompatInfo
 20 * @author   Laurent Laville <pear@laurent-laville.org>
 21 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD License
 22 * @version  Release: @package_version@
 23 * @link     http://php5.laurent-laville.org/compatinfo/
 24 * @link     http://www.php.net/manual/en/book.spl.php
 25 */
 26class PHP_CompatInfo_Reference_SPL implements PHP_CompatInfo_Reference
 27{
 28    /**
 29     * Gets all informations at once about:
 30     * extensions, interfaces, classes, functions, constants
 31     *
 32     * @param string $extension OPTIONAL
 33     * @param string $version   OPTIONAL PHP version
 34     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 35     *
 36     * @return array
 37     */
 38    public function getAll($extension = null, $version = null)
 39    {
 40        $references = array(
 41            'extensions' => $this->getExtensions($extension, $version),
 42            'interfaces' => $this->getInterfaces($extension, $version),
 43            'classes'    => $this->getClasses($extension, $version),
 44            'functions'  => $this->getFunctions($extension, $version),
 45            'constants'  => $this->getConstants($extension, $version),
 46        );
 47        return $references;
 48    }
 49
 50    /**
 51     * Gets informations about extensions
 52     *
 53     * @param string $extension OPTIONAL
 54     * @param string $version   OPTIONAL PHP version
 55     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 56     *
 57     * @return array
 58     */
 59    public function getExtensions($extension = null, $version = null)
 60    {
 61        $extensions = array(
 62            'SPL' => array('5.0.0', '', '0.2')
 63        );
 64        return $extensions;
 65    }
 66
 67    /**
 68     * Gets informations about interfaces
 69     *
 70     * @param string $extension OPTIONAL
 71     * @param string $version   OPTIONAL PHP version
 72     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 73     *
 74     * @return array
 75     * @link   http://www.php.net/manual/en/spl.interfaces.php
 76     */
 77    public function getInterfaces($extension = null, $version = null)
 78    {
 79        $interfaces = array();
 80
 81        if ((null == $version ) || ('4' == $version)) {
 82            $version4 = array(
 83            );
 84            $interfaces = array_merge(
 85                $interfaces,
 86                $version4
 87            );
 88        }
 89        if ((null == $version ) || ('5' == $version)) {
 90            $version5 = array(
 91                'Countable'                      => array('5.1.0', ''),
 92                'OuterIterator'                  => array('5.1.0', ''),
 93                'RecursiveIterator'              => array('5.1.0', ''),
 94                'SeekableIterator'               => array('5.1.0', ''),
 95                'Traversable'                    => array('5.1.0', ''),
 96                'Iterator'                       => array('5.1.0', ''),
 97                'IteratorAggregate'              => array('5.1.0', ''),
 98                'ArrayAccess'                    => array('5.1.0', ''),
 99                'Serializable'                   => array('5.1.0', ''),
100                'SplObserver'                    => array('5.1.0', ''),
101                'SplSubject'                     => array('5.1.0', ''),
102            );
103            $interfaces = array_merge(
104                $interfaces,
105                $version5
106            );
107        }
108        return $interfaces;
109    }
110
111    /**
112     * Gets informations about classes
113     *
114     * @param string $extension OPTIONAL
115     * @param string $version   OPTIONAL PHP version
116     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
117     *
118     * @return array
119     * @link   http://www.php.net/manual/en/spl.datastructures.php
120     * @link   http://www.php.net/manual/en/spl.iterators.php
121     * @link   http://www.php.net/manual/en/spl.exceptions.php
122     * @link   http://www.php.net/manual/en/spl.files.php
123     */
124    public function getClasses($extension = null, $version = null)
125    {
126        $classes = array();
127
128        if ((null == $version ) || ('4' == $version)) {
129            $version4 = array(
130            );
131            $classes = array_merge(
132                $classes,
133                $version4
134            );
135        }
136        if ((null == $version ) || ('5' == $version)) {
137            $version5 = array(
138                'Exception'                      => array('5.1.0', ''),
139                'ErrorException'                 => array('5.1.0', ''),
140                'LogicException'                 => array('5.1.0', ''),
141                'BadFunctionCallException'       => array('5.1.0', ''),
142                'BadMethodCallException'         => array('5.1.0', ''),
143                'DomainException'                => array('5.1.0', ''),
144                'InvalidArgumentException'       => array('5.1.0', ''),
145                'LengthException'                => array('5.1.0', ''),
146                'OutOfRangeException'            => array('5.1.0', ''),
147                'RuntimeException'               => array('5.1.0', ''),
148                'OutOfBoundsException'           => array('5.1.0', ''),
149                'OverflowException'              => array('5.1.0', ''),
150                'RangeException'                 => array('5.1.0', ''),
151                'UnderflowException'             => array('5.1.0', ''),
152                'UnexpectedValueException'       => array('5.1.0', ''),
153                'RecursiveIteratorIterator'      => array('5.1.3', ''),
154                'IteratorIterator'               => array('5.1.0', ''),
155                'FilterIterator'                 => array('5.1.0', ''),
156                'RecursiveFilterIterator'        => array('5.1.0', ''),
157                'CallbackFilterIterator'         => array('5.4.0', ''),
158                'RecursiveCallbackFilterIterator'
159                                                 => array('5.4.0', ''),
160                'ParentIterator'                 => array('5.1.0', ''),
161                'LimitIterator'                  => array('5.1.0', ''),
162                'CachingIterator'                => array('5.0.0', ''),
163                'RecursiveCachingIterator'       => array('5.1.0', ''),
164                'NoRewindIterator'               => array('5.1.0', ''),
165                'AppendIterator'                 => array('5.1.0', ''),
166                'InfiniteIterator'               => array('5.1.0', ''),
167                'RegexIterator'                  => array('5.2.0', ''),
168                'RecursiveRegexIterator'         => array('5.2.0', ''),
169                'EmptyIterator'                  => array('5.1.0', ''),
170                'RecursiveTreeIterator'          => array('5.3.0', ''),
171                'ArrayObject'                    => array('5.0.0', ''),
172                'ArrayIterator'                  => array('5.0.0', ''),
173                'RecursiveArrayIterator'         => array('5.1.0', ''),
174                'SplFileInfo'                    => array('5.1.2', ''),
175                'DirectoryIterator'              => array('5.0.0', ''),
176                'FilesystemIterator'             => array('5.3.0', ''),
177                'RecursiveDirectoryIterator'     => array('5.1.2', ''),
178                'GlobIterator'                   => array('5.3.0', ''),
179                'SplFileObject'                  => array('5.1.0', ''),
180                'SplTempFileObject'              => array('5.1.2', ''),
181                'SplDoublyLinkedList'            => array('5.3.0', ''),
182                'SplQueue'                       => array('5.3.0', ''),
183                'SplStack'                       => array('5.3.0', ''),
184                'SplHeap'                        => array('5.3.0', ''),
185                'SplMinHeap'                     => array('5.3.0', ''),
186                'SplMaxHeap'                     => array('5.3.0', ''),
187                'SplPriorityQueue'               => array('5.3.0', ''),
188                'SplFixedArray'                  => array('5.3.0', ''),
189                'SplObjectStorage'               => array('5.1.0', ''),
190                'MultipleIterator'               => array('5.3.0', ''),
191            );
192            $classes = array_merge(
193                $classes,
194                $version5
195            );
196        }
197
198        return $classes;
199    }
200
201    /**
202     * Gets informations about functions
203     *
204     * @param string $extension OPTIONAL
205     * @param string $version   OPTIONAL PHP version
206     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
207     *
208     * @return array
209     * @link   http://www.php.net/manual/en/ref.spl.php
210     */
211    public function getFunctions($extension = null, $version = null)
212    {
213        $functions = array();
214
215        if ((null == $version ) || ('4' == $version)) {
216            $version4 = array(
217            );
218            $functions = array_merge(
219                $functions,
220                $version4
221            );
222        }
223        if ((null == $version ) || ('5' == $version)) {
224            $version5 = array(
225                'spl_classes'                    => array('5.0.0', ''),
226                'spl_autoload'                   => array('5.1.2', ''),
227                'spl_autoload_extensions'        => array('5.1.2', ''),
228                'spl_autoload_register'          => array('5.1.2', ''),
229                'spl_autoload_unregister'        => array('5.1.2', ''),
230                'spl_autoload_functions'         => array('5.1.2', ''),
231                'spl_autoload_call'              => array('5.1.2', ''),
232                'class_parents'                  => array('5.1.0', ''),
233                'class_uses'                     => array('5.4.0', ''),
234                'class_implements'               => array('5.1.0', ''),
235                'spl_object_hash'                => array('5.2.0', ''),
236                'iterator_to_array'              => array('5.1.0', ''),
237                'iterator_count'                 => array('5.1.0', ''),
238                'iterator_apply'                 => array('5.1.0', ''),
239            );
240            $functions = array_merge(
241                $functions,
242                $version5
243            );
244        }
245        return $functions;
246    }
247
248    /**
249     * Gets informations about constants
250     *
251     * @param string $extension OPTIONAL
252     * @param string $version   OPTIONAL PHP version
253     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
254     *
255     * @return array
256     */
257    public function getConstants($extension = null, $version = null)
258    {
259        $constants = array();
260
261        if ((null == $version ) || ('4' == $version)) {
262            $version4 = array(
263            );
264            $constants = array_merge(
265                $constants,
266                $version4
267            );
268        }
269        if ((null == $version ) || ('5' == $version)) {
270            $version5 = array(
271            );
272            $constants = array_merge(
273                $constants,
274                $version5
275            );
276        }
277
278        return $constants;
279    }
280
281}