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


PHP VarCloner::cloneVar方法代码示例

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


在下文中一共展示了VarCloner::cloneVar方法的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: dump

 /**
  * Print dans la console les infos sur la variable en param.
  *
  * @param mixed $var
  *
  * @throws Exception
  */
 protected function dump($var)
 {
     if (null === $this->__dumper) {
         $this->__initDumper();
     }
     $this->__dumper->dump($this->__cloner->cloneVar($var));
 }
开发者ID:hmlb,项目名称:date-bundle,代码行数:14,代码来源:DumperCapabilities.php

示例3: testCollect

 public function testCollect()
 {
     $c = new RequestDataCollector();
     $c->collect($request = $this->createRequest(), $this->createResponse());
     $cloner = new VarCloner();
     $attributes = $c->getRequestAttributes();
     $this->assertSame('request', $c->getName());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getRequestHeaders());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestServer());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestCookies());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $attributes);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestRequest());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestQuery());
     $this->assertSame('html', $c->getFormat());
     $this->assertEquals('foobar', $c->getRoute());
     $this->assertEquals($cloner->cloneVar(array('name' => 'foo')), $c->getRouteParams());
     $this->assertSame(array(), $c->getSessionAttributes());
     $this->assertSame('en', $c->getLocale());
     $this->assertEquals($cloner->cloneVar($request->attributes->get('resource')), $attributes->get('resource'));
     $this->assertEquals($cloner->cloneVar($request->attributes->get('object')), $attributes->get('object'));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getResponseHeaders());
     $this->assertSame('OK', $c->getStatusText());
     $this->assertSame(200, $c->getStatusCode());
     $this->assertSame('application/json', $c->getContentType());
 }
开发者ID:ayoah,项目名称:symfony,代码行数:25,代码来源:RequestDataCollectorTest.php

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

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

示例6: __invoke

 public function __invoke($var)
 {
     ob_start();
     $this->dumper->dump($this->cloner->cloneVar($var));
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
开发者ID:bkrukowski,项目名称:error-dumper,代码行数:8,代码来源:SymfonyVarDumper.php

示例7: testCollect

 public function testCollect()
 {
     $cloner = new VarCloner();
     $collectedMessages = array(array('id' => 'foo', 'translation' => 'foo (en)', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_DEFINED, 'parameters' => array(), 'transChoiceNumber' => null), array('id' => 'bar', 'translation' => 'bar (fr)', 'locale' => 'fr', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, 'parameters' => array(), 'transChoiceNumber' => null), array('id' => 'choice', 'translation' => 'choice', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_MISSING, 'parameters' => array('%count%' => 3), 'transChoiceNumber' => 3), array('id' => 'choice', 'translation' => 'choice', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_MISSING, 'parameters' => array('%count%' => 3), 'transChoiceNumber' => 3), array('id' => 'choice', 'translation' => 'choice', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_MISSING, 'parameters' => array('%count%' => 4, '%foo%' => 'bar'), 'transChoiceNumber' => 4));
     $expectedMessages = array(array('id' => 'foo', 'translation' => 'foo (en)', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_DEFINED, 'count' => 1, 'parameters' => array(), 'transChoiceNumber' => null), array('id' => 'bar', 'translation' => 'bar (fr)', 'locale' => 'fr', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK, 'count' => 1, 'parameters' => array(), 'transChoiceNumber' => null), array('id' => 'choice', 'translation' => 'choice', 'locale' => 'en', 'domain' => 'messages', 'state' => DataCollectorTranslator::MESSAGE_MISSING, 'count' => 3, 'parameters' => array($cloner->cloneVar(array('%count%' => 3)), $cloner->cloneVar(array('%count%' => 3)), $cloner->cloneVar(array('%count%' => 4, '%foo%' => 'bar'))), 'transChoiceNumber' => 3));
     $translator = $this->getTranslator();
     $translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
     $dataCollector = new TranslationDataCollector($translator);
     $dataCollector->lateCollect();
     $this->assertEquals(1, $dataCollector->getCountMissings());
     $this->assertEquals(1, $dataCollector->getCountFallbacks());
     $this->assertEquals(1, $dataCollector->getCountDefines());
     $this->assertEquals($expectedMessages, array_values($dataCollector->getMessages()));
 }
开发者ID:symfony,项目名称:symfony,代码行数:14,代码来源:TranslationDataCollectorTest.php

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

示例9: testCloneVarStringWithScheme

 public function testCloneVarStringWithScheme()
 {
     $c = new CloneVarDataCollector('scheme://foo');
     $c->collect(new Request(), new Response());
     $cloner = new VarCloner();
     $this->assertEquals($cloner->cloneVar('scheme://foo'), $c->getData());
 }
开发者ID:yceruto,项目名称:symfony,代码行数:7,代码来源:DataCollectorTest.php

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

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

示例12: render

 /**
  * Renders data.
  *
  * @return string
  */
 public function render()
 {
     $cloner = new VarCloner();
     $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
     $output = fopen('php://memory', 'r+b');
     $dumper->dump($cloner->cloneVar($this->getData()), $output);
     return stream_get_contents($output, -1, 0);
 }
开发者ID:view-components,项目名称:view-components,代码行数:13,代码来源:SymfonyVarDump.php

示例13: boot

 public function boot(Application $app)
 {
     VarDumper::setHandler(function ($var) {
         $cloner = new VarCloner();
         $dumper = 'cli' === PHP_SAPI ? new CliDumper() : new HtmlDumper();
         $dumper->dump($cloner->cloneVar($var));
     });
 }
开发者ID:groovey,项目名称:framework,代码行数:8,代码来源:Dumper.php

示例14: geny_dump

 public function geny_dump($data)
 {
     $stream = fopen('php://memory', 'r+b');
     $dumper = new HtmlDumper($stream);
     $cloner = new VarCloner();
     $dumper->dump($cloner->cloneVar($data));
     rewind($stream);
     return stream_get_contents($stream);
 }
开发者ID:ninsuo,项目名称:GenyBundle,代码行数:9,代码来源:GenyExtension.php

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


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