Файловый менеджер - Редактировать - /home/easybachat/hisabat365.com/4a7891/error-solutions.tar
Ðазад
phpstan.neon.dist 0000644 00000000235 15060171644 0010050 0 ustar 00 includes: - phpstan-baseline.neon parameters: level: 8 paths: - src tmpDir: build/phpstan checkMissingIterableValueType: true src/Support/Laravel/LivewireComponentParser.php 0000644 00000006225 15060171644 0015745 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Livewire\Component; use Livewire\LivewireManager; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; class LivewireComponentParser { /** @var class-string<Component> */ protected string $componentClass; /** @var ReflectionClass<Component> */ protected ReflectionClass $reflectionClass; public static function create(string $componentAlias): self { return new self($componentAlias); } public function __construct(protected string $componentAlias) { $this->componentClass = app(LivewireManager::class)->getClass($this->componentAlias); $this->reflectionClass = new ReflectionClass($this->componentClass); } public function getComponentClass(): string { return $this->componentClass; } /** @return Collection<int, string> */ public function getPropertyNamesLike(string $similar): Collection { $properties = collect($this->reflectionClass->getProperties(ReflectionProperty::IS_PUBLIC)) ->reject(fn (ReflectionProperty $reflectionProperty) => $reflectionProperty->class !== $this->reflectionClass->name) ->map(fn (ReflectionProperty $reflectionProperty) => $reflectionProperty->name); $computedProperties = collect($this->reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC)) ->reject(fn (ReflectionMethod $reflectionMethod) => $reflectionMethod->class !== $this->reflectionClass->name) ->filter(fn (ReflectionMethod $reflectionMethod) => str_starts_with($reflectionMethod->name, 'get') && str_ends_with($reflectionMethod->name, 'Property')) ->map(fn (ReflectionMethod $reflectionMethod) => lcfirst(Str::of($reflectionMethod->name)->after('get')->before('Property'))); return $this->filterItemsBySimilarity( $properties->merge($computedProperties), $similar ); } /** @return Collection<int, string> */ public function getMethodNamesLike(string $similar): Collection { $methods = collect($this->reflectionClass->getMethods(ReflectionMethod::IS_PUBLIC)) ->reject(fn (ReflectionMethod $reflectionMethod) => $reflectionMethod->class !== $this->reflectionClass->name) ->map(fn (ReflectionMethod $reflectionMethod) => $reflectionMethod->name); return $this->filterItemsBySimilarity($methods, $similar); } /** * @param Collection<int, string> $items * * @return Collection<int, string> */ protected function filterItemsBySimilarity(Collection $items, string $similar): Collection { return $items ->map(function (string $name) use ($similar) { similar_text($similar, $name, $percentage); return ['match' => $percentage, 'value' => $name]; }) ->sortByDesc('match') ->filter(function (array $item) { return $item['match'] > 40; }) ->map(function (array $item) { return $item['value']; }) ->values(); } } src/Support/Laravel/StringComparator.php 0000644 00000003050 15060171644 0014406 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel; use Illuminate\Support\Collection; class StringComparator { /** * @param array<int|string, string> $strings * @param string $input * @param int $sensitivity * * @return string|null */ public static function findClosestMatch(array $strings, string $input, int $sensitivity = 4): ?string { $closestDistance = -1; $closestMatch = null; foreach ($strings as $string) { $levenshteinDistance = levenshtein($input, $string); if ($levenshteinDistance === 0) { $closestMatch = $string; $closestDistance = 0; break; } if ($levenshteinDistance <= $closestDistance || $closestDistance < 0) { $closestMatch = $string; $closestDistance = $levenshteinDistance; } } if ($closestDistance <= $sensitivity) { return $closestMatch; } return null; } /** * @param array<int, string> $strings * @param string $input * * @return string|null */ public static function findSimilarText(array $strings, string $input): ?string { if (empty($strings)) { return null; } return Collection::make($strings) ->sortByDesc(function (string $string) use ($input) { similar_text($input, $string, $percentage); return $percentage; }) ->first(); } } src/Support/Laravel/Composer/FakeComposer.php 0000644 00000000703 15060171644 0015257 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel\Composer; class FakeComposer implements Composer { /** @return array<string, mixed> */ public function getClassMap(): array { return []; } /** @return array<string, mixed> */ public function getPrefixes(): array { return []; } /** @return array<string, mixed> */ public function getPrefixesPsr4(): array { return []; } } src/Support/Laravel/Composer/Composer.php 0000644 00000000525 15060171644 0014472 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel\Composer; interface Composer { /** @return array<string, mixed> */ public function getClassMap(): array; /** @return array<string, mixed> */ public function getPrefixes(): array; /** @return array<string, mixed> */ public function getPrefixesPsr4(): array; } src/Support/Laravel/Composer/ComposerClassMap.php 0000644 00000007373 15060171644 0016126 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel\Composer; use function app_path; use function base_path; use Illuminate\Support\Str; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; class ComposerClassMap { /** @var \Spatie\ErrorSolutions\Support\Laravel\Composer\Composer */ protected object $composer; protected string $basePath; public function __construct(?string $autoloaderPath = null) { $autoloaderPath = $autoloaderPath ?? base_path('/vendor/autoload.php'); $this->composer = file_exists($autoloaderPath) ? require $autoloaderPath : new FakeComposer(); $this->basePath = app_path(); } /** @return array<string, string> */ public function listClasses(): array { $classes = $this->composer->getClassMap(); return array_merge($classes, $this->listClassesInPsrMaps()); } public function searchClassMap(string $missingClass): ?string { foreach ($this->composer->getClassMap() as $fqcn => $file) { $basename = basename($file, '.php'); if ($basename === $missingClass) { return $fqcn; } } return null; } /** @return array<string, mixed> */ public function listClassesInPsrMaps(): array { // TODO: This is incorrect. Doesnt list all fqcns. Need to parse namespace? e.g. App\LoginController is wrong $prefixes = array_merge( $this->composer->getPrefixes(), $this->composer->getPrefixesPsr4() ); $classes = []; foreach ($prefixes as $namespace => $directories) { foreach ($directories as $directory) { if (file_exists($directory)) { $files = (new Finder) ->in($directory) ->files() ->name('*.php'); foreach ($files as $file) { if ($file instanceof SplFileInfo) { $fqcn = $this->getFullyQualifiedClassNameFromFile($namespace, $file); $classes[$fqcn] = $file->getRelativePathname(); } } } } } return $classes; } public function searchPsrMaps(string $missingClass): ?string { $prefixes = array_merge( $this->composer->getPrefixes(), $this->composer->getPrefixesPsr4() ); foreach ($prefixes as $namespace => $directories) { foreach ($directories as $directory) { if (file_exists($directory)) { $files = (new Finder) ->in($directory) ->files() ->name('*.php'); foreach ($files as $file) { if ($file instanceof SplFileInfo) { $basename = basename($file->getRelativePathname(), '.php'); if ($basename === $missingClass) { return $namespace . basename($file->getRelativePathname(), '.php'); } } } } } } return null; } protected function getFullyQualifiedClassNameFromFile(string $rootNamespace, SplFileInfo $file): string { $class = trim(str_replace($this->basePath, '', (string)$file->getRealPath()), DIRECTORY_SEPARATOR); $class = str_replace( [DIRECTORY_SEPARATOR, 'App\\'], ['\\', app()->getNamespace()], ucfirst(Str::replaceLast('.php', '', $class)) ); return $rootNamespace . $class; } } src/Support/Laravel/LaravelVersion.php 0000644 00000000273 15060171644 0014050 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support\Laravel; class LaravelVersion { public static function major(): string { return explode('.', app()->version())[0]; } } src/Support/AiPromptRenderer.php 0000644 00000001076 15060171644 0012752 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Support; class AiPromptRenderer { /** * @param array<string, mixed> $data * * @return void */ public function render(array $data, string $viewPath): void { $viewFile = $viewPath; extract($data, EXTR_OVERWRITE); include $viewFile; } /** * @param array<string, mixed> $data */ public function renderAsString(array $data, string $viewPath): string { ob_start(); $this->render($data, $viewPath); return ob_get_clean(); } } src/SolutionProviders/Laravel/IncorrectValetDbCredentialsSolutionProvider.php 0000644 00000003154 15060171644 0023773 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\UseDefaultValetDbCredentialsSolution; use Throwable; class IncorrectValetDbCredentialsSolutionProvider implements HasSolutionsForThrowable { const MYSQL_ACCESS_DENIED_CODE = 1045; public function canSolve(Throwable $throwable): bool { if (PHP_OS !== 'Darwin') { return false; } if (! $throwable instanceof QueryException) { return false; } if (! $this->isAccessDeniedCode($throwable->getCode())) { return false; } if (! $this->envFileExists()) { return false; } if (! $this->isValetInstalled()) { return false; } if ($this->usingCorrectDefaultCredentials()) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [new UseDefaultValetDbCredentialsSolution()]; } protected function envFileExists(): bool { return file_exists(base_path('.env')); } protected function isAccessDeniedCode(string $code): bool { return $code === static::MYSQL_ACCESS_DENIED_CODE; } protected function isValetInstalled(): bool { return file_exists('/usr/local/bin/valet'); } protected function usingCorrectDefaultCredentials(): bool { return env('DB_USERNAME') === 'root' && env('DB_PASSWORD') === ''; } } src/SolutionProviders/Laravel/UndefinedLivewirePropertySolutionProvider.php 0000644 00000003234 15060171644 0023577 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Livewire\Exceptions\PropertyNotFoundException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewirePropertyNameSolution; use Spatie\ErrorSolutions\Support\Laravel\LivewireComponentParser; use Throwable; class UndefinedLivewirePropertySolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { return $throwable instanceof PropertyNotFoundException; } public function getSolutions(Throwable $throwable): array { ['variable' => $variable, 'component' => $component] = $this->getMethodAndComponent($throwable); if ($variable === null || $component === null) { return []; } $parsed = LivewireComponentParser::create($component); return $parsed->getPropertyNamesLike($variable) ->map(function (string $suggested) use ($parsed, $variable) { return new SuggestLivewirePropertyNameSolution( $variable, $parsed->getComponentClass(), '$'.$suggested ); }) ->toArray(); } /** * @param \Throwable $throwable * * @return array<string, string|null> */ protected function getMethodAndComponent(Throwable $throwable): array { preg_match_all('/\[([\d\w\-_\$]*)\]/m', $throwable->getMessage(), $matches, PREG_SET_ORDER, 0); return [ 'variable' => $matches[0][1] ?? null, 'component' => $matches[1][1] ?? null, ]; } } src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php 0000644 00000007466 15060171644 0021024 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Arr; use Illuminate\Support\Facades\View; use InvalidArgumentException; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\StringComparator; use Spatie\Ignition\Exceptions\ViewException as IgnitionViewException; use Spatie\LaravelFlare\Exceptions\ViewException as FlareViewException; use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\SplFileInfo; use Throwable; class ViewNotFoundSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/View \[(.*)\] not found/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof InvalidArgumentException && (! $throwable instanceof IgnitionViewException || ! $throwable instanceof FlareViewException)) { return false; } return (bool)preg_match(self::REGEX, $throwable->getMessage(), $matches); } public function getSolutions(Throwable $throwable): array { preg_match(self::REGEX, $throwable->getMessage(), $matches); $missingView = $matches[1] ?? null; $suggestedView = $this->findRelatedView($missingView); if ($suggestedView) { return [ BaseSolution::create() ->setSolutionTitle("{$missingView} was not found.") ->setSolutionDescription("Did you mean `{$suggestedView}`?"), ]; } return [ BaseSolution::create() ->setSolutionTitle("{$missingView} was not found.") ->setSolutionDescription('Are you sure the view exists and is a `.blade.php` file?'), ]; } protected function findRelatedView(string $missingView): ?string { $views = $this->getAllViews(); return StringComparator::findClosestMatch($views, $missingView); } /** @return array<int, string> */ protected function getAllViews(): array { /** @var \Illuminate\View\FileViewFinder $fileViewFinder */ $fileViewFinder = View::getFinder(); $extensions = $fileViewFinder->getExtensions(); $viewsForHints = collect($fileViewFinder->getHints()) ->flatMap(function ($paths, string $namespace) use ($extensions) { $paths = Arr::wrap($paths); return collect($paths) ->flatMap(fn (string $path) => $this->getViewsInPath($path, $extensions)) ->map(fn (string $view) => "{$namespace}::{$view}") ->toArray(); }); $viewsForViewPaths = collect($fileViewFinder->getPaths()) ->flatMap(fn (string $path) => $this->getViewsInPath($path, $extensions)); return $viewsForHints->merge($viewsForViewPaths)->toArray(); } /** * @param string $path * @param array<int, string> $extensions * * @return array<int, string> */ protected function getViewsInPath(string $path, array $extensions): array { $filePatterns = array_map(fn (string $extension) => "*.{$extension}", $extensions); $extensionsWithDots = array_map(fn (string $extension) => ".{$extension}", $extensions); $files = (new Finder()) ->in($path) ->files(); foreach ($filePatterns as $filePattern) { $files->name($filePattern); } $views = []; foreach ($files as $file) { if ($file instanceof SplFileInfo) { $view = $file->getRelativePathname(); $view = str_replace($extensionsWithDots, '', $view); $view = str_replace('/', '.', $view); $views[] = $view; } } return $views; } } src/SolutionProviders/Laravel/MissingAppKeySolutionProvider.php 0000644 00000001264 15060171644 0021146 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use RuntimeException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\GenerateAppKeySolution; use Throwable; class MissingAppKeySolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof RuntimeException) { return false; } return $throwable->getMessage() === 'No application encryption key has been specified.'; } public function getSolutions(Throwable $throwable): array { return [new GenerateAppKeySolution()]; } } src/SolutionProviders/Laravel/MissingLivewireComponentSolutionProvider.php 0000644 00000002130 15060171644 0023417 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Livewire\Exceptions\ComponentNotFoundException; use Livewire\LivewireComponentsFinder; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\LivewireDiscoverSolution; use Throwable; class MissingLivewireComponentSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if (! $this->livewireIsInstalled()) { return false; } if (! $throwable instanceof ComponentNotFoundException) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [new LivewireDiscoverSolution('A Livewire component was not found')]; } public function livewireIsInstalled(): bool { if (! class_exists(ComponentNotFoundException::class)) { return false; } if (! class_exists(LivewireComponentsFinder::class)) { return false; } return true; } } src/SolutionProviders/Laravel/OpenAiSolutionProvider.php 0000644 00000002127 15060171644 0017575 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Str; use OpenAI\Client; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionProvider as BaseOpenAiSolutionProvider; use Throwable; class OpenAiSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if (! class_exists(Client::class)) { return false; } if (config('ErrorSolutions.open_ai_key') === null) { return false; } return true; } public function getSolutions(Throwable $throwable): array { $solutionProvider = new BaseOpenAiSolutionProvider( openAiKey: config('ErrorSolutions.open_ai_key'), cache: cache()->store(config('cache.default')), cacheTtlInSeconds: 60, applicationType: 'Laravel ' . Str::before(app()->version(), '.'), applicationPath: base_path(), ); return $solutionProvider->getSolutions($throwable); } } src/SolutionProviders/Laravel/UndefinedLivewireMethodSolutionProvider.php 0000644 00000003136 15060171644 0023174 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Livewire\Exceptions\MethodNotFoundException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewireMethodNameSolution; use Spatie\ErrorSolutions\Support\Laravel\LivewireComponentParser; use Throwable; class UndefinedLivewireMethodSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { return $throwable instanceof MethodNotFoundException; } public function getSolutions(Throwable $throwable): array { ['methodName' => $methodName, 'component' => $component] = $this->getMethodAndComponent($throwable); if ($methodName === null || $component === null) { return []; } $parsed = LivewireComponentParser::create($component); return $parsed->getMethodNamesLike($methodName) ->map(function (string $suggested) use ($parsed, $methodName) { return new SuggestLivewireMethodNameSolution( $methodName, $parsed->getComponentClass(), $suggested ); }) ->toArray(); } /** @return array<string, string|null> */ protected function getMethodAndComponent(Throwable $throwable): array { preg_match_all('/\[([\d\w\-_]*)\]/m', $throwable->getMessage(), $matches, PREG_SET_ORDER); return [ 'methodName' => $matches[0][1] ?? null, 'component' => $matches[1][1] ?? null, ]; } } src/SolutionProviders/Laravel/LazyLoadingViolationSolutionProvider.php 0000644 00000002613 15060171644 0022524 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\LazyLoadingViolationException; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\LaravelVersion; use Throwable; class LazyLoadingViolationSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if ($throwable instanceof LazyLoadingViolationException) { return true; } if (! $previous = $throwable->getPrevious()) { return false; } return $previous instanceof LazyLoadingViolationException; } public function getSolutions(Throwable $throwable): array { $majorVersion = LaravelVersion::major(); return [BaseSolution::create( 'Lazy loading was disabled to detect N+1 problems' ) ->setSolutionDescription( 'Either avoid lazy loading the relation or allow lazy loading.' ) ->setDocumentationLinks([ 'Read the docs on preventing lazy loading' => "https://laravel.com/docs/{$majorVersion}.x/eloquent-relationships#preventing-lazy-loading", 'Watch a video on how to deal with the N+1 problem' => 'https://www.youtube.com/watch?v=ZE7KBeraVpc', ]),]; } } src/SolutionProviders/Laravel/RunningLaravelDuskInProductionProvider.php 0000644 00000002133 15060171644 0022776 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Exception; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class RunningLaravelDuskInProductionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof Exception) { return false; } return $throwable->getMessage() === 'It is unsafe to run Dusk in production.'; } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create() ->setSolutionTitle('Laravel Dusk should not be run in production.') ->setSolutionDescription('Install the dependencies with the `--no-dev` flag.'), BaseSolution::create() ->setSolutionTitle('Laravel Dusk can be run in other environments.') ->setSolutionDescription('Consider setting the `APP_ENV` to something other than `production` like `local` for example.'), ]; } } src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php 0000644 00000007275 15060171644 0022635 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Contracts\Solution; use Spatie\ErrorSolutions\Solutions\Laravel\MakeViewVariableOptionalSolution; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestCorrectVariableNameSolution; use Spatie\LaravelFlare\Exceptions\ViewException as FlareViewException; use Spatie\LaravelIgnition\Exceptions\ViewException as IgnitionViewException; use Throwable; class UndefinedViewVariableSolutionProvider implements HasSolutionsForThrowable { protected string $variableName; protected string $viewFile; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof IgnitionViewException && ! $throwable instanceof FlareViewException) { return false; } return $this->getNameAndView($throwable) !== null; } public function getSolutions(Throwable $throwable): array { $solutions = []; /** @phpstan-ignore-next-line */ extract($this->getNameAndView($throwable)); if (! isset($variableName)) { return []; } if (isset($viewFile)) { /** @phpstan-ignore-next-line */ $solutions = $this->findCorrectVariableSolutions($throwable, $variableName, $viewFile); $solutions[] = $this->findOptionalVariableSolution($variableName, $viewFile); } return $solutions; } /** * @param IgnitionViewException|FlareViewException $throwable * @param string $variableName * @param string $viewFile * * @return array<int, \Spatie\ErrorSolutions\Contracts\Solution> */ protected function findCorrectVariableSolutions( IgnitionViewException|FlareViewException $throwable, string $variableName, string $viewFile ): array { return collect($throwable->getViewData()) ->map(function ($value, $key) use ($variableName) { similar_text($variableName, $key, $percentage); return ['match' => $percentage, 'value' => $value]; }) ->sortByDesc('match') ->filter(fn ($var) => $var['match'] > 40) ->keys() ->map(fn ($suggestion) => new SuggestCorrectVariableNameSolution($variableName, $viewFile, $suggestion)) ->map(function ($solution) { return $solution->isRunnable() ? $solution : BaseSolution::create($solution->getSolutionTitle()) ->setSolutionDescription($solution->getSolutionDescription()); }) ->toArray(); } protected function findOptionalVariableSolution(string $variableName, string $viewFile): Solution { $optionalSolution = new MakeViewVariableOptionalSolution($variableName, $viewFile); return $optionalSolution->isRunnable() ? $optionalSolution : BaseSolution::create($optionalSolution->getSolutionTitle()) ->setSolutionDescription($optionalSolution->getSolutionDescription()); } /** * @param \Throwable $throwable * * @return array<string, string>|null */ protected function getNameAndView(Throwable $throwable): ?array { $pattern = '/Undefined variable:? (.*?) \(View: (.*?)\)/'; preg_match($pattern, $throwable->getMessage(), $matches); if (count($matches) === 3) { [, $variableName, $viewFile] = $matches; $variableName = ltrim($variableName, '$'); return compact('variableName', 'viewFile'); } return null; } } src/SolutionProviders/Laravel/UnknownMariadbCollationSolutionProvider.php 0000644 00000001661 15060171644 0023210 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMariadbDatabaseSolution; use Throwable; class UnknownMariadbCollationSolutionProvider implements HasSolutionsForThrowable { const MYSQL_UNKNOWN_COLLATION_CODE = 1273; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof QueryException) { return false; } if ($throwable->getCode() !== self::MYSQL_UNKNOWN_COLLATION_CODE) { return false; } return str_contains( $throwable->getMessage(), 'Unknown collation: \'utf8mb4_uca1400_ai_ci\'' ); } public function getSolutions(Throwable $throwable): array { return [new SuggestUsingMariadbDatabaseSolution()]; } } src/SolutionProviders/Laravel/InvalidRouteActionSolutionProvider.php 0000644 00000005760 15060171644 0022173 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Str; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\Composer\ComposerClassMap; use Spatie\ErrorSolutions\Support\Laravel\StringComparator; use Throwable; use UnexpectedValueException; class InvalidRouteActionSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/\[([a-zA-Z\\\\]+)\]/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof UnexpectedValueException) { return false; } if (! preg_match(self::REGEX, $throwable->getMessage(), $matches)) { return false; } return Str::startsWith($throwable->getMessage(), 'Invalid route action: '); } public function getSolutions(Throwable $throwable): array { preg_match(self::REGEX, $throwable->getMessage(), $matches); $invalidController = $matches[1] ?? null; if (! $invalidController) { return []; } $suggestedController = $this->findRelatedController($invalidController); if ($suggestedController === $invalidController) { return [ BaseSolution::create("`{$invalidController}` is not invokable.") ->setSolutionDescription("The controller class `{$invalidController}` is not invokable. Did you forget to add the `__invoke` method or is the controller's method missing in your routes file?"), ]; } if ($suggestedController) { return [ BaseSolution::create("`{$invalidController}` was not found.") ->setSolutionDescription("Controller class `{$invalidController}` for one of your routes was not found. Did you mean `{$suggestedController}`?"), ]; } return [ BaseSolution::create("`{$invalidController}` was not found.") ->setSolutionDescription("Controller class `{$invalidController}` for one of your routes was not found. Are you sure this controller exists and is imported correctly?"), ]; } protected function findRelatedController(string $invalidController): ?string { $composerClassMap = app(ComposerClassMap::class); $controllers = collect($composerClassMap->listClasses()) ->filter(function (string $file, string $fqcn) { return Str::endsWith($fqcn, 'Controller'); }) ->mapWithKeys(function (string $file, string $fqcn) { return [$fqcn => class_basename($fqcn)]; }) ->toArray(); $basenameMatch = StringComparator::findClosestMatch($controllers, $invalidController, 4); $controllers = array_flip($controllers); $fqcnMatch = StringComparator::findClosestMatch($controllers, $invalidController, 4); return $fqcnMatch ?? $basenameMatch; } } src/SolutionProviders/Laravel/SailNetworkSolutionProvider.php 0000644 00000002030 15060171644 0020655 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class SailNetworkSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { return app()->runningInConsole() && str_contains($throwable->getMessage(), 'php_network_getaddresses') && file_exists(base_path('vendor/bin/sail')) && file_exists(base_path('docker-compose.yml')) && env('LARAVEL_SAIL') === null; } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create('Network address not found') ->setSolutionDescription('Did you mean to use `sail artisan`?') ->setDocumentationLinks([ 'Sail: Executing Artisan Commands' => 'https://laravel.com/docs/sail#executing-artisan-commands', ]), ]; } } src/SolutionProviders/Laravel/RouteNotDefinedSolutionProvider.php 0000644 00000003206 15060171644 0021457 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Facades\Route; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\StringComparator; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Throwable; class RouteNotDefinedSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/Route \[(.*)\] not defined/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof RouteNotFoundException) { return false; } return (bool)preg_match(self::REGEX, $throwable->getMessage(), $matches); } public function getSolutions(Throwable $throwable): array { preg_match(self::REGEX, $throwable->getMessage(), $matches); $missingRoute = $matches[1] ?? ''; $suggestedRoute = $this->findRelatedRoute($missingRoute); if ($suggestedRoute) { return [ BaseSolution::create("{$missingRoute} was not defined.") ->setSolutionDescription("Did you mean `{$suggestedRoute}`?"), ]; } return [ BaseSolution::create("{$missingRoute} was not defined.") ->setSolutionDescription('Are you sure that the route is defined'), ]; } protected function findRelatedRoute(string $missingRoute): ?string { Route::getRoutes()->refreshNameLookups(); return StringComparator::findClosestMatch(array_keys(Route::getRoutes()->getRoutesByName()), $missingRoute); } } src/SolutionProviders/Laravel/UnknownMysql8CollationSolutionProvider.php 0000644 00000001653 15060171644 0023047 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMysql8DatabaseSolution; use Throwable; class UnknownMysql8CollationSolutionProvider implements HasSolutionsForThrowable { const MYSQL_UNKNOWN_COLLATION_CODE = 1273; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof QueryException) { return false; } if ($throwable->getCode() !== self::MYSQL_UNKNOWN_COLLATION_CODE) { return false; } return str_contains( $throwable->getMessage(), 'Unknown collation: \'utf8mb4_0900_ai_ci\'' ); } public function getSolutions(Throwable $throwable): array { return [new SuggestUsingMysql8DatabaseSolution()]; } } src/SolutionProviders/Laravel/MissingColumnSolutionProvider.php 0000644 00000001743 15060171644 0021214 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\RunMigrationsSolution; use Throwable; class MissingColumnSolutionProvider implements HasSolutionsForThrowable { /** * See https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html#error_er_bad_field_error. */ const MYSQL_BAD_FIELD_CODE = '42S22'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof QueryException) { return false; } return $this->isBadTableErrorCode($throwable->getCode()); } protected function isBadTableErrorCode(string $code): bool { return $code === static::MYSQL_BAD_FIELD_CODE; } public function getSolutions(Throwable $throwable): array { return [new RunMigrationsSolution('A column was not found')]; } } src/SolutionProviders/Laravel/GenericLaravelExceptionSolutionProvider.php 0000644 00000003447 15060171644 0023172 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Broadcasting\BroadcastException; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\LaravelVersion; use Throwable; class GenericLaravelExceptionSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { return ! is_null($this->getSolutionTexts($throwable)); } public function getSolutions(Throwable $throwable): array { if (! $texts = $this->getSolutionTexts($throwable)) { return []; } $solution = BaseSolution::create($texts['title']) ->setSolutionDescription($texts['description']) ->setDocumentationLinks($texts['links']); return ([$solution]); } /** * @param \Throwable $throwable * * @return array<string, mixed>|null */ protected function getSolutionTexts(Throwable $throwable) : ?array { foreach ($this->getSupportedExceptions() as $supportedClass => $texts) { if ($throwable instanceof $supportedClass) { return $texts; } } return null; } /** @return array<string, mixed> */ protected function getSupportedExceptions(): array { $majorVersion = LaravelVersion::major(); return [ BroadcastException::class => [ 'title' => 'Here are some links that might help solve this problem', 'description' => '', 'links' => [ 'Laravel docs on authentication' => "https://laravel.com/docs/{$majorVersion}.x/authentication", ], ], ]; } } src/SolutionProviders/Laravel/UnknownValidationSolutionProvider.php 0000644 00000004754 15060171644 0022104 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use BadMethodCallException; use Illuminate\Support\Collection; use Illuminate\Support\Str; use Illuminate\Validation\Validator; use ReflectionClass; use ReflectionMethod; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Support\Laravel\StringComparator; use Throwable; class UnknownValidationSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/Illuminate\\\\Validation\\\\Validator::(?P<method>validate(?!(Attribute|UsingCustomRule))[A-Z][a-zA-Z]+)/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof BadMethodCallException) { return false; } return ! is_null($this->getMethodFromExceptionMessage($throwable->getMessage())); } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create() ->setSolutionTitle('Unknown Validation Rule') ->setSolutionDescription($this->getSolutionDescription($throwable)), ]; } protected function getSolutionDescription(Throwable $throwable): string { $method = (string)$this->getMethodFromExceptionMessage($throwable->getMessage()); $possibleMethod = StringComparator::findSimilarText( $this->getAvailableMethods()->toArray(), $method ); if (empty($possibleMethod)) { return ''; } $rule = Str::snake(str_replace('validate', '', $possibleMethod)); return "Did you mean `{$rule}` ?"; } protected function getMethodFromExceptionMessage(string $message): ?string { if (! preg_match(self::REGEX, $message, $matches)) { return null; } return $matches['method']; } protected function getAvailableMethods(): Collection { $class = new ReflectionClass(Validator::class); $extensions = Collection::make((app('validator')->make([], []))->extensions) ->keys() ->map(fn (string $extension) => 'validate'.Str::studly($extension)); return Collection::make($class->getMethods()) ->filter(fn (ReflectionMethod $method) => preg_match('/(validate(?!(Attribute|UsingCustomRule))[A-Z][a-zA-Z]+)/', $method->name)) ->map(fn (ReflectionMethod $method) => $method->name) ->merge($extensions); } } src/SolutionProviders/Laravel/MissingImportSolutionProvider.php 0000644 00000002657 15060171644 0021236 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\SuggestImportSolution; use Spatie\ErrorSolutions\Support\Laravel\Composer\ComposerClassMap; use Throwable; class MissingImportSolutionProvider implements HasSolutionsForThrowable { protected ?string $foundClass; protected ComposerClassMap $composerClassMap; public function canSolve(Throwable $throwable): bool { $pattern = '/Class \"([^\s]+)\" not found/m'; if (! preg_match($pattern, $throwable->getMessage(), $matches)) { return false; } $class = $matches[1]; $this->composerClassMap = new ComposerClassMap(); $this->search($class); return ! is_null($this->foundClass); } /** * @param \Throwable $throwable * * @return array<int, SuggestImportSolution> */ public function getSolutions(Throwable $throwable): array { if (is_null($this->foundClass)) { return []; } return [new SuggestImportSolution($this->foundClass)]; } protected function search(string $missingClass): void { $this->foundClass = $this->composerClassMap->searchClassMap($missingClass); if (is_null($this->foundClass)) { $this->foundClass = $this->composerClassMap->searchPsrMaps($missingClass); } } } src/SolutionProviders/Laravel/DefaultDbNameSolutionProvider.php 0000644 00000001632 15060171644 0021055 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingCorrectDbNameSolution; use Throwable; class DefaultDbNameSolutionProvider implements HasSolutionsForThrowable { const MYSQL_UNKNOWN_DATABASE_CODE = 1049; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof QueryException) { return false; } if ($throwable->getCode() !== self::MYSQL_UNKNOWN_DATABASE_CODE) { return false; } if (! in_array(env('DB_DATABASE'), ['homestead', 'laravel'])) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [new SuggestUsingCorrectDbNameSolution()]; } } src/SolutionProviders/Laravel/MissingMixManifestSolutionProvider.php 0000644 00000001320 15060171644 0022172 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Str; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class MissingMixManifestSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { return Str::startsWith($throwable->getMessage(), 'Mix manifest not found'); } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create('Missing Mix Manifest File') ->setSolutionDescription('Did you forget to run `npm install && npm run dev`?'), ]; } } src/SolutionProviders/Laravel/MissingViteManifestSolutionProvider.php 0000644 00000003470 15060171644 0022354 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Support\Str; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Contracts\Solution; use Throwable; class MissingViteManifestSolutionProvider implements HasSolutionsForThrowable { /** @var array<string, string> */ protected array $links = [ 'Asset bundling with Vite' => 'https://laravel.com/docs/9.x/vite#running-vite', ]; public function canSolve(Throwable $throwable): bool { return Str::startsWith($throwable->getMessage(), 'Vite manifest not found'); } public function getSolutions(Throwable $throwable): array { return [ $this->getSolution(), ]; } public function getSolution(): Solution { /** @var string */ $baseCommand = collect([ 'pnpm-lock.yaml' => 'pnpm', 'yarn.lock' => 'yarn', ])->first(fn ($_, $lockfile) => file_exists(base_path($lockfile)), 'npm run'); return app()->environment('local') ? $this->getLocalSolution($baseCommand) : $this->getProductionSolution($baseCommand); } protected function getLocalSolution(string $baseCommand): Solution { return BaseSolution::create('Start the development server') ->setSolutionDescription("Run `{$baseCommand} dev` in your terminal and refresh the page.") ->setDocumentationLinks($this->links); } protected function getProductionSolution(string $baseCommand): Solution { return BaseSolution::create('Build the production assets') ->setSolutionDescription("Run `{$baseCommand} build` in your deployment script.") ->setDocumentationLinks($this->links); } } src/SolutionProviders/Laravel/TableNotFoundSolutionProvider.php 0000644 00000001742 15060171644 0021130 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders\Laravel; use Illuminate\Database\QueryException; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Solutions\Laravel\RunMigrationsSolution; use Throwable; class TableNotFoundSolutionProvider implements HasSolutionsForThrowable { /** * See https://dev.mysql.com/doc/refman/8.0/en/server-error-reference.html#error_er_bad_table_error. */ const MYSQL_BAD_TABLE_CODE = '42S02'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof QueryException) { return false; } return $this->isBadTableErrorCode($throwable->getCode()); } protected function isBadTableErrorCode(string $code): bool { return $code === static::MYSQL_BAD_TABLE_CODE; } public function getSolutions(Throwable $throwable): array { return [new RunMigrationsSolution('A table was not found')]; } } src/SolutionProviders/UndefinedPropertySolutionProvider.php 0000644 00000006736 15060171644 0020514 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders; use ErrorException; use Illuminate\Support\Collection; use ReflectionClass; use ReflectionProperty; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class UndefinedPropertySolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/([a-zA-Z\\\\]+)::\$([a-zA-Z]+)/m'; protected const MINIMUM_SIMILARITY = 80; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof ErrorException) { return false; } if (is_null($this->getClassAndPropertyFromExceptionMessage($throwable->getMessage()))) { return false; } if (! $this->similarPropertyExists($throwable)) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create('Unknown Property') ->setSolutionDescription($this->getSolutionDescription($throwable)), ]; } public function getSolutionDescription(Throwable $throwable): string { if (! $this->canSolve($throwable) || ! $this->similarPropertyExists($throwable)) { return ''; } extract( /** @phpstan-ignore-next-line */ $this->getClassAndPropertyFromExceptionMessage($throwable->getMessage()), EXTR_OVERWRITE, ); $possibleProperty = $this->findPossibleProperty($class ?? '', $property ?? ''); $class = $class ?? ''; return "Did you mean {$class}::\${$possibleProperty->name} ?"; } protected function similarPropertyExists(Throwable $throwable): bool { /** @phpstan-ignore-next-line */ extract($this->getClassAndPropertyFromExceptionMessage($throwable->getMessage()), EXTR_OVERWRITE); $possibleProperty = $this->findPossibleProperty($class ?? '', $property ?? ''); return $possibleProperty !== null; } /** * @param string $message * * @return null|array<string, string> */ protected function getClassAndPropertyFromExceptionMessage(string $message): ?array { if (! preg_match(self::REGEX, $message, $matches)) { return null; } return [ 'class' => $matches[1], 'property' => $matches[2], ]; } /** * @param class-string $class * @param string $invalidPropertyName * * @return mixed */ protected function findPossibleProperty(string $class, string $invalidPropertyName): mixed { return $this->getAvailableProperties($class) ->sortByDesc(function (ReflectionProperty $property) use ($invalidPropertyName) { similar_text($invalidPropertyName, $property->name, $percentage); return $percentage; }) ->filter(function (ReflectionProperty $property) use ($invalidPropertyName) { similar_text($invalidPropertyName, $property->name, $percentage); return $percentage >= self::MINIMUM_SIMILARITY; })->first(); } /** * @param class-string $class * * @return Collection<int, ReflectionProperty> */ protected function getAvailableProperties(string $class): Collection { $class = new ReflectionClass($class); return Collection::make($class->getProperties()); } } src/SolutionProviders/MergeConflictSolutionProvider.php 0000644 00000004100 15060171644 0017546 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders; use Illuminate\Support\Str; use ParseError; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class MergeConflictSolutionProvider implements HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool { if (! ($throwable instanceof ParseError)) { return false; } if (! $this->hasMergeConflictExceptionMessage($throwable)) { return false; } $file = (string)file_get_contents($throwable->getFile()); if (! str_contains($file, '=======')) { return false; } if (! str_contains($file, '>>>>>>>')) { return false; } return true; } public function getSolutions(Throwable $throwable): array { $file = (string)file_get_contents($throwable->getFile()); preg_match('/\>\>\>\>\>\>\> (.*?)\n/', $file, $matches); $source = $matches[1]; $target = $this->getCurrentBranch(basename($throwable->getFile())); return [ BaseSolution::create("Merge conflict from branch '$source' into $target") ->setSolutionDescription('You have a Git merge conflict. To undo your merge do `git reset --hard HEAD`'), ]; } protected function getCurrentBranch(string $directory): string { $branch = "'".trim((string)shell_exec("cd {$directory}; git branch | grep \\* | cut -d ' ' -f2"))."'"; if ($branch === "''") { $branch = 'current branch'; } return $branch; } protected function hasMergeConflictExceptionMessage(Throwable $throwable): bool { // For PHP 7.x and below if (Str::startsWith($throwable->getMessage(), 'syntax error, unexpected \'<<\'')) { return true; } // For PHP 8+ if (Str::startsWith($throwable->getMessage(), 'syntax error, unexpected token "<<"')) { return true; } return false; } } src/SolutionProviders/BadMethodCallSolutionProvider.php 0000644 00000005243 15060171644 0017461 0 ustar 00 <?php namespace Spatie\ErrorSolutions\SolutionProviders; use BadMethodCallException; use Illuminate\Support\Collection; use ReflectionClass; use ReflectionMethod; use Spatie\ErrorSolutions\Contracts\BaseSolution; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class BadMethodCallSolutionProvider implements HasSolutionsForThrowable { protected const REGEX = '/([a-zA-Z\\\\]+)::([a-zA-Z]+)/m'; public function canSolve(Throwable $throwable): bool { if (! $throwable instanceof BadMethodCallException) { return false; } if (is_null($this->getClassAndMethodFromExceptionMessage($throwable->getMessage()))) { return false; } return true; } public function getSolutions(Throwable $throwable): array { return [ BaseSolution::create('Bad Method Call') ->setSolutionDescription($this->getSolutionDescription($throwable)), ]; } public function getSolutionDescription(Throwable $throwable): string { if (! $this->canSolve($throwable)) { return ''; } /** @phpstan-ignore-next-line */ extract($this->getClassAndMethodFromExceptionMessage($throwable->getMessage()), EXTR_OVERWRITE); $possibleMethod = $this->findPossibleMethod($class ?? '', $method ?? ''); $class ??= 'UnknownClass'; return "Did you mean {$class}::{$possibleMethod?->name}() ?"; } /** * @param string $message * * @return null|array<string, mixed> */ protected function getClassAndMethodFromExceptionMessage(string $message): ?array { if (! preg_match(self::REGEX, $message, $matches)) { return null; } return [ 'class' => $matches[1], 'method' => $matches[2], ]; } /** * @param class-string $class * @param string $invalidMethodName * * @return \ReflectionMethod|null */ protected function findPossibleMethod(string $class, string $invalidMethodName): ?ReflectionMethod { return $this->getAvailableMethods($class) ->sortByDesc(function (ReflectionMethod $method) use ($invalidMethodName) { similar_text($invalidMethodName, $method->name, $percentage); return $percentage; })->first(); } /** * @param class-string $class * * @return \Illuminate\Support\Collection<int, ReflectionMethod> */ protected function getAvailableMethods(string $class): Collection { $class = new ReflectionClass($class); return Collection::make($class->getMethods()); } } src/Solutions/Laravel/UseDefaultValetDbCredentialsSolution.php 0000644 00000003165 15060171644 0020660 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Illuminate\Support\Str; use Spatie\ErrorSolutions\Contracts\RunnableSolution; class UseDefaultValetDbCredentialsSolution implements RunnableSolution { public function getSolutionActionDescription(): string { return 'Pressing the button will change `DB_USER` and `DB_PASSWORD` in your `.env` file.'; } public function getRunButtonText(): string { return 'Use default Valet credentials'; } public function getSolutionTitle(): string { return 'Could not connect to database'; } public function run(array $parameters = []): void { if (! file_exists(base_path('.env'))) { return; } $this->ensureLineExists('DB_USERNAME', 'root'); $this->ensureLineExists('DB_PASSWORD', ''); } protected function ensureLineExists(string $key, string $value): void { $envPath = base_path('.env'); $envLines = array_map(fn (string $envLine) => Str::startsWith($envLine, $key) ? "{$key}={$value}".PHP_EOL : $envLine, file($envPath) ?: []); file_put_contents($envPath, implode('', $envLines)); } public function getRunParameters(): array { return []; } public function getDocumentationLinks(): array { return [ 'Valet documentation' => 'https://laravel.com/docs/master/valet', ]; } public function getSolutionDescription(): string { return 'You seem to be using Valet, but the .env file does not contain the right default database credentials.'; } } src/Solutions/Laravel/SuggestLivewireMethodNameSolution.php 0000644 00000001405 15060171644 0020264 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestLivewireMethodNameSolution implements Solution { public function __construct( protected string $methodName, protected string $componentClass, protected string $suggested ) { } public function getSolutionTitle(): string { return "Possible typo `{$this->componentClass}::{$this->methodName}`"; } public function getDocumentationLinks(): array { return []; } public function getSolutionDescription(): string { return "Did you mean `{$this->componentClass}::{$this->suggested}`?"; } public function isRunnable(): bool { return false; } } src/Solutions/Laravel/SuggestUsingMysql8DatabaseSolution.php 0000644 00000001537 15060171644 0020372 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestUsingMysql8DatabaseSolution implements Solution { public function getSolutionTitle(): string { return 'Database is not a MySQL 8 database'; } public function getSolutionDescription(): string { return "Laravel 11 changed the default collation for MySQL and MariaDB. It seems you are trying to use the MySQL 8 collation `utf8mb4_0900_ai_ci` with a MariaDB or MySQL 5.7 database.\n\nEdit the `.env` file and use the correct database in the `DB_CONNECTION` key."; } /** @return array<string, string> */ public function getDocumentationLinks(): array { return [ 'Database: Getting Started docs' => 'https://laravel.com/docs/master/database#configuration', ]; } } src/Solutions/Laravel/LivewireDiscoverSolution.php 0000644 00000002370 15060171644 0016461 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Livewire\LivewireComponentsFinder; use Spatie\ErrorSolutions\Contracts\RunnableSolution; class LivewireDiscoverSolution implements RunnableSolution { protected string $customTitle; public function __construct(string $customTitle = '') { $this->customTitle = $customTitle; } public function getSolutionTitle(): string { return $this->customTitle; } public function getSolutionDescription(): string { return 'You might have forgotten to discover your Livewire components.'; } public function getDocumentationLinks(): array { return [ 'Livewire: Artisan Commands' => 'https://laravel-livewire.com/docs/2.x/artisan-commands', ]; } public function getRunParameters(): array { return []; } public function getSolutionActionDescription(): string { return 'You can discover your Livewire components using `php artisan livewire:discover`.'; } public function getRunButtonText(): string { return 'Run livewire:discover'; } public function run(array $parameters = []): void { app(LivewireComponentsFinder::class)->build(); } } src/Solutions/Laravel/SuggestUsingCorrectDbNameSolution.php 0000644 00000001475 15060171644 0020221 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestUsingCorrectDbNameSolution implements Solution { public function getSolutionTitle(): string { return 'Database name seems incorrect'; } public function getSolutionDescription(): string { $defaultDatabaseName = env('DB_DATABASE'); return "You're using the default database name `$defaultDatabaseName`. This database does not exist.\n\nEdit the `.env` file and use the correct database name in the `DB_DATABASE` key."; } /** @return array<string, string> */ public function getDocumentationLinks(): array { return [ 'Database: Getting Started docs' => 'https://laravel.com/docs/master/database#configuration', ]; } } src/Solutions/Laravel/MakeViewVariableOptionalSolution.php 0000644 00000007442 15060171644 0020065 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Illuminate\Support\Facades\Blade; use Illuminate\Support\Str; use Spatie\ErrorSolutions\Contracts\RunnableSolution; class MakeViewVariableOptionalSolution implements RunnableSolution { protected ?string $variableName; protected ?string $viewFile; public function __construct(string $variableName = null, string $viewFile = null) { $this->variableName = $variableName; $this->viewFile = $viewFile; } public function getSolutionTitle(): string { return "$$this->variableName is undefined"; } public function getDocumentationLinks(): array { return []; } public function getSolutionActionDescription(): string { $output = [ 'Make the variable optional in the blade template.', "Replace `{{ $$this->variableName }}` with `{{ $$this->variableName ?? '' }}`", ]; return implode(PHP_EOL, $output); } public function getRunButtonText(): string { return 'Make variable optional'; } public function getSolutionDescription(): string { return $this->getSolutionActionDescription(); } public function getRunParameters(): array { return [ 'variableName' => $this->variableName, 'viewFile' => $this->viewFile, ]; } /** * @param array<string, mixed> $parameters * * @return bool */ public function isRunnable(array $parameters = []): bool { return $this->makeOptional($this->getRunParameters()) !== false; } /** * @param array<string, string> $parameters * * @return void */ public function run(array $parameters = []): void { $output = $this->makeOptional($parameters); if ($output !== false) { file_put_contents($parameters['viewFile'], $output); } } protected function isSafePath(string $path): bool { if (! Str::startsWith($path, ['/', './'])) { return false; } if (! Str::endsWith($path, '.blade.php')) { return false; } return true; } /** * @param array<string, string> $parameters * * @return bool|string */ public function makeOptional(array $parameters = []): bool|string { if (! $this->isSafePath($parameters['viewFile'])) { return false; } $originalContents = (string)file_get_contents($parameters['viewFile']); $newContents = str_replace('$'.$parameters['variableName'], '$'.$parameters['variableName']." ?? ''", $originalContents); $originalTokens = token_get_all(Blade::compileString($originalContents)); $newTokens = token_get_all(Blade::compileString($newContents)); $expectedTokens = $this->generateExpectedTokens($originalTokens, $parameters['variableName']); if ($expectedTokens !== $newTokens) { return false; } return $newContents; } /** * @param array<int, mixed> $originalTokens * @param string $variableName * * @return array<int, mixed> */ protected function generateExpectedTokens(array $originalTokens, string $variableName): array { $expectedTokens = []; foreach ($originalTokens as $token) { $expectedTokens[] = $token; if ($token[0] === T_VARIABLE && $token[1] === '$'.$variableName) { $expectedTokens[] = [T_WHITESPACE, ' ', $token[2]]; $expectedTokens[] = [T_COALESCE, '??', $token[2]]; $expectedTokens[] = [T_WHITESPACE, ' ', $token[2]]; $expectedTokens[] = [T_CONSTANT_ENCAPSED_STRING, "''", $token[2]]; } } return $expectedTokens; } } src/Solutions/Laravel/GenerateAppKeySolution.php 0000644 00000002060 15060171644 0016034 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Illuminate\Support\Facades\Artisan; use Spatie\ErrorSolutions\Contracts\RunnableSolution; class GenerateAppKeySolution implements RunnableSolution { public function getSolutionTitle(): string { return 'Your app key is missing'; } public function getDocumentationLinks(): array { return [ 'Laravel installation' => 'https://laravel.com/docs/master/installation#configuration', ]; } public function getSolutionActionDescription(): string { return 'Generate your application encryption key using `php artisan key:generate`.'; } public function getRunButtonText(): string { return 'Generate app key'; } public function getSolutionDescription(): string { return $this->getSolutionActionDescription(); } public function getRunParameters(): array { return []; } public function run(array $parameters = []): void { Artisan::call('key:generate'); } } src/Solutions/Laravel/RunMigrationsSolution.php 0000644 00000002322 15060171644 0015772 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Illuminate\Support\Facades\Artisan; use Spatie\ErrorSolutions\Contracts\RunnableSolution; class RunMigrationsSolution implements RunnableSolution { protected string $customTitle; public function __construct(string $customTitle = '') { $this->customTitle = $customTitle; } public function getSolutionTitle(): string { return $this->customTitle; } public function getSolutionDescription(): string { return 'You might have forgotten to run your database migrations.'; } public function getDocumentationLinks(): array { return [ 'Database: Running Migrations docs' => 'https://laravel.com/docs/master/migrations#running-migrations', ]; } public function getRunParameters(): array { return []; } public function getSolutionActionDescription(): string { return 'You can try to run your migrations using `php artisan migrate`.'; } public function getRunButtonText(): string { return 'Run migrations'; } public function run(array $parameters = []): void { Artisan::call('migrate'); } } src/Solutions/Laravel/SuggestLivewirePropertyNameSolution.php 0000644 00000001326 15060171644 0020672 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestLivewirePropertyNameSolution implements Solution { public function __construct( protected string $variableName, protected string $componentClass, protected string $suggested, ) { } public function getSolutionTitle(): string { return "Possible typo {$this->variableName}"; } public function getDocumentationLinks(): array { return []; } public function getSolutionDescription(): string { return "Did you mean `$this->suggested`?"; } public function isRunnable(): bool { return false; } } src/Solutions/Laravel/SuggestUsingMariadbDatabaseSolution.php 0000644 00000001524 15060171644 0020530 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\Laravel; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestUsingMariadbDatabaseSolution implements Solution { public function getSolutionTitle(): string { return 'Database is not a MariaDB database'; } public function getSolutionDescription(): string { return "Laravel 11 changed the default collation for MySQL and MariaDB. It seems you are trying to use the MariaDB collation `utf8mb4_uca1400_ai_ci` with a MySQL database.\n\nEdit the `.env` file and use the correct database in the `DB_CONNECTION` key."; } /** @return array<string, string> */ public function getDocumentationLinks(): array { return [ 'Database: Getting Started docs' => 'https://laravel.com/docs/master/database#configuration', ]; } } src/Solutions/OpenAi/OpenAiPromptViewModel.php 0000644 00000001616 15060171644 0015417 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\OpenAi; class OpenAiPromptViewModel { public function __construct( protected string $file, protected string $exceptionMessage, protected string $exceptionClass, protected string $snippet, protected string $line, protected string|null $applicationType = null, ) { } public function file(): string { return $this->file; } public function line(): string { return $this->line; } public function snippet(): string { return $this->snippet; } public function exceptionMessage(): string { return $this->exceptionMessage; } public function exceptionClass(): string { return $this->exceptionClass; } public function applicationType(): string|null { return $this->applicationType; } } src/Solutions/OpenAi/DummyCache.php 0000644 00000001635 15060171644 0013246 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\OpenAi; use Psr\SimpleCache\CacheInterface; class DummyCache implements CacheInterface { public function get(string $key, mixed $default = null): mixed { return null; } public function set(string $key, mixed $value, \DateInterval|int|null $ttl = null): bool { return true; } public function delete(string $key): bool { return true; } public function clear(): bool { return true; } public function getMultiple(iterable $keys, mixed $default = null): iterable { return []; } public function setMultiple(iterable $values, \DateInterval|int|null $ttl = null): bool { return true; } public function deleteMultiple(iterable $keys): bool { return true; } public function has(string $key): bool { return false; } } src/Solutions/OpenAi/OpenAiSolutionProvider.php 0000644 00000003025 15060171644 0015645 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\OpenAi; use Psr\SimpleCache\CacheInterface; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Throwable; class OpenAiSolutionProvider implements HasSolutionsForThrowable { public function __construct( protected string $openAiKey, protected ?CacheInterface $cache = null, protected int $cacheTtlInSeconds = 60 * 60, protected string|null $applicationType = null, protected string|null $applicationPath = null, ) { $this->cache ??= new DummyCache(); } public function canSolve(Throwable $throwable): bool { return true; } public function getSolutions(Throwable $throwable): array { return [ new OpenAiSolution( $throwable, $this->openAiKey, $this->cache, $this->cacheTtlInSeconds, $this->applicationType, $this->applicationPath, ), ]; } public function applicationType(string $applicationType): self { $this->applicationType = $applicationType; return $this; } public function applicationPath(string $applicationPath): self { $this->applicationPath = $applicationPath; return $this; } public function useCache(CacheInterface $cache, int $cacheTtlInSeconds = 60 * 60): self { $this->cache = $cache; $this->cacheTtlInSeconds = $cacheTtlInSeconds; return $this; } } src/Solutions/OpenAi/OpenAiSolution.php 0000644 00000006371 15060171644 0014141 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\OpenAi; use OpenAI; use Psr\SimpleCache\CacheInterface; use Spatie\Backtrace\Backtrace; use Spatie\Backtrace\Frame; use Spatie\ErrorSolutions\Contracts\Solution; use Spatie\ErrorSolutions\Support\AiPromptRenderer; use Throwable; class OpenAiSolution implements Solution { public bool $aiGenerated = true; protected string $prompt; protected OpenAiSolutionResponse $openAiSolutionResponse; public function __construct( protected Throwable $throwable, protected string $openAiKey, protected CacheInterface|null $cache = null, protected int|null $cacheTtlInSeconds = 60, protected string|null $applicationType = null, protected string|null $applicationPath = null, ) { $this->prompt = $this->generatePrompt(); $this->openAiSolutionResponse = $this->getAiSolution(); } public function getSolutionTitle(): string { return 'AI Generated Solution'; } public function getSolutionDescription(): string { return $this->openAiSolutionResponse->description(); } public function getDocumentationLinks(): array { return $this->openAiSolutionResponse->links(); } public function getAiSolution(): ?OpenAiSolutionResponse { $solution = $this->cache->get($this->getCacheKey()); if ($solution) { return new OpenAiSolutionResponse($solution); } $solutionText = OpenAI::client($this->openAiKey) ->chat() ->create([ 'model' => $this->getModel(), 'messages' => [['role' => 'user', 'content' => $this->prompt]], 'max_tokens' => 1000, 'temperature' => 0, ])->choices[0]->message->content; $this->cache->set($this->getCacheKey(), $solutionText, $this->cacheTtlInSeconds); return new OpenAiSolutionResponse($solutionText); } protected function getCacheKey(): string { $hash = sha1($this->prompt); return "ignition-solution-{$hash}"; } protected function generatePrompt(): string { $viewPath = __DIR__.'/../../../resources/views/aiPrompt.php'; $viewModel = new OpenAiPromptViewModel( file: $this->throwable->getFile(), exceptionMessage: $this->throwable->getMessage(), exceptionClass: get_class($this->throwable), snippet: $this->getApplicationFrame($this->throwable)->getSnippetAsString(15), line: $this->throwable->getLine(), applicationType: $this->applicationType, ); return (new AiPromptRenderer())->renderAsString( ['viewModel' => $viewModel], $viewPath, ); } protected function getModel(): string { return 'gpt-3.5-turbo'; } protected function getApplicationFrame(Throwable $throwable): ?Frame { $backtrace = Backtrace::createForThrowable($throwable); if ($this->applicationPath) { $backtrace->applicationPath($this->applicationPath); } $frames = $backtrace->frames(); return $frames[$backtrace->firstApplicationFrameIndex()] ?? null; } } src/Solutions/OpenAi/OpenAiSolutionResponse.php 0000644 00000002643 15060171644 0015656 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions\OpenAi; class OpenAiSolutionResponse { protected string $rawText; public function __construct(string $rawText) { $this->rawText = trim($rawText); } public function description(): string { return $this->between('FIX', 'ENDFIX', $this->rawText); } public function links(): array { $textLinks = $this->between('LINKS', 'ENDLINKS', $this->rawText); $textLinks = explode(PHP_EOL, $textLinks); $textLinks = array_map(function ($textLink) { $textLink = str_replace('\\', '\\\\', $textLink); $textLink = str_replace('\\\\\\', '\\\\', $textLink); return json_decode($textLink, true); }, $textLinks); array_filter($textLinks); $links = []; foreach ($textLinks as $textLink) { $links[$textLink['title']] = $textLink['url']; } return $links; } protected function between(string $start, string $end, string $text): string { $startPosition = strpos($text, $start); if ($startPosition === false) { return ""; } $startPosition += strlen($start); $endPosition = strpos($text, $end, $startPosition); if ($endPosition === false) { return ""; } return trim(substr($text, $startPosition, $endPosition - $startPosition)); } } src/Solutions/SuggestCorrectVariableNameSolution.php 0000644 00000001612 15060171644 0017016 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestCorrectVariableNameSolution implements Solution { protected ?string $variableName; protected ?string $viewFile; protected ?string $suggested; public function __construct(string $variableName = null, string $viewFile = null, string $suggested = null) { $this->variableName = $variableName; $this->viewFile = $viewFile; $this->suggested = $suggested; } public function getSolutionTitle(): string { return 'Possible typo $'.$this->variableName; } public function getDocumentationLinks(): array { return []; } public function getSolutionDescription(): string { return "Did you mean `$$this->suggested`?"; } public function isRunnable(): bool { return false; } } src/Solutions/SolutionTransformer.php 0000644 00000001604 15060171644 0014107 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions; use Illuminate\Contracts\Support\Arrayable; use Spatie\ErrorSolutions\Contracts\Solution; /** @implements Arrayable<string, array<string,string>|string|false> */ class SolutionTransformer implements Arrayable { protected Solution $solution; public function __construct(Solution $solution) { $this->solution = $solution; } /** @return array<string, array<string,string>|string|false> */ public function toArray(): array { return [ 'class' => get_class($this->solution), 'title' => $this->solution->getSolutionTitle(), 'links' => $this->solution->getDocumentationLinks(), 'description' => $this->solution->getSolutionDescription(), 'is_runnable' => false, 'ai_generated' => $this->solution->aiGenerated ?? false, ]; } } src/Solutions/SuggestImportSolution.php 0000644 00000001154 15060171644 0014421 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Solutions; use Spatie\ErrorSolutions\Contracts\Solution; class SuggestImportSolution implements Solution { protected string $class; public function __construct(string $class) { $this->class = $class; } public function getSolutionTitle(): string { return 'A class import is missing'; } public function getSolutionDescription(): string { return 'You have a missing class import. Try importing this class: `'.$this->class.'`.'; } public function getDocumentationLinks(): array { return []; } } src/DiscoverSolutionProviders.php 0000644 00000004312 15060171644 0013261 0 ustar 00 <?php namespace Spatie\ErrorSolutions; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; class DiscoverSolutionProviders { /** @var array<string, string> */ protected array $config = [ 'ai' => 'SolutionProviders/OpenAi', 'php' => 'SolutionProviders', 'laravel' => 'SolutionProviders/Laravel', ]; /** * @param array<string> $types * * @return array<HasSolutionsForThrowable> */ public static function for(array $types): array { if (in_array('php', $types)) { $types[] = 'ai'; } return (new self($types))->get(); } /** * @param array<string> $types */ public function __construct(protected array $types) { } /** @return array<HasSolutionsForThrowable> */ public function get(): array { $providers = []; foreach ($this->types as $type) { $providers = array_merge($providers, $this->getProviderClassesForType($type)); } return $providers; } /** @return array<HasSolutionsForThrowable> */ protected function getProviderClassesForType(string $type): array { $relativePath = $this->config[$type] ?? null; if (! $relativePath) { return []; } $namespace = $this->getNamespaceForPath($relativePath); $globPattern = __DIR__ . '/' . $relativePath . '/*.php'; $files = glob($globPattern); if (! $files) { return []; } $solutionProviders = array_map(function (string $solutionProviderFilePath) use ($namespace) { $fileName = pathinfo($solutionProviderFilePath, PATHINFO_FILENAME); $fqcn = $namespace . '\\' . $fileName; $validClass = in_array(HasSolutionsForThrowable::class, class_implements($fqcn) ?: []); return $validClass ? $fqcn : null; }, $files); return array_values(array_filter($solutionProviders)); } protected function getNamespaceForPath(string $relativePath): string { $namespacePath = str_replace('/', '\\', $relativePath); $namespace = 'Spatie\\ErrorSolutions\\' . $namespacePath; return $namespace; } } src/Contracts/BaseSolution.php 0000644 00000002564 15060171644 0012426 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; class BaseSolution implements Solution { protected string $title; protected string $description = ''; /** @var array<string, string> */ protected array $links = []; public static function create(string $title = ''): static { // It's important to keep the return type as static because // the old Facade Ignition contracts extend from this method. /** @phpstan-ignore-next-line */ return new static($title); } public function __construct(string $title = '') { $this->title = $title; } public function getSolutionTitle(): string { return $this->title; } public function setSolutionTitle(string $title): self { $this->title = $title; return $this; } public function getSolutionDescription(): string { return $this->description; } public function setSolutionDescription(string $description): self { $this->description = $description; return $this; } /** @return array<string, string> */ public function getDocumentationLinks(): array { return $this->links; } /** @param array<string, string> $links */ public function setDocumentationLinks(array $links): self { $this->links = $links; return $this; } } src/Contracts/Solution.php 0000644 00000000417 15060171644 0011626 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; interface Solution { public function getSolutionTitle(): string; public function getSolutionDescription(): string; /** @return array<string, string> */ public function getDocumentationLinks(): array; } src/Contracts/RunnableSolution.php 0000644 00000000623 15060171644 0013314 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; interface RunnableSolution extends Solution { public function getSolutionActionDescription(): string; public function getRunButtonText(): string; /** @param array<string, mixed> $parameters */ public function run(array $parameters = []): void; /** @return array<string, mixed> */ public function getRunParameters(): array; } src/Contracts/HasSolutionsForThrowable.php 0000644 00000000475 15060171644 0014770 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; use Throwable; /** * Interface used for SolutionProviders. */ interface HasSolutionsForThrowable { public function canSolve(Throwable $throwable): bool; /** @return array<int, Solution> */ public function getSolutions(Throwable $throwable): array; } src/Contracts/ProvidesSolution.php 0000644 00000000316 15060171644 0013340 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; /** * Interface to be used on exceptions that provide their own solution. */ interface ProvidesSolution { public function getSolution(): Solution; } src/Contracts/SolutionProviderRepository.php 0000644 00000001610 15060171644 0015435 0 ustar 00 <?php namespace Spatie\ErrorSolutions\Contracts; use Throwable; interface SolutionProviderRepository { /** * @param class-string<HasSolutionsForThrowable>|HasSolutionsForThrowable $solutionProvider * * @return $this */ public function registerSolutionProvider(string $solutionProvider): self; /** * @param array<class-string<HasSolutionsForThrowable>|HasSolutionsForThrowable> $solutionProviders * * @return $this */ public function registerSolutionProviders(array $solutionProviders): self; /** * @param Throwable $throwable * * @return array<int, Solution> */ public function getSolutionsForThrowable(Throwable $throwable): array; /** * @param class-string<Solution> $solutionClass * * @return null|Solution */ public function getSolutionForClass(string $solutionClass): ?Solution; } src/SolutionProviderRepository.php 0000644 00000007235 15060171644 0013506 0 ustar 00 <?php namespace Spatie\ErrorSolutions; use Illuminate\Support\Collection; use Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\Contracts\ProvidesSolution; use Spatie\ErrorSolutions\Contracts\Solution; use Spatie\ErrorSolutions\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract; use Throwable; class SolutionProviderRepository implements SolutionProviderRepositoryContract { /** @var Collection<int, class-string<HasSolutionsForThrowable>|HasSolutionsForThrowable> */ protected Collection $solutionProviders; /** @param array<int, class-string<HasSolutionsForThrowable>|HasSolutionsForThrowable> $solutionProviders */ public function __construct(array $solutionProviders = []) { $this->solutionProviders = Collection::make($solutionProviders); } public function registerSolutionProvider(string|HasSolutionsForThrowable $solutionProvider): SolutionProviderRepositoryContract { $this->solutionProviders->push($solutionProvider); return $this; } public function registerSolutionProviders(array $solutionProviderClasses): SolutionProviderRepositoryContract { $this->solutionProviders = $this->solutionProviders->merge($solutionProviderClasses); return $this; } public function getSolutionsForThrowable(Throwable $throwable): array { $solutions = []; if ($throwable instanceof Solution) { $solutions[] = $throwable; } if ($throwable instanceof ProvidesSolution) { $solutions[] = $throwable->getSolution(); } $providedSolutions = $this ->initialiseSolutionProviderRepositories() ->filter(function (HasSolutionsForThrowable $solutionProvider) use ($throwable) { try { return $solutionProvider->canSolve($throwable); } catch (Throwable $exception) { return false; } }) ->map(function (HasSolutionsForThrowable $solutionProvider) use ($throwable) { try { return $solutionProvider->getSolutions($throwable); } catch (Throwable $exception) { return []; } }) ->flatten() ->toArray(); return array_merge($solutions, $providedSolutions); } public function getSolutionForClass(string $solutionClass): ?Solution { if (! class_exists($solutionClass)) { return null; } if (! in_array(Solution::class, class_implements($solutionClass) ?: [])) { return null; } if (! function_exists('app')) { return null; } return app($solutionClass); } /** @return Collection<int, HasSolutionsForThrowable> */ protected function initialiseSolutionProviderRepositories(): Collection { return $this->solutionProviders ->filter(function (HasSolutionsForThrowable|string $provider) { if (! in_array(HasSolutionsForThrowable::class, class_implements($provider) ?: [])) { return false; } if (function_exists('config') && in_array($provider, config('ErrorSolutions.ignored_solution_providers', []))) { return false; } return true; }) ->map(function (string|HasSolutionsForThrowable $provider): HasSolutionsForThrowable { if (is_string($provider)) { return new $provider; } return $provider; }); } } LICENSE.md 0000644 00000002076 15060171644 0006161 0 ustar 00 The MIT License (MIT) Copyright (c) Spatie <ruben@spatie.be> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. legacy/laravel-ignition/Solutions/UseDefaultValetDbCredentialsSolution.php 0000644 00000000532 15060171644 0023206 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\UseDefaultValetDbCredentialsSolution as BaseUseDefaultValetDbCredentialsSolutionAlias; use Spatie\Ignition\Contracts\Solution; class UseDefaultValetDbCredentialsSolution extends BaseUseDefaultValetDbCredentialsSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestLivewireMethodNameSolution.php 0000644 00000000515 15060171644 0022620 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewireMethodNameSolution as BaseSuggestLivewireMethodNameSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestLivewireMethodNameSolution extends BaseSuggestLivewireMethodNameSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SolutionProviders/IncorrectValetDbCredentialsSolutionProvider.php 0000644 00000000660 15060171644 0030324 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\IncorrectValetDbCredentialsSolutionProvider as BaseIncorrectValetDbCredentialsSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class IncorrectValetDbCredentialsSolutionProvider extends BaseIncorrectValetDbCredentialsSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UndefinedLivewirePropertySolutionProvider.php 0000644 00000000650 15060171644 0030130 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UndefinedLivewirePropertySolutionProvider as BaseUndefinedLivewirePropertySolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UndefinedLivewirePropertySolutionProvider extends BaseUndefinedLivewirePropertySolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/ViewNotFoundSolutionProvider.php 0000644 00000000565 15060171644 0025347 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\ViewNotFoundSolutionProvider as BaseViewNotFoundSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class ViewNotFoundSolutionProvider extends BaseViewNotFoundSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingAppKeySolutionProvider.php 0000644 00000000571 15060171644 0025500 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingAppKeySolutionProvider as BaseMissingAppKeySolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingAppKeySolutionProvider extends BaseMissingAppKeySolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingLivewireComponentSolutionProvider.php 0000644 00000000645 15060171644 0027762 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingLivewireComponentSolutionProvider as BaseMissingLivewireComponentSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingLivewireComponentSolutionProvider extends BaseMissingLivewireComponentSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/OpenAiSolutionProvider.php 0000644 00000000534 15060171644 0024127 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\OpenAiSolutionProvider as BaseOpenAiSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class OpenAiSolutionProvider extends BaseOpenAiSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UndefinedLivewireMethodSolutionProvider.php 0000644 00000000640 15060171644 0027523 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UndefinedLivewireMethodSolutionProvider as BaseUndefinedLivewireMethodSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UndefinedLivewireMethodSolutionProvider extends BaseUndefinedLivewireMethodSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/LazyLoadingViolationSolutionProvider.php 0000644 00000000624 15060171644 0027056 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; use Spatie\ErrorSolutions\SolutionProviders\Laravel\LazyLoadingViolationSolutionProvider as BaseLazyLoadingViolationSolutionProviderAlias; class LazyLoadingViolationSolutionProvider extends BaseLazyLoadingViolationSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/RunningLaravelDuskInProductionProvider.php 0000644 00000000634 15060171644 0027334 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\RunningLaravelDuskInProductionProvider as BaseRunningLaravelDuskInProductionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class RunningLaravelDuskInProductionProvider extends BaseRunningLaravelDuskInProductionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UndefinedViewVariableSolutionProvider.php 0000644 00000000630 15060171644 0027153 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UndefinedViewVariableSolutionProvider as BaseUndefinedViewVariableSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UndefinedViewVariableSolutionProvider extends BaseUndefinedViewVariableSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UnknownMariadbCollationSolutionProvider.php 0000644 00000000640 15060171644 0027536 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UnknownMariadbCollationSolutionProvider as BaseUnknownMariadbCollationSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UnknownMariadbCollationSolutionProvider extends BaseUnknownMariadbCollationSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/InvalidRouteActionSolutionProvider.php 0000644 00000000615 15060171644 0026517 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\InvalidRouteActionSolutionProvider as BaseInvalidRouteActionSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class InvalidRouteActionSolutionProvider extends BaseInvalidRouteActionSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/SailNetworkSolutionProvider.php 0000644 00000000560 15060171644 0025215 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\SailNetworkSolutionProvider as BaseSailNetworkSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class SailNetworkSolutionProvider extends BaseSailNetworkSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/RouteNotDefinedSolutionProvider.php 0000644 00000000600 15060171644 0026004 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\RouteNotDefinedSolutionProvider as BaseRouteNotDefinedSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class RouteNotDefinedSolutionProvider extends BaseRouteNotDefinedSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UnknownMysql8CollationSolutionProvider.php 0000644 00000000634 15060171644 0027377 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UnknownMysql8CollationSolutionProvider as BaseUnknownMysql8CollationSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UnknownMysql8CollationSolutionProvider extends BaseUnknownMysql8CollationSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingColumnSolutionProvider.php 0000644 00000000571 15060171644 0025544 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingColumnSolutionProvider as BaseMissingColumnSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingColumnSolutionProvider extends BaseMissingColumnSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/GenericLaravelExceptionSolutionProvider.php 0000644 00000000640 15060171644 0027514 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\GenericLaravelExceptionSolutionProvider as BaseGenericLaravelExceptionSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class GenericLaravelExceptionSolutionProvider extends BaseGenericLaravelExceptionSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/UnknownValidationSolutionProvider.php 0000644 00000000610 15060171644 0026421 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\UnknownValidationSolutionProvider as BaseUnknownValidationSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UnknownValidationSolutionProvider extends BaseUnknownValidationSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingImportSolutionProvider.php 0000644 00000000572 15060171644 0025562 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingImportSolutionProvider as BaseMissingImportSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingImportSolutionProvider extends BaseMissingImportSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/DefaultDbNameSolutionProvider.php 0000644 00000000570 15060171644 0025407 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\DefaultDbNameSolutionProvider as BaseDefaultDbNameSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class DefaultDbNameSolutionProvider extends BaseDefaultDbNameSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/SolutionProviderRepository.php 0000644 00000000604 15060171644 0025131 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviderRepository as BaseSolutionProviderRepositoryAlias; use Spatie\Ignition\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract; class SolutionProviderRepository extends BaseSolutionProviderRepositoryAlias implements SolutionProviderRepositoryContract { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingMixManifestSolutionProvider.php 0000644 00000000614 15060171644 0026531 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingMixManifestSolutionProvider as BaseMissingMixManifestSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingMixManifestSolutionProvider extends BaseMissingMixManifestSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/MissingViteManifestSolutionProvider.php 0000644 00000000620 15060171644 0026700 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\MissingViteManifestSolutionProvider as BaseMissingViteManifestSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MissingViteManifestSolutionProvider extends BaseMissingViteManifestSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SolutionProviders/TableNotFoundSolutionProvider.php 0000644 00000000570 15060171644 0025460 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\Laravel\TableNotFoundSolutionProvider as BaseTableNotFoundSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class TableNotFoundSolutionProvider extends BaseTableNotFoundSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/laravel-ignition/Solutions/SuggestUsingMysql8DatabaseSolution.php 0000644 00000000522 15060171644 0022716 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMysql8DatabaseSolution as BaseSuggestUsingMysql8DatabaseSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestUsingMysql8DatabaseSolution extends BaseSuggestUsingMysql8DatabaseSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/LivewireDiscoverSolution.php 0000644 00000000453 15060171644 0021014 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\LivewireDiscoverSolution as BaseLivewireDiscoverSolutionAlias; use Spatie\Ignition\Contracts\Solution; class LivewireDiscoverSolution extends BaseLivewireDiscoverSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestUsingCorrectDbNameSolution.php 0000644 00000000517 15060171644 0022550 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingCorrectDbNameSolution as BaseSuggestUsingCorrectDbNameSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestUsingCorrectDbNameSolution extends BaseSuggestUsingCorrectDbNameSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/MakeViewVariableOptionalSolution.php 0000644 00000000512 15060171644 0022407 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\MakeViewVariableOptionalSolution as BaseMakeViewVariableOptionalSolutionAlias; use Spatie\Ignition\Contracts\Solution; class MakeViewVariableOptionalSolution extends BaseMakeViewVariableOptionalSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/GenerateAppKeySolution.php 0000644 00000000442 15060171644 0020371 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\GenerateAppKeySolution as BaseGenerateAppKeySolutionAlias; use Spatie\Ignition\Contracts\Solution; class GenerateAppKeySolution extends BaseGenerateAppKeySolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/RunMigrationsSolution.php 0000644 00000000436 15060171644 0020331 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\RunMigrationsSolution as BaseRunMigrationsSolutionAlias; use Spatie\Ignition\Contracts\Solution; class RunMigrationsSolution extends BaseRunMigrationsSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestCorrectVariableNameSolution.php 0000644 00000000512 15060171644 0022735 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\SuggestCorrectVariableNameSolution as BaseSuggestCorrectVariableNameSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestCorrectVariableNameSolution extends BaseSuggestCorrectVariableNameSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestLivewirePropertyNameSolution.php 0000644 00000000526 15060171644 0023226 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewirePropertyNameSolution as BaseSuggestLivewirePropertyNameSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestLivewirePropertyNameSolution extends BaseSuggestLivewirePropertyNameSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestUsingMariadbDatabaseSolution.php 0000644 00000000526 15060171644 0023064 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMariadbDatabaseSolution as BaseSuggestUsingMariadbDatabaseSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestUsingMariadbDatabaseSolution extends BaseSuggestUsingMariadbDatabaseSolutionAlias implements Solution { } legacy/laravel-ignition/Solutions/SuggestImportSolution.php 0000644 00000000427 15060171644 0020344 0 ustar 00 <?php namespace Spatie\LaravelIgnition\Solutions; use Spatie\ErrorSolutions\Solutions\SuggestImportSolution as BaseSuggestImportSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestImportSolution extends BaseSuggestImportSolutionAlias implements Solution { } legacy/ignition/Solutions/SolutionProviders/UndefinedPropertySolutionProvider.php 0000644 00000000571 15060171644 0024777 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\UndefinedPropertySolutionProvider as BaseUndefinedPropertySolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class UndefinedPropertySolutionProvider extends BaseUndefinedPropertySolutionProviderAlias implements HasSolutionsForThrowable { } legacy/ignition/Solutions/SolutionProviders/MergeConflictSolutionProvider.php 0000644 00000000550 15060171644 0024047 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\MergeConflictSolutionProvider as BaseMergeConflictSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class MergeConflictSolutionProvider extends BaseMergeConflictSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/ignition/Solutions/SolutionProviders/BadMethodCallSolutionProvider.php 0000644 00000000550 15060171644 0023751 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviders\BadMethodCallSolutionProvider as BaseBadMethodCallSolutionProviderAlias; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class BadMethodCallSolutionProvider extends BaseBadMethodCallSolutionProviderAlias implements HasSolutionsForThrowable { } legacy/ignition/Solutions/SolutionProviders/SolutionProviderRepository.php 0000644 00000000574 15060171644 0023513 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\SolutionProviders; use Spatie\ErrorSolutions\SolutionProviderRepository as BaseSolutionProviderRepositoryAlias; use Spatie\Ignition\Contracts\SolutionProviderRepository as SolutionProviderRepositoryContract; class SolutionProviderRepository extends BaseSolutionProviderRepositoryAlias implements SolutionProviderRepositoryContract { } legacy/ignition/Solutions/OpenAi/OpenAiPromptViewModel.php 0000644 00000000232 15060171644 0017705 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\OpenAi; class OpenAiPromptViewModel extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiPromptViewModel { } legacy/ignition/Solutions/OpenAi/DummyCache.php 0000644 00000000205 15060171644 0015533 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\OpenAi; class DummyCache extends \Spatie\ErrorSolutions\Solutions\OpenAi\DummyCache { } legacy/ignition/Solutions/OpenAi/OpenAiSolutionProvider.php 0000644 00000000372 15060171644 0020144 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\OpenAi; use Spatie\Ignition\Contracts\HasSolutionsForThrowable; class OpenAiSolutionProvider extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionProvider implements HasSolutionsForThrowable { } legacy/ignition/Solutions/OpenAi/OpenAiSolution.php 0000644 00000000312 15060171644 0016423 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\OpenAi; use Spatie\Ignition\Contracts\Solution; class OpenAiSolution extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolution implements Solution { } legacy/ignition/Solutions/OpenAi/OpenAiSolutionResponse.php 0000644 00000000235 15060171644 0020146 0 ustar 00 <?php namespace Spatie\Ignition\Solutions\OpenAi; class OpenAiSolutionResponse extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionResponse { } legacy/ignition/Solutions/SuggestCorrectVariableNameSolution.php 0000644 00000000502 15060171644 0021310 0 ustar 00 <?php namespace Spatie\Ignition\Solutions; use Spatie\ErrorSolutions\Solutions\SuggestCorrectVariableNameSolution as BaseSuggestCorrectVariableNameSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestCorrectVariableNameSolution extends BaseSuggestCorrectVariableNameSolutionAlias implements Solution { } legacy/ignition/Solutions/SolutionTransformer.php 0000644 00000000210 15060171644 0016374 0 ustar 00 <?php namespace Spatie\Ignition\Solutions; class SolutionTransformer extends \Spatie\ErrorSolutions\Solutions\SolutionTransformer { } legacy/ignition/Solutions/SuggestImportSolution.php 0000644 00000000417 15060171644 0016717 0 ustar 00 <?php namespace Spatie\Ignition\Solutions; use Spatie\ErrorSolutions\Solutions\SuggestImportSolution as BaseSuggestImportSolutionAlias; use Spatie\Ignition\Contracts\Solution; class SuggestImportSolution extends BaseSuggestImportSolutionAlias implements Solution { } legacy/ignition/Contracts/BaseSolution.php 0000644 00000000216 15060171644 0014713 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; class BaseSolution extends \Spatie\ErrorSolutions\Contracts\BaseSolution implements Solution { } legacy/ignition/Contracts/Solution.php 0000644 00000000166 15060171644 0014124 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; interface Solution extends \Spatie\ErrorSolutions\Contracts\Solution { } legacy/ignition/Contracts/RunnableSolution.php 0000644 00000000206 15060171644 0015606 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; interface RunnableSolution extends \Spatie\ErrorSolutions\Contracts\RunnableSolution { } legacy/ignition/Contracts/HasSolutionsForThrowable.php 0000644 00000000226 15060171644 0017257 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; interface HasSolutionsForThrowable extends \Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable { } legacy/ignition/Contracts/ProvidesSolution.php 0000644 00000000206 15060171644 0015633 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; interface ProvidesSolution extends \Spatie\ErrorSolutions\Contracts\ProvidesSolution { } legacy/ignition/Contracts/SolutionProviderRepository.php 0000644 00000000233 15060171644 0017732 0 ustar 00 <?php namespace Spatie\Ignition\Contracts; interface SolutionProviderRepository extends \Spatie\ErrorSolutions\Contracts\SolutionProviderRepository { } CHANGELOG.md 0000644 00000000273 15060171644 0006363 0 ustar 00 # Changelog All notable changes to `error-solutions` will be documented in this file. ## 0.0.1 - 2024-06-11 **Full Changelog**: https://github.com/spatie/error-solutions/commits/0.0.1 composer.json 0000644 00000004150 15060171644 0007272 0 ustar 00 { "name" : "spatie/error-solutions", "description" : "This is my package error-solutions", "keywords" : [ "Spatie", "error-solutions" ], "homepage" : "https://github.com/spatie/error-solutions", "license" : "MIT", "authors" : [ { "name" : "Ruben Van Assche", "email" : "ruben@spatie.be", "role" : "Developer" } ], "require" : { "php": "^8.0" }, "require-dev" : { "livewire/livewire": "^2.11|^3.3.5", "illuminate/support": "^10.0|^11.0", "illuminate/broadcasting" : "^10.0|^11.0", "openai-php/client": "^0.10.1", "illuminate/cache" : "^10.0|^11.0", "pestphp/pest" : "^2.20", "phpstan/phpstan" : "^1.11", "psr/simple-cache-implementation" : "^3.0", "psr/simple-cache" : "^3.0", "spatie/ray" : "^1.28", "symfony/cache" : "^5.4|^6.0|^7.0", "symfony/process" : "^5.4|^6.0|^7.0", "vlucas/phpdotenv" : "^5.5", "orchestra/testbench": "^7.0|8.22.3|^9.0" }, "autoload" : { "psr-4" : { "Spatie\\ErrorSolutions\\" : "src", "Spatie\\Ignition\\" : "legacy/ignition", "Spatie\\LaravelIgnition\\" : "legacy/laravel-ignition" } }, "autoload-dev" : { "psr-4" : { "Spatie\\ErrorSolutions\\Tests\\" : "tests" } }, "suggest" : { "openai-php/client" : "Require get solutions from OpenAI", "simple-cache-implementation" : "To cache solutions from OpenAI" }, "scripts" : { "analyse" : "vendor/bin/phpstan analyse", "baseline" : "vendor/bin/phpstan analyse --generate-baseline", "test" : "vendor/bin/pest", "test-coverage" : "vendor/bin/pest --coverage", "format" : "vendor/bin/pint" }, "config" : { "sort-packages" : true, "allow-plugins" : { "pestphp/pest-plugin": true, "phpstan/extension-installer": true, "php-http/discovery": false } }, "minimum-stability" : "dev", "prefer-stable" : true } resources/views/aiPrompt.php 0000644 00000001751 15060171644 0012227 0 ustar 00 <?php /** @var \Spatie\Ignition\ignition\Solutions\OpenAi\OpenAiPromptViewModel $viewModel */ ?> You are a very skilled PHP programmer. <?php if($viewModel->applicationType()) { ?> You are working on a <?php echo $viewModel->applicationType() ?> application. <?php } ?> Use the following context to find a possible fix for the exception message at the end. Limit your answer to 4 or 5 sentences. Also include a few links to documentation that might help. Use this format in your answer, make sure links are json: FIX insert the possible fix here ENDFIX LINKS {"title": "Title link 1", "url": "URL link 1"} {"title": "Title link 2", "url": "URL link 2"} ENDLINKS --- Here comes the context and the exception message: Line: <?php echo $viewModel->line() ?> File: <?php echo $viewModel->file() ?> Snippet including line numbers: <?php echo $viewModel->snippet() ?> Exception class: <?php echo $viewModel->exceptionClass() ?> Exception message: <?php echo $viewModel->exceptionMessage() ?> .php_cs.php 0000644 00000002175 15060171644 0006620 0 ustar 00 <?php $finder = Symfony\Component\Finder\Finder::create() ->in([ __DIR__ . '/src', __DIR__ . '/tests', ]) ->name('*.php') ->notName('*.blade.php') ->ignoreDotFiles(true) ->ignoreVCS(true); return (new PhpCsFixer\Config()) ->setRules([ '@PSR2' => true, 'array_syntax' => ['syntax' => 'short'], 'ordered_imports' => ['sort_algorithm' => 'alpha'], 'no_unused_imports' => true, 'not_operator_with_successor_space' => true, 'trailing_comma_in_multiline' => true, 'phpdoc_scalar' => true, 'unary_operator_spaces' => true, 'binary_operator_spaces' => true, 'blank_line_before_statement' => [ 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], ], 'phpdoc_single_line_var_spacing' => true, 'phpdoc_var_without_name' => true, 'method_argument_space' => [ 'on_multiline' => 'ensure_fully_multiline', 'keep_multiple_spaces_after_comma' => true, ], 'single_trait_insert_per_statement' => true, ]) ->setFinder($finder); README.md 0000644 00000004462 15060171644 0006035 0 ustar 00 # Error solutions [](https://packagist.org/packages/spatie/error-solutions) [](https://github.com/spatie/error-solutions/actions/workflows/run-tests.yml) [](https://packagist.org/packages/spatie/error-solutions) At Spatie we develop multiple packages handling errors and providing solutions for these errors. This package is a collection of all these solutions. ## Support us [<img src="https://github-ads.s3.eu-central-1.amazonaws.com/error-solutions.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/error-solutions) We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). ## Installation You can install the package via composer: ```bash composer require spatie/error-solutions ``` ## Usage We've got some excellent documentation on how to use solutions: - [Flare](https://flareapp.io/docs/ignition/solutions/implementing-solutions) - [Ignition](https://github.com/spatie/ignition/?tab=readme-ov-file#displaying-solutions) ## Testing ```bash composer test ``` ## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. ## Security Vulnerabilities Please review [our security policy](../../security/policy) on how to report security vulnerabilities. ## Credits - [Ruben Van Assche](https://github.com/rubenvanassche) - [All Contributors](../../contributors) ## License The MIT License (MIT). Please see [License File](LICENSE.md) for more information. phpstan-baseline.neon 0000644 00000021223 15060171644 0010666 0 ustar 00 parameters: ignoreErrors: - message: "#^PHPDoc tag @param for parameter \\$solutionProvider with type class\\-string\\<Spatie\\\\ErrorSolutions\\\\Contracts\\\\HasSolutionsForThrowable\\>\\|Spatie\\\\ErrorSolutions\\\\Contracts\\\\HasSolutionsForThrowable is not subtype of native type string\\.$#" count: 1 path: src/Contracts/SolutionProviderRepository.php - message: "#^Method Spatie\\\\ErrorSolutions\\\\DiscoverSolutionProviders\\:\\:getProviderClassesForType\\(\\) should return array\\<Spatie\\\\ErrorSolutions\\\\Contracts\\\\HasSolutionsForThrowable\\> but returns array\\<int, string\\>\\.$#" count: 1 path: src/DiscoverSolutionProviders.php - message: "#^Unable to resolve the template type TKey in call to function collect$#" count: 1 path: src/SolutionProviders/Laravel/InvalidRouteActionSolutionProvider.php - message: "#^Unable to resolve the template type TValue in call to function collect$#" count: 1 path: src/SolutionProviders/Laravel/InvalidRouteActionSolutionProvider.php - message: "#^Call to method getSolutionDescription\\(\\) on an unknown class Spatie\\\\ErrorSolutions\\\\Solutions\\\\Laravel\\\\SuggestCorrectVariableNameSolution\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Call to method getSolutionTitle\\(\\) on an unknown class Spatie\\\\ErrorSolutions\\\\Solutions\\\\Laravel\\\\SuggestCorrectVariableNameSolution\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Call to method getViewData\\(\\) on an unknown class Spatie\\\\LaravelFlare\\\\Exceptions\\\\ViewException\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Call to method getViewData\\(\\) on an unknown class Spatie\\\\LaravelIgnition\\\\Exceptions\\\\ViewException\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Call to method isRunnable\\(\\) on an unknown class Spatie\\\\ErrorSolutions\\\\Solutions\\\\Laravel\\\\SuggestCorrectVariableNameSolution\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Class Spatie\\\\LaravelFlare\\\\Exceptions\\\\ViewException not found\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Class Spatie\\\\LaravelIgnition\\\\Exceptions\\\\ViewException not found\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Instantiated class Spatie\\\\ErrorSolutions\\\\Solutions\\\\Laravel\\\\SuggestCorrectVariableNameSolution not found\\.$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Parameter \\$throwable of method Spatie\\\\ErrorSolutions\\\\SolutionProviders\\\\Laravel\\\\UndefinedViewVariableSolutionProvider\\:\\:findCorrectVariableSolutions\\(\\) has invalid type Spatie\\\\LaravelFlare\\\\Exceptions\\\\ViewException\\.$#" count: 2 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Parameter \\$throwable of method Spatie\\\\ErrorSolutions\\\\SolutionProviders\\\\Laravel\\\\UndefinedViewVariableSolutionProvider\\:\\:findCorrectVariableSolutions\\(\\) has invalid type Spatie\\\\LaravelIgnition\\\\Exceptions\\\\ViewException\\.$#" count: 2 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Unable to resolve the template type TKey in call to function collect$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Unable to resolve the template type TValue in call to function collect$#" count: 1 path: src/SolutionProviders/Laravel/UndefinedViewVariableSolutionProvider.php - message: "#^Method Spatie\\\\ErrorSolutions\\\\SolutionProviders\\\\Laravel\\\\UnknownValidationSolutionProvider\\:\\:getAvailableMethods\\(\\) return type with generic class Illuminate\\\\Support\\\\Collection does not specify its types\\: TKey, TValue$#" count: 1 path: src/SolutionProviders/Laravel/UnknownValidationSolutionProvider.php - message: "#^Parameter \\#1 \\$callback of method Illuminate\\\\Support\\\\Collection\\<int,ReflectionMethod\\>\\:\\:filter\\(\\) expects \\(callable\\(ReflectionMethod, int\\)\\: bool\\)\\|null, Closure\\(ReflectionMethod\\)\\: \\(0\\|1\\|false\\) given\\.$#" count: 1 path: src/SolutionProviders/Laravel/UnknownValidationSolutionProvider.php - message: "#^Unable to resolve the template type TMakeKey in call to method static method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:make\\(\\)$#" count: 1 path: src/SolutionProviders/Laravel/UnknownValidationSolutionProvider.php - message: "#^Unable to resolve the template type TMakeValue in call to method static method Illuminate\\\\Support\\\\Collection\\<\\(int\\|string\\),mixed\\>\\:\\:make\\(\\)$#" count: 1 path: src/SolutionProviders/Laravel/UnknownValidationSolutionProvider.php - message: "#^Call to method getMessage\\(\\) on an unknown class Spatie\\\\Ignition\\\\Exceptions\\\\ViewException\\.$#" count: 1 path: src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php - message: "#^Call to method getMessage\\(\\) on an unknown class Spatie\\\\LaravelFlare\\\\Exceptions\\\\ViewException\\.$#" count: 1 path: src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php - message: "#^Class Spatie\\\\Ignition\\\\Exceptions\\\\ViewException not found\\.$#" count: 1 path: src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php - message: "#^Class Spatie\\\\LaravelFlare\\\\Exceptions\\\\ViewException not found\\.$#" count: 1 path: src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php - message: "#^Parameter \\#1 \\$missingView of method Spatie\\\\ErrorSolutions\\\\SolutionProviders\\\\Laravel\\\\ViewNotFoundSolutionProvider\\:\\:findRelatedView\\(\\) expects string, string\\|null given\\.$#" count: 1 path: src/SolutionProviders/Laravel/ViewNotFoundSolutionProvider.php - message: "#^Class Livewire\\\\LivewireComponentsFinder not found\\.$#" count: 1 path: src/Solutions/Laravel/LivewireDiscoverSolution.php - message: "#^Method Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\DummyCache\\:\\:setMultiple\\(\\) has parameter \\$values with no value type specified in iterable type iterable\\.$#" count: 1 path: src/Solutions/OpenAi/DummyCache.php - message: "#^Cannot call method get\\(\\) on Psr\\\\SimpleCache\\\\CacheInterface\\|null\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Cannot call method getSnippetAsString\\(\\) on Spatie\\\\Backtrace\\\\Frame\\|null\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Cannot call method set\\(\\) on Psr\\\\SimpleCache\\\\CacheInterface\\|null\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Parameter \\#1 \\$rawText of class Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiSolutionResponse constructor expects string, string\\|null given\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Parameter \\$line of class Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiPromptViewModel constructor expects string, int given\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Property Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiSolution\\:\\:\\$openAiSolutionResponse \\(Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiSolutionResponse\\) does not accept Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiSolutionResponse\\|null\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolution.php - message: "#^Method Spatie\\\\ErrorSolutions\\\\Solutions\\\\OpenAi\\\\OpenAiSolutionResponse\\:\\:links\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 path: src/Solutions/OpenAi/OpenAiSolutionResponse.php - message: "#^Method Spatie\\\\ErrorSolutions\\\\Support\\\\AiPromptRenderer\\:\\:renderAsString\\(\\) should return string but returns string\\|false\\.$#" count: 1 path: src/Support/AiPromptRenderer.php - message: "#^Property Spatie\\\\ErrorSolutions\\\\Support\\\\Laravel\\\\LivewireComponentParser\\:\\:\\$reflectionClass \\(ReflectionClass\\<Livewire\\\\Component\\>\\) does not accept ReflectionClass\\<object\\>\\.$#" count: 1 path: src/Support/Laravel/LivewireComponentParser.php
| ver. 1.4 |
Github
|
.
| PHP 8.2.29 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0.03 |
proxy
|
phpinfo
|
ÐаÑтройка