PHP_CompatInfo
[ class tree: PHP_CompatInfo ] [ index: PHP_CompatInfo ] [ all elements ]

Source for file CompatInfo.php

Documentation is available at CompatInfo.php

  1. <?php
  2. /**
  3.  * Copyright (c) 2004-2008, Davey Shafik <davey@php.net>
  4.  *                          Laurent Laville <pear@laurent-laville.org>
  5.  *
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms, with or without
  9.  * modification, are permitted provided that the following conditions
  10.  * are met:
  11.  *
  12.  *     * Redistributions of source code must retain the above copyright
  13.  *       notice, this list of conditions and the following disclaimer.
  14.  *     * Redistributions in binary form must reproduce the above copyright
  15.  *       notice, this list of conditions and the following disclaimer in the
  16.  *       documentation and/or other materials provided with the distribution.
  17.  *     * Neither the name of the authors nor the names of its contributors
  18.  *       may be used to endorse or promote products derived from this software
  19.  *       without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  25.  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  31.  * POSSIBILITY OF SUCH DAMAGE.
  32.  *
  33.  * PHP versions 4 and 5
  34.  *
  35.  * @category PHP
  36.  * @package  PHP_CompatInfo
  37.  * @author   Davey Shafik <davey@php.net>
  38.  * @author   Laurent Laville <pear@laurent-laville.org>
  39.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  40.  * @version  CVS: $Id: CompatInfo.php,v 1.103 2008/07/22 20:27:32 farell Exp $
  41.  * @link     http://pear.php.net/package/PHP_CompatInfo
  42.  * @since    File available since Release 0.7.0
  43.  */
  44.  
  45. require_once 'PHP/CompatInfo/Parser.php';
  46.  
  47. /**
  48.  * Check Compatibility of chunk of PHP code
  49.  *
  50.  * This class is the controller in the MVC design pattern of API 1.8.0 (since beta 2)
  51.  *
  52.  * @category  PHP
  53.  * @package   PHP_CompatInfo
  54.  * @author    Davey Shafik <davey@php.net>
  55.  * @author    Laurent Laville <pear@laurent-laville.org>
  56.  * @copyright 2003 Davey Shafik and Synaptic Media. All Rights Reserved.
  57.  * @license   http://www.opensource.org/licenses/bsd-license.php  BSD
  58.  * @version   Release: 1.8.0
  59.  * @link      http://pear.php.net/package/PHP_CompatInfo
  60.  * @since     Class available since Release 0.7.0
  61.  */
  62. {
  63.     /**
  64.      * Instance of the parser (model in MVC desing pattern)
  65.      *
  66.      * @var    object 
  67.      * @since  1.8.0b2
  68.      * @access protected
  69.      */
  70.     var $parser;
  71.  
  72.     /**
  73.      * Class constructor (ZE1) for PHP4
  74.      *
  75.      * @param string $render (optional) Type of renderer to show results
  76.      * @param array  $conf   (optional) A hash containing any additional
  77.      *                        configuration a renderer may use
  78.      *
  79.      * @access public
  80.      * @since  version 1.8.0b2 (2008-06-03)
  81.      */
  82.     function PHP_CompatInfo($render 'array'$conf = array())
  83.     {
  84.         $this->__construct($render$conf);
  85.     }
  86.  
  87.     /**
  88.      * Class constructor (ZE2) for PHP5+
  89.      *
  90.      * @param string $render (optional) Type of renderer to show results
  91.      * @param array  $conf   (optional) A hash containing any additional
  92.      *                        configuration a renderer may use
  93.      *
  94.      * @access public
  95.      * @since  version 1.8.0b2 (2008-06-03)
  96.      */
  97.     function __construct($render 'array'$conf = array())
  98.     {
  99.         $this->parser = new PHP_CompatInfo_Parser();
  100.         $this->parser->setOutputDriver($render$conf);
  101.     }
  102.  
  103.     /**
  104.      * Registers a new listener
  105.      *
  106.      * Registers a new listener with the given criteria.
  107.      *
  108.      * @param mixed  $callback A PHP callback
  109.      * @param string $nName    (optional) Expected notification name
  110.      *
  111.      * @access public
  112.      * @return void 
  113.      * @since  version 1.8.0b3 (2008-06-07)
  114.      */
  115.     function addListener($callback$nName = EVENT_DISPATCHER_GLOBAL)
  116.     {
  117.         $this->parser->addListener($callback$nName);
  118.     }
  119.  
  120.     /**
  121.      * Removes a registered listener
  122.      *
  123.      * Removes a registered listener that correspond to the given criteria.
  124.      *
  125.      * @param mixed  $callback A PHP callback
  126.      * @param string $nName    (optional) Expected notification name
  127.      *
  128.      * @access public
  129.      * @return bool  True if listener was removed, false otherwise.
  130.      * @since  version 1.8.0b3 (2008-06-07)
  131.      */
  132.     function removeListener($callback$nName = EVENT_DISPATCHER_GLOBAL)
  133.     {
  134.         return $this->parser->removeListener($callback$nName);
  135.     }
  136.  
  137.     /**
  138.      * Load components list
  139.      *
  140.      * Load components list for a PHP version or subset
  141.      *
  142.      * @param string         $min           PHP minimal version
  143.      * @param string|boolean$max           (optional) PHP maximal version
  144.      * @param boolean        $include_const (optional) include constants list
  145.      *                                                  in final result
  146.      * @param boolean        $groupby_vers  (optional) give initial php version
  147.      *                                                  of function or constant
  148.      *
  149.      * @return array         An array of php function/constant names history
  150.      * @access public
  151.      * @static
  152.      * @since  version 1.2.0 (2006-08-23)
  153.      */
  154.     function loadVersion($min$max = false,
  155.                          $include_const = false$groupby_vers = false)
  156.     {
  157.         return $this->parser->loadVersion($min$max$include_const$groupby_vers);
  158.     }
  159.  
  160.     /**
  161.      * Parse a data source
  162.      *
  163.      * Parse a data source with auto detect ability. This data source, may be
  164.      * one of these follows: a directory, a file, a string (chunk of code),
  165.      * an array of multiple origin.
  166.      *
  167.      * Each of five parsing functions support common and specifics options.
  168.      *
  169.      *  * Common options :
  170.      *  - 'debug'                   Contains a boolean to control whether
  171.      *                              extra ouput is shown.
  172.      *  - 'ignore_functions'        Contains an array of functions to ignore
  173.      *                              when calculating the version needed.
  174.      *  - 'ignore_constants'        Contains an array of constants to ignore
  175.      *                              when calculating the version needed.
  176.      *  - 'ignore_extensions'       Contains an array of php extensions to ignore
  177.      *                              when calculating the version needed.
  178.      *  - 'ignore_versions'         Contains an array of php versions to ignore
  179.      *                              when calculating the version needed.
  180.      *  - 'ignore_functions_match'  Contains an array of function patterns to ignore
  181.      *                              when calculating the version needed.
  182.      *  - 'ignore_extensions_match' Contains an array of extension patterns to ignore
  183.      *                              when calculating the version needed.
  184.      *  - 'ignore_constants_match'  Contains an array of constant patterns to ignore
  185.      *                              when calculating the version needed.
  186.      *
  187.      *  * parseArray, parseDir|parseFolder, specific options :
  188.      *  - 'file_ext'                Contains an array of file extensions to parse
  189.      *                              for PHP code. Default: php, php4, inc, phtml
  190.      *  - 'ignore_files'            Contains an array of files to ignore.
  191.      *                              File names are case insensitive.
  192.      *
  193.      *  * parseArray specific options :
  194.      *  - 'is_string'               Contains a boolean which says if the array values
  195.      *                              are strings or file names.
  196.      *
  197.      *  * parseDir|parseFolder specific options :
  198.      *  - 'recurse_dir'             Boolean on whether to recursively find files
  199.      *  - 'ignore_dirs'             Contains an array of directories to ignore.
  200.      *                              Directory names are case insensitive.
  201.      *
  202.      * @param mixed $data    Data source (may be file, dir, string, or array)
  203.      * @param array $options An array of options. See above.
  204.      *
  205.      * @access public
  206.      * @return array or false on error
  207.      * @since  version 1.8.0b2 (2008-06-03)
  208.      * @see    PHP_CompatInfo_Parser::parseData()
  209.      */
  210.     function parseData($data$options = array())
  211.     {
  212.         return $this->parser->parseData($data$options);
  213.     }
  214.  
  215.     /**
  216.      * Parse an Array of Files or Strings
  217.      *
  218.      * You can parse an array of Files or Strings, to parse
  219.      * strings, $options['is_string'] must be set to true.
  220.      *
  221.      * This recommandation is no more valid since version 1.8.0b2
  222.      * Array my contains multiple and mixed origin (file, dir, string).
  223.      *
  224.      * @param array $array   Array of data sources
  225.      * @param array $options Parser options (see parseData() method for details)
  226.      *
  227.      * @access public
  228.      * @return array or false on error
  229.      * @since  version 0.7.0 (2004-03-09)
  230.      * @see    parseData()
  231.      */
  232.     function parseArray($array$options = array())
  233.     {
  234.         return $this->parser->parseData($array$options);
  235.     }
  236.  
  237.     /**
  238.      * Parse a string
  239.      *
  240.      * Parse a string for its compatibility info
  241.      *
  242.      * @param string $string  PHP Code to parse
  243.      * @param array  $options Parser options (see parseData() method for details)
  244.      *
  245.      * @access public
  246.      * @return array or false on error
  247.      * @since  version 0.7.0 (2004-03-09)
  248.      * @see    parseData()
  249.      */
  250.     function parseString($string$options = array())
  251.     {
  252.         return $this->parser->parseData($string$options);
  253.     }
  254.  
  255.     /**
  256.      * Parse a single file
  257.      *
  258.      * Parse a file for its compatibility info
  259.      *
  260.      * @param string $file    Path of File to parse
  261.      * @param array  $options Parser options (see parseData() method for details)
  262.      *
  263.      * @access public
  264.      * @return array or false on error
  265.      * @since  version 0.7.0 (2004-03-09)
  266.      * @see    parseData()
  267.      */
  268.     function parseFile($file$options = array())
  269.     {
  270.         return $this->parser->parseData($file$options);
  271.     }
  272.  
  273.     /**
  274.      * Parse a directory
  275.      *
  276.      * Parse a directory recursively for its compatibility info
  277.      *
  278.      * @param string $dir     Path of folder to parse
  279.      * @param array  $options Parser options (see parseData() method for details)
  280.      *
  281.      * @access public
  282.      * @return array or false on error
  283.      * @since  version 0.8.0 (2004-04-22)
  284.      * @see    parseData()
  285.      */
  286.     function parseDir($dir$options = array())
  287.     {
  288.         return $this->parser->parseData($dir$options);
  289.     }
  290.  
  291.     /**
  292.      * Alias of parseDir
  293.      *
  294.      * Alias of parseDir function
  295.      *
  296.      * @param string $folder  Path of folder to parse
  297.      * @param array  $options Parser options (see parseData() method for details)
  298.      *
  299.      * @access public
  300.      * @return array or false on error
  301.      * @since  version 0.7.0 (2004-03-09)
  302.      * @see    parseDir(), parseData()
  303.      */
  304.     function parseFolder($folder$options = array())
  305.     {
  306.         return $this->parser->parseData($folder$options);
  307.     }
  308. }
  309. ?>

Documentation generated on Fri, 01 Aug 2008 11:30:22 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.