From da29568127ab6ebc947baaf0dff7b5bd4255b9d3 Mon Sep 17 00:00:00 2001 From: rurban Date: Tue, 24 Aug 2004 00:21:57 +0000 Subject: [PATCH] Print the PHP compatibility info for phpwiki. per file and per project, (which function is dependend on which php version?) git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@3920 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- tests/CompatInfo.php | 166 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 tests/CompatInfo.php diff --git a/tests/CompatInfo.php b/tests/CompatInfo.php new file mode 100755 index 000000000..1900f909a --- /dev/null +++ b/tests/CompatInfo.php @@ -0,0 +1,166 @@ + + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with PhpWiki; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +require_once 'PHP/CompatInfo.php'; + +function out_row($row, $header = false) { + if (empty($row)) return; + echo ""; + $tag = $header ? "th" : "td"; + // link to file? + $file = $row[0]; + if (!empty($file) and substr($file,0,3) != '' and $file != 'File') { + $row[0] = ''.$file.''; + } + foreach ($row as $r) { + echo "<$tag>", empty($r) ? ' ' : "$r", ""; + } + echo "\n"; +} + +$info = new PHP_CompatInfo; +$dir = str_replace(array('\\','/'), '/', dirname(__FILE__)); +$dir = preg_replace('/\/'.basename(dirname(__FILE__)).'$/', '', $dir); +$debug = !empty($_GET['debug']); +$detail = !empty($_GET['detail']); +// echo $dir; +$options = array('file_ext' => array('php'), + 'ignore_files' => array(__FILE__), + 'recurse_dir' => false, + 'ignore_functions' => array(), + 'debug' => $debug or $detail, + ); +// var_dump($options); +set_time_limit(240); +$cols = array('File','Version','Extensions','Constants'); + +if (empty($_GET['file'])) { + $file = false; + echo "

All Files

\n"; + echo " Show Details: YES"; + echo " NO
\n"; + $r = $info->parseFolder($dir, $options); +} else { + $file = urldecode($_GET['file']); + echo "

File $file

\n"; + echo " Show Details: YES"; + echo " NO
\n"; + echo " => Back to All Files
\n"; + $r = $info->parseFile("$dir/$file", $options); +} + +echo "\n"; + +out_row($cols,1); + +foreach ($r as $key => $info) { + + if ($key == 'extensions') + out_row(array("$key", '', join(',',$info), '')); + elseif ($key == 'constants') + out_row(array("$key", '', '', join(',',$info))); + elseif ($key == 'version') + out_row(array("$key", $info, '', '')); + elseif ($key == 'ignored_files') + out_row(array("$key", join(',',$info), '')); + else{ + if (empty($_GET['file'])) { + $file = str_replace(array('\\','/'),'/',$key); + if (strlen($key) > strlen($dir)) + $file = substr(str_replace($dir,'',$file),1); + if (!isset($info['extensions'][0])) { + $ext = ''; + } else { + $ext = array_shift($info['extensions']); + } + if (!isset($info['constants'][0])) { + $const = ''; + } else { + $const = array_shift($info['constants']); + } + out_row(array($file, $info['version'], $ext, $const)); + + if (is_array($info['extensions']) + and sizeof($info['extensions']) >= sizeof($info['constants'])) { + foreach ($info['extensions'] as $i => $ext) { + if (isset($info['constants'][$i])) { + $const = $info['constants'][$i]; + } else { + $const = ''; + } + out_row(array('','', $ext, $const)); + } + } elseif (is_array($info['constants'])) { + foreach ($info['constants'] as $i => $const) { + if (isset($info['extensions'][$i])) { + $ext = $info['extensions'][$i]; + } else { + $ext = ''; + } + out_row(array('', '', $ext, $const)); + } + } + } + if ($detail and is_array($info)) { + out_row(array('DETAIL','Version','Function','Extension'),1); + unset($info['version']); + unset($info['constants']); + unset($info['extensions']); + if (!empty($_GET['file'])) { + $version = $key; + foreach ($info as $func) { + out_row(array('',$version,$func['function'],$func['extension'])); + } + } else { + foreach ($info as $version => $functions) { + foreach ($functions as $func) { + out_row(array('',$version,$func['function'],$func['extension'])); + } + } + } + } + } +} +echo "
\n"; + +if ($debug) { + echo "
\n";
+    var_dump ($r);
+    echo "
\n"; +} + +// $Log: not supported by cvs2svn $ + +// (c-file-style: "gnu") +// Local Variables: +// mode: php +// tab-width: 8 +// c-basic-offset: 4 +// c-hanging-comment-ender-p: nil +// indent-tabs-mode: nil +// End: +?> \ No newline at end of file -- 2.45.0