当前位置: 首页>>代码示例>>PHP>>正文


PHP Dumper::dump方法代码示例

本文整理汇总了PHP中Dumper::dump方法的典型用法代码示例。如果您正苦于以下问题:PHP Dumper::dump方法的具体用法?PHP Dumper::dump怎么用?PHP Dumper::dump使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Dumper的用法示例。


在下文中一共展示了Dumper::dump方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: printDump

 /**
  * Output pretty-printed arrays / objects.
  *
  * @see \Dumper::dump
  *
  * @param  mixed $var
  * @return string
  */
 public function printDump($var)
 {
     if ($this->safe) {
         return '?';
     }
     if ($this->app['config']->get('general/debug')) {
         return \Dumper::dump($var, DUMPER_CAPTURE);
     } else {
         return '';
     }
 }
开发者ID:LeonB,项目名称:site,代码行数:19,代码来源:TwigExtension.php

示例2: dump

 public function dump($subject, $nestLevel = 0)
 {
     $elements = [];
     foreach (get_object_vars($subject) as $key => $value) {
         $elements[] = sprintf("'%s' => %s", $key, $this->masterDumper->dump($value, $nestLevel));
     }
     $methods = get_class_methods($subject);
     $approvedMethods = array_filter($methods, function ($method) use($subject) {
         if (preg_match("/^(get|has|is)[A-Z]/", $method) > 0) {
             $reflection = new \ReflectionMethod(get_class($subject), $method);
             if ($reflection->getNumberOfParameters() === 0) {
                 return true;
             }
             return false;
         }
     });
     foreach ($approvedMethods as $method) {
         $key = lcfirst(preg_replace("/^(get|has|is)/", '', $method));
         $value = call_user_func([$subject, $method]);
         //            $value = $method;
         $elements[] = sprintf("'%s' => %s", $key, $this->masterDumper->dump($value, $nestLevel));
     }
     return "[\n\t" . implode(",\n\t", preg_replace("/\n/", "\n\t", $elements)) . "\n],\n";
 }
开发者ID:pkoltermann,项目名称:vo-debug,代码行数:24,代码来源:ObjectDumper.php

示例3: testDumpSubsections

    public function testDumpSubsections()
    {
        $data = array('main' => array('explore' => true, 'sub' => array('sub' => array('value' => 5))));
        $dumper = new Dumper();
        $result = $dumper->dump($data);
        $expected = <<<EOT
[main]
explore=true

[main.sub]

[main.sub.sub]
value=5

EOT;
        $this->assertEquals($expected, $result);
    }
开发者ID:mauris,项目名称:ini-writer,代码行数:17,代码来源:DumperTest.php

示例4: dataUri

 /**
  *
  * @param mixed     $source     DataURI source
  * @param boolean   $strict     Use strict mode (length output)
  * @param string    $mime       the mime type
  * @param array     $parameters Extra parameters, see rfc
  * @return null
  */
 public function dataUri($source, $strict = true, $mime = null, $parameters = array())
 {
     $data = null;
     try {
         switch (true) {
             case is_resource($source):
                 $data = $this->getDataFromRessource($source, $strict, $mime, $parameters);
                 break;
             case is_scalar($source):
                 $data = $this->getDataFromScalar($source, $strict, $mime, $parameters);
                 break;
             default:
                 trigger_error("Tried to convert an unsupported source format", E_USER_WARNING);
                 break;
         }
     } catch (Exception\Exception $e) {
         trigger_error(sprintf("Error while building DataUri : %s", $e->getMessage()), E_USER_WARNING);
     }
     if ($data) {
         return Dumper::dump($data);
     }
     return null;
 }
开发者ID:vgrish,项目名称:TwigExtension-DataUri,代码行数:31,代码来源:TwigExtension.php

示例5: dump

 /**
  * Dumps a PHP array to a YAML string.
  *
  * The dump method, when supplied with an array, will do its best
  * to convert the array into friendly YAML.
  *
  * @param array   $array PHP array
  * @param integer $inline The level where you switch to inline YAML
  *
  * @return string A YAML string representing the original PHP array
  */
 public static function dump($array, $inline = 2)
 {
     $yaml = new Dumper();
     return $yaml->dump($array, $inline);
 }
开发者ID:jcsilkey,项目名称:CodeReviewSecurityRepo,代码行数:16,代码来源:YAML.php

