]> granicus.if.org Git - php/commitdiff
modify php_dump.php, .cvsignore ignores *.php
authorGreg Beaver <cellog@php.net>
Sat, 29 May 2004 09:09:46 +0000 (09:09 +0000)
committerGreg Beaver <cellog@php.net>
Sat, 29 May 2004 09:09:46 +0000 (09:09 +0000)
move include to the place where it is used

pear/tests/PEAR_test_mock_pearweb.php.inc
pear/tests/pear_downloader_invalid.phpt
pear/tests/php_dump.php.inc [new file with mode: 0644]

index 9206a4d2900127f15af6ad5d085c30e2010a43a0..baff2cbe48cb4d0aeeb230e26c4fee6153595e91 100644 (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:
index 22f61e92adf890b5869352e47bbae5a10bd5dcae..c571708432d0baa4dadeb5f61d41313a0ed052f2 100644 (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
diff --git a/pear/tests/php_dump.php.inc b/pear/tests/php_dump.php.inc
new file mode 100644 (file)
index 0000000..4f7a666
--- /dev/null
@@ -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;
+    }
+}
+?>
\ No newline at end of file