Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,266 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Array.php,v 1.9 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b2
*/
/**
* Array renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Array class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply display results as
* a PHP array.
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b2
*/
class PHP_CompatInfo_Renderer_Array extends PHP_CompatInfo_Renderer
{
/**
* Driver to display results array.
*
* Default is PHP::var_export, but you can use PEAR::Var_Dump if available
*
* @var string
* @access public
*/
var $driver;
/**
* Array Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function PHP_CompatInfo_Renderer_Array(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Array Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function __construct(&$parser, $conf)
{
parent::PHP_CompatInfo_Renderer($parser, $conf);
$driver = 'PEAR::Var_Dump';
if (isset($conf[$driver])) {
$var_dump = 'Var_Dump.php';
if (PHP_CompatInfo_Renderer::isIncludable($var_dump)) {
include_once $var_dump;
$class_options = $conf['PEAR::Var_Dump'];
if (isset($class_options['options'])) {
$options = $class_options['options'];
} else {
$options = array();
}
if (isset($class_options['rendererOptions'])) {
$rendererOptions = $class_options['rendererOptions'];
} else {
$rendererOptions = array();
}
if (php_sapi_name() == 'cli') {
// prevent wrong display on command line interface
$options['display_mode'] = 'Text';
}
Var_Dump::displayInit($options, $rendererOptions);
$this->driver = $driver;
}
}
if (!isset($this->driver)) {
// if optional driver not defined, then use default PHP::var_export
$this->driver = 'PHP';
}
}
/**
* Display final results
*
* Display final results, when data source parsing is over.
*
* @access public
* @return void
* @since version 1.8.0b2 (2008-06-03)
*/
function display()
{
$o = $this->args['output-level'];
$v = $this->args['verbose'];
$data = $this->parseData;
$src = $this->_parser->dataSource;
if ($data === false) {
// invalid data source
if ($this->driver == 'PHP') {
var_export($data);
} else {
Var_Dump::display($data);
}
return;
}
$options = $this->_parser->options;
if (isset($this->args['dir'])) {
$files = $this->_parser->getFilelist($this->args['dir'], $options);
} elseif (isset($this->args['file'])) {
$files = array($this->args['file']);
} elseif ($src['dataType'] == 'directory') {
$files = $src['dataSource'];
} elseif ($src['dataType'] == 'file') {
$files = array($src['dataSource']);
} else {
$files = $src['dataSource'];
}
if ($options['is_string'] == true) {
foreach ($files as $k => $str) {
$files[$k] = 'string_' . ($k+1);
}
}
if ($o & 16) {
// display Version
} else {
unset($data['version'], $data['max_version']);
}
if ($o & 1) {
// display Conditions
} else {
unset($data['cond_code']);
}
if ($o & 2) {
// display Extensions
} else {
unset($data['extensions']);
}
if ($o & 4) {
if ($o & 8) {
// display Constants/Tokens
} else {
// display Constants
unset($data['tokens']);
}
} else {
unset($data['constants']);
if ($o & 8) {
// display Tokens
} else {
unset($data['tokens']);
}
}
if ($v & 4 || $options['debug'] == true) {
// display Functions
} else {
unset($data['functions']);
}
if (count($files) > 1) {
if ($this->args['summarize'] === true) {
foreach ($files as $file) {
unset($data[$file]);
}
} else {
foreach ($files as $file) {
if ($o & 16) {
// display Version
} else {
unset($data[$file]['version'], $data[$file]['max_version']);
}
if ($o & 1) {
// display Conditions
} else {
unset($data[$file]['cond_code']);
}
if ($o & 2) {
// display Extensions
} else {
unset($data[$file]['extensions']);
}
if ($o & 4) {
if ($o & 8) {
// display Constants/Tokens
} else {
// display Constants
unset($data[$file]['tokens']);
}
} else {
unset($data[$file]['constants']);
if ($o & 8) {
// display Tokens
} else {
unset($data[$file]['tokens']);
}
}
if ($v & 4 || $options['debug'] == true) {
// display Functions
} else {
unset($data[$file]['functions']);
}
}
}
}
if ($this->driver == 'PHP') {
var_export($data);
} else {
Var_Dump::display($data);
}
}
}
?>

View File