示例6: dumpContainers

 /**
  * Dump containers.
  *
  * @param array $containers An array of containers.
  *
  * @api
  */
 public function dumpContainers(array $containers)
 {
     // output
     foreach ($containers as $container) {
         foreach ($container->getDefinitions() as $name => $definition) {
             $output = $definition->getOutput($name);
             $dir = $output->getDir();
             $file = $dir . DIRECTORY_SEPARATOR . str_replace('\\', '/', $definition->getClass()) . '.php';
             $path = dirname($file);
             if (!file_exists($path) && false === @mkdir($path, 0777, true)) {
                 throw new \RuntimeException(sprintf('Unable to create the %s directory.', $path));
             }
             if (!is_writable($path)) {
                 throw new \RuntimeException(sprintf('Unable to write in the %s directory.', $path));
             }
             if (!file_exists($file) || $output->getOverride()) {
                 $dumper = new Dumper($definition);
                 $content = $dumper->dump();
                 $tmpFile = tempnam(dirname($file), basename($file));
                 if (false === @file_put_contents($tmpFile, $content) || !@rename($tmpFile, $file)) {
                     throw new \RuntimeException(sprintf('Failed to write the file "%s".', $file));
                 }
                 @chmod($file, 0666 & ~umask());
             }
         }
     }
 }
开发者ID:mongator,项目名称:mondator,代码行数:34,代码来源:Mondator.php

示例7: printDump

 /**
  * Output pretty-printed arrays / objects.
  *
  * @see \Dumper::dump
  *
  * @param  mixed $var
  * @return string
  */
 public function printDump($var)
 {
     return \Dumper::dump($var, DUMPER_CAPTURE);
 }
开发者ID:viyancs,项目名称:bolt,代码行数:12,代码来源:TwigExtension.php

示例8: tempnam

            $tmpname1 = tempnam('', '');
            $tmpname2 = tempnam('', '');
            $file_name1 = 'files/' . str_pad($i * $delta, 8, '0', STR_PAD_LEFT) . '.json.gz';
            $file_name2 = 'files/bussiness-' . str_pad($i * $delta, 8, '0', STR_PAD_LEFT) . '.json.gz';
            $fp[1] = $fp[3] = gzopen($tmpname1, 'w');
            $fp[2] = gzopen($tmpname2, 'w');
            $unit_id = null;
            $unit = new StdClass();
            foreach (UnitData::search("`id` >= {$start} AND `id` <= {$end}")->order("`id`, `column_id`")->volumemode(10000) as $unit_data) {
                if (!is_null($unit_id) and $unit_data->id != $unit_id) {
                    fwrite($fp[$this->getType($unit_id)], str_pad($unit_id, 8, '0', STR_PAD_LEFT) . ',' . json_encode($unit, JSON_UNESCAPED_UNICODE) . "\n");
                    $unit = new StdClass();
                }
                $unit_id = $unit_data->id;
                $unit->{$columns[$unit_data->column_id]} = json_decode($unit_data->value);
            }
            if (!is_null($unit_id)) {
                fwrite($fp[$this->getType($unit_id)], str_pad($unit_id, 8, '0', STR_PAD_LEFT) . ',' . json_encode($unit, JSON_UNESCAPED_UNICODE) . "\n");
            }
            fclose($fp[1]);
            fclose($fp[2]);
            DropboxLib::putFile($tmpname1, $file_name1);
            DropboxLib::putFile($tmpname2, $file_name2);
            unlink($tmpname1);
            unlink($tmpname2);
        }
    }
}
$dumper = new Dumper();
$dumper->dump();
开发者ID:yslbc,项目名称:twcompany,代码行数:30,代码来源:dump.php

示例9: A

<?php

require '../../class.dumper.php';
class A
{
    public $b;
    public $c;
}
$x = new A();
$x->b = new A();
$x->b->b = new A();
$x->b->c = new A();
$x->b->c->b = new A();
Dumper::dump($x);
开发者ID:forloops,项目名称:dumper,代码行数:14,代码来源:class.php

