public static dump ( mixed $var, integer $maxDepth = 2, boolean $stripTags = true, boolean $echo = true ) : string | ||
$var | mixed | The variable to dump. |
$maxDepth | integer | The maximum nesting level for object properties. |
$stripTags | boolean | Whether output should strip HTML tags. |
$echo | boolean | Send the dumped value to the output buffer |
Результат | string |
public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true)
{
$html = ini_get('html_errors');
if ($html !== true) {
ini_set('html_errors', true);
}
if (extension_loaded('xdebug')) {
ini_set('xdebug.var_display_max_depth', $maxDepth);
}
$var = self::export($var, $maxDepth);
ob_start();
var_dump($var);
$dump = ob_get_contents();
ob_end_clean();
$dumpText = $stripTags ? strip_tags(html_entity_decode($dump)) : $dump;
ini_set('html_errors', $html);
if ($echo) {
echo $dumpText;
}
return $dumpText;
}
/** * @see Console\Command\Command */ protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output) { $dm = $this->getHelper('dm')->getDocumentManager(); $query = json_decode($input->getArgument('query')); $cursor = $dm->getRepository($input->getArgument('class'))->findBy((array) $query); $cursor->hydrate((bool) $input->getOption('hydrate')); $depth = $input->getOption('depth'); if (!is_numeric($depth)) { throw new \LogicException("Option 'depth' must contain an integer value"); } if (($skip = $input->getOption('skip')) !== null) { if (!is_numeric($skip)) { throw new \LogicException("Option 'skip' must contain an integer value"); } $cursor->skip((int) $skip); } if (($limit = $input->getOption('limit')) !== null) { if (!is_numeric($limit)) { throw new \LogicException("Option 'limit' must contain an integer value"); } $cursor->limit((int) $limit); } $resultSet = $cursor->toArray(); \Doctrine\Common\Util\Debug::dump($resultSet, $depth); }