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,36 @@
<?php
/**
* Test Constants that appeared in >= 4.3.0
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Davey Shafik <davey@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: checkConstants.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/**
* @ignore
*/
function test_constants()
{
return __FUNCTION__;
}
$info = new PHP_CompatInfo();
$file = __FILE__;
$r = $info->parseFile($file);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,53 @@
<?php
/**
* Test Extensions that appeared both as standard or PECL
*
* 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: checkExtensions.php,v 1.3 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
xdebug_start_trace();
require_once 'PHP/CompatInfo.php';
/**
* @ignore
*/
function test_extensions()
{
$image = imagecreate(320, 240);
imageantialias($image, true);
return $image;
}
/*
Cannot be parsed on CLI
print_r(apache_get_modules());
*/
if (!extension_loaded('sqlite')) {
$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
xdebug_stop_trace();
$info = new PHP_CompatInfo();
$file = __FILE__;
$options = array('debug' => true);
$r = $info->parseFile($file, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,118 @@
<?php
/**
* Test tokens that appeared in PHP 5
* T_ABSTRACT
* T_CATCH
* T_FINAL
* T_INSTANCEOF
* T_PRIVATE
* T_PROTECTED
* T_PUBLIC
* T_THROW
* T_TRY
* T_CLONE
* T_INTERFACE
* T_IMPLEMENTS
*
* 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: checkPHP5.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/**
* @ignore
*/
abstract class AbstractClass
{
abstract protected function getValue();
}
/**
* @ignore
*/
interface ITemplate
{
public function setVariable($name, $var);
public function getHtml($template);
}
/**
* @ignore
*/
class Template implements ITemplate
{
private $vars = array();
public function setVariable($name, $var)
{
$this->vars[$name] = $var;
}
public function getHtml($template)
{
foreach ($this->vars as $name => $value) {
$template = str_replace('{' . $name . '}', $value, $template);
}
return $template;
}
}
/**
* @ignore
*/
class BaseClass
{
public $objet1;
public $objet2;
public function __construct()
{
}
public function __clone()
{
$this->object1 = clone($this->object1);
}
private function foo()
{
}
protected function bar()
{
if ($this->object1 instanceof BaseClass) {
return;
}
try {
$error = 'my error';
throw new Exception($error);
} catch(Exception $__bar_exception) {
}
}
final public function moreTesting()
{
echo "BaseClass::moreTesting() called \n";
}
}
$info = new PHP_CompatInfo();
$file = __FILE__;
$options = array('debug' => true);
$r = $info->parseFile($file, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,274 @@
<?php
/**
* PEAR::CompatInfo Web frontend
*
* 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: ci_frontend.php,v 1.6 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PEAR/Registry.php';
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/advmultiselect.php';
if (version_compare(phpversion(), '5.0.0', '<')) {
include_once 'PHP/Compat.php';
PHP_Compat::loadFunction('array_combine');
}
session_start();
$sess =& $_SESSION;
$config = new PEAR_Config();
$pear_install_dir = $config->get('php_dir');
$reg = new PEAR_Registry($pear_install_dir);
if (count($sess) == 0) {
// PEAR packages installed from each channel
$allpackages = $reg->listAllPackages();
foreach ($allpackages as $channel => $packages) {
if ($packages) {
sort($packages, SORT_ASC);
foreach ($packages as $package) {
$info = &$reg->getPackage($package, $channel);
if (is_object($info)) {
$name = $info->getPackage();
$version = $info->getVersion();
$release_state = $info->getState();
} else {
$name = $info['package'];
$version = $info['version'];
$release_state = $info['state'];
}
$sess['packages'][$channel][] = "$name $version ($release_state)";
}
} else {
$sess['packages'][$channel] = array();
}
}
// channels
$channels = array_keys($sess['packages']);
array_unshift($channels, '');
$sess['channels'] = array_combine($channels, $channels);
// packages
$names[''] = array();
foreach ($sess['packages'] as $c => $p) {
if (count($p)) {
$l = array();
foreach ($p as $k) {
list($n, $v, $s) = explode(' ', $k);
$l[] = $n;
}
$names[$c] = array_combine($l, $p);
} else {
$names[$c] = array();
}
}
$sess['pkgnames'] = $names;
// PHP internal functions
$func = get_defined_functions();
sort($func['internal']);
$sess['phpfunctions'] = $func['internal'];
}
// ignore functions
$ignore_functions = array_combine($sess['phpfunctions'], $sess['phpfunctions']);
// web frontend
$form = new HTML_QuickForm('cife');
$form->removeAttribute('name'); // XHTML compliance
// header
$form->addElement('header', 'cife_hdr', 'CompatInfo :: Web frontend');
// ignore functions
$ams1 =& $form->addElement('advmultiselect', 'ignore_functions', null,
$ignore_functions,
array('size' => 5, 'style' => 'width:250px;', 'class' => 'pool'));
$ams1->setLabel(array('PHP functions:', 'available', 'ignore'));
// packages installed
$pkgInstalled =& $form->addElement('hierselect', 'package', null, array('class' => 'flat'), '&nbsp;');
$pkgInstalled->setLabel('Packages installed:');
$pkgInstalled->setOptions(array($sess['channels'], $sess['pkgnames']));
$form->addElement('submit', 'filelist', 'File List');
// ignore files
$safe = $form->getSubmitValues();
if (isset($safe['filelist'])) {
$package = &$reg->getPackage($safe['package'][1], $safe['package'][0]);
$files = array();
$filelist = $package->getFilelist();
foreach ($filelist as $name => $atts) {
if (isset($atts['role']) && $atts['role'] != 'php') {
continue;
}
if (!preg_match('/\.php$/', $name)) {
continue;
}
$files[] = $atts['installed_as'];
}
$sess['phpfiles'] = $files;
$labels = str_replace($pear_install_dir . DIRECTORY_SEPARATOR, '', $files);
$ignore_files = array_combine($files, $labels);
} else {
$ignore_files = array();
}
$ams2 =& $form->addElement('advmultiselect', 'ignore_files', null,
$ignore_files,
array('size' => 5, 'style' => 'width:300px;', 'class' => 'pool'));
$ams2->setLabel(array('Package files (role=php):', 'available', 'ignore'));
// dump options
$dump =& $form->addElement('checkbox', 'dump');
$dump->setLabel('Dump:');
$dump->setText('PHP min version only');
$dbg =& $form->addElement('checkbox', 'dbg');
$dbg->setLabel('Debug:');
$dbg->setText('Extra output');
// commands
$form->addElement('submit', 'process', 'Process');
$form->addElement('submit', 'abort', 'Abort');
// initial values
$form->setDefaults(array(
'ignore_functions' => array(),
'ignore_files' => array(),
'dump' => true
));
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>PEAR::PHP_CompatInfo Web frontend </title>
<style type="text/css">
<!--
body {
background-color: #FFF;
font-family: Verdana, Arial, helvetica;
font-size: 10pt;
}
.error {
color: red;
font-weight: bold;
}
.dump {
background-color: #EEE;
color: black;
}
table.pool {
border: 0;
background-color: #339900;
width:450px;
}
table.pool th {
font-size: 80%;
font-style: italic;
text-align: left;
}
table.pool select {
color: white;
background-color: #006600;
}
.inputCommand {
background-color: #d0d0d0;
border: 1px solid #7B7B88;
width: 7em;
margin-bottom: 2px;
}
-->
</style>
<script type="text/javascript">
//<![CDATA[
<?php
echo $ams1->getElementJs();
echo $ams2->getElementJs();
?>
//]]>
</script>
</head>
<body>
<?php
if ($form->validate()) {
$safe = $form->getSubmitValues();
if (isset($safe['ignore_files'])) {
$ignore_files = $safe['ignore_files'];
} else {
$ignore_files = array();
}
if (isset($safe['ignore_functions'])) {
$ignore_functions = $safe['ignore_functions'];
} else {
$ignore_functions = array();
}
if (!isset($sess['phpfiles']) && !isset($safe['abort'])) {
echo '<p class="error">Please get file list before to process.</p>';
} else {
if (isset($safe['process'])) {
include_once 'PHP/CompatInfo.php';
$info = new PHP_CompatInfo();
$options = array(
'debug' => (isset($safe['dbg'])),
'ignore_files' => $ignore_files,
'ignore_functions' => $ignore_functions
);
$res = $info->parseArray($sess['phpfiles'], $options);
$php = $res['version'];
echo "<h1>CompatInfo for package {$safe['package'][1]}</h1>";
echo "<h2>PHP $php min is required</h2>";
if (!isset($safe['dump'])) {
echo '<pre class="dump">';
var_dump($res);
echo '</pre>';
}
}
if (isset($safe['process']) || isset($safe['abort'])) {
// cleansweep before quit
$_SESSION = array();
session_destroy();
if (isset($safe['abort'])) {
echo '<h1>Task was aborted !</h1>';
}
exit();
}
}
}
$form->display();
?>
</body>
</html>

View File

@@ -0,0 +1,21 @@
<?php
/**
* How to cutomize CLI output version. Requires at least version 1.3.1
*
* 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: cliCustom.php,v 1.5 2008/07/22 21:09:37 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
* @deprecated since version 1.8.0b2
*/
require_once 'PHP/CompatInfo/Cli.php';
// split filename to 30 char. max and continuation char. is +
$cli = new PHP_CompatInfo_Cli(30, '+');
$cli->run();
?>

View File

@@ -0,0 +1,35 @@
+----------------------+---------+------------+-----------+
| File | Version | Extensions | Constants |
+----------------------+---------+------------+-----------+
| ..\..\CompatInfo.php | 4.3.0 | tokenizer | |
| | | sockets | |
+----------------------+---------+------------+-----------+
Debug:
+---------+-------------------+---------------+
| Version | Function | Extension |
+---------+-------------------+---------------+
| 4.3.0 | file_get_contents | ext_standard |
| 4.2.0 | token_get_all | ext_tokenizer |
| 4.1.0 | version_compare | ext_standard |
| 4.0.6 | array_map | ext_standard |
| 4.0.3 | pathinfo | ext_standard |
| 4.0.2 | read | ext_sockets |
| 4.0.2 | close | ext_sockets |
| 4.0.1 | array_unique | ext_standard |
| 4.0.0 | array_merge | ext_standard |
| 4.0.0 | strlen | zend |
| 4.0.0 | substr | ext_standard |
| 4.0.0 | is_dir | ext_standard |
| 4.0.0 | is_readable | ext_standard |
| 4.0.0 | in_array | ext_standard |
| 4.0.0 | strtolower | ext_standard |
| 4.0.0 | sizeof | ext_standard |
| 4.0.0 | array_reverse | ext_standard |
| 4.0.0 | ksort | ext_standard |
| 4.0.0 | is_string | ext_standard |
| 4.0.0 | dir | ext_standard |
| 4.0.0 | is_file | ext_standard |
| 4.0.0 | is_array | ext_standard |
+---------+-------------------+---------------+

View File

@@ -0,0 +1,33 @@
<?php
/**
* Exclude all PHP5 functions when calculating the version needed.
*
* 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: ignorePHP5implements.php,v 1.5 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
$info = new PHP_CompatInfo();
$dir = 'C:\PEAR\Tools and utilities\PhpDocumentor-1.3.0';
$options = array(
'debug' => true,
'ignore_functions' => PHP_CompatInfo::loadVersion('5.0.0'),
'ignore_constants' => array('clone', 'public')
);
$r = $info->parseFolder($dir, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,34 @@
<?php
/**
* Get the Compatibility info for an array
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Davey Shafik <davey@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: parseArray.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
require_once 'PEAR.php';
$info = new PHP_CompatInfo();
$files = get_included_files();
$options = array(
'debug' => false,
'ignore_files' => array($files[0]),
'ignore_functions' => array('debug_backtrace')
);
$r = $info->parseArray($files, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,33 @@
<?php
/**
* Get the Compatibility info for an entire folder (recursive)
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Davey Shafik <davey@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: parseDir.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
$info = new PHP_CompatInfo();
$folder = dirname(__FILE__);
$options = array(
'file_ext' => array('php3', 'php'),
'ignore_files' => array(__FILE__)
);
var_dump($options);
$r = $info->parseFolder($folder, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,50 @@
<?php
/**
* Show a progress bar when parsing a directory from CLI
* Do not display any progress bar from other SAPI
*
* To run on Windows platform, do:
* (path to PHP cli)\php.exe -f (this script)
*
* 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: parseDir_withCustomProgressBar.php,v 1.4 2008/07/24 21:18:08 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
if (php_sapi_name() == 'cli') {
/*
Display a progress bar like this one:
[))))) ] 8% - 45/563 files
*/
$pbar = array('formatString' => '[%bar%] %percent% - %fraction% files',
'barfill' => ')',
'prefill' => ' ',
'options' => array('percent_precision' => 0));
$driverType = 'text';
$driverOptions = array('silent' => false, 'progress' => 'bar',
'progressbar' => $pbar);
} else {
$driverType = 'array';
$driverOptions = array();
}
$info = new PHP_CompatInfo($driverType, $driverOptions);
$dir = 'C:\php\pear\HTML_Progress2';
$r = $info->parseDir($dir);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* Get the Compatibility info for a single file
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Davey Shafik <davey@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: parseFile.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
$info = new PHP_CompatInfo();
$file = __FILE__;
$r = $info->parseFile($file);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* Get the Compatibility info for a string
*
* PHP versions 4 and 5
*
* @category PHP
* @package PHP_CompatInfo
* @author Davey Shafik <davey@php.net>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @version CVS: $Id: parseString.php,v 1.7 2008/07/22 21:13:14 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @ignore
*/
require_once 'PHP/CompatInfo.php';
$info = new PHP_CompatInfo();
$r = $info->parseString('<?php $file = file_get_contents(__FILE__); $tokens = token_get_all($file); ?>');
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,26 @@
<?php
/**
* Get PHP functions and constants history from a range of version,
* group by version number
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_loadversion.php,v 1.3 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0RC2 (2008-07-18)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
$compatInfo = new PHP_CompatInfo();
$r = $compatInfo->loadVersion('4.3.2', '4.4.0', true, true);
var_export($r);
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* Get the Compatibility info for a list of different source (directory, file)
* which may have no link between them.
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsearray_files.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b3 (2008-06-07)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/*
With all default options, its same as version 1.8.0b1 or less
No need to specify driver type ('array') and options, in class constructor
Results display made with PHP::var_export
*/
//$compatInfo = new PHP_CompatInfo();
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
*/
$driverType = 'array';
/*
Display wait messages or a progress bar (PEAR::Console_ProgressBar)
if available while parsing data source
Default behavior is: silent = true (no wait system)
Use (progress => text) if you don't want a progress bar but only text messages
*/
$driverOptions = array('silent' => false, 'progress' => 'bar');
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$source = array('C:\wamp\tmp\Log-1.10.0\Log', 'C:\wamp\tmp\File_Find-1.3.0\Find.php');
$options = array();
$r = $compatInfo->parseArray($source, $options);
// You may also use the new unified method parseData(), parseArray() became an alias
//$r = $compatInfo->parseData($source, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,86 @@
<?php
/**
* Get the Compatibility info for a list of chunk of code (strings)
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsearray_strings.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b3 (2008-06-07)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/*
With all default options, its same as version 1.8.0b1 or less
No need to specify driver type ('array') and options, in class constructor
Results display made with PHP::var_export
*/
//$compatInfo = new PHP_CompatInfo();
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
*/
$driverType = 'array';
/*
Display wait messages or a progress bar (PEAR::Console_ProgressBar)
if available while parsing data source
Default behavior is: silent = true (no wait system)
*/
$driverOptions = array('silent' => false, 'progress' => 'text');
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$str1 = '<?php
$nl = "\n";
echo "$nl Atom = " . DATE_ATOM;
echo "$nl Cookie = " . DATE_COOKIE;
echo "$nl Iso8601 = " . DATE_ISO8601;
echo "$nl Rfc822 = " . DATE_RFC822;
echo "$nl Rfc850 = " . DATE_RFC850;
echo "$nl Rfc1036 = " . DATE_RFC1036;
echo "$nl Rfc1123 = " . DATE_RFC1123;
echo "$nl Rfc2822 = " . DATE_RFC2822;
echo "$nl RSS = " . DATE_RSS;
echo "$nl W3C = " . DATE_W3C;
?>';
$str2 = '<?php
class Request6056
{
function testMaxVersion()
{
// PHP 5 <= 5.0.4
$res = php_check_syntax(\'bug6581.php\');
$array1 = array(\'blue\' => 1, \'red\' => 2, \'green\' => 3);
$array2 = array(\'green\' => 5, \'blue\' => 6, \'yellow\' => 7);
// PHP 5 >= 5.1.0RC1
$diff = array_diff_key($array1, $array2);
}
}
?>';
$source = array($str1, $str2);
// CAUTION: if you forget this option, you will have no output except a FALSE result (see $r)
$options = array('is_string' => true);
$r = $compatInfo->parseArray($source, $options);
// You may also use the new unified method parseData(), parseArray() became an alias
//$r = $compatInfo->parseData($source, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,43 @@
<?php
/**
* Get the Compatibility info for a chunk of code
*
* This example show the new options|features available with API 1.8.0
* Especially the xml renderer
*
* 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: pci180_parsedata_toxml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0RC2 (2008-07-18)
* @ignore
*/
header('Content-type: text/xml');
require_once 'PHP/CompatInfo.php';
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
Here we choose to display result as XML stream,
Even if PEAR::XML_Beautifier package is available (installed) we won't use it
*/
$driverType = 'xml';
/*
Won't use PEAR::XML_Beautifier
(reason bug #5450 http://pear.php.net/bugs/bug.php?id=5450, that strip XML declaration)
*/
$driverOptions = array('use-beautifier' => 'no');
$source = array('C:\wamp\tmp\Log-1.10.0\Log', 'C:\wamp\tmp\File_Find-1.3.0\Find.php');
$options = array('debug' => true);
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$compatInfo->parseData($source, $options);
?>

View File

@@ -0,0 +1,130 @@
<?php
/**
* Get the Compatibility info for a list of files into a directory
* Output is produced by a custom renderer (html2).
* Rather than write your own stylesheet, you may use the default one, and
* change some colors on the fly.
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsedir_tohtml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b4 (2008-06-18)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
require_once 'PHP/CompatInfo/Renderer.php';
require_once 'PHP/CompatInfo/Renderer/Html.php';
/**
* Custom html layout
*
* @ignore
*/
class PHP_CompatInfo_Renderer_Html2 extends PHP_CompatInfo_Renderer_Html
{
/**
* Html2 Renderer Class constructor
*
* @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_Html2(&$parser, $conf)
{
parent::__construct($parser, $conf);
// use default stylesheet (pci.css)
$this->setStyleSheet(); // Important: do not remove it
}
/**
* Returns HTML code of parsing result
*
* @param object $obj instance of HTML_Table
*
* @access public
* @return string
*/
function toHtml($obj)
{
$styles = $this->getStyleSheet(3, array(&$this, '_getStyles'));
$body = $obj->toHtml();
$html = <<<HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<meta name="author" content="Laurent Laville" />
<title>my PCI widget</title>
<link rel="stylesheet" type="text/css" href="yoursite.css" />
<link rel="stylesheet" type="text/css" href="$styles" />
</head>
<body>
<div id="header">
<h1>Laurent-Laville.org</h1>
</div>
<div id="footer">
</div>
<div id="contents">
<div class="outer">
<div class="inner">
$body
</div>
</div>
</div>
</body>
</html>
HTML;
return $html;
}
/**
* User callback to modify stylesheet object
*
* @param object $css Instance of HTML_CSS
* @return string
* @access private
*/
function _getStyles($css)
{
$stylesheet = 'pciskin.css';
$css->setStyle('.inner', 'height', '12em');
$css->setStyle('.inner .even', 'background-color', '#449922');
$css->setStyle('.inner .even', 'color', '#FFFFFF');
$css->setStyle('.outer thead td', 'background-color', '#006600');
$css->setStyle('.outer tfoot td', 'background-color', '#006600');
$css->toFile(dirname(__FILE__) . DIRECTORY_SEPARATOR . $stylesheet);
return $stylesheet;
}
}
/*
Display parsing result of directory '$source' with a website integration
look and feel.
*/
$driverType = 'html2';
$driverOptions = array('args' => array('output-level' => 18));
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$source = 'C:\wamp\tmp\Services_W3C_CSSValidator-0.1.0';
$compatInfo->parseData($source);
?>

View File

@@ -0,0 +1,56 @@
<?php
/**
* Get the Compatibility info for a single file
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsefile.php,v 1.3 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b2 (2008-06-03)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/*
With all default options, its same as version 1.8.0b1 or less
No need to specify driver type ('array') and options, in class constructor
Results display made with PHP::var_export
*/
//$compatInfo = new PHP_CompatInfo();
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
Here we choose to display result still as an array, but with PEAR::Var_Dump
package if available (installed).
On CLI we have only ability to use the "Text" Var_Dump renderer (display_mode)
*/
$driverType = 'array';
// use default "HTML4_Table" Var_Dump renderer
/* Be aware that if you run this script in CLI, the Var_Dump renderer used
is "Text" (no choice) */
$driverOptions
= array('PEAR::Var_Dump' =>
array('options' => array('display_mode' => 'HTML4_Table')));
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$source = 'C:\php\pear\HTML_Progress2\Progress2.php';
$r = $compatInfo->parseFile($source);
// You may also use the new unified method parseData(), parseFile() became an alias
//$r = $compatInfo->parseData($source);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
?>

View File

@@ -0,0 +1,58 @@
<?php
/**
* Get the Compatibility info for a single directory
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsefolder.php,v 1.3 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b2 (2008-06-03)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/*
With all default options, its same as version 1.8.0b1 or less
No need to specify driver type ('array') and options, in class constructor
Results display made with PHP::var_export
*/
//$compatInfo = new PHP_CompatInfo();
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
Here we choose to display result as XML stream, beautified if PEAR::XML_Beautifier
package is available (installed).
*/
$driverType = 'xml';
/*
Display wait messages or a progress bar (PEAR::Console_ProgressBar)
if available while parsing data source
Default behavior is: silent = true (no wait system)
Use (progress => text) if you don't want a progress bar but only text messages
*/
$driverOptions = array('silent' => false, 'progress' => 'bar');
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$source = 'C:\wamp\tmp\Log-1.10.0\Log';
$options = array();
$r = $compatInfo->parseFolder($source, $options);
// You may also use the new unified method parseData(), parseFolder() became an alias
//$r = $compatInfo->parseData($source);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,129 @@
<?php
/**
* Parse a folder and wait with an HTML Progress bar
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsefolder_tohtml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b4 (2008-06-18)
* @ignore
*/
require_once 'HTML/Progress2.php';
require_once 'PHP/CompatInfo.php';
/**
* @ignore
*/
class myClass
{
function doSomething()
{
global $bar;
// You may also use, all others renderer available
$driverType = 'html';
$driverOptions = array('args' => array('output-level' => 18));
$info = new PHP_CompatInfo($driverType, $driverOptions);
$info->addListener(array(&$bar, 'notify'));
$dir = 'C:\Temp\beehiveforum082\forum';
$opt = array();
// You may use the new unified method parseData(), parseDir() became an alias
$info->parseData($dir, $opt);
}
}
/**
* @ignore
*/
class myBar extends HTML_Progress2
{
// number of file to parse
var $_fileCount;
function myBar()
{
parent::HTML_Progress2();
$this->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1');
$this->setLabelAttributes('txt1', array(
'valign' => 'top',
'left' => 0,
));
$this->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2');
$this->setLabelAttributes('txt2', array(
'valign' => 'bottom',
'left' => 0,
));
}
function notify(&$notification)
{
$notifyName = $notification->getNotificationName();
$notifyInfo = $notification->getNotificationInfo();
switch ($notifyName) {
case PHP_COMPATINFO_EVENT_AUDITSTARTED :
$this->_fileCount = $notifyInfo['dataCount'];
// to keep the good proportion with default increment (+1)
$this->setMaximum($this->_fileCount);
break;
case PHP_COMPATINFO_EVENT_FILESTARTED :
$current = $notifyInfo['fileindex'];
$max = $this->_fileCount;
$file = basename($notifyInfo['filename']);
$this->setLabelAttributes('txt1',
array('value' => $current.'/'.$max.' files'));
$this->setLabelAttributes('txt2',
array('value' => $file));
break;
case PHP_COMPATINFO_EVENT_FILEFINISHED :
$this->moveNext();
break;
case PHP_COMPATINFO_EVENT_AUDITFINISHED :
$this->hide(); // progress bar hidden
break;
}
}
}
set_time_limit(0); // because parsing a huge folder may exceed 30 seconds
$bar = new myBar();
?>
<!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>Parse a folder and wait with an HTML progress bar</title>
<style type="text/css">
<!--
<?php echo $bar->getStyle(); ?>
body {
background-color: #FFFFFF;
}
-->
</style>
<?php echo $bar->getScript(false); ?>
</head>
<body>
<?php
$bar->display();
$process = new myClass();
$process->doSomething();
?>
</body>
</html>

View File

@@ -0,0 +1,65 @@
<?php
/**
* Get the Compatibility info for a chunk of code
*
* This example show the new options|features available with API 1.8.0
*
* 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: pci180_parsestring.php,v 1.3 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b2 (2008-06-03)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
/*
With all default options, its same as version 1.8.0b1 or less
No need to specify driver type ('array') and options, in class constructor
Results display made with PHP::var_export
*/
//$compatInfo = new PHP_CompatInfo();
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
Here we choose to display result as XML stream, beautified if PEAR::XML_Beautifier
package is available (installed).
*/
$driverType = 'xml';
// use some options of XML_Beautifier to change default render
$driverOptions = array('beautifier' => array('indent' => ' ', 'linebreak' => PHP_EOL));
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$source = '<?php
$nl = "\n";
echo "$nl Atom = " . DATE_ATOM;
echo "$nl Cookie = " . DATE_COOKIE;
echo "$nl Iso8601 = " . DATE_ISO8601;
echo "$nl Rfc822 = " . DATE_RFC822;
echo "$nl Rfc850 = " . DATE_RFC850;
echo "$nl Rfc1036 = " . DATE_RFC1036;
echo "$nl Rfc1123 = " . DATE_RFC1123;
echo "$nl Rfc2822 = " . DATE_RFC2822;
echo "$nl RSS = " . DATE_RSS;
echo "$nl W3C = " . DATE_W3C;
?>';
$r = $compatInfo->parseString($source);
// You may also use the new unified method parseData(), parseString() became an alias
//$r = $compatInfo->parseData($source);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
var_export($r);
?>

View File

@@ -0,0 +1,96 @@
<?php
/**
* Get the Compatibility info for a chunk of code
*
* This example show the new options|features available with API 1.8.0
* Especially, observer and xml renderer
*
* 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: pci180_parsestring_toxml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
* @link http://pear.php.net/package/PHP_CompatInfo
* @since version 1.8.0b4 (2008-06-18)
* @ignore
*/
require_once 'PHP/CompatInfo.php';
define('DEST_LOG_FILE', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'notify.log');
/*
Add an observer to listen all PCI events
*/
function pci180_debug(&$auditEvent)
{
$notifyName = $auditEvent->getNotificationName();
$notifyInfo = $auditEvent->getNotificationInfo();
error_log('notifyName:'. $notifyName . PHP_EOL, 3, DEST_LOG_FILE);
error_log('notifyInfo:'. PHP_EOL .
var_export($notifyInfo, true) . PHP_EOL, 3, DEST_LOG_FILE);
}
/*
With API 1.8.0 you may choose a custom render,
between all default renderers (all customizable).
Here we choose to display result as XML stream,
beautified if PEAR::XML_Beautifier package is available (installed).
*/
$driverType = 'xml';
// use some options of XML_Beautifier to change default render
$driverOptions = array('beautifier' => array('indent' => ' ',
'linebreak' => PHP_EOL),
// output all informations except tokens (output-level = 23)
'args' => array('output-level' => 23));
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
$compatInfo->addListener('pci180_debug');
$str1 = '<?php
$nl = "\n";
echo "$nl Atom = " . DATE_ATOM;
echo "$nl Cookie = " . DATE_COOKIE;
echo "$nl Iso8601 = " . DATE_ISO8601;
echo "$nl Rfc822 = " . DATE_RFC822;
echo "$nl Rfc850 = " . DATE_RFC850;
echo "$nl Rfc1036 = " . DATE_RFC1036;
echo "$nl Rfc1123 = " . DATE_RFC1123;
echo "$nl Rfc2822 = " . DATE_RFC2822;
echo "$nl RSS = " . DATE_RSS;
echo "$nl W3C = " . DATE_W3C;
?>';
$str2 = '<?php
class Request6056
{
function testMaxVersion()
{
// PHP 5 <= 5.0.4
$res = php_check_syntax(\'bug6581.php\');
$array1 = array(\'blue\' => 1, \'red\' => 2, \'green\' => 3);
$array2 = array(\'green\' => 5, \'blue\' => 6, \'yellow\' => 7);
// PHP 5 >= 5.1.0RC1
$diff = array_diff_key($array1, $array2);
}
}
?>';
$source = array($str1, $str2);
$options = array('is_string' => true, 'debug' => true);
//$r = $compatInfo->parseString($source, $options);
// You may also use the new unified method parseData(), parseString() became an alias
$r = $compatInfo->parseData($source, $options);
/*
To keep backward compatibility, result is also return (here in $r)
but you don't need to print it, it's the default behavior of API 1.8.0
*/
//var_export($r);
?>

View File

@@ -0,0 +1,60 @@
body {
margin:0;
border:0;
padding:0;
height:100%;
max-height:100%;
background:#eee;
overflow: hidden;
}
#header {
position:absolute;
top:0;
left:0;
width:100%;
height:86px;
overflow:auto;
background:#ccffff;
color:#090;
border-bottom: 4px solid #eee;
}
#header h1 {
color: #090;
text-align: left;
font-size: 150%;
}
#footer {
position:absolute;
bottom:0;
left:0;
width:100%;
height:38px;
overflow:auto;
text-align:right;
background:#cfc;
border-top: 2px solid #090;
}
#contents {
position:fixed;
top:90px;
left:0;
bottom:40px;
right:0;
overflow:auto;
background:#fff;
padding: 1.5em;
}
/* for internet explorer */
* html body {
padding:90px 0 50px 0;
}
* html #contents {
height:100%;
width:100%;
}