Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #94: Add a middleware handler to control dumps' output destinatio…
…n, add `dump` function
- Loading branch information
Showing
6 changed files
with
71 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\VarDumper\Handler; | ||
|
||
use Yiisoft\VarDumper\HandlerInterface; | ||
use Yiisoft\VarDumper\VarDumper; | ||
|
||
final class EchoHandler implements HandlerInterface | ||
{ | ||
public function handle(mixed $variable, int $depth, bool $highlight = false): void | ||
{ | ||
$varDumper = VarDumper::create($variable); | ||
$output = $varDumper->asString($depth); | ||
|
||
if ($highlight) { | ||
$result = highlight_string("<?php\n" . $output, true); | ||
$output = preg_replace('/<\\?php<br \\/>/', '', $result, 1); | ||
} | ||
|
||
echo $output; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\VarDumper; | ||
|
||
interface HandlerInterface | ||
{ | ||
public function handle(mixed $variable, int $depth, bool $highlight = false): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters