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

Source for file Array.php

Documentation is available at Array.php

  1. <?php
  2. /**
  3.  * Copyright (c) 2008, Laurent Laville <pear@laurent-laville.org>
  4.  *
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  *     * Redistributions of source code must retain the above copyright
  12.  *       notice, this list of conditions and the following disclaimer.
  13.  *     * Redistributions in binary form must reproduce the above copyright
  14.  *       notice, this list of conditions and the following disclaimer in the
  15.  *       documentation and/or other materials provided with the distribution.
  16.  *     * Neither the name of the authors nor the names of its contributors
  17.  *       may be used to endorse or promote products derived from this software
  18.  *       without specific prior written permission.
  19.  *
  20.  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  21.  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  22.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  23.  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  24.  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  25.  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  26.  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  27.  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  28.  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29.  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  30.  * POSSIBILITY OF SUCH DAMAGE.
  31.  *
  32.  * PHP versions 4 and 5
  33.  *
  34.  * @category PHP
  35.  * @package  PHP_CompatInfo
  36.  * @author   Laurent Laville <pear@laurent-laville.org>
  37.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  38.  * @version  CVS: $Id: Array.php,v 1.8 2008/07/22 20:26:19 farell Exp $
  39.  * @link     http://pear.php.net/package/PHP_CompatInfo
  40.  * @since    File available since Release 1.8.0b2
  41.  */
  42.  
  43. /**
  44.  * Array renderer for PHP_CompatInfo component.
  45.  *
  46.  * The PHP_CompatInfo_Renderer_Array class is a concrete implementation
  47.  * of PHP_CompatInfo_Renderer abstract class. It simply display results as
  48.  * a PHP array.
  49.  *
  50.  * @category PHP
  51.  * @package  PHP_CompatInfo
  52.  * @author   Laurent Laville <pear@laurent-laville.org>
  53.  * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
  54.  * @version  Release: 1.9.0b1
  55.  * @link     http://pear.php.net/package/PHP_CompatInfo
  56.  * @since    Class available since Release 1.8.0b2
  57.  */
  58. {
  59.     /**
  60.      * Driver to display results array.
  61.      *
  62.      * Default is PHP::var_export, but you can use PEAR::Var_Dump if available
  63.      *
  64.      * @var    string 
  65.      * @access public
  66.      */
  67.     var $driver;
  68.  
  69.     /**
  70.      * Array Renderer Class constructor (ZE1) for PHP4
  71.      *
  72.      * @param object &$parser Instance of the parser (model of MVC pattern)
  73.      * @param array  $conf    A hash containing any additional configuration
  74.      *
  75.      * @access public
  76.      * @since  version 1.8.0b2 (2008-06-03)
  77.      */
  78.     function PHP_CompatInfo_Renderer_Array(&$parser$conf)
  79.     {
  80.         $this->__construct($parser$conf);
  81.     }
  82.  
  83.     /**
  84.      * Array Renderer Class constructor (ZE2) for PHP5+
  85.      *
  86.      * @param object &$parser Instance of the parser (model of MVC pattern)
  87.      * @param array  $conf    A hash containing any additional configuration
  88.      *
  89.      * @access public
  90.      * @since  version 1.8.0b2 (2008-06-03)
  91.      */
  92.     function __construct(&$parser$conf)
  93.     {
  94.         parent::PHP_CompatInfo_Renderer($parser$conf);
  95.  
  96.         $driver 'PEAR::Var_Dump';
  97.  
  98.         if (isset($conf[$driver])) {
  99.             $var_dump 'Var_Dump.php';
  100.             if (PHP_CompatInfo_Renderer::isIncludable($var_dump)) {
  101.                 include_once $var_dump;
  102.  
  103.                 $class_options $conf['PEAR::Var_Dump'];
  104.                 if (isset($class_options['options'])) {
  105.                     $options $class_options['options'];
  106.                 else {
  107.                     $options = array();
  108.                 }
  109.                 if (isset($class_options['rendererOptions'])) {
  110.                     $rendererOptions $class_options['rendererOptions'];
  111.                 else {
  112.                     $rendererOptions = array();
  113.                 }
  114.                 if (php_sapi_name(== 'cli'{
  115.                     // prevent wrong display on command line interface
  116.                     $options['display_mode''Text';
  117.                 }
  118.  
  119.                 Var_Dump::displayInit($options$rendererOptions);
  120.                 $this->driver = $driver;
  121.             }
  122.         }
  123.  
  124.         if (!isset($this->driver)) {
  125.             // if optional driver not defined, then use default PHP::var_export
  126.             $this->driver = 'PHP';
  127.         }
  128.     }
  129.  
  130.     /**
  131.      * Display final results
  132.      *
  133.      * Display final results, when data source parsing is over.
  134.      *
  135.      * @access public
  136.      * @return void 
  137.      * @since  version 1.8.0b2 (2008-06-03)
  138.      */
  139.     function display()
  140.     {
  141.         $o    $this->args['output-level'];
  142.         $v    $this->args['verbose'];
  143.         $data $this->parseData;
  144.         $src  $this->_parser->dataSource;
  145.  
  146.         if ($data === false{
  147.             // invalid data source
  148.             if ($this->driver == 'PHP'{
  149.                 var_export($data);
  150.             else {
  151.                 Var_Dump::display($data);
  152.             }
  153.             return;
  154.         }
  155.  
  156.         $options $this->_parser->options;
  157.  
  158.         if (isset($this->args['dir'])) {
  159.             $files $this->_parser->getFilelist($this->args['dir']$options);
  160.         elseif (isset($this->args['file'])) {
  161.             $files = array($this->args['file']);
  162.         elseif ($src['dataType'== 'directory'{
  163.             $files $src['dataSource'];
  164.         elseif ($src['dataType'== 'file'{
  165.             $files = array($src['dataSource']);
  166.         else {
  167.             $files $src['dataSource'];
  168.         }
  169.  
  170.         if ($options['is_string'== true{
  171.             foreach ($files as $k => $str{
  172.                 $files[$k'string_' ($k+1);
  173.             }
  174.         }
  175.  
  176.         if ($o 16{
  177.             // display Version
  178.         else {
  179.             unset($data['version']$data['max_version']);
  180.         }
  181.         if ($o 1{
  182.             // display Conditions
  183.         else {
  184.             unset($data['cond_code']);
  185.         }
  186.         if ($o 2{
  187.             // display Extensions
  188.         else {
  189.             unset($data['extensions']);
  190.         }
  191.         if ($o 4{
  192.             if ($o 8{
  193.                 // display Constants/Tokens
  194.             else {
  195.                 // display Constants
  196.                 unset($data['tokens']);
  197.             }
  198.         else {
  199.             unset($data['constants']);
  200.             if ($o 8{
  201.                 // display Tokens
  202.             else {
  203.                 unset($data['tokens']);
  204.             }
  205.         }
  206.         if ($v 4 || $options['debug'== true{
  207.             // display Functions
  208.         else {
  209.             unset($data['functions']);
  210.         }
  211.  
  212.         if (count($files> 1{
  213.             if ($this->args['summarize'=== true{
  214.                 foreach ($files as $file{
  215.                     unset($data[$file]);
  216.                 }
  217.             else {
  218.                 foreach ($files as $file{
  219.                     if ($o 16{
  220.                         // display Version
  221.                     else {
  222.                         unset($data[$file]['version']$data[$file]['max_version']);
  223.                     }
  224.                     if ($o 1{
  225.                         // display Conditions
  226.                     else {
  227.                         unset($data[$file]['cond_code']);
  228.                     }
  229.                     if ($o 2{
  230.                         // display Extensions
  231.                     else {
  232.                         unset($data[$file]['extensions']);
  233.                     }
  234.                     if ($o 4{
  235.                         if ($o 8{
  236.                             // display Constants/Tokens
  237.                         else {
  238.                             // display Constants
  239.                             unset($data[$file]['tokens']);
  240.                         }
  241.                     else {
  242.                         unset($data[$file]['constants']);
  243.                         if ($o 8{
  244.                             // display Tokens
  245.                         else {
  246.                             unset($data[$file]['tokens']);
  247.                         }
  248.                     }
  249.                     if ($v 4 || $options['debug'== true{
  250.                         // display Functions
  251.                     else {
  252.                         unset($data[$file]['functions']);
  253.                     }
  254.                 }
  255.             }
  256.         }
  257.  
  258.         if ($this->driver == 'PHP'{
  259.             var_export($data);
  260.         else {
  261.             Var_Dump::display($data);
  262.         }
  263.     }
  264. }
  265. ?>

Documentation generated on Sun, 30 Nov 2008 16:30:22 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.