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


PHP CliDumper::dump方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: dump

 /**
  * @param $data
  * @param null|int $flags
  */
 public function dump($data, $flags = null)
 {
     if ($flags !== null) {
         if ($flags & self::NEWLINE_BEFORE) {
             $this->output->writeln('');
         }
     }
     $this->cliDumper->dump($this->varCloner->cloneVar($data));
     if ($flags !== null) {
         if ($flags & self::NEWLINE_AFTER) {
             $this->output->writeln('');
         }
     }
 }
开发者ID:sfie,项目名称:pimcore,代码行数:18,代码来源:Dumper.php

示例5: dump

 /**
  * {@inheritdoc}
  */
 public function dump(Data $data, $output = null, array $extraDisplayOptions = array())
 {
     $this->extraDisplayOptions = $extraDisplayOptions;
     $result = parent::dump($data, $output);
     $this->dumpId = 'sf-dump-' . mt_rand();
     return $result;
 }
开发者ID:symfony,项目名称:symfony,代码行数:10,代码来源:HtmlDumper.php

示例6: importResource

 /**
  * @param string          $targetUrl   target url to import resource into
  * @param string          $file        path to file being loaded
  * @param OutputInterface $output      output of the command
  * @param Document        $doc         document to load
  * @param string          $host        host to import into
  * @param string          $rewriteHost string to replace with value from $host during loading
  * @param string          $rewriteTo   string to replace value from $rewriteHost with during loading
  * @param boolean         $sync        send requests syncronously
  *
  * @return Promise\Promise|null
  */
 protected function importResource($targetUrl, $file, OutputInterface $output, Document $doc, $host, $rewriteHost, $rewriteTo, $sync = false)
 {
     $content = str_replace($rewriteHost, $rewriteTo, $doc->getContent());
     $successFunc = function (ResponseInterface $response) use($output) {
         $output->writeln('<comment>Wrote ' . $response->getHeader('Link')[0] . '</comment>');
     };
     $errFunc = function (RequestException $e) use($output, $file) {
         $output->writeln('<error>' . str_pad(sprintf('Failed to write <%s> from \'%s\' with message \'%s\'', $e->getRequest()->getUri(), $file, $e->getMessage()), 140, ' ') . '</error>');
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $this->dumper->dump($this->cloner->cloneVar($this->parser->parse($e->getResponse()->getBody(), false, false, true)), function ($line, $depth) use($output) {
                 if ($depth > 0) {
                     $output->writeln('<error>' . str_pad(str_repeat('  ', $depth) . $line, 140, ' ') . '</error>');
                 }
             });
         }
     };
     if ($sync === false) {
         $promise = $this->client->requestAsync('PUT', $targetUrl, ['json' => $this->parseContent($content, $file)]);
         $promise->then($successFunc, $errFunc);
     } else {
         $promise = new Promise\Promise();
         try {
             $promise->resolve($successFunc($this->client->request('PUT', $targetUrl, ['json' => $this->parseContent($content, $file)])));
         } catch (BadResponseException $e) {
             $promise->resolve($errFunc($e));
         }
     }
     return $promise;
 }
开发者ID:alebon,项目名称:import-export,代码行数:41,代码来源:ImportCommand.php

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: assertDumpEquals

 private function assertDumpEquals($dump, $data, $message = '')
 {
     $dumper = new CliDumper();
     $dumper->setColors(false);
     $this->assertSame(rtrim($dump), rtrim($dumper->dump($data, true)), $message);
 }
开发者ID:yceruto,项目名称:symfony,代码行数:6,代码来源:DataCollectorTest.php

示例15: execute

 private function execute($input)
 {
     $input = trim($input);
     if (empty($input)) {
         return;
     }
     $args = array_filter(explode(' ', $input));
     if (count($args) === 1 and array_key_exists($args[0], $this->currentLevel['content'])) {
         $this->execute("cd' {$args[0]}");
         return;
     }
     switch ($args[0]) {
         case 'ls':
             $this->output($this->ls());
             break;
         case 'cd':
             if (strpos($args[1], '/')) {
                 foreach (explode('/', $args[1]) as $arg) {
                     $this->execute("cd {$arg}");
                 }
                 break;
             }
             $item = str_replace('/', '', $args[1]);
             if ($item === '..') {
                 array_pop($this->levels);
                 $this->currentLevel = $this->parent();
                 break;
             } elseif ($item === '/') {
                 $this->levels = [$this->commands['content']['name']];
                 $this->currentLevel = $this->commands;
                 break;
             } elseif (array_key_exists($item, $this->currentLevel['content'])) {
                 array_push($this->levels, $item);
                 $this->currentLevel = $this->currentLevel['content'][$item];
                 break;
             } elseif ($item === '.') {
                 break;
             } else {
                 $this->output("Error: {$item} not found.\n");
                 break;
             }
         case 'exec':
             if (!isset($args[1])) {
                 $this->output("'exec' requires current element to be a command. Select one by 'cd'\n");
                 return;
             }
             $method = new \ReflectionMethod($this->levels[count($this->levels) - 2], $this->currentLevel['name']);
             $cmd = $method->invokeArgs(null, array_slice($args, 1));
             $this->client->send($cmd);
             $cloner = new VarCloner();
             $dumper = new CliDumper();
             $dumper->dump($cloner->cloneVar($this->client->getResponse()));
             break;
         case '?':
             $this->output("======== Available commands ========\n");
             $this->output(" - ls       : List available objects\n");
             $this->output(" - cd       : Change current directory ('cd ..' works)\n");
             $this->output(" - exec     : Execute current command eg: exec param1 param2 param3\n");
             $this->output(" - history  : Show command history\n");
             $this->output(" - quit     : Show command history\n");
             $this->output(" - ?        : Show this menu.....\n");
             break;
         case 'history':
             $this->output('  * ' . implode("\n  * ", array_values($this->history)) . "\n");
             break;
         case '':
             $this->prompt();
             break;
         case 'q':
         case 'quit':
             $this->client->logout();
             exit(0);
             break;
         default:
             $this->output("Error: Command not found for '{$input}'\n");
             $this->execute('?');
             $this->prompt();
     }
 }
开发者ID:lukebeer,项目名称:broadworks-ocip,代码行数:79,代码来源:Console.php


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