From 09ee88f9bf1f5b81c23f30a2829ec9755c9b8ac1 Mon Sep 17 00:00:00 2001 From: Greg Beaver Date: Sat, 29 May 2004 09:09:46 +0000 Subject: [PATCH] modify php_dump.php, .cvsignore ignores *.php move include to the place where it is used --- pear/tests/PEAR_test_mock_pearweb.php.inc | 1 + pear/tests/pear_downloader_invalid.phpt | 1 - pear/tests/php_dump.php.inc | 57 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 pear/tests/php_dump.php.inc diff --git a/pear/tests/PEAR_test_mock_pearweb.php.inc b/pear/tests/PEAR_test_mock_pearweb.php.inc index 9206a4d290..baff2cbe48 100644 --- a/pear/tests/PEAR_test_mock_pearweb.php.inc +++ b/pear/tests/PEAR_test_mock_pearweb.php.inc @@ -61,6 +61,7 @@ class PEAR_test_mock_pearweb { return false; } if (!isset($this->_config['xmlrpc'][$method][serialize($params)])) { + include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'php_dump.php.inc'; $args = $params; switch (count($args)) { case 0: diff --git a/pear/tests/pear_downloader_invalid.phpt b/pear/tests/pear_downloader_invalid.phpt index 22f61e92ad..c571708432 100644 --- a/pear/tests/pear_downloader_invalid.phpt +++ b/pear/tests/pear_downloader_invalid.phpt @@ -69,7 +69,6 @@ if (!empty($home)) { } require_once "PEAR/Downloader.php"; require_once 'PEAR/Installer.php'; -require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'php_dump.php'; require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'download_test_classes.php.inc'; // no UI is needed for these tests diff --git a/pear/tests/php_dump.php.inc b/pear/tests/php_dump.php.inc new file mode 100644 index 0000000000..4f7a666295 --- /dev/null +++ b/pear/tests/php_dump.php.inc @@ -0,0 +1,57 @@ +_var = $var; + } + + function toPHP() + { + return $this->_toUnknown($this->_var); + } + + function _toUnknown($var, $indent = ' ') + { + switch (gettype($var)) { + case 'array' : + return $this->_toArray($var, $indent); + case 'boolean' : + return $this->_toBool($var, $indent); + case 'double' : + case 'integer' : + return $this->_toNumber($var, $indent); + case 'NULL' : + return "{$indent}null"; + case 'string' : + return $this->_toString($var, $indent); + } + } + + function _toString($var, $indent) + { + return $indent . '"' . addslashes($var) . '"'; + } + + function _toBool($var, $indent) + { + return $indent . ($var ? 'true' : 'false'); + } + + function _toNumber($var, $indent) + { + return $indent . $var; + } + + function _toArray($var, $indent = ' ') + { + $ret = $indent . "array(\n"; + foreach ($var as $key => $value) { + $ret .= $indent . ((is_int($key) || is_double($key)) ? $key : "'$key'") . " =>\n"; + $ret .= $this->_toUnknown($value, "$indent ") . ",\n"; + } + $ret .= $indent . ')'; + return $ret; + } +} +?> \ No newline at end of file -- 2.40.0