@@ -0,0 +1,296 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Csv.php,v 1.6 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b3
*/
/**
* Csv renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Csv class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply output informations
* in Comma Seperated Value style.
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b4
*/
class PHP_CompatInfo_Renderer_Csv extends PHP_CompatInfo_Renderer
{
/**
* Csv Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function PHP_CompatInfo_Renderer_Csv(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Csv Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function __construct(&$parser, $conf)
{
$defaults = array('fields-values-separated-by' => ',',
'fields-terminated-by' => ';',
'fields-enclosed-by' => '"',
'lines-terminated-by' => PHP_EOL);
$conf = array_merge($defaults, $conf);
parent::PHP_CompatInfo_Renderer($parser, $conf);
}
/**
* Display final results
*
* Display final results, when data source parsing is over.
*
* @access public
* @return void
* @since version 1.8.0b4 (2008-06-18)
*/
function display()
{
$fvsb = $this->conf['fields-values-separated-by'];
$o = $this->args['output-level'];
$info = $this->parseData;
$hdr = array();
$src = $this->_parser->dataSource;
if ($info === false) {
// invalid data source
return;
}
$options = $this->_parser->options;
if (isset($this->args['dir'])) {
$dir = $this->args['dir'];
$hdr[] = 'Files';
} elseif (isset($this->args['file'])) {
$file = $this->args['file'];
$hdr[] = 'File';
} elseif (isset($this->args['string'])) {
$string = $this->args['string'];
$hdr[] = 'Source code';
} elseif ($src['dataType'] == 'directory') {
$dir = $src['dataSource'];
$hdr[] = 'Files';
} elseif ($src['dataType'] == 'file') {
$file = $src['dataSource'];
$hdr[] = 'File';
} else {
if ($options['is_string'] == true) {
$string = $src['dataSource'];
$hdr[] = 'Source code';
} else {
$dir = $src['dataSource'];
$hdr[] = 'Files';
}
}
if ($o & 16) {
$hdr[] = 'Version';
}
if ($o & 1) {
$hdr[] = 'C';
}
if ($o & 2) {
$hdr[] = 'Extensions';
}
if ($o & 4) {
if ($o & 8) {
$hdr[] = 'Constants/Tokens';
} else {
$hdr[] = 'Constants';
}
} else {
if ($o & 8) {
$hdr[] = 'Tokens';
}
}
// print headers
$this->_printf($hdr);
$ext = implode($fvsb, $info['extensions']);
$const = implode($fvsb, array_merge($info['constants'], $info['tokens']));
if (isset($dir)) {
$ds = DIRECTORY_SEPARATOR;
if (is_array($dir)) {
$data = array(dirname($dir[0]));
} else {
$dir = str_replace(array('\\', '/'), $ds, $dir);
$data = array($dir);
}
} elseif (isset($file)) {
$data = array($file);
} else {
$data = array('<?php ... ?>');
}
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode($fvsb, array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode($fvsb, $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode($fvsb, $info['tokens']);
}
}
$this->_printf($data);
// summarize : print only summary for directory without files details
if ($this->args['summarize'] === false && isset($dir)) {
unset($info['max_version']);
unset($info['version']);
unset($info['classes']);
unset($info['functions']);
unset($info['extensions']);
unset($info['constants']);
unset($info['tokens']);
unset($info['cond_code']);
$ignored = $info['ignored_files'];
unset($info['ignored_files']);
unset($info['ignored_functions']);
unset($info['ignored_extensions']);
unset($info['ignored_constants']);
foreach ($info as $file => $info) {
if ($info === false) {
continue; // skip this (invalid) file
}
$ext = implode($fvsb, $info['extensions']);
$const = implode($fvsb, array_merge($info['constants'],
$info['tokens']));
$file = str_replace(array('\\', '/'), $ds, $file);
$data = array($file);
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode($fvsb, array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode($fvsb, $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode($fvsb, $info['tokens']);
}
}
$this->_printf($data);
}
}
}
/**
* Print a single line of CSV report
*
* @param array $data Data list to print
*
* @return void
* @access private
* @since 1.8.0b4 (2008-06-18)
*/
function _printf($data)
{
$string = '';
foreach ($data as $i => $d) {
if ($i > 0) {
$string .= $this->conf['fields-terminated-by'];
}
$string .= $this->conf['fields-enclosed-by'] . $d .
$this->conf['fields-enclosed-by'];
}
$string .= $this->conf['lines-terminated-by'];
echo $string;
}
}
?>

View File

