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


PHP Dumper\CliDumper类代码示例

本文整理汇总了PHP中Symfony\Component\VarDumper\Dumper\CliDumper的典型用法代码示例。如果您正苦于以下问题:PHP CliDumper类的具体用法?PHP CliDumper怎么用?PHP CliDumper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: appendLog

 /**
  * @param mixed $var
  */
 function appendLog($var)
 {
     static $handler = null;
     if ($handler === null) {
         $logDir = LOG_DIR;
         assert(is_dir($logDir), 'log dir "' . $logDir . '" must be a dir');
         $logDir .= '/' . date('Ymd');
         if (!is_dir($logDir)) {
             $success = mkdir($logDir);
             assert($success, 'log dir create failed: ' . $logDir . ': ' . json_encode(error_get_last()));
         }
         $logFile = $logDir . '/' . GAME_VERSION;
         $cloner = new VarCloner();
         $dumper = new CliDumper($logFile);
         $handler = function ($var) use($cloner, $dumper) {
             $dumper->dump($cloner->cloneVar($var));
         };
     }
     $origHandler = VarDumper::setHandler($handler);
     VarDumper::dump(date('c'));
     foreach (func_get_args() as $var) {
         VarDumper::dump($var);
     }
     VarDumper::setHandler($origHandler);
 }
开发者ID:jiangyu7408,项目名称:notification,代码行数:28,代码来源:dump.php

示例2: boot

 public function boot(Application $app)
 {
     // This code is here to lazy load the dump stack. This default
     // configuration for CLI mode is overridden in HTTP mode on
     // 'kernel.request' event
     VarDumper::setHandler(function ($var) use($app) {
         $dumper = new CliDumper();
         $dumper->dump($app['var_dumper.cloner']->cloneVar($var));
     });
 }
开发者ID:jeromemacias,项目名称:silex-debug,代码行数:10,代码来源:DebugServiceProvider.php

示例3: getVarDumperDump

 private function getVarDumperDump($data)
 {
     $h = fopen('php://memory', 'r+b');
     $cloner = new VarCloner();
     $dumper = new CliDumper($h);
     $dumper->setColors(false);
     $dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
     $data = stream_get_contents($h, -1, 0);
     fclose($h);
     return rtrim($data);
 }
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:11,代码来源:VarDumperTestCase.php

示例4: format

 /**
  * {@inheritdoc}
  */
 public function format($response)
 {
     $temp = tmpfile();
     $cloner = new VarCloner();
     $dumper = new CliDumper($temp);
     $dumper->dump($cloner->cloneVar($response));
     fseek($temp, 0);
     $response = stream_get_contents($temp);
     fclose($temp);
     return $response;
 }
开发者ID:glooby,项目名称:debug-bundle,代码行数:14,代码来源:VarDumperFormatter.php