示例10: dump

 /**
  * Dump information about a variable
  *
  * @param mixed $data,...
  * @access public
  * @static
  */
 public static function dump($data, $capture = false)
 {
     // If we're capturing call dump() with just data and capture the output
     if ($capture === DUMPER_CAPTURE) {
         ob_start();
         Dumper::dump($data);
         $str = ob_get_clean();
         return $str;
     }
     $clearObjectRecursionProtection = false;
     if (self::$objectRecursionProtection === NULL) {
         self::$objectRecursionProtection = array();
         $clearObjectRecursionProtection = true;
     }
     // disabled
     if (!Dumper::_debug()) {
         return false;
     }
     // more arguments
     if (func_num_args() > 1) {
         $_ = func_get_args();
         foreach ($_ as $d) {
             Dumper::dump($d);
         }
         return;
     }
     // find caller
     $_ = debug_backtrace();
     while ($d = array_pop($_)) {
         $callback = self::$lineNumberTestCallback;
         $function = strToLower($d['function']);
         if (in_array($function, array("krumo", "k", "kd")) || strToLower(@$d['class']) == 'krumo' || is_callable($callback) && $callback($d)) {
             break;
         }
     }
     $showVersion = Dumper::_config('display', 'show_version', TRUE);
     $showCallInfo = Dumper::_config('display', 'show_call_info', TRUE);
     $krumoUrl = 'https://github.com/oodle/krumo';
     //////////////////////
     // Start HTML header//
     //////////////////////
     print "<div class=\"dumper-root\">\n";
     print "\t<ul class=\"dumper-node dumper-first\">\n";
     // The actual item itself
     print Dumper::_dump($data);
     if ($showVersion || $showCallInfo) {
         print "\t\t<li class=\"dumper-footnote\" onDblClick=\"toggle_expand_all();\">\n";
         if ($showCallInfo && isset($d['file']) && $d['file']) {
             print "<span class=\"dumper-call\" style=\"white-space:nowrap;\">";
             print "Called from <strong><code>" . $d['file'] . "</code></strong>, ";
             print "line <strong><code>" . $d['line'] . "</code></strong></span>";
         }
         if ($showVersion) {
             $version = Dumper::version();
             print "<span class=\"dumper-version\" style=\"white-space:nowrap;\">\n";
             print "<strong class=\"dumper-version-number\">Krumo version {$version}</strong> | <a href=\"{$krumoUrl}\" target=\"_blank\">{$krumoUrl}</a>\n";
             print "</span>\n";
         }
         print "</li>";
     }
     print "</ul></div>\n";
     print "<!-- Dumper - HTML -->\n\n";
     // Output the CSS and JavaScript AFTER the HTML
     Dumper::_css();
     ////////////////////
     // End HTML header//
     ////////////////////
     // flee the hive
     $_recursion_marker = Dumper::_marker();
     if ($hive =& Dumper::_hive($dummy)) {
         foreach ($hive as $i => $bee) {
             if (is_object($bee)) {
                 if (($hash = spl_object_hash($bee)) && isset(self::$objectRecursionProtection[$hash])) {
                     unset(self::$objectRecursionProtection[$hash]);
                 }
             } elseif (isset($hive[$i]->{$_recursion_marker})) {
                 unset($hive[$i][$_recursion_marker]);
             }
         }
     }
     if ($clearObjectRecursionProtection) {
         self::$objectRecursionProtection = NULL;
     }
     // End of dump()
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:92,代码来源:class.dumper.php

示例11: getSequence

 /**
  * Get the next number from a sequence
  *
  * @return int
  */
 private function getSequence($formconfig, $form, $formname, $column)
 {
     $sequence = null;
     // Attempt get the next sequence from a table, if specified..
     if (!empty($formconfig['insert_into_table'])) {
         try {
             $query = sprintf("SELECT MAX(%s) as max FROM %s", $column, $formconfig['insert_into_table']);
             $sequence = $this->app['db']->executeQuery($query)->fetchColumn();
         } catch (\Doctrine\DBAL\DBALException $e) {
             // Oops. User will get a warning on the dashboard about tables that need to be repaired.
             $this->app['log']->add("SimpleForms could not fetch next sequence number from table" . $formconfig['insert_into_table'] . ' - check if the table exists.', 3);
             echo "Couldn't fetch next sequence number from table " . $formconfig['insert_into_table'] . ".";
         }
     }
     $sequence++;
     if ($formconfig['debugmode'] == true) {
         \Dumper::dump('Get sequence for ' . $formname . ' column: ' . $column . ' - ' . $sequence);
     }
     return $sequence;
 }
开发者ID:Hoplite-Software,项目名称:observatory,代码行数:25,代码来源:extension.php

示例12: array

<?php

require '../../class.dumper.php';
$obj = (object) array('a' => array('b' => array('c' => array('d' => array('e' => null)))));
Dumper::dump($obj);
开发者ID:forloops,项目名称:dumper,代码行数:5,代码来源:object.php


注:本文中的Dumper::dump方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。