本文整理汇总了PHP中Symfony\Component\VarDumper\Cloner\VarCloner::setMaxItems方法的典型用法代码示例。如果您正苦于以下问题:PHP VarCloner::setMaxItems方法的具体用法?PHP VarCloner::setMaxItems怎么用?PHP VarCloner::setMaxItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\VarDumper\Cloner\VarCloner
的用法示例。
在下文中一共展示了VarCloner::setMaxItems方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getVarDumperDump
private function getVarDumperDump($data)
{
$h = fopen('php://memory', 'r+b');
$cloner = new VarCloner();
$cloner->setMaxItems(-1);
$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);
}
示例2: 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);
}
示例3: 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));
}
示例4: register
public function register(Container $app)
{
$app['var_dumper.cloner'] = function ($app) {
$cloner = new VarCloner();
if (isset($app['debug.max_items'])) {
$cloner->setMaxItems($app['debug.max_items']);
}
if (isset($app['debug.max_string_length'])) {
$cloner->setMaxString($app['debug.max_string_length']);
}
return $cloner;
};
$app['data_collector.templates'] = $app->extend('data_collector.templates', function ($templates) {
$templates[] = array('dump', '@Debug/Profiler/dump.html.twig');
return $templates;
});
$app['data_collector.dump'] = function ($app) {
return new DumpDataCollector($app['stopwatch'], $app['code.file_link_format']);
};
$app->extend('data_collectors', function ($collectors, $app) {
$collectors['dump'] = function ($app) {
return $app['data_collector.dump'];
};
return $collectors;
});
$app->extend('twig', function ($twig, $app) {
if (class_exists('\\Symfony\\Bridge\\Twig\\Extension\\DumpExtension')) {
$twig->addExtension(new DumpExtension($app['var_dumper.cloner']));
}
return $twig;
});
$app->extend('twig.loader.filesystem', function ($loader, $app) {
$loader->addPath($app['debug.templates_path'], 'Debug');
return $loader;
});
$app['debug.templates_path'] = function () {
$r = new \ReflectionClass('Symfony\\Bundle\\DebugBundle\\DependencyInjection\\Configuration');
return dirname(dirname($r->getFileName())) . '/Resources/views';
};
}
示例5: testHtmlDump
public function testHtmlDump()
{
$e = $this->getTestException(1);
ExceptionCaster::$srcContext = -1;
$cloner = new VarCloner();
$cloner->setMaxItems(1);
$dumper = new HtmlDumper();
$dumper->setDumpHeader('<foo></foo>');
$dumper->setDumpBoundaries('<bar>', '</bar>');
$dump = $dumper->dump($cloner->cloneVar($e)->withRefHandles(false), true);
$expectedDump = <<<'EODUMP'
<foo></foo><bar><span class=sf-dump-note>Exception</span> {<samp>
#<span class=sf-dump-protected title="Protected property">message</span>: "<span class=sf-dump-str title="3 characters">foo</span>"
#<span class=sf-dump-protected title="Protected property">code</span>: <span class=sf-dump-num>0</span>
#<span class=sf-dump-protected title="Protected property">file</span>: "<span class=sf-dump-str title="%sExceptionCasterTest.php
%d characters"><span class=sf-dump-ellipsis>%sTests</span>%eCaster%eExceptionCasterTest.php</span>"
#<span class=sf-dump-protected title="Protected property">line</span>: <span class=sf-dump-num>25</span>
-<span class=sf-dump-private title="Private property defined in class: `Exception`">trace</span>: {<samp>
<span class=sf-dump-meta title="%sExceptionCasterTest.php
Stack level %d."><span class=sf-dump-ellipsis>%sVarDumper%eTests</span>%eCaster%eExceptionCasterTest.php</span>: <span class=sf-dump-num>25</span>
…12
</samp>}
</samp>}
</bar>
EODUMP;
$this->assertStringMatchesFormat($expectedDump, $dump);
}