| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Copyright (c) 2008-2009, 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.9 2009/01/02 10:18:47 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.0
|
|
|
55 |
* @link http://pear.php.net/package/PHP_CompatInfo
|
|
|
56 |
* @since Class available since Release 1.8.0b2
|
|
|
57 |
*/
|
|
|
58 |
class PHP_CompatInfo_Renderer_Array extends PHP_CompatInfo_Renderer
|
|
|
59 |
{
|
|
|
60 |
/**
|
|
|
61 |
* Driver to display results array.
|
|
|
62 |
*
|
|
|
63 |
* Default is PHP::var_export, but you can use PEAR::Var_Dump if available
|
|
|
64 |
*
|
|
|
65 |
* @var string
|
|
|
66 |
* @access public
|
|
|
67 |
*/
|
|
|
68 |
var $driver;
|
|
|
69 |
|
|
|
70 |
/**
|
|
|
71 |
* Array Renderer Class constructor (ZE1) for PHP4
|
|
|
72 |
*
|
|
|
73 |
* @param object &$parser Instance of the parser (model of MVC pattern)
|
|
|
74 |
* @param array $conf A hash containing any additional configuration
|
|
|
75 |
*
|
|
|
76 |
* @access public
|
|
|
77 |
* @since version 1.8.0b2 (2008-06-03)
|
|
|
78 |
*/
|
|
|
79 |
function PHP_CompatInfo_Renderer_Array(&$parser, $conf)
|
|
|
80 |
{
|
|
|
81 |
$this->__construct($parser, $conf);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
/**
|
|
|
85 |
* Array Renderer Class constructor (ZE2) for PHP5+
|
|
|
86 |
*
|
|
|
87 |
* @param object &$parser Instance of the parser (model of MVC pattern)
|
|
|
88 |
* @param array $conf A hash containing any additional configuration
|
|
|
89 |
*
|
|
|
90 |
* @access public
|
|
|
91 |
* @since version 1.8.0b2 (2008-06-03)
|
|
|
92 |
*/
|
|
|
93 |
function __construct(&$parser, $conf)
|
|
|
94 |
{
|
|
|
95 |
parent::PHP_CompatInfo_Renderer($parser, $conf);
|
|
|
96 |
|
|
|
97 |
$driver = 'PEAR::Var_Dump';
|
|
|
98 |
|
|
|
99 |
if (isset($conf[$driver])) {
|
|
|
100 |
$var_dump = 'Var_Dump.php';
|
|
|
101 |
if (PHP_CompatInfo_Renderer::isIncludable($var_dump)) {
|
|
|
102 |
include_once $var_dump;
|
|
|
103 |
|
|
|
104 |
$class_options = $conf['PEAR::Var_Dump'];
|
|
|
105 |
if (isset($class_options['options'])) {
|
|
|
106 |
$options = $class_options['options'];
|
|
|
107 |
} else {
|
|
|
108 |
$options = array();
|
|
|
109 |
}
|
|
|
110 |
if (isset($class_options['rendererOptions'])) {
|
|
|
111 |
$rendererOptions = $class_options['rendererOptions'];
|
|
|
112 |
} else {
|
|
|
113 |
$rendererOptions = array();
|
|
|
114 |
}
|
|
|
115 |
if (php_sapi_name() == 'cli') {
|
|
|
116 |
// prevent wrong display on command line interface
|
|
|
117 |
$options['display_mode'] = 'Text';
|
|
|
118 |
}
|
|
|
119 |
|
|
|
120 |
Var_Dump::displayInit($options, $rendererOptions);
|
|
|
121 |
$this->driver = $driver;
|
|
|
122 |
}
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
if (!isset($this->driver)) {
|
|
|
126 |
// if optional driver not defined, then use default PHP::var_export
|
|
|
127 |
$this->driver = 'PHP';
|
|
|
128 |
}
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
/**
|
|
|
132 |
* Display final results
|
|
|
133 |
*
|
|
|
134 |
* Display final results, when data source parsing is over.
|
|
|
135 |
*
|
|
|
136 |
* @access public
|
|
|
137 |
* @return void
|
|
|
138 |
* @since version 1.8.0b2 (2008-06-03)
|
|
|
139 |
*/
|
|
|
140 |
function display()
|
|
|
141 |
{
|
|
|
142 |
$o = $this->args['output-level'];
|
|
|
143 |
$v = $this->args['verbose'];
|
|
|
144 |
$data = $this->parseData;
|
|
|
145 |
$src = $this->_parser->dataSource;
|
|
|
146 |
|
|
|
147 |
if ($data === false) {
|
|
|
148 |
// invalid data source
|
|
|
149 |
if ($this->driver == 'PHP') {
|
|
|
150 |
var_export($data);
|
|
|
151 |
} else {
|
|
|
152 |
Var_Dump::display($data);
|
|
|
153 |
}
|
|
|
154 |
return;
|
|
|
155 |
}
|
|
|
156 |
|
|
|
157 |
$options = $this->_parser->options;
|
|
|
158 |
|
|
|
159 |
if (isset($this->args['dir'])) {
|
|
|
160 |
$files = $this->_parser->getFilelist($this->args['dir'], $options);
|
|
|
161 |
} elseif (isset($this->args['file'])) {
|
|
|
162 |
$files = array($this->args['file']);
|
|
|
163 |
} elseif ($src['dataType'] == 'directory') {
|
|
|
164 |
$files = $src['dataSource'];
|
|
|
165 |
} elseif ($src['dataType'] == 'file') {
|
|
|
166 |
$files = array($src['dataSource']);
|
|
|
167 |
} else {
|
|
|
168 |
$files = $src['dataSource'];
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
if ($options['is_string'] == true) {
|
|
|
172 |
foreach ($files as $k => $str) {
|
|
|
173 |
$files[$k] = 'string_' . ($k+1);
|
|
|
174 |
}
|
|
|
175 |
}
|
|
|
176 |
|
|
|
177 |
if ($o & 16) {
|
|
|
178 |
// display Version
|
|
|
179 |
} else {
|
|
|
180 |
unset($data['version'], $data['max_version']);
|
|
|
181 |
}
|
|
|
182 |
if ($o & 1) {
|
|
|
183 |
// display Conditions
|
|
|
184 |
} else {
|
|
|
185 |
unset($data['cond_code']);
|
|
|
186 |
}
|
|
|
187 |
if ($o & 2) {
|
|
|
188 |
// display Extensions
|
|
|
189 |
} else {
|
|
|
190 |
unset($data['extensions']);
|
|
|
191 |
}
|
|
|
192 |
if ($o & 4) {
|
|
|
193 |
if ($o & 8) {
|
|
|
194 |
// display Constants/Tokens
|
|
|
195 |
} else {
|
|
|
196 |
// display Constants
|
|
|
197 |
unset($data['tokens']);
|
|
|
198 |
}
|
|
|
199 |
} else {
|
|
|
200 |
unset($data['constants']);
|
|
|
201 |
if ($o & 8) {
|
|
|
202 |
// display Tokens
|
|
|
203 |
} else {
|
|
|
204 |
unset($data['tokens']);
|
|
|
205 |
}
|
|
|
206 |
}
|
|
|
207 |
if ($v & 4 || $options['debug'] == true) {
|
|
|
208 |
// display Functions
|
|
|
209 |
} else {
|
|
|
210 |
unset($data['functions']);
|
|
|
211 |
}
|
|
|
212 |
|
|
|
213 |
if (count($files) > 1) {
|
|
|
214 |
if ($this->args['summarize'] === true) {
|
|
|
215 |
foreach ($files as $file) {
|
|
|
216 |
unset($data[$file]);
|
|
|
217 |
}
|
|
|
218 |
} else {
|
|
|
219 |
foreach ($files as $file) {
|
|
|
220 |
if ($o & 16) {
|
|
|
221 |
// display Version
|
|
|
222 |
} else {
|
|
|
223 |
unset($data[$file]['version'], $data[$file]['max_version']);
|
|
|
224 |
}
|
|
|
225 |
if ($o & 1) {
|
|
|
226 |
// display Conditions
|
|
|
227 |
} else {
|
|
|
228 |
unset($data[$file]['cond_code']);
|
|
|
229 |
}
|
|
|
230 |
if ($o & 2) {
|
|
|
231 |
// display Extensions
|
|
|
232 |
} else {
|
|
|
233 |
unset($data[$file]['extensions']);
|
|
|
234 |
}
|
|
|
235 |
if ($o & 4) {
|
|
|
236 |
if ($o & 8) {
|
|
|
237 |
// display Constants/Tokens
|
|
|
238 |
} else {
|
|
|
239 |
// display Constants
|
|
|
240 |
unset($data[$file]['tokens']);
|
|
|
241 |
}
|
|
|
242 |
} else {
|
|
|
243 |
unset($data[$file]['constants']);
|
|
|
244 |
if ($o & 8) {
|
|
|
245 |
// display Tokens
|
|
|
246 |
} else {
|
|
|
247 |
unset($data[$file]['tokens']);
|
|
|
248 |
}
|
|
|
249 |
}
|
|
|
250 |
if ($v & 4 || $options['debug'] == true) {
|
|
|
251 |
// display Functions
|
|
|
252 |
} else {
|
|
|
253 |
unset($data[$file]['functions']);
|
|
|
254 |
}
|
|
|
255 |
}
|
|
|
256 |
}
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
if ($this->driver == 'PHP') {
|
|
|
260 |
var_export($data);
|
|
|
261 |
} else {
|
|
|
262 |
Var_Dump::display($data);
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
}
|
|
|
266 |
?>
|