Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated symfony/debug package #52

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"timber/timber": "^1.24.0",
"monolog/monolog": "^2.9.1",
"http-interop/response-sender": "^1.0",
"symfony/debug": "^4.4.44",
"illuminate/collections": "^8.53.1||^9.52.16",
"statamic/stringy": "^3.1.3",
"laminas/laminas-diactoros": "^2.25.2",
Expand All @@ -23,7 +22,8 @@
"mindplay/middleman": "^3.1.0",
"psr/log": "^1.1.4",
"laminas/laminas-zendframework-bridge": "^1.7",
"symfony/var-dumper": "^5.0||^6.3.6"
"symfony/var-dumper": "^5.0||^6.3.6",
"symfony/error-handler": "^6.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6.13",
Expand Down
10 changes: 4 additions & 6 deletions src/Bootstrappers/RegisterExceptionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Rareloop\Lumberjack\Application;
use Rareloop\Lumberjack\Exceptions\HandlerInterface;
use Rareloop\Router\Responsable;
use Symfony\Component\Debug\Exception\FatalErrorException;
use Symfony\Component\ErrorHandler\Error\FatalError;
use Zend\Diactoros\ServerRequestFactory;
use function Http\Response\send;

Expand Down Expand Up @@ -122,16 +122,14 @@ public function handleShutdown()
*
* @param array $error
* @param int|null $traceOffset
* @return \Symfony\Component\Debug\Exception\FatalErrorException
* @return \Symfony\Component\ErrorHandler\Error\FatalError
*/
protected function fatalExceptionFromError(array $error, $traceOffset = null)
{
return new FatalErrorException(
return new FatalError(
$error['message'],
$error['type'],
0,
$error['file'],
$error['line'],
$error,
$traceOffset
);
}
Expand Down
9 changes: 4 additions & 5 deletions src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
use Psr\Http\Message\ServerRequestInterface;
use Rareloop\Lumberjack\Application;
use Rareloop\Lumberjack\Facades\Config;
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
use Symfony\Component\Debug\Exception\FlattenException;
use Symfony\Component\ErrorHandler\ErrorRenderer\HtmlErrorRenderer;
use Zend\Diactoros\Response\HtmlResponse;

class Handler implements HandlerInterface
Expand Down Expand Up @@ -36,11 +35,11 @@ public function report(Exception $e)

public function render(ServerRequestInterface $request, Exception $e) : ResponseInterface
{
$e = FlattenException::create($e);
$htmlRenderer = new HtmlErrorRenderer(Config::get('app.debug', false));

$handler = new SymfonyExceptionHandler(Config::get('app.debug', false));
$exception = $htmlRenderer->render($e);

return new HtmlResponse($handler->getHtml($e), $e->getStatusCode(), $e->getHeaders());
return new HtmlResponse($exception->getAsString(), $exception->getStatusCode(), $exception->getHeaders());
}

protected function shouldNotReport(Exception $e)
Expand Down
1 change: 0 additions & 1 deletion tests/Unit/Bootstrappers/RegisterExceptionHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Rareloop\Lumberjack\Exceptions\HandlerInterface;
use Rareloop\Lumberjack\Test\Unit\BrainMonkeyPHPUnitIntegration;
use Rareloop\Router\Responsable;
use Symfony\Component\Debug\Exception\FatalErrorException;
use Zend\Diactoros\Response;
use Zend\Diactoros\Response\TextResponse;
use Zend\Diactoros\ServerRequest;
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/PostQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ public function can_create_a_builder_from_static_functions()

/**
* @test
* @runInSeparateProcess
*/
public function throw_error_on_missing_static_function()
{
$errorThrown = false;

try {
Post::missingStaticFunction();
} catch (Throwable $e) {
Expand Down
2 changes: 0 additions & 2 deletions tests/Unit/ScopedQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,10 @@ public function can_pass_params_into_a_query_scope_on_post_object()

/**
* @test
* @runInSeparateProcess
*/
public function missing_query_scope_throws_an_error()
{
$errorThrown = false;

try {
$builder = new ScopedQueryBuilder(PostWithQueryScope::class);
$builder->nonExistentScope();
Expand Down
Loading