示例5: getDump

 protected function getDump($data)
 {
     $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
     $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
     $h = fopen('php://memory', 'r+b');
     $cloner = new VarCloner();
     $cloner->setMaxItems(-1);
     $dumper = new CliDumper($h, null, $flags);
     $dumper->setColors(false);
     $dumper->dump($cloner->cloneVar($data)->withRefHandles(false));
     $data = stream_get_contents($h, -1, 0);
     fclose($h);
     return rtrim($data);
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:14,代码来源:VarDumperTestTrait.php

示例6: getDump

 protected function getDump($data, $key = null)
 {
     $flags = getenv('DUMP_LIGHT_ARRAY') ? CliDumper::DUMP_LIGHT_ARRAY : 0;
     $flags |= getenv('DUMP_STRING_LENGTH') ? CliDumper::DUMP_STRING_LENGTH : 0;
     $cloner = new VarCloner();
     $cloner->setMaxItems(-1);
     $dumper = new CliDumper(null, null, $flags);
     $dumper->setColors(false);
     $data = $cloner->cloneVar($data)->withRefHandles(false);
     if (null !== $key && null === ($data = $data->seek($key))) {
         return;
     }
     return rtrim($dumper->dump($data, true));
 }
开发者ID:ayoah,项目名称:symfony,代码行数:14,代码来源:VarDumperTestTrait.php

示例7: boot

 public function boot()
 {
     if ($this->container->getParameter('kernel.debug')) {
         $container = $this->container;
         // This code is here to lazy load the dump stack. This default
         // configuration for CLI mode is overridden in HTTP mode on
         // 'kernel.request' event
         VarDumper::setHandler(function ($var) use($container) {
             $dumper = new CliDumper();
             $cloner = $container->get('var_dumper.cloner');
             $handler = function ($var) use($dumper, $cloner) {
                 $dumper->dump($cloner->cloneVar($var));
             };
             VarDumper::setHandler($handler);
             $handler($var);
         });
     }
 }
开发者ID:vomasmic,项目名称:symfony,代码行数:18,代码来源:DebugBundle.php

示例8: __destruct

 public function __destruct()
 {
     if (0 === $this->clonesCount-- && !$this->isCollected && $this->data) {
         $this->clonesCount = 0;
         $this->isCollected = true;
         $h = headers_list();
         $i = count($h);
         array_unshift($h, 'Content-Type: ' . ini_get('default_mimetype'));
         while (0 !== stripos($h[$i], 'Content-Type:')) {
             --$i;
         }
         if ('cli' !== PHP_SAPI && stripos($h[$i], 'html')) {
             $dumper = new HtmlDumper('php://output', $this->charset);
         } else {
             $dumper = new CliDumper('php://output', $this->charset);
             $dumper->setColors(false);
         }
         foreach ($this->data as $i => $dump) {
             $this->data[$i] = null;
             if ($dumper instanceof HtmlDumper) {
                 $dump['name'] = $this->htmlEncode($dump['name']);
                 $dump['file'] = $this->htmlEncode($dump['file']);
                 if ('' !== $dump['file']) {
                     if ($this->fileLinkFormat) {
                         $link = strtr($this->fileLinkFormat, array('%f' => $dump['file'], '%l' => $dump['line']));
                         $dump['name'] = sprintf('<a href="%s" title="%s">%s</a>', $link, $dump['file'], $dump['name']);
                     } else {
                         $dump['name'] = sprintf('<abbr title="%s">%s</abbr>', $dump['file'], $dump['name']);
                     }
                 }
                 echo "\n<span class=\"sf-dump-meta\">{$dump['name']} on line {$dump['line']}:</span>";
             } else {
                 echo "{$dump['name']} on line {$dump['line']}:\n";
             }
             $dumper->dump($dump['data']);
         }
         $this->data = array();
         $this->dataCount = 0;
     }
 }
开发者ID:vadim2404,项目名称:symfony,代码行数:40,代码来源:DumpDataCollector.php

示例9: testBuggyRefs

    /**
     * @runInSeparateProcess
     * @preserveGlobalState disabled
     */
    public function testBuggyRefs()
    {
        if (PHP_VERSION_ID >= 50600) {
            $this->markTestSkipped('PHP 5.6 fixed refs counting');
        }
        $var = $this->getSpecialVars();
        $var = $var[0];
        $dumper = new CliDumper();
        $dumper->setColors(false);
        $cloner = new VarCloner();
        $data = $cloner->cloneVar($var)->withMaxDepth(3);
        $out = '';
        $dumper->dump($data, function ($line, $depth) use(&$out) {
            if ($depth >= 0) {
                $out .= str_repeat('  ', $depth) . $line . "\n";
            }
        });
        $this->assertSame(<<<EOTXT
array:1 [
  0 => array:1 [
    0 => array:1 [
      0 => array:1 [ …1]
    ]
  ]
]

EOTXT
, $out);
    }
开发者ID:kadvani1,项目名称:symfony,代码行数:33,代码来源:CliDumperTest.php

示例10: inlineData

 private function inlineData(array $extraction)
 {
     $dumper = new CliDumper();
     $inlined = array();
     foreach ($extraction as $k => $v) {
         if (is_array($v)) {
             $inlined[$k] = $this->inlineData($v);
         } elseif ($v instanceof Data) {
             $inlined[$k] = rtrim($dumper->dump($v->withRefHandles(false), true));
         } else {
             $inlined[$k] = $v;
         }
     }
     return $inlined;
 }
开发者ID:paradajozsef,项目名称:symfony,代码行数:15,代码来源:FormDataExtractorTest.php

示例11: replaceDefaultSymfonyLineDumpers

 /**
  * Replaces the default output stream of Symfony's
  * CliDumper and HtmlDumper classes in order to
  * be able to run on Google App Engine.
  *
  * 'php://stdout' is used by CliDumper,
  * 'php://output' is used by HtmlDumper,
  * both are not supported on GAE.
  */
 protected function replaceDefaultSymfonyLineDumpers()
 {
     HtmlDumper::$defaultOutput = CliDumper::$defaultOutput = function ($line, $depth, $indentPad) {
         if (-1 !== $depth) {
             echo str_repeat($indentPad, $depth) . $line . PHP_EOL;
         }
     };
 }
开发者ID:wasay,项目名称:GaeSupportL5,代码行数:17,代码来源:Application.php

示例12: dump

 /**
  * Dump a value with elegance.
  *
  * @param  mixed  $value
  *
  * @return void
  */
 public function dump($value)
 {
     $dumper = new CliDumper();
     $dumper->dump((new VarCloner())->cloneVar($value));
 }
开发者ID:scrubmx,项目名称:sharks-with-laser-beams,代码行数:12,代码来源:Dumper.php

示例13: escape

 /**
  * @param string $input
  *
  * @return mixed
  */
 public function escape($input)
 {
     $this->dumper->dump($this->cloner->cloneVar($input), $this->memoryStream);
     $output = stream_get_contents($this->memoryStream, -1, 0);
     ftruncate($this->memoryStream, 0);
     return rtrim($output, "\n");
 }
开发者ID:nochso,项目名称:diff,代码行数:12,代码来源:Cli.php

示例14: dump

 /**
  * @param $variable
  * @return resource|string
  * @throws Exception
  * @throws null
  */
 protected function dump($variable)
 {
     $output = fopen('php://memory', 'r+b');
     $this->dumper->dump($this->cloner->cloneVar($variable), $output);
     rewind($output);
     $output = stream_get_contents($output);
     return $output;
 }
开发者ID:morrislaptop,项目名称:error-tracker-adapter-email,代码行数:14,代码来源:Body.php

示例15: describeViewComposer

 /**
  * Describe a View Composer for logging.
  * @param View $view    View being created
  * @param mixed $viewComposer   View Composer
  * @return string
  */
 protected function describeViewComposer(View $view, $viewComposer)
 {
     $description = "View Composer called for view '{$view->name()}': ";
     $this->cliDumper->dump($this->varCloner->cloneVar($viewComposer), function ($line, $depth) use(&$description) {
         $description .= "{$line} ";
     });
     return $description;
 }
开发者ID:joshbrw,项目名称:laravel-debugbar-viewcomposers,代码行数:14,代码来源:ViewComposerCollector.php


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