modify php_dump.php, .cvsignore ignores *.php

move include to the place where it is used
This commit is contained in:
Greg Beaver 2004-05-29 09:09:46 +00:00
parent 71e0c354ff
commit 09ee88f9bf
3 changed files with 58 additions and 1 deletions

View File

@ -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:

View File

@ -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

View File

@ -0,0 +1,57 @@
<?php
class PHP_Dump {
var $_var;
function PHP_Dump($var)
{
$this->_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;
}
}
?>