PageRenderTime 56ms CodeModel.GetById 11ms app.highlight 40ms RepoModel.GetById 1ms app.codeStats 0ms

/PHP/CompatInfo/Reference/core.php

http://github.com/llaville/php-compat-info
PHP | 361 lines | 268 code | 12 blank | 81 comment | 38 complexity | a8dcf896a20c88f24459e191c36e2c15 MD5 | raw file
  1<?php
  2/**
  3 * Version informations about components always available with PHP
  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 always available with PHP
 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 */
 25class PHP_CompatInfo_Reference_Core implements PHP_CompatInfo_Reference
 26{
 27    /**
 28     * Gets all informations at once about:
 29     * extensions, interfaces, classes, functions, constants
 30     *
 31     * @param string $extension OPTIONAL
 32     * @param string $version   OPTIONAL PHP version
 33     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 34     *
 35     * @return array
 36     */
 37    public function getAll($extension = null, $version = null)
 38    {
 39        $references = array(
 40            'extensions' => $this->getExtensions($extension, $version),
 41            'interfaces' => $this->getInterfaces($extension, $version),
 42            'classes'    => $this->getClasses($extension, $version),
 43            'functions'  => $this->getFunctions($extension, $version),
 44            'constants'  => $this->getConstants($extension, $version),
 45        );
 46        return $references;
 47    }
 48
 49    /**
 50     * Gets informations about extensions
 51     *
 52     * @param string $extension OPTIONAL
 53     * @param string $version   OPTIONAL PHP version
 54     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 55     *
 56     * @return array
 57     */
 58    public function getExtensions($extension = null, $version = null)
 59    {
 60        if ((null == $version ) || ('4' == $version)) {
 61            $extensions = array(
 62                'Core' => array('4.0.0', '', '')
 63            );
 64        }
 65        if ('5' == $version) {
 66            $extensions = array(
 67                'Core' => array('5.0.0', '', '')
 68            );
 69        }
 70        return $extensions;
 71    }
 72
 73    /**
 74     * Gets informations about interfaces
 75     *
 76     * @param string $extension OPTIONAL
 77     * @param string $version   OPTIONAL PHP version
 78     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
 79     *
 80     * @return array
 81     * @link   http://www.php.net/manual/en/reserved.interfaces.php
 82     */
 83    public function getInterfaces($extension = null, $version = null)
 84    {
 85        $interfaces = array();
 86
 87        if ((null == $version ) || ('4' == $version)) {
 88            $version4 = array(
 89            );
 90            $interfaces = array_merge(
 91                $interfaces,
 92                $version4
 93            );
 94        }
 95        if ((null == $version ) || ('5' == $version)) {
 96            $version5 = array(
 97            );
 98            $interfaces = array_merge(
 99                $interfaces,
100                $version5
101            );
102        }
103        return $interfaces;
104    }
105
106    /**
107     * Gets informations about classes
108     *
109     * @param string $extension OPTIONAL
110     * @param string $version   OPTIONAL PHP version
111     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
112     *
113     * @return array
114     * @link   http://www.php.net/manual/en/reserved.classes.php
115     * @link   http://www.php.net/manual/en/reserved.exceptions.php
116     */
117    public function getClasses($extension = null, $version = null)
118    {
119        $classes = array();
120
121        if ((null == $version ) || ('4' == $version)) {
122            $version4 = array(
123                'stdClass'                       => array('4.0.0', ''),
124            );
125            $classes = array_merge(
126                $classes,
127                $version4
128            );
129        }
130        if ((null == $version ) || ('5' == $version)) {
131            $version5 = array(
132                'Closure'                        => array('5.3.0', ''),
133                'ErrorException'                 => array('5.1.0', ''),
134                'Exception'                      => array('5.1.0', ''),
135            );
136            $classes = array_merge(
137                $classes,
138                $version5
139            );
140        }
141
142        return $classes;
143    }
144
145    /**
146     * Gets informations about functions
147     *
148     * @param string $extension OPTIONAL
149     * @param string $version   OPTIONAL PHP version
150     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
151     *
152     * @return array
153     */
154    public function getFunctions($extension = null, $version = null)
155    {
156        $functions = array();
157
158        if ((null == $version ) || ('4' == $version)) {
159            $version4 = array(
160                'zend_version'                   => array('4.0.0', ''),
161                'func_num_args'                  => array('4.0.0', ''),
162                'func_get_arg'                   => array('4.0.0', ''),
163                'func_get_args'                  => array('4.0.0', ''),
164                'strlen'                         => array('4.0.0', ''),
165                'strcmp'                         => array('4.0.0', ''),
166                'strncmp'                        => array('4.0.0', ''),
167                'strcasecmp'                     => array('4.0.0', ''),
168                'strncasecmp'                    => array('4.0.2', ''),
169                'each'                           => array('4.0.0', ''),
170                'error_reporting'                => array('4.0.0', ''),
171                'define'                         => array('4.0.0', ''),
172                'defined'                        => array('4.0.0', ''),
173                'get_class'                      => array('4.0.0', ''),
174                'get_parent_class'               => array('4.0.0', ''),
175                'method_exists'                  => array('4.0.0', ''),
176                'class_exists'                   => array('4.0.0', '', '4.0.0, 5.0.0'),
177                'function_exists'                => array('4.0.0', ''),
178                'get_included_files'             => array('4.0.0', ''),
179                'get_required_files'             => array('4.0.0', ''),
180                'is_subclass_of'                 => array('4.0.0', ''),
181                'is_a'                           => array('4.2.0', '', '4.2.0, 4.2.0, 5.3.9'),
182                'get_class_vars'                 => array('4.0.0', ''),
183                'get_object_vars'                => array('4.0.0', ''),
184                'get_class_methods'              => array('4.0.0', ''),
185                'trigger_error'                  => array('4.0.1', ''),
186                'user_error'                     => array('4.0.0', ''),
187                'set_error_handler'              => array('4.0.1', ''),
188                'restore_error_handler'          => array('4.0.1', ''),
189                'get_declared_classes'           => array('4.0.0', ''),
190                'get_defined_functions'          => array('4.0.4', ''),
191                'get_defined_vars'               => array('4.0.4', ''),
192                'create_function'                => array('4.0.1', ''),
193                'get_resource_type'              => array('4.0.2', ''),
194                'get_loaded_extensions'          => array('4.0.0', ''),
195                'extension_loaded'               => array('4.0.0', ''),
196                'get_extension_funcs'            => array('4.0.0', ''),
197                'get_defined_constants'          => array('4.0.7', ''),
198                'debug_backtrace'                => array('4.3.0', ''),
199            );
200            $functions = array_merge(
201                $functions,
202                $version4
203            );
204        }
205        if ((null == $version ) || ('5' == $version)) {
206            $version5 = array(
207                'class_alias'                    => array('5.3.0', ''),
208                'debug_print_backtrace'          => array('5.0.0', ''),
209                'gc_collect_cycles'              => array('5.3.0', ''),
210                'gc_enabled'                     => array('5.3.0', ''),
211                'gc_enable'                      => array('5.3.0', ''),
212                'gc_disable'                     => array('5.3.0', ''),
213                'get_called_class'               => array('5.3.0', ''),
214                'get_declared_interfaces'        => array('5.0.0', ''),
215                'get_declared_traits'            => array('5.4.0', ''),
216                'interface_exists'               => array('5.0.2', ''),
217                'property_exists'                => array('5.1.0', ''),
218                'restore_exception_handler'      => array('5.0.0', ''),
219                'set_exception_handler'          => array('5.0.0', ''),
220                'trait_exists'                   => array('5.4.0', ''),
221                'zend_thread_id'                 => array('5.0.0', ''),
222            );
223            $functions = array_merge(
224                $functions,
225                $version5
226            );
227        }
228        return $functions;
229    }
230
231    /**
232     * Gets informations about constants
233     *
234     * @param string $extension OPTIONAL
235     * @param string $version   OPTIONAL PHP version
236     *                          (4 => only PHP4, 5 or null => PHP4 + PHP5)
237     *
238     * @return array
239     * @link   http://www.php.net/manual/en/reserved.constants.php
240     */
241    public function getConstants($extension = null, $version = null)
242    {
243        $constants = array();
244
245        if ((null == $version ) || ('4' == $version)) {
246            $version4 = array(
247                '__CLASS__'                      => array('4.3.0', ''),
248                '__FILE__'                       => array('4.0.0', ''),
249                '__FUNCTION__'                   => array('4.3.0', ''),
250                '__LINE__'                       => array('4.0.0', ''),
251                'DEFAULT_INCLUDE_PATH'           => array('4.0.0', ''),
252                'E_ALL'                          => array('4.0.0', ''),
253                'E_ERROR'                        => array('4.0.0', ''),
254                'E_WARNING'                      => array('4.0.0', ''),
255                'E_PARSE'                        => array('4.0.0', ''),
256                'E_NOTICE'                       => array('4.0.0', ''),
257                'E_COMPILE_ERROR'                => array('4.0.0', ''),
258                'E_COMPILE_WARNING'              => array('4.0.0', ''),
259                'E_CORE_ERROR'                   => array('4.0.0', ''),
260                'E_CORE_WARNING'                 => array('4.0.0', ''),
261                'E_USER_ERROR'                   => array('4.0.0', ''),
262                'E_USER_WARNING'                 => array('4.0.0', ''),
263                'E_USER_NOTICE'                  => array('4.0.0', ''),
264                'FALSE'                          => array('4.0.0', ''),
265                'NULL'                           => array('4.0.0', ''),
266                'PEAR_INSTALL_DIR'               => array('4.0.0', ''),
267                'PEAR_EXTENSION_DIR'             => array('4.0.0', ''),
268                'PHP_BINDIR'                     => array('4.0.0', ''),
269                'PHP_CONFIG_FILE_PATH'           => array('4.0.0', ''),
270                'PHP_CONFIG_FILE_SCAN_DIR'       => array('4.0.0', ''),
271                'PHP_DATADIR'                    => array('4.0.0', ''),
272                'PHP_LIBDIR'                     => array('4.0.0', ''),
273                'PHP_EOL'                        => array('4.3.10', ''),
274                'PHP_EXTENSION_DIR'              => array('4.0.0', ''),
275                'PHP_INT_MAX'                    => array('4.4.0', ''),
276                'PHP_INT_SIZE'                   => array('4.4.0', ''),
277                'PHP_LOCALSTATEDIR'              => array('4.0.0', ''),
278                'PHP_PREFIX'                     => array('4.3.0', ''),
279                'PHP_OS'                         => array('4.0.0', ''),
280                'PHP_OUTPUT_HANDLER_CONT'        => array('4.0.0', ''),
281                'PHP_OUTPUT_HANDLER_END'         => array('4.0.0', ''),
282                'PHP_OUTPUT_HANDLER_START'       => array('4.0.0', ''),
283                'PHP_SAPI'                       => array('4.2.0', ''),
284                'PHP_SHLIB_SUFFIX'               => array('4.3.0', ''),
285                'PHP_SYSCONFDIR'                 => array('4.0.0', ''),
286                'PHP_VERSION'                    => array('4.0.0', ''),
287                'STDERR'                         => array('4.3.0', ''),
288                'STDIN'                          => array('4.3.0', ''),
289                'STDOUT'                         => array('4.3.0', ''),
290                'TRUE'                           => array('4.0.0', ''),
291                'UPLOAD_ERR_FORM_SIZE'           => array('4.3.0', ''),
292                'UPLOAD_ERR_INI_SIZE'            => array('4.3.0', ''),
293                'UPLOAD_ERR_NO_FILE'             => array('4.3.0', ''),
294                'UPLOAD_ERR_NO_TMP_DIR'          => array('4.3.10', ''),
295                'UPLOAD_ERR_OK'                  => array('4.3.0', ''),
296                'UPLOAD_ERR_PARTIAL'             => array('4.3.0', ''),
297                'ZEND_THREAD_SAFE'               => array('4.0.0', ''),
298            );
299            $constants = array_merge(
300                $constants,
301                $version4
302            );
303        }
304        if ((null == $version ) || ('5' == $version)) {
305            $version5 = array(
306                '__COMPILER_HALT_OFFSET__'          => array('5.1.0', ''),
307                '__DIR__'                           => array('5.3.0', ''),
308                '__METHOD__'                        => array('5.0.0', ''),
309                '__NAMESPACE__'                     => array('5.3.0', ''),
310                '__TRAIT__'                         => array('5.4.0', ''),
311                'DEBUG_BACKTRACE_IGNORE_ARGS'       => array('5.3.6', ''),
312                'DEBUG_BACKTRACE_PROVIDE_OBJECT'    => array('5.3.6', ''),
313                'E_RECOVERABLE_ERROR'               => array('5.2.0', ''),
314                'E_DEPRECATED'                      => array('5.3.0', ''),
315                'E_USER_DEPRECATED'                 => array('5.3.0', ''),
316                'E_STRICT'                          => array('5.0.0', ''),
317                'PHP_BINARY'                        => array('5.4.0', ''),
318                'PHP_DEBUG'                         => array('5.2.7', ''),
319                'PHP_EXTRA_VERSION'                 => array('5.2.7', ''),
320                'PHP_MAJOR_VERSION'                 => array('5.2.7', ''),
321                'PHP_MANDIR'                        => array('5.3.7', ''),
322                'PHP_MAXPATHLEN'                    => array('5.3.0', ''),
323                'PHP_MINOR_VERSION'                 => array('5.2.7', ''),
324                'PHP_OUTPUT_HANDLER_CLEAN'          => array('5.4.0', ''),
325                'PHP_OUTPUT_HANDLER_CLEANABLE'      => array('5.4.0', ''),
326                'PHP_OUTPUT_HANDLER_DISABLED'       => array('5.4.0', ''),
327                'PHP_OUTPUT_HANDLER_FINAL'          => array('5.4.0', ''),
328                'PHP_OUTPUT_HANDLER_FLUSH'          => array('5.4.0', ''),
329                'PHP_OUTPUT_HANDLER_FLUSHABLE'      => array('5.4.0', ''),
330                'PHP_OUTPUT_HANDLER_REMOVABLE'      => array('5.4.0', ''),
331                'PHP_OUTPUT_HANDLER_STARTED'        => array('5.4.0', ''),
332                'PHP_OUTPUT_HANDLER_STDFLAGS'       => array('5.4.0', ''),
333                'PHP_OUTPUT_HANDLER_WRITE'          => array('5.4.0', ''),
334                'PHP_RELEASE_VERSION'               => array('5.2.7', ''),
335                'PHP_VERSION_ID'                    => array('5.2.7', ''),
336                'PHP_WINDOWS_VERSION_MAJOR'         => array('5.3.0', ''),
337                'PHP_WINDOWS_VERSION_MINOR'         => array('5.3.0', ''),
338                'PHP_WINDOWS_VERSION_BUILD'         => array('5.3.0', ''),
339                'PHP_WINDOWS_VERSION_PLATFORM'      => array('5.3.0', ''),
340                'PHP_WINDOWS_VERSION_SP_MAJOR'      => array('5.3.0', ''),
341                'PHP_WINDOWS_VERSION_SP_MINOR'      => array('5.3.0', ''),
342                'PHP_WINDOWS_VERSION_SUITEMASK'     => array('5.3.0', ''),
343                'PHP_WINDOWS_VERSION_PRODUCTTYPE'   => array('5.3.0', ''),
344                'PHP_WINDOWS_NT_DOMAIN_CONTROLLER'  => array('5.3.0', ''),
345                'PHP_WINDOWS_NT_SERVER'             => array('5.3.0', ''),
346                'PHP_WINDOWS_NT_WORKSTATION'        => array('5.3.0', ''),
347                'PHP_ZTS'                           => array('5.2.7', ''),
348                'UPLOAD_ERR_CANT_WRITE'             => array('5.1.0', ''),
349                'UPLOAD_ERR_EXTENSION'              => array('5.2.0', ''),
350                'ZEND_DEBUG_BUILD'                  => array('5.3.0', ''),
351                'ZEND_MULTIBYTE'                    => array('5.3.4', '5.3.14'),
352            );
353            $constants = array_merge(
354                $constants,
355                $version5
356            );
357        }
358
359        return $constants;
360    }
361}