@@ -0,0 +1,454 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Html.php,v 1.14 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b4
*/
require_once 'HTML/Table.php';
require_once 'HTML/CSS.php';
/**
* Html renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Html class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply display results
* as web/html content with help of PEAR::Html_Table
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b4
*/
class PHP_CompatInfo_Renderer_Html extends PHP_CompatInfo_Renderer
{
/**
* Style sheet for the custom layout
*
* @var string
* @access public
* @since 1.8.0b4
*/
var $css;
/**
* Html Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function PHP_CompatInfo_Renderer_Html(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Html Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function __construct(&$parser, $conf)
{
$defaults = array('tdwidth' => array(18, 4, 2, 7, 13));
$conf = array_merge($defaults, $conf);
parent::PHP_CompatInfo_Renderer($parser, $conf);
}
/**
* Display final results
*
* Display final results, when data source parsing is over.
*
* @access public
* @return void
* @since version 1.8.0b4 (2008-06-18)
*/
function display()
{
$o = $this->args['output-level'];
$info = $this->parseData;
if ($info == false) {
// protect against invalid data source
print 'Invalid data source';
return;
}
$src = $this->_parser->dataSource;
if ($src['dataType'] == 'directory') {
$dir = $src['dataSource'];
$hdr_col1 = 'Directory';
} elseif ($src['dataType'] == 'file') {
$file = $src['dataSource'];
$hdr_col1 = 'File';
} else {
$string = $src['dataSource'];
$hdr_col1 = 'Source code';
}
$dataTable = new HTML_Table();
$thead =& $dataTable->getHeader();
$tbody =& $dataTable->getBody();
$tfoot =& $dataTable->getFooter();
$hdr = array($hdr_col1);
$atr = array('scope="col"');
if ($o & 16) {
$hdr[] = 'Version';
$atr[] = 'scope="col"';
}
if ($o & 1) {
$hdr[] = 'C';
$atr[] = 'scope="col"';
}
if ($o & 2) {
$hdr[] = 'Extensions';
$atr[] = 'scope="col"';
}
if ($o & 4) {
if ($o & 8) {
$hdr[] = 'Constants/Tokens';
$atr[] = 'scope="col"';
} else {
$hdr[] = 'Constants';
$atr[] = 'scope="col"';
}
} else {
if ($o & 8) {
$hdr[] = 'Tokens';
$atr[] = 'scope="col"';
}
}
$thead->addRow($hdr, $atr);
$ext = implode("<br/>", $info['extensions']);
$const = implode("<br/>", array_merge($info['constants'], $info['tokens']));
if (isset($dir)) {
$ds = DIRECTORY_SEPARATOR;
$dir = str_replace(array('\\', '/'), $ds, $dir);
$title = $src['dataCount'] . ' file';
if ($src['dataCount'] > 1) {
$title .= 's'; // plural
}
} elseif (isset($file)) {
$title = '1 file';
} else {
$title = '1 chunk of code';
}
$data = array('Summary: '. $title . ' parsed');
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode("<br/>", array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode("<br/>", $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode("<br/>", $info['tokens']);
}
}
// summary informations
$tfoot->addRow($data);
// summarize : print only summary for directory without files details
if ($this->args['summarize'] === false && isset($dir)) {
// display result of parsing multiple files
unset($info['max_version']);
unset($info['version']);
unset($info['classes']);
unset($info['functions']);
unset($info['extensions']);
unset($info['constants']);
unset($info['tokens']);
unset($info['cond_code']);
$ignored = $info['ignored_files'];
unset($info['ignored_files']);
unset($info['ignored_functions']);
unset($info['ignored_extensions']);
unset($info['ignored_constants']);
foreach ($info as $file => $info) {
if ($info === false) {
continue; // skip this (invalid) file
}
$ext = implode("<br/>", $info['extensions']);
$const = implode("<br/>", array_merge($info['constants'],
$info['tokens']));
$file = str_replace(array('\\', '/'), $ds, $file);
$path = dirname($file);
$tbody->addRow(array($path), array('class' => 'dirname',
'colspan' => count($hdr)));
$data = array(basename($file));
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode("<br/>", array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode("<br/>", $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode("<br/>", $info['tokens']);
}
}
$tbody->addRow($data);
}
} elseif ($this->args['summarize'] === false && !isset($dir)) {
// display result of parsing a single file, or a chunk of code
if (isset($file)) {
$path = dirname($file);
} else {
$path = '.';
}
$tbody->addRow(array($path), array('class' => 'dirname',
'colspan' => count($hdr)));
if (isset($file)) {
$data[0] = basename($file);
} else {
$data[0] = htmlspecialchars('<?php ... ?>');
}
$tbody->addRow($data);
} else {
// display only result summary of parsing a data source
if (isset($dir)) {
$path = dirname($dir[0]);
} elseif (isset($file)) {
$path = dirname($file);
} else {
$path = '.';
}
$tbody->addRow(array($path), array('class' => 'dirname',
'colspan' => count($hdr)));
}
$evenRow = array('class' => 'even');
$oddRow = null;
$tbody->altRowAttributes(1, $evenRow, $oddRow, true);
echo $this->toHtml($dataTable);
}
/**
* Returns the custom style sheet
*
* Returns the custom style sheet to use for layout
*
* @param int $destination (optional) Destination of css content
* @param mixed $extra (optional) Additional data depending of destination
*
* @return mixed
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function getStyleSheet($destination = 1, $extra = null)
{
$css = new HTML_CSS();
$css->parseFile($this->css);
$tdw = $this->conf['tdwidth'];
$em = array_sum($tdw);
$td = 'td';
$o = $this->args['output-level'];
$css->setStyle('.outer td.dirname', 'width', $em.'em');
if ($o & 16) {
$td .= '+td';
$css->setStyle('.outer '.$td, 'width', $tdw[1].'em');
$em = $em - $tdw[1];
}
if ($o & 1) {
$td .= '+td';
$css->setStyle('.outer '.$td, 'width', $tdw[2].'em');
$em = $em - $tdw[2];
}
if ($o & 2) {
$td .= '+td';
$css->setStyle('.outer '.$td, 'width', $tdw[3].'em');
$em = $em - $tdw[3];
}
if ($o & 12) {
$td .= '+td';
$css->setStyle('.outer '.$td, 'width', $tdw[4].'em');
$em = $em - $tdw[4];
}
$css->setStyle('.outer td', 'width', $em .'em');
$styles = '';
switch ($destination) {
case 1: // embedded styles
$styles = $css->toString();
break;
case 2: // save only to file
$css->toFile($extra);
$styles = $extra;
break;
case 3: // apply a user function
if (is_callable($extra)) {
$styles = call_user_func_array($extra, array($css));
}
break;
default:
break;
}
return $styles;
}
/**
* Set a custom style sheet
*
* Set a custom style sheet to use your own styles
*
* @param string $css (optional) File to read user-defined styles from
*
* @return bool True if custom styles, false if default styles applied
* @access public
* @since version 1.8.0b4 (2008-06-18)
*/
function setStyleSheet($css = null)
{
// default stylesheet is into package data directory
if (!isset($css)) {
$css = '\php\pear\data' . DIRECTORY_SEPARATOR
. 'PHP_CompatInfo' . DIRECTORY_SEPARATOR
. 'pci.css';
}
$res = isset($css) && file_exists($css);
if ($res) {
$this->css = $css;
}
return $res;
}
/**
* Returns HTML code
*
* Returns HTML code of parsing result
*
* @param object $obj instance of HTML_Table
*
* @access public
* @return string
* @since version 1.8.0b4 (2008-06-18)
*/
function toHtml($obj)
{
if (!isset($this->css)) {
// when no user-styles defined, used the default values
$this->setStyleSheet();
}
$styles = $this->getStyleSheet();
$body = $obj->toHtml();
$html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>PHP_CompatInfo</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<style type="text/css">
<!--
$styles
-->
</style>
</head>
<body>
<div class="outer">
<div class="inner">
$body
</div>
</div>
</body>
</html>
HTML;
return $html;
}
}
?>

