Import statements and update configuration.

This commit is contained in:
James Cole
2025-05-27 16:57:36 +02:00
parent 7c04c4c2bc
commit c074fec0a7
165 changed files with 530 additions and 335 deletions

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
class BadHttpHeaderException extends \Exception
use Exception;
class BadHttpHeaderException extends Exception
{
public int $statusCode = 406;
}

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
/**
* Class DuplicateTransactionException
*/
class DuplicateTransactionException extends \Exception {}
class DuplicateTransactionException extends Exception {}

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
/**
* Class FireflyException.
*/
class FireflyException extends \Exception {}
class FireflyException extends Exception {}

View File

@@ -34,6 +34,8 @@ use FireflyIII\User;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;
use Override;
use Throwable;
/**
* Class GracefulNotFoundHandler
@@ -45,12 +47,12 @@ class GracefulNotFoundHandler extends ExceptionHandler
*
* @param Request $request
*
* @throws \Throwable
* @throws Throwable
*
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
#[\Override]
public function render($request, \Throwable $e): Response
#[Override]
public function render($request, Throwable $e): Response
{
$route = $request->route();
if (null === $route) {
@@ -149,9 +151,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
}
/**
* @throws \Throwable
* @throws Throwable
*/
private function handleAccount(Request $request, \Throwable $exception): Response
private function handleAccount(Request $request, Throwable $exception): Response
{
app('log')->debug('404 page is probably a deleted account. Redirect to overview of account types.');
@@ -184,9 +186,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
/**
* @return Response
*
* @throws \Throwable
* @throws Throwable
*/
private function handleGroup(Request $request, \Throwable $exception)
private function handleGroup(Request $request, Throwable $exception)
{
app('log')->debug('404 page is probably a deleted group. Redirect to overview of group types.');
@@ -224,9 +226,9 @@ class GracefulNotFoundHandler extends ExceptionHandler
/**
* @return Response
*
* @throws \Throwable
* @throws Throwable
*/
private function handleAttachment(Request $request, \Throwable $exception)
private function handleAttachment(Request $request, Throwable $exception)
{
app('log')->debug('404 page is probably a deleted attachment. Redirect to parent object.');

View File

@@ -44,6 +44,9 @@ use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use ErrorException;
use Override;
use Throwable;
// temp
/**
@@ -52,7 +55,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class Handler extends ExceptionHandler
{
/**
* @var array<int, class-string<\Throwable>>
* @var array<int, class-string<Throwable>>
*/
protected $dontReport
= [
@@ -70,7 +73,7 @@ class Handler extends ExceptionHandler
/**
* Register the exception handling callbacks for the application.
*/
#[\Override]
#[Override]
public function register(): void {}
/**
@@ -79,13 +82,13 @@ class Handler extends ExceptionHandler
*
* @param Request $request
*
* @throws \Throwable
* @throws Throwable
*
* @SuppressWarnings("PHPMD.NPathComplexity")
* @SuppressWarnings("PHPMD.CyclomaticComplexity")
*/
#[\Override]
public function render($request, \Throwable $e): Response
#[Override]
public function render($request, Throwable $e): Response
{
$expectsJson = $request->expectsJson();
@@ -188,7 +191,7 @@ class Handler extends ExceptionHandler
return response()->view('errors.DatabaseException', ['exception' => $e, 'debug' => $isDebug], 500);
}
if ($e instanceof FireflyException || $e instanceof \ErrorException || $e instanceof OAuthServerException) {
if ($e instanceof FireflyException || $e instanceof ErrorException || $e instanceof OAuthServerException) {
app('log')->debug('Return Firefly III error view.');
$isDebug = config('app.debug');
@@ -203,10 +206,10 @@ class Handler extends ExceptionHandler
/**
* Report or log an exception.
*
* @throws \Throwable
* @throws Throwable
*/
#[\Override]
public function report(\Throwable $e): void
#[Override]
public function report(Throwable $e): void
{
$doMailError = (bool) config('firefly.send_error_message');
if ($this->shouldntReportLocal($e) || !$doMailError) {
@@ -250,7 +253,7 @@ class Handler extends ExceptionHandler
parent::report($e);
}
private function shouldntReportLocal(\Throwable $e): bool
private function shouldntReportLocal(Throwable $e): bool
{
return null !== Arr::first(
$this->dontReport,
@@ -263,7 +266,7 @@ class Handler extends ExceptionHandler
*
* @param Request $request
*/
#[\Override]
#[Override]
protected function invalid($request, LaravelValidationException $exception): \Illuminate\Http\Response|JsonResponse|RedirectResponse
{
// protect against open redirect when submitting invalid forms.

View File

@@ -25,11 +25,13 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use FireflyIII\Support\Calendar\Periodicity;
use Exception;
use Throwable;
/**
* Class IntervalException
*/
final class IntervalException extends \Exception
final class IntervalException extends Exception
{
public array $availableIntervals;
public Periodicity $periodicity;
@@ -37,7 +39,7 @@ final class IntervalException extends \Exception
/** @var mixed */
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null)
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
{
parent::__construct($message, $code, $previous);
$this->availableIntervals = [];
@@ -48,7 +50,7 @@ final class IntervalException extends \Exception
Periodicity $periodicity,
array $intervals,
int $code = 0,
?\Throwable $previous = null
?Throwable $previous = null
): self {
$message = sprintf(
'The periodicity %s is unknown. Choose one of available periodicity: %s',

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
/**
* Class NotImplementedException.
*/
class NotImplementedException extends \Exception {}
class NotImplementedException extends Exception {}

View File

@@ -24,7 +24,9 @@ declare(strict_types=1);
namespace FireflyIII\Exceptions;
use Exception;
/**
* Class ValidationExceptions.
*/
class ValidationException extends \Exception {}
class ValidationException extends Exception {}