Skip to content
Permalink
Browse files

/

  • Loading branch information
rodolfoberrios committed Feb 14, 2020
1 parent a5bcdac commit 09e564ac2c09412c730a900b186e5beb794a840c
Showing with 219 additions and 142 deletions.
  1. +16 −0 .php_cs.dist
  2. +1 −1 components/Benchmark/Interfaces/RunInterface.php
  3. +1 −1 components/Controller/Traits/JsonApiTrait.php
  4. +1 −1 components/Controller/Traits/ResponseStringTrait.php
  5. +1 −0 components/ExceptionHandler/Tests/Documents/PlainDocumentTest.php
  6. +12 −0 components/ExceptionHandler/Tests/ErrorHandlerTest.php
  7. +0 −1 components/ExceptionHandler/Tests/ExceptionTest.php
  8. +0 −1 components/Message/Message.php
  9. +11 −0 components/Router/Interfaces/RouteCacheInterface.php
  10. +11 −0 components/Router/Tests/RoutedTest.php
  11. +0 −2 components/VarDump/Interfaces/VarDumpeableInterface.php
  12. +2 −3 components/VarDump/Outputters/ConsoleOutputter.php
  13. +3 −3 components/VarDump/Outputters/HtmlOutputter.php
  14. +17 −14 components/VarDump/Outputters/PlainOutputter.php
  15. +33 −22 components/VarDump/Tests/Outputters/HtmlOutputterTest.php
  16. +27 −33 components/VarDump/Tests/Outputters/PlainOutputterTest.php
  17. +4 −15 components/VarDump/Tests/Outputters/_resources/output-html.php
  18. +1 −1 components/VarDump/Tests/Processors/ArrayProcessorTest.php
  19. +1 −6 components/VarDump/Tests/Processors/BooleanProcessorTest.php
  20. +1 −1 components/VarDump/Tests/Processors/FloatProcessorTest.php
  21. +1 −1 components/VarDump/Tests/Processors/IntegerProcessorTest.php
  22. +1 −1 components/VarDump/Tests/Processors/NullProcessorTest.php
  23. +1 −1 components/VarDump/Tests/Processors/ObjectProcessorTest.php
  24. +1 −1 components/VarDump/Tests/Processors/ResourceProcessorTest.php
  25. +1 −1 components/VarDump/Tests/Processors/StringProcessorTest.php
  26. +39 −0 components/VarDump/Tests/Traits/DebugBacktraceTrait.php
  27. +1 −1 components/VarDump/Tests/{Processors → }/Traits/VarDumperTrait.php
  28. +0 −5 components/VarDump/Tests/VarDumpeableTest.php
  29. +14 −13 components/VarDump/VarDump.php
  30. +0 −7 components/VarDump/VarDumpeable.php
  31. +2 −1 composer.json
  32. +5 −0 dir/_resources/output-html.php
  33. +2 −1 trash/App/Exceptions/BuildAlreadyMakedException.php
  34. +2 −1 trash/App/Exceptions/BuildFileNotExistsException.php
  35. +2 −1 trash/App/Exceptions/ParametersDuplicatedException.php
  36. +2 −1 trash/App/Exceptions/ParametersWrongKeyException.php
  37. +2 −1 trash/App/Exceptions/ParametersWrongTypeException.php
@@ -9,6 +9,21 @@
* file that was distributed with this source code.
*/

declare(strict_types=1);

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

$finder = PhpCsFixer\Finder::create()
->notPath('_resources')
->in(__DIR__);

$header = <<<'EOF'
This file is part of Chevere.
@@ -69,4 +84,5 @@ return PhpCsFixer\Config::create()
'whitespace_after_comma_in_array' => true,
])
->setRiskyAllowed(true)
->setFinder($finder)
->setLineEnding("\n");
@@ -39,7 +39,7 @@ public function times(): int;
public function withTimeLimit(int $timeLimit): RunInterface;

public function timeLimit(): int;

public function exec();

/**
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of Chevereto\Core.
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of Chevereto\Core.
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
@@ -36,6 +36,7 @@ public function setUp(): void
new LogicException('Ups', 100)
));
}

public function testConstruct(): void
{
$document = new PlainDocument($this->exceptionHandler);
@@ -1,4 +1,16 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Chevere\Components\ExceptionHandler\Tests;

use Chevere\Components\ExceptionHandler\ErrorHandler;
@@ -59,7 +59,6 @@ public function testConstructWithErrorInvalidSeverity(): void
}
}


/**
* A dummy ErrorException that allows to inject severity values.
*/
@@ -77,7 +77,6 @@ public function strong(string $search, string $replace): MessageInterface
return $new->wrap($search, $replace);
}


public function toString(): string
{
$message = $this->message;
@@ -1,5 +1,16 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Chevere\Components\Router\Interfaces;

use Chevere\Components\Route\Interfaces\RouteInterface;
@@ -1,5 +1,16 @@
<?php

/*
* This file is part of Chevere.
*
* (c) Rodolfo Berrios <rodolfo@chevere.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Chevere\Components\Router\Tests;

use Chevere\Components\Route\PathUri;
@@ -21,7 +21,5 @@ public function var();

public function type(): string;

public function template(): array;

public function processorName(): string;
}
@@ -14,7 +14,6 @@
namespace Chevere\Components\VarDump\Outputters;

use JakubOnderka\PhpConsoleColor\ConsoleColor;
use Symfony\Component\Console\Output\ConsoleOutput;

final class ConsoleOutputter extends PlainOutputter
{
@@ -34,14 +33,14 @@ public function prepare(): void
if ($bt['function'] ?? null) {
$caller .= $bt['function'] . '()';
}
$this->streamWriter->write(
$this->writer->write(
"\n" . (new ConsoleColor)->apply(['bold', 'red'], $caller)
. "\n" . $this->outputHr . "\n"
);
}

public function callback(): void
{
$this->streamWriter->write("\n" . $this->outputHr . "\n");
$this->writer->write("\n" . $this->outputHr . "\n");
}
}
@@ -29,21 +29,21 @@ public function prepare(): void
{
if (headers_sent() === false || headers_list() === []) {
$this->hasHeader = true;
$this->streamWriter->write(
$this->writer->write(
'<html style="background: '
. self::BACKGROUND_SHADE
. ';"><head></head><body>'
);
}
$this->streamWriter->write(
$this->writer->write(
'<pre style="' . self::STYLE . '">'
);
}

public function callback(): void
{
if ($this->hasHeader) {
$this->streamWriter->write('</body></html>');
$this->writer->write('</body></html>');
}
}
}
@@ -23,7 +23,7 @@ class PlainOutputter implements OutputterInterface
{
const OFFSET = 1;

protected WriterInterface $streamWriter;
protected WriterInterface $writer;

public function prepare(): void
{
@@ -34,48 +34,51 @@ public function callback(): void
}

final public function __construct(
WriterInterface $streamWriter,
WriterInterface $writer,
array $debugBacktrace,
FormatterInterface $formatter,
...$vars
) {
$this->streamWriter = $streamWriter;
$this->writer = $writer;
$this->debugBacktrace = $debugBacktrace;
$this->formatter = $formatter;
$this->vars = $vars;
}

final public function process(): void
{
$this->prepare();
$this->handleClass();
$this->streamWriter->write(
$this->writer->write(
$this->formatter
->highlight(
'_function',
$this->debugBacktrace[self::OFFSET]['function'] . '()'
$this->debugBacktrace[1]['function'] . '()'
)
);
$this->handleFile();
$this->writeCallerFile();
$this->handleArgs();
$this->callback();
}

final private function handleClass(): void
{
$item = $this->debugBacktrace[self::OFFSET];
$item = $this->debugBacktrace[1];
$class = $item['class'] ?? null;
if ($class !== null) {
$type = $item['type'];
$this->streamWriter->write(
$this->writer->write(
$this->formatter
->highlight('_class', $class) . $type
);
}
}

final private function handleFile(): void
final private function writeCallerFile(): void
{
$pos = self::OFFSET - 1;
$item = $this->debugBacktrace[$pos];
$item = $this->debugBacktrace[0];
if ($item !== null && isset($item['file'])) {
$this->streamWriter->write(
$this->writer->write(
"\n"
. $this->formatter
->highlight(
@@ -91,11 +94,11 @@ public function callback(): void
$pos = 1;
foreach ($this->vars as $value) {
$varProcess = new VarDumper(
$this->streamWriter,
$this->writer,
new VarDumpeable($value),
$this->formatter
);
$this->streamWriter->write("\n\nArg#" . $pos . ' ');
$this->writer->write("\n\nArg#" . $pos . ' ');
$varProcess->withProcessor();
++$pos;
}
@@ -19,28 +19,39 @@
use Chevere\Components\Filesystem\Path;
use Chevere\Components\VarDump\Formatters\HtmlFormatter;
use Chevere\Components\VarDump\Outputters\HtmlOutputter;
use Chevere\Components\VarDump\VarDumper;
use Chevere\Components\VarDump\Tests\Traits\DebugBacktraceTrait;
use Chevere\Components\Variable\VariableExport;
use Chevere\Components\Writers\StreamWriter;
use PHPUnit\Framework\TestCase;
use function GuzzleHttp\Psr7\stream_for;

// final class HtmlOutputterTest extends TestCase
// {
// public function testEmpty(): void
// {
// $varDumper = new VarDumper(new HtmlFormatter);
// $outputter = new HtmlOutputter($varDumper);
// $line = __LINE__ - 2;
// // $fileReturn = new FileReturn(
// // new PhpFile(new File(
// // new Path(__DIR__ . '/_resources/output-html.php')
// // ))
// // );
// // $fileReturn->put(new VariableExport($outputter->toString()));
// $parsed = strtr(include '_resources/output-html.php', [
// '%className%' => self::class,
// '%functionName%' => __FUNCTION__,
// '%fileLine%' => __FILE__ . ':' . $line
// ]);
// $this->assertSame($parsed, $outputter->emit());
// }
// }
final class HtmlOutputterTest extends TestCase
{
use DebugBacktraceTrait;

public function testNull(): void
{
$backtrace = $this->getDebugBacktrace();
$writer = new StreamWriter(stream_for(''));
$outputter = new HtmlOutputter(
$writer,
$backtrace,
new HtmlFormatter,
null,
);
$outputter->process();
$fileReturn = new FileReturn(
new PhpFile(new File(
new Path(__DIR__ . '/_resources/output-html.php')
))
);
$fileReturn->put(new VariableExport($writer->toString()));

$parsed = strtr(include '_resources/output-html.php', [
'%className%' => $backtrace[1]['class'],
'%functionName%' => $backtrace[1]['function'],
'%fileLine%' => $backtrace[0]['file'] . ':' . $backtrace[0]['line']
]);
$this->assertSame($parsed, $writer->toString());
}
}

0 comments on commit 09e564a

Please sign in to comment.
You can’t perform that action at this time.