View File

@@ -0,0 +1,98 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Null.php,v 1.5 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b2
*/
/**
* Null renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Null class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply consumes output events.
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b2
*/
class PHP_CompatInfo_Renderer_Null extends PHP_CompatInfo_Renderer
{
/**
* Null Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function PHP_CompatInfo_Renderer_Null(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Null Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function __construct(&$parser, $conf)
{
parent::PHP_CompatInfo_Renderer($parser, $conf);
}
/**
* Consumes output events
*
* @access public
* @return void
* @since version 1.8.0RC1 (2008-07-01)
*/
function display()
{
}
}
?>

View File

@@ -0,0 +1,498 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Text.php,v 1.13 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b3
*/
require_once 'Console/Table.php';
/**
* Text renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Text class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply display results
* for the command line interface with help of PEAR::Console_Table
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b3
*/
class PHP_CompatInfo_Renderer_Text extends PHP_CompatInfo_Renderer
{
/**
* Text Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b3 (2008-06-07)
*/
function PHP_CompatInfo_Renderer_Text(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Text Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b3 (2008-06-07)
*/
function __construct(&$parser, $conf)
{
$defaults = array('colwidth' => array('f' => 29, 'e' => 12, 'c' => 20));
$conf = array_merge($defaults, $conf);
parent::PHP_CompatInfo_Renderer($parser, $conf);
}
/**
* Display final results
*
* Display final results, when data source parsing is over.
*
* @access public
* @return void
* @since version 1.8.0b3 (2008-06-07)
*/
function display()
{
$o = $this->args['output-level'];
$info = $this->parseData;
$hdr = array();
$src = $this->_parser->dataSource;
if (isset($this->args['dir'])) {
$dir = $this->args['dir'];
$hdr[] = 'Files';
} elseif (isset($this->args['file'])) {
$file = $this->args['file'];
$hdr[] = 'File';
} elseif (isset($this->args['string'])) {
$string = $this->args['string'];
$hdr[] = 'Source code';
} elseif ($src['dataType'] == 'directory') {
$dir = $src['dataSource'];
$hdr[] = 'Files';
} elseif ($src['dataType'] == 'file') {
$file = $src['dataSource'];
$hdr[] = 'File';
} else {
$string = $src['dataSource'];
$hdr[] = 'Source code';
}
$table = new Console_Table();
$f = 0;
if ($o & 16) {
$hdr[] = 'Version';
$f++;
}
if ($o & 1) {
$hdr[] = 'C';
$f++;
}
if ($o & 2) {
$hdr[] = 'Extensions';
$filter2 = array(&$this, '_splitExtname');
$table->addFilter($f+1, $filter2);
$f++;
}
if ($o & 4) {
if ($o & 8) {
$hdr[] = 'Constants/Tokens';
} else {
$hdr[] = 'Constants';
}
$f++;
} else {
if ($o & 8) {
$hdr[] = 'Tokens';
$f++;
}
}
$table->setHeaders($hdr);
$filter0 = array(&$this, '_splitFilename');
$table->addFilter(0, $filter0);
if ($o > 3 && $o < 16 || $o > 19) {
$filter3 = array(&$this, '_splitConstant');
$table->addFilter($f, $filter3);
}
$ext = implode("\r\n", $info['extensions']);
$const = implode("\r\n", array_merge($info['constants'], $info['tokens']));
if (isset($dir)) {
$ds = DIRECTORY_SEPARATOR;
$dir = str_replace(array('\\', '/'), $ds, $dir);
$data = array($dir . $ds . '*');
} elseif (isset($file)) {
$data = array($file);
} else {
$data = array('<?php ... ?>');
}
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode("\r\n", array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode("\r\n", $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode("\r\n", $info['tokens']);
}
}
$table->addRow($data);
unset($info['max_version']);
unset($info['version']);
unset($info['classes']);
unset($info['functions']);
unset($info['extensions']);
unset($info['constants']);
unset($info['tokens']);
unset($info['cond_code']);
$ignored = $info['ignored_files'];
$all_functions = array();
unset($info['ignored_files']);
unset($info['ignored_functions']);
unset($info['ignored_extensions']);
unset($info['ignored_constants']);
// summarize : print only summary for directory without files details
if ($this->args['summarize'] === false && isset($dir)) {
foreach ($info as $file => $info) {
if (is_numeric($file{0})) {
// extra information available only when debug mode is on
$all_functions[$file] = $info;
continue;
}
if ($info === false) {
continue; // skip this (invalid) file
}
$ext = implode("\r\n", $info['extensions']);
$const = implode("\r\n", array_merge($info['constants'],
$info['tokens']));
$file = str_replace(array('\\', '/'), $ds, $file);
$table->addSeparator();
$data = array($file);
if ($o & 16) {
if (empty($info['max_version'])) {
$data[] = $info['version'];
} else {
$data[] = implode("\r\n", array($info['version'],
$info['max_version']));
}
}
if ($o & 1) {
$data[] = $info['cond_code'][0];
}
if ($o & 2) {
$data[] = $ext;
}
if ($o & 4) {
if ($o & 8) {
$data[] = $const;
} else {
$data[] = implode("\r\n", $info['constants']);
}
} else {
if ($o & 8) {
$data[] = implode("\r\n", $info['tokens']);
}
}
$table->addRow($data);
}
} else {
foreach ($info as $file => $info) {
if (is_numeric($file{0})) {
// extra information available only when debug mode is on
$all_functions[$file] = $info;
}
}
}
$output = $table->getTable();
// verbose level
$v = isset($this->args['verbose']) ? $this->args['verbose'] : 0;
// command line resume
if ($v & 1) {
$output .= "\nCommand Line resume :\n\n";
$table = new Console_Table();
$table->setHeaders(array('Option', 'Value'));
$filter0 = array(&$this, '_splitOption');
$table->addFilter(0, $filter0);
$filter1 = array(&$this, '_splitValue');
$table->addFilter(1, $filter1);
if (is_array($this->args)) {
foreach ($this->args as $key => $raw) {
if ($key == 'summarize') {
$raw = ($raw === true) ? 'TRUE' : 'FALSE';
}
if (is_array($raw)) {
$raw = implode(', ', $raw);
}
$contents = array($key, $raw);
$table->addRow($contents);
}
}
$output .= $table->getTable();
}
// parser options resume
if ($v & 2) {
$output .= "\nParser options :\n\n";
$table = new Console_Table();
$table->setHeaders(array('Option', 'Value'));
$filter0 = array(&$this, '_splitOption');
$table->addFilter(0, $filter0);
$filter1 = array(&$this, '_splitValue');
$table->addFilter(1, $filter1);
$opts = $this->_parser->options;
if (is_array($opts)) {
foreach ($opts as $key => $raw) {
if ($key == 'debug'
|| $key == 'recurse_dir'
|| $key == 'is_string') {
$raw = ($raw === true) ? 'TRUE' : 'FALSE';
}
if (substr($key, -6) == '_match') {
$val = array_values($raw[1]);
array_unshift($val, $raw[0]);
$raw = implode("\r\n", $val);
} else {
if (is_array($raw)) {
$raw = implode("\r\n", $raw);
}
}
$contents = array($key, $raw);
$table->addRow($contents);
}
}
$output .= $table->getTable();
}
// extra information
if ($v & 4) {
$output .= "\nDebug:\n\n";
$table = new Console_Table();
$table->setHeaders(array('Version', 'Function', 'Extension', 'PECL'));
foreach ($all_functions as $version => $functions) {
foreach ($functions as $func) {
$table->addRow(array($version,
$func['function'], $func['extension'],
(isset($func['pecl']) ?
(($func['pecl'] === true) ? 'yes' : 'no') : '')));
}
}
$output .= $table->getTable();
}
echo $output;
}
/**
* The Console_Table filter callback limits table output to 80 columns,
* and Path column to 29 characters
* (27 + 1 blank margin left + 1 blank margin right).
*
* @param string $data Content of filename column (0)
*
* @return string
* @access private
* @since 1.3.0
*/
function _splitFilename($data)
{
$w = $this->conf['colwidth']['f'] - 2;
if (strlen($data) <= $w) {
$str = str_pad($data, $w);
} else {
$str = '...' . substr($data, (strlen($data) - ($w - 3)));
}
return $str;
}
/**
* The Console_Table filter callback limits table output to 80 columns,
* and Extensions column to 12 characters
* (10 + 1 blank margin left + 1 blank margin right).
*
* @param string $data Content of extensions column
*
* @return string
* @access private
* @since 1.7.0
*/
function _splitExtname($data)
{
$szlim = $this->conf['colwidth']['e'] - 2;
$extArr = explode("\r\n", $data);
$str = '';
foreach ($extArr as $ext) {
if (strlen($ext) <= $szlim) {
$str .= str_pad($ext, $szlim);
} else {
$str .= '...' . substr($ext, (strlen($ext) - ($szlim - 3)));
}
$str .= "\r\n";
}
$str = rtrim($str, "\r\n");
return $str;
}
/**
* The Console_Table filter callback limits table output to 80 columns,
* and Constants/Tokens column to 20 characters
* (18 + 1 blank margin left + 1 blank margin right)
*
* @param string $data Content of constants/tokens column
*
* @return string
* @access private
* @since 1.7.0
*/
function _splitConstant($data)
{
$szlim = $this->conf['colwidth']['c'] - 2;
$cstArr = explode("\r\n", $data);
$str = '';
foreach ($cstArr as $cst) {
if (strlen($cst) <= $szlim) {
$str .= str_pad($cst, $szlim);
} else {
$str .= '...' . substr($cst, (strlen($cst) - ($szlim - 3)));
}
$str .= "\r\n";
}
$str = rtrim($str, "\r\n");
return $str;
}
/**
* The Console_Table filter callback limits table output to 80 columns,
* and Command line Option column to 25 characters
* (23 + 1 blank margin left + 1 blank margin right).
*
* @param string $data Content of option column (0)
*
* @return string
* @access private
* @since 1.7.0
*/
function _splitOption($data)
{
if (strlen($data) <= 23) {
$str = str_pad($data, 23);
} else {
$str = '...' . substr($data, (strlen($data) - 20));
}
return $str;
}
/**
* The Console_Table filter callback limits table output to 80 columns,
* and Command line Value column to 51 characters
* (49 + 1 blank margin left + 1 blank margin right)
*
* @param string $data Content of value column (1)
*
* @return string
* @access private
* @since 1.7.0
*/
function _splitValue($data)
{
$cstArr = explode("\r\n", $data);
$str = '';
foreach ($cstArr as $cst) {
if (strlen($cst) <= 49) {
$str .= str_pad($cst, 49);
} else {
$str .= '...' . substr($cst, (strlen($cst) - 46));
}
$str .= "\r\n";
}
$str = rtrim($str, "\r\n");
return $str;
}
}
?>

View File

@@ -0,0 +1,438 @@
<?php
/**
* Copyright (c) 2008-2009, Laurent Laville <pear@laurent-laville.org>
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the authors nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: Xml.php,v 1.13 2009/01/02 10:18:47 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since File available since Release 1.8.0b2
*/
require_once 'XML/Util.php';
/**
* Array renderer for PHP_CompatInfo component.
*
* The PHP_CompatInfo_Renderer_Xml class is a concrete implementation
* of PHP_CompatInfo_Renderer abstract class. It simply display results as
* an XML stream.
*
* @category PHP
* @package PHP_CompatInfo
* @author Laurent Laville <pear@laurent-laville.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version Release: 1.9.0
* @link http://pear.php.net/package/PHP_CompatInfo
* @since Class available since Release 1.8.0b2
*/
class PHP_CompatInfo_Renderer_Xml extends PHP_CompatInfo_Renderer
{
/**
* Xml Renderer Class constructor (ZE1) for PHP4
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function PHP_CompatInfo_Renderer_Xml(&$parser, $conf)
{
$this->__construct($parser, $conf);
}
/**
* Xml Renderer Class constructor (ZE2) for PHP5+
*
* @param object &$parser Instance of the parser (model of MVC pattern)
* @param array $conf A hash containing any additional configuration
*
* @access public
* @since version 1.8.0b2 (2008-06-03)
*/
function __construct(&$parser, $conf)
{
$defaults = array('use-beautifier' => 'auto');
$conf = array_merge($defaults, $conf);
parent::PHP_CompatInfo_Renderer($parser, $conf);
}
/**
* Display final results
*
* Display final results, when data source parsing is over.
*
* @access public
* @return void
* @since version 1.8.0b2 (2008-06-03)
*/
function display()
{
if ($this->parseData === false) {
// invalid data source
return;
}
$version = isset($this->conf['xml']['version'])
? $this->conf['xml']['version'] : '1.0';
$encoding = isset($this->conf['xml']['encoding'])
? $this->conf['xml']['encoding'] : 'UTF-8';
$standalone = isset($this->conf['xml']['standalone'])
? $this->conf['xml']['standalone'] : null;
$msg = XML_Util::getXMLDeclaration($version, $encoding, $standalone);
$msg .= PHP_EOL;
$msg .= XML_Util::createStartElement('pci',
array('version' => '1.9.0'));
$o = $this->args['output-level'];
$v = $this->args['verbose'];
$dataSource = $this->_parser->dataSource['dataSource'];
$dataType = $this->_parser->dataSource['dataType'];
$options = $this->_parser->options;
if ($dataType == 'directory'
|| $dataType == 'array'
|| $dataType == 'file') {
// parsing a directory or a list of files, chunks of code
if ($options['is_string'] == false) {
if ($dataType == 'directory') {
// print <dir> tag
$tag = array('qname' => 'dir',
'content' => dirname($dataSource[0]));
} else {
// print <file> tag
$tag = array('qname' => 'file',
'content' => $dataSource[0]);
}
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
// print global <version> tag
if ($o & 16) {
if (empty($this->parseData['max_version'])) {
$attr = array();
} else {
$attr = array('max' => $this->parseData['max_version']);
}
$tag = array('qname' => 'version',
'attributes' => $attr,
'content' => $this->parseData['version']);
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
// print global <conditions> tag group
if ($o & 1) {
$msg .= $this->_printTagList($this->parseData['cond_code'],
'condition');
}
// print global <extensions> tag group
if ($o & 2) {
$msg .= $this->_printTagList($this->parseData['extensions'],
'extension');
}
// print global <constants> tag group
if ($o & 4) {
$msg .= $this->_printTagList($this->parseData['constants'],
'constant');
}
// print global <tokens> tag group
if ($o & 8) {
$msg .= $this->_printTagList($this->parseData['tokens'],
'token');
}
// print global <ignored> tag group
$msg .= XML_Util::createStartElement('ignored');
$msg .= PHP_EOL;
// with children groups <files>, <functions>, <extensions>, <constants>
$ignored = array('file' => $this->parseData['ignored_files'],
'function' => $this->parseData['ignored_functions'],
'extension' => $this->parseData['ignored_extensions'],
'constant' => $this->parseData['ignored_constants']);
foreach ($ignored as $tag => $data) {
$msg .= $this->_printTagList($data, $tag);
}
$msg .= XML_Util::createEndElement('ignored');
$msg .= PHP_EOL;
// remove summary data
unset($this->parseData['ignored_files']);
unset($this->parseData['ignored_functions']);
unset($this->parseData['ignored_extensions']);
unset($this->parseData['ignored_constants']);
unset($this->parseData['max_version']);
unset($this->parseData['version']);
unset($this->parseData['classes']);
unset($this->parseData['functions']);
unset($this->parseData['extensions']);
unset($this->parseData['constants']);
unset($this->parseData['tokens']);
unset($this->parseData['cond_code']);
if ($v & 4 || $options['debug'] == true) {
// print local <functions> tag group
$msg .= $this->_printTagList($this->parseData, 'function');
$entries = array_keys($this->parseData);
foreach ($entries as $k) {
if (is_numeric($k{0})) {
unset($this->parseData[$k]);
}
}
}
if ($dataType == 'file') {
// parsing a single file
$files = array($dataSource[0] => $this->parseData);
} else {
$files = $this->parseData;
}
} else {
// ... or a chunk of code (string)
$files = array($this->parseData);
}
if ($this->args['summarize'] === false
&& count($files) > 1) {
if ($options['is_string'] == false) {
// print <files> tag group
$msg .= XML_Util::createStartElement('files',
array('count' => count($files)));
$msg .= PHP_EOL;
}
foreach ($files as $file => $this->parseData) {
if ($options['is_string'] == true) {
$msg .= XML_Util::createStartElement('string',
array('name' => $file));
} else {
// print local <file> tag
$msg .= XML_Util::createStartElement('file',
array('name' => $file));
}
$msg .= PHP_EOL;
// print local <version> tag
if ($o & 16) {
if (empty($this->parseData['max_version'])) {
$attr = array();
} else {
$attr = array('max' => $this->parseData['max_version']);
}
$tag = array('qname' => 'version',
'attributes' => $attr,
'content' => $this->parseData['version']);
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
// print local <conditions> tag group
if ($o & 1) {
$msg .= $this->_printTagList($this->parseData['cond_code'],
'condition');
}
// print local <extensions> tag group
if ($o & 2) {
$msg .= $this->_printTagList($this->parseData['extensions'],
'extension');
}
// print local <constants> tag group
if ($o & 4) {
$msg .= $this->_printTagList($this->parseData['constants'],
'constant');
}
// print local <tokens> tag group
if ($o & 8) {
$msg .= $this->_printTagList($this->parseData['tokens'],
'token');
}
// print local <ignored> tag group
$msg .= XML_Util::createStartElement('ignored');
$msg .= PHP_EOL;
// with children groups <functions>, <extensions>, <constants>
$ignored = array(
'function' => $this->parseData['ignored_functions'],
'extension' => $this->parseData['ignored_extensions'],
'constant' => $this->parseData['ignored_constants']
);
foreach ($ignored as $tag => $data) {
$msg .= $this->_printTagList($data, $tag);
}
$msg .= XML_Util::createEndElement('ignored');
$msg .= PHP_EOL;
// extra information only if verbose mode >= 4
if ($v & 4 || $options['debug'] == true) {
unset($this->parseData['ignored_files']);
unset($this->parseData['ignored_functions']);
unset($this->parseData['ignored_extensions']);
unset($this->parseData['ignored_constants']);
unset($this->parseData['max_version']);
unset($this->parseData['version']);
unset($this->parseData['classes']);
unset($this->parseData['functions']);
unset($this->parseData['extensions']);
unset($this->parseData['constants']);
unset($this->parseData['tokens']);
unset($this->parseData['cond_code']);
// print local <functions> tag group
$msg .= $this->_printTagList($this->parseData, 'function');
}
if ($options['is_string'] == true) {
$msg .= XML_Util::createEndElement('string');
} else {
$msg .= XML_Util::createEndElement('file');
}
$msg .= PHP_EOL;
}
if ($options['is_string'] == false) {
$msg .= XML_Util::createEndElement('files');
$msg .= PHP_EOL;
}
}
$msg .= XML_Util::createEndElement('pci');
$msg .= PHP_EOL;
if (strtolower($this->conf['use-beautifier']) != 'no') {
// try to see if we can improve XML render
$beautifier = 'XML/Beautifier.php';
if (PHP_CompatInfo_Renderer::isIncludable($beautifier)) {
include_once $beautifier;
$def = array();
$opt = isset($this->conf['beautifier'])
? $this->conf['beautifier'] : $def;
$fmt = new XML_Beautifier($opt);
$msg = $fmt->formatString($msg);
}
}
echo $msg;
}
/**
* Print a group of same tag in the XML report.
*
* Groups list are : extension(s), constant(s), token(s)
*
* @param array $dataSrc Data source
* @param string $tagName Name of the XML tag
*
* @return string
* @access private
* @since version 1.7.0b4 (2008-04-03)
*/
function _printTagList($dataSrc, $tagName)
{
$msg = '';
if ($tagName == 'function') {
$c = 0;
foreach ($dataSrc as $version => $functions) {
$c += count($functions);
}
$attributes = array('count' => $c);
} elseif ($tagName == 'condition') {
if ($this->_parser->options['debug'] === true) {
$c = 0;
foreach ($dataSrc[1] as $cond => $elements) {
$c += count($elements);
}
$attributes = array('count' => $c, 'level' => $dataSrc[0]);
} else {
$attributes = array('level' => $dataSrc[0]);
}
} else {
$attributes = array('count' => count($dataSrc));
}
$msg .= XML_Util::createStartElement($tagName.'s', $attributes);
$msg .= PHP_EOL;
if ($tagName == 'function') {
foreach ($dataSrc as $version => $functions) {
foreach ($functions as $data) {
$attr = array('version' => $version);
if (!empty($data['extension'])) {
$attr['extension'] = $data['extension'];
$attr['pecl'] = $data['pecl'] === true ?
'true' : 'false';
}
$tag = array('qname' => $tagName,
'attributes' => $attr,
'content' => $data['function']);
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
}
} elseif ($tagName == 'condition') {
if ($this->_parser->options['debug'] == true) {
foreach ($dataSrc[1] as $cond => $elements) {
$cond = ($cond == 0) ? 1 : ($cond * 2);
foreach ($elements as $data) {
$tag = array('qname' => $tagName,
'attributes' => array('level' => $cond),
'content' => $data);
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
}
}
} else {
foreach ($dataSrc as $data) {
$tag = array('qname' => $tagName,
'attributes' => array(),
'content' => $data);
$msg .= XML_Util::createTagFromArray($tag);
$msg .= PHP_EOL;
}
}
$msg .= XML_Util::createEndElement($tagName.'s');
$msg .= PHP_EOL;
return $msg;
}
}
?>