Making debug = false by default and cleanup

This commit is contained in:
Yonel Ceruto 2019-07-22 11:38:55 -04:00
parent 7dfc97be9f
commit b28986f119
9 changed files with 8 additions and 11 deletions

View File

@ -31,7 +31,6 @@
<service id="error_renderer.renderer.txt" class="Symfony\Component\ErrorRenderer\ErrorRenderer\TxtErrorRenderer">
<tag name="error_renderer.renderer" />
<argument>%kernel.debug%</argument>
<argument>%kernel.charset%</argument>
</service>
</services>
</container>

View File

@ -33,7 +33,7 @@ class HtmlErrorRenderer implements ErrorRendererInterface
private $charset;
private $fileLinkFormat;
public function __construct(bool $debug = true, string $charset = null, $fileLinkFormat = null)
public function __construct(bool $debug = false, string $charset = null, $fileLinkFormat = null)
{
$this->debug = $debug;
$this->charset = $charset ?: (ini_get('default_charset') ?: 'UTF-8');

View File

@ -20,7 +20,7 @@ class JsonErrorRenderer implements ErrorRendererInterface
{
private $debug;
public function __construct(bool $debug = true)
public function __construct(bool $debug = false)
{
$this->debug = $debug;
}

View File

@ -19,12 +19,10 @@ use Symfony\Component\ErrorRenderer\Exception\FlattenException;
class TxtErrorRenderer implements ErrorRendererInterface
{
private $debug;
private $charset;
public function __construct(bool $debug = true, string $charset = null)
public function __construct(bool $debug = false)
{
$this->debug = $debug;
$this->charset = $charset ?: (ini_get('default_charset') ?: 'UTF-8');
}
/**

View File

@ -21,7 +21,7 @@ class XmlErrorRenderer implements ErrorRendererInterface
private $debug;
private $charset;
public function __construct(bool $debug = true, string $charset = null)
public function __construct(bool $debug = false, string $charset = null)
{
$this->debug = $debug;
$this->charset = $charset ?: (ini_get('default_charset') ?: 'UTF-8');

View File

@ -22,6 +22,6 @@ class HtmlErrorRendererTest extends TestCase
$exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '<!DOCTYPE html>%A<html>%A<head>%A<title>Internal Server Error</title>%A<h1 class="break-long-words exception-message">Foo</h1>%A<abbr title="RuntimeException">RuntimeException</abbr>%A';
$this->assertStringMatchesFormat($expected, (new HtmlErrorRenderer())->render($exception));
$this->assertStringMatchesFormat($expected, (new HtmlErrorRenderer(true))->render($exception));
}
}

View File

@ -32,6 +32,6 @@ class JsonErrorRendererTest extends TestCase
"trace":
JSON;
$this->assertStringStartsWith($expected, (new JsonErrorRenderer())->render($exception));
$this->assertStringStartsWith($expected, (new JsonErrorRenderer(true))->render($exception));
}
}

View File

@ -22,6 +22,6 @@ class TxtErrorRendererTest extends TestCase
$exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '[title] Internal Server Error%A[status] 500%A[detail] Foo%A[1] RuntimeException: Foo%A';
$this->assertStringMatchesFormat($expected, (new TxtErrorRenderer())->render($exception));
$this->assertStringMatchesFormat($expected, (new TxtErrorRenderer(true))->render($exception));
}
}

View File

@ -22,6 +22,6 @@ class XmlErrorRendererTest extends TestCase
$exception = FlattenException::createFromThrowable(new \RuntimeException('Foo'));
$expected = '<?xml version="1.0" encoding="UTF-8" ?>%A<problem xmlns="urn:ietf:rfc:7807">%A<title>Internal Server Error</title>%A<status>500</status>%A<detail>Foo</detail>%A';
$this->assertStringMatchesFormat($expected, (new XmlErrorRenderer())->render($exception));
$this->assertStringMatchesFormat($expected, (new XmlErrorRenderer(true))->render($exception));
}
}