Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * Get the Compatibility info for a chunk of code
4
 *
5
 * This example show the new options|features available with API 1.8.0
6
 * Especially, observer and xml renderer
7
 *
8
 * PHP versions 4 and 5
9
 *
10
 * @category PHP
11
 * @package  PHP_CompatInfo
12
 * @author   Laurent Laville <pear@laurent-laville.org>
13
 * @license  http://www.opensource.org/licenses/bsd-license.php  BSD
14
 * @version  CVS: $Id: pci180_parsestring_toxml.php,v 1.2 2008/07/22 20:26:45 farell Exp $
15
 * @link     http://pear.php.net/package/PHP_CompatInfo
16
 * @since    version 1.8.0b4 (2008-06-18)
17
 * @ignore
18
 */
19
 
20
require_once 'PHP/CompatInfo.php';
21
 
22
define('DEST_LOG_FILE', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'notify.log');
23
 
24
/*
25
   Add an observer to listen all PCI events
26
 */
27
function pci180_debug(&$auditEvent)
28
{
29
    $notifyName = $auditEvent->getNotificationName();
30
    $notifyInfo = $auditEvent->getNotificationInfo();
31
    error_log('notifyName:'. $notifyName . PHP_EOL, 3, DEST_LOG_FILE);
32
    error_log('notifyInfo:'. PHP_EOL .
33
               var_export($notifyInfo, true) . PHP_EOL, 3, DEST_LOG_FILE);
34
}
35
 
36
/*
37
   With API 1.8.0 you may choose a custom render,
38
   between all default renderers (all customizable).
39
 
40
   Here we choose to display result as XML stream,
41
   beautified if PEAR::XML_Beautifier package is available (installed).
42
 */
43
$driverType = 'xml';
44
 
45
// use some options of XML_Beautifier to change default render
46
$driverOptions = array('beautifier' => array('indent' => ' ',
47
                                             'linebreak' => PHP_EOL),
48
//                     output all informations except tokens (output-level = 23)
49
                       'args' => array('output-level' => 23));
50
$compatInfo = new PHP_CompatInfo($driverType, $driverOptions);
51
$compatInfo->addListener('pci180_debug');
52
 
53
$str1 = '<?php
54
$nl = "\n";
55
echo "$nl Atom    = " . DATE_ATOM;
56
echo "$nl Cookie  = " . DATE_COOKIE;
57
echo "$nl Iso8601 = " . DATE_ISO8601;
58
echo "$nl Rfc822  = " . DATE_RFC822;
59
echo "$nl Rfc850  = " . DATE_RFC850;
60
echo "$nl Rfc1036 = " . DATE_RFC1036;
61
echo "$nl Rfc1123 = " . DATE_RFC1123;
62
echo "$nl Rfc2822 = " . DATE_RFC2822;
63
echo "$nl RSS     = " . DATE_RSS;
64
echo "$nl W3C     = " . DATE_W3C;
65
?>';
66
 
67
$str2 = '<?php
68
class Request6056
69
{
70
    function testMaxVersion()
71
    {
72
        // PHP 5 <= 5.0.4
73
        $res = php_check_syntax(\'bug6581.php\');
74
 
75
        $array1 = array(\'blue\'  => 1, \'red\'  => 2, \'green\'  => 3);
76
        $array2 = array(\'green\' => 5, \'blue\' => 6, \'yellow\' => 7);
77
 
78
        // PHP 5 >= 5.1.0RC1
79
        $diff = array_diff_key($array1, $array2);
80
    }
81
}
82
?>';
83
 
84
$source  = array($str1, $str2);
85
$options = array('is_string' => true, 'debug' => true);
86
 
87
//$r = $compatInfo->parseString($source, $options);
88
// You may also use the new unified method parseData(), parseString() became an alias
89
$r = $compatInfo->parseData($source, $options);
90
 
91
/*
92
   To keep backward compatibility, result is also return (here in $r)
93
   but you don't need to print it, it's the default behavior of API 1.8.0
94
 */
95
//var_export($r);
96
?>