This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -4,6 +4,12 @@ namespace Spatie\Ignition;
use ArrayObject;
use ErrorException;
use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable;
use Spatie\ErrorSolutions\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract;
use Spatie\ErrorSolutions\SolutionProviderRepository;
use Spatie\ErrorSolutions\SolutionProviders\BadMethodCallSolutionProvider;
use Spatie\ErrorSolutions\SolutionProviders\MergeConflictSolutionProvider;
use Spatie\ErrorSolutions\SolutionProviders\UndefinedPropertySolutionProvider;
use Spatie\FlareClient\Context\BaseContextProviderDetector;
use Spatie\FlareClient\Context\ContextProviderDetector;
use Spatie\FlareClient\Enums\MessageLevels;
@@ -13,14 +19,8 @@ use Spatie\FlareClient\FlareMiddleware\AddSolutions;
use Spatie\FlareClient\FlareMiddleware\FlareMiddleware;
use Spatie\FlareClient\Report;
use Spatie\Ignition\Config\IgnitionConfig;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
use Spatie\Ignition\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract;
use Spatie\Ignition\ErrorPage\ErrorPageViewModel;
use Spatie\Ignition\ErrorPage\Renderer;
use Spatie\Ignition\Solutions\SolutionProviders\BadMethodCallSolutionProvider;
use Spatie\Ignition\Solutions\SolutionProviders\MergeConflictSolutionProvider;
use Spatie\Ignition\Solutions\SolutionProviders\SolutionProviderRepository;
use Spatie\Ignition\Solutions\SolutionProviders\UndefinedPropertySolutionProvider;
use Throwable;
class Ignition
@@ -58,9 +58,10 @@ class Ignition
return new self();
}
public function __construct()
{
$this->flare = Flare::make();
public function __construct(
?Flare $flare = null,
) {
$this->flare = $flare ?? Flare::make();
$this->ignitionConfig = IgnitionConfig::loadFromConfigFile();
@@ -237,14 +238,14 @@ class Ignition
return $this;
}
public function register(): self
public function register(?int $errorLevels = null): self
{
error_reporting(-1);
error_reporting($errorLevels ?? -1);
/** @phpstan-ignore-next-line */
set_error_handler([$this, 'renderError']);
$errorLevels
? set_error_handler([$this, 'renderError'], $errorLevels)
: set_error_handler([$this, 'renderError']);
/** @phpstan-ignore-next-line */
set_exception_handler([$this, 'handleException']);
return $this;
@@ -267,6 +268,12 @@ class Ignition
int $line = 0,
array $context = []
): void {
if (error_reporting() === (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR | E_PARSE)) {
// This happens when PHP version is >=8 and we caught an error that was suppressed with the "@" operator
// See the first warning box in https://www.php.net/manual/en/language.operators.errorcontrol.php
return;
}
throw new ErrorException($message, 0, $level, $file, $line);
}