Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eec5c92
[Debug] Symfony debug extension
Mar 7, 2014
4bf9300
[Debug] a README for the debug extension
nicolas-grekas Mar 20, 2014
07135a0
[VarDumper] algo to clone any PHP variable to a breadth-first queue
nicolas-grekas Apr 5, 2014
5b7ae28
[VarDumper] symfony_debug ext. fast and memory efficient cloning algo
nicolas-grekas Apr 5, 2014
3ddbf4b
[VarDumper] add casters for per class/resource custom state extraction
nicolas-grekas Apr 5, 2014
c91bc83
[VarDumper] casters for exceptions representation
nicolas-grekas Apr 5, 2014
da3e50a
[VarDumper] casters for SPL data structures
nicolas-grekas Apr 5, 2014
0a92c08
[VarDumper] casters for PDO related objects
nicolas-grekas Apr 5, 2014
c426d8b
[VarDumper] casters for Doctrine objects
nicolas-grekas Apr 5, 2014
0266072
[VarDumper] casters for DOM objects
nicolas-grekas Aug 24, 2014
1d5e3f4
[VarDumper] interface for dumping collected variables
nicolas-grekas Apr 5, 2014
fa81544
[VarDumper] CLI dedicated dumper and related abstract
nicolas-grekas Apr 5, 2014
e6dde33
[VarDumper] HTML variant of the CLI dumper
nicolas-grekas Apr 5, 2014
5eaa187
[VarDumper] tests for CliDumper
nicolas-grekas Apr 5, 2014
a69e962
[VarDumper] tests for HtmlDumper
nicolas-grekas Jun 13, 2014
297d373
[VarDumper] README, LICENSE and composer.json
nicolas-grekas Apr 5, 2014
9dea601
[DebugBundle] global dump() function for daily use
nicolas-grekas May 29, 2014
eb98c81
[DebugBundle] dump() + better Symfony glue
nicolas-grekas Aug 26, 2014
8d5d970
[DebugBundle] adjust after review
nicolas-grekas Aug 27, 2014
c8746a4
[DebugBundle] add tests for twig and for the bundle
nicolas-grekas Aug 27, 2014
0d8a942
[VarDumper] add Stub objects for cutting cleanly and dumping consts
nicolas-grekas Sep 8, 2014
081363c
[HttpKernel] tests for DumpListener
nicolas-grekas Sep 8, 2014
49f13c6
[HttpKernel] add tests for DumpDataCollector
nicolas-grekas Sep 9, 2014
de05cd9
[DebugBundle] enhance dump excerpts
nicolas-grekas Sep 12, 2014
e4e00ef
[TwigBridge] DumpNode and Token parser
ruian Sep 12, 2014
5f59811
[DebugBundle] Add doc example for Twig usage
Sep 12, 2014
a8d81e4
[DebugBundle] Inlined assets to avoid installation issues
Sep 12, 2014
d43ae82
[VarDumper] Add workaround to https://bugs.php.net/65967
romainneutron Sep 12, 2014
0f8d30f
[VarDumper] Replace \e with \x1B in CliDumper to support colour in PH…
oscherler Sep 12, 2014
2e167ba
[TwigBridge] add Twig dump() function + tests and fixes
nicolas-grekas Sep 17, 2014
80fd736
[DebugBundle] Enhance some comments
lyrixx Sep 23, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[VarDumper] CLI dedicated dumper and related abstract
  • Loading branch information
nicolas-grekas committed Sep 23, 2014
commit fa81544075ec2657bdea3a50933072ed77c35a66
123 changes: 123 additions & 0 deletions src/Symfony/Component/VarDumper/Dumper/AbstractDumper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\VarDumper\Dumper;

use Symfony\Component\VarDumper\Cloner\Data;

/**
* Abstract mechanism for dumping a Data object.
*
* @author Nicolas Grekas <[email protected]>
*/
abstract class AbstractDumper implements DataDumperInterface, DumperInternalsInterface
{
public static $defaultOutputStream = 'php://output';

protected $line = '';
protected $lineDumper;
protected $outputStream;
protected $decimalPoint; // This is locale dependent
protected $indentPad = ' ';

/**
* @param callable|resource|string|null $outputStream A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutputStream.
*/
public function __construct($outputStream = null)
{
$this->decimalPoint = (string) 0.5;
$this->decimalPoint = $this->decimalPoint[1];
if (is_callable($outputStream)) {
$this->setLineDumper($outputStream);
} else {
if (null === $outputStream) {
$outputStream =& static::$defaultOutputStream;
}
if (is_string($outputStream)) {
$outputStream = fopen($outputStream, 'wb');
}
$this->outputStream = $outputStream;
$this->setLineDumper(array($this, 'echoLine'));
}
}

/**
* Sets a line dumper callback.
*
* @param callable $callback A callback responsible for writing the dump, one line at a time.
*
* @return callable|null The previous line dumper.
*/
public function setLineDumper($callback)
{
$prev = $this->lineDumper;
$this->lineDumper = $callback;

return $prev;
}

/**
* Sets the indentation pad string.
*
* @param string $pad A string the will be prepended to dumped lines, repeated by nesting level.
*
* @return string The indent pad.
*/
public function setIndentPad($pad)
{
$prev = $this->indentPad;
$this->indentPad = $pad;

return $prev;
}

/**
* Dumps a Data object.
*
* @param Data $data A Data object.
* @param callable|null $lineDumper A callback for writing dump's lines.
*/
public function dump(Data $data, $lineDumper = null)
{
$this->decimalPoint = (string) 0.5;
$this->decimalPoint = $this->decimalPoint[1];
$dumper = clone $this;
if ($lineDumper) {
$dumper->setLineDumper($lineDumper);
}
$data->dump($dumper);
$dumper->dumpLine(false);
}

/**
* Dumps the current line.
*
* @param int $depth The recursive depth in the dumped structure for the line being dumped.
*/
protected function dumpLine($depth)
{
call_user_func($this->lineDumper, $this->line, $depth);
$this->line = '';
}

/**
* Generic line dumper callback.
*
* @param string $line The line to write.
* @param int $depth The recursive depth in the dumped structure.
*/
protected function echoLine($line, $depth)
{
if (false !== $depth) {
fwrite($this->outputStream, str_repeat($this->indentPad, $depth).$line."\n");
}
}
}
Loading