Initial commit

This commit is contained in:
Ahrom
2025-11-16 12:43:07 +03:30
commit 4bbe56b83f
16778 changed files with 1914371 additions and 0 deletions

21
vendor/spatie/backtrace/LICENSE.md vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Spatie bvba <info@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.

205
vendor/spatie/backtrace/README.md vendored Normal file
View File

@@ -0,0 +1,205 @@
# A better PHP backtrace
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/backtrace.svg?style=flat-square)](https://packagist.org/packages/spatie/backtrace)
![Tests](https://github.com/spatie/backtrace/workflows/Tests/badge.svg)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/backtrace.svg?style=flat-square)](https://packagist.org/packages/spatie/backtrace)
To get the backtrace in PHP you can use the `debug_backtrace` function. By default, it can be hard to work with. The
reported function name for a frame is skewed: it belongs to the previous frame. Also, options need to be passed using a bitmask.
This package provides a better way than `debug_backtrace` to work with a back trace. Here's an example:
```php
// returns an array with `Spatie\Backtrace\Frame` instances
$frames = Spatie\Backtrace\Backtrace::create()->frames();
$firstFrame = $frames[0];
$firstFrame->file; // returns the file name
$firstFrame->lineNumber; // returns the line number
$firstFrame->class; // returns the class name
```
## Support us
[<img src="https://github-ads.s3.eu-central-1.amazonaws.com/backtrace.jpg?t=1" width="419px" />](https://spatie.be/github-ad-click/backtrace)
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/backtrace
```
## Usage
This is how you can create a backtrace instance:
```php
$backtrace = Spatie\Backtrace\Backtrace::create();
```
### Getting the frames
To get all the frames you can call `frames`.
```php
$frames = $backtrace->frames(); // contains an array with `Spatie\Backtrace\Frame` instances
```
A `Spatie\Backtrace\Frame` has these properties:
- `file`: the name of the file
- `lineNumber`: the line number
- `arguments`: the arguments used for this frame. Will be `null` if `withArguments` was not used.
- `class`: the class name for this frame. Will be `null` if the frame concerns a function.
- `method`: the method used in this frame
- `applicationFrame`: contains `true` is this frame belongs to your application, and `false` if it belongs to a file in
the vendor directory
### Collecting arguments
For performance reasons, the frames of the back trace will not contain the arguments of the called functions. If you
want to add those use the `withArguments` method.
```php
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments();
```
#### Reducing arguments
For viewing purposes, arguments can be reduced to a string:
```php
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments()->reduceArguments();
```
By default, some typical types will be reduced to a string. You can define your own reduction algorithm per type by implementing an `ArgumentReducer`:
```php
class DateTimeWithOtherFormatArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof DateTimeInterface) {
return UnReducedArgument::create();
}
return new ReducedArgument(
$argument->format('d/m/y H:i'),
get_class($argument),
);
}
}
```
This is a copy of the built-in argument reducer for `DateTimeInterface` where we've updated the format. An `UnReducedArgument` object is returned when the argument is not of the expected type. A `ReducedArgument` object is returned with the reduced value of the argument and the original type of the argument.
The reducer can be used as such:
```php
$backtrace = Spatie\Backtrace\Backtrace::create()->withArguments()->reduceArguments(
Spatie\Backtrace\Arguments\ArgumentReducers::default([
new DateTimeWithOtherFormatArgumentReducer()
])
);
```
Which will first execute the new reducer and then the default ones.
### Setting the application path
You can use the `applicationPath` to pass the base path of your app. This value will be used to determine whether a
frame is an application frame, or a vendor frame. Here's an example using a Laravel specific function.
```php
$backtrace = Spatie\Backtrace\Backtrace::create()->applicationPath(base_path());
```
### Removing the application path from the file name
You can use `trimFilePaths` to remove the base path of your app from the file. This will only work if you use it in conjunction the `applicationPath` method re above. Here's an example using a Laravel specific function. This will ensure the Frame has the trimmedFilePath property set.
```php
$backtrace = Backtrace::create()->applicationPath(base_path())->trimFilePaths());
```
### Getting a certain part of a trace
If you only want to have the frames starting from a particular frame in the backtrace you can use
the `startingFromFrame` method:
```php
use Spatie\Backtrace\Backtrace;
use Spatie\Backtrace\Frame;
$frames = Backtrace::create()
->startingFromFrame(function (Frame $frame) {
return $frame->class === MyClass::class;
})
->frames();
```
With this code, all frames before the frame that concerns `MyClass` will have been filtered out.
Alternatively, you can use the `offset` method, which will skip the given number of frames. In this example the first 2 frames will not end up in `$frames`.
```php
$frames = Spatie\Backtrace\Backtrace::create()
->offset(2)
->frames();
```
### Limiting the number of frames
To only get a specific number of frames use the `limit` function. In this example, we'll only get the first two frames.
```php
$frames = Spatie\Backtrace\Backtrace::create()
->limit(2)
->frames();
```
### Getting a backtrace for a throwable
Here's how you can get a backtrace for a throwable.
```php
$frames = Spatie\Backtrace\Backtrace::createForThrowable($throwable)
```
Because we will use the backtrace that is already available the throwable, the frames will always contain the arguments used.
## 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
- [Freek Van de Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)
## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

59
vendor/spatie/backtrace/composer.json vendored Normal file
View File

@@ -0,0 +1,59 @@
{
"name": "spatie/backtrace",
"description": "A better backtrace",
"license": "MIT",
"keywords": [
"spatie",
"backtrace"
],
"authors": [
{
"name": "Freek Van de Herten",
"email": "freek@spatie.be",
"homepage": "https://spatie.be",
"role": "Developer"
}
],
"homepage": "https://github.com/spatie/backtrace",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/spatie"
},
{
"type": "other",
"url": "https://spatie.be/open-source/support-us"
}
],
"require": {
"php": "^7.3 || ^8.0"
},
"require-dev": {
"ext-json": "*",
"laravel/serializable-closure": "^1.3 || ^2.0",
"phpunit/phpunit": "^9.3 || ^11.4.3",
"spatie/phpunit-snapshot-assertions": "^4.2 || ^5.1.6",
"symfony/var-dumper": "^5.1 || ^6.0 || ^7.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"Spatie\\Backtrace\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Spatie\\Backtrace\\Tests\\": "tests"
}
},
"config": {
"sort-packages": true
},
"scripts": {
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"psalm": "vendor/bin/psalm",
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage-html coverage"
}
}

View File

@@ -0,0 +1,81 @@
<?php
namespace Spatie\Backtrace\Arguments;
use Spatie\Backtrace\Arguments\Reducers\ArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\ArrayArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\BaseTypeArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\ClosureArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\DateTimeArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\DateTimeZoneArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\EnumArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\MinimalArrayArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\SensitiveParameterArrayReducer;
use Spatie\Backtrace\Arguments\Reducers\StdClassArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\StringableArgumentReducer;
use Spatie\Backtrace\Arguments\Reducers\SymphonyRequestArgumentReducer;
class ArgumentReducers
{
/** @var array<int, ArgumentReducer> */
public $argumentReducers = [];
/**
* @param array<ArgumentReducer|class-string<ArgumentReducer>> $argumentReducers
*/
public static function create(array $argumentReducers): self
{
return new self(array_map(
function ($argumentReducer) {
/** @var $argumentReducer ArgumentReducer|class-string<ArgumentReducer> */
return $argumentReducer instanceof ArgumentReducer ? $argumentReducer : new $argumentReducer();
},
$argumentReducers
));
}
public static function default(array $extra = []): self
{
return new self(static::defaultReducers($extra));
}
public static function minimal(array $extra = []): self
{
return new self(static::minimalReducers($extra));
}
/**
* @param array<int, ArgumentReducer> $argumentReducers
*/
protected function __construct(array $argumentReducers)
{
$this->argumentReducers = $argumentReducers;
}
protected static function defaultReducers(array $extra = []): array
{
return array_merge($extra, [
new BaseTypeArgumentReducer(),
new ArrayArgumentReducer(),
new StdClassArgumentReducer(),
new EnumArgumentReducer(),
new ClosureArgumentReducer(),
new SensitiveParameterArrayReducer(),
new DateTimeArgumentReducer(),
new DateTimeZoneArgumentReducer(),
new SymphonyRequestArgumentReducer(),
new StringableArgumentReducer(),
]);
}
protected static function minimalReducers(array $extra = []): array
{
return array_merge($extra, [
new BaseTypeArgumentReducer(),
new MinimalArrayArgumentReducer(),
new EnumArgumentReducer(),
new ClosureArgumentReducer(),
new SensitiveParameterArrayReducer(),
]);
}
}

View File

@@ -0,0 +1,118 @@
<?php
namespace Spatie\Backtrace\Arguments;
use ReflectionParameter;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\TruncatedReducedArgument;
class ProvidedArgument
{
/** @var string */
public $name;
/** @var bool */
public $passedByReference = false;
/** @var bool */
public $isVariadic = false;
/** @var bool */
public $hasDefaultValue = false;
/** @var mixed */
public $defaultValue = null;
/** @var bool */
public $defaultValueUsed = false;
/** @var bool */
public $truncated = false;
/** @var mixed */
public $reducedValue = null;
/** @var string|null */
public $originalType = null;
public static function fromReflectionParameter(ReflectionParameter $parameter): self
{
return new self(
$parameter->getName(),
$parameter->isPassedByReference(),
$parameter->isVariadic(),
$parameter->isDefaultValueAvailable(),
$parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : null,
);
}
public static function fromNonReflectableParameter(
int $index
): self {
return new self(
"arg{$index}",
false,
);
}
public function __construct(
string $name,
bool $passedByReference = false,
bool $isVariadic = false,
bool $hasDefaultValue = false,
$defaultValue = null,
bool $defaultValueUsed = false,
bool $truncated = false,
$reducedValue = null,
?string $originalType = null
) {
$this->originalType = $originalType;
$this->reducedValue = $reducedValue;
$this->truncated = $truncated;
$this->defaultValueUsed = $defaultValueUsed;
$this->defaultValue = $defaultValue;
$this->hasDefaultValue = $hasDefaultValue;
$this->isVariadic = $isVariadic;
$this->passedByReference = $passedByReference;
$this->name = $name;
if ($this->isVariadic) {
$this->defaultValue = [];
}
}
public function setReducedArgument(
ReducedArgument $reducedArgument
): self {
$this->reducedValue = $reducedArgument->value;
$this->originalType = $reducedArgument->originalType;
if ($reducedArgument instanceof TruncatedReducedArgument) {
$this->truncated = true;
}
return $this;
}
public function defaultValueUsed(): self
{
$this->defaultValueUsed = true;
$this->originalType = get_debug_type($this->defaultValue);
return $this;
}
public function toArray(): array
{
return [
'name' => $this->name,
'value' => $this->defaultValueUsed
? $this->defaultValue
: $this->reducedValue,
'original_type' => $this->originalType,
'passed_by_reference' => $this->passedByReference,
'is_variadic' => $this->isVariadic,
'truncated' => $this->truncated,
];
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace Spatie\Backtrace\Arguments;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
class ReduceArgumentPayloadAction
{
/** @var \Spatie\Backtrace\Arguments\ArgumentReducers */
protected $argumentReducers;
public function __construct(
ArgumentReducers $argumentReducers
) {
$this->argumentReducers = $argumentReducers;
}
public function reduce($argument, bool $includeObjectType = false): ReducedArgument
{
foreach ($this->argumentReducers->argumentReducers as $reducer) {
$reduced = $reducer->execute($argument);
if ($reduced instanceof ReducedArgument) {
return $reduced;
}
}
if (gettype($argument) === 'object' && $includeObjectType) {
return new ReducedArgument(
'object ('.get_class($argument).')',
get_debug_type($argument),
);
}
if (gettype($argument) === 'object') {
return new ReducedArgument('object', get_debug_type($argument), );
}
return new ReducedArgument(
$argument,
get_debug_type($argument),
);
}
}

View File

@@ -0,0 +1,117 @@
<?php
namespace Spatie\Backtrace\Arguments;
use ReflectionException;
use ReflectionFunction;
use ReflectionMethod;
use ReflectionParameter;
use Spatie\Backtrace\Arguments\ReducedArgument\VariadicReducedArgument;
use Throwable;
class ReduceArgumentsAction
{
/** @var ArgumentReducers */
protected $argumentReducers;
/** @var ReduceArgumentPayloadAction */
protected $reduceArgumentPayloadAction;
public function __construct(
ArgumentReducers $argumentReducers
) {
$this->argumentReducers = $argumentReducers;
$this->reduceArgumentPayloadAction = new ReduceArgumentPayloadAction($argumentReducers);
}
public function execute(
?string $class,
?string $method,
?array $frameArguments
): ?array {
try {
if ($frameArguments === null) {
return null;
}
$parameters = $this->getParameters($class, $method);
if ($parameters === null) {
$arguments = [];
foreach ($frameArguments as $index => $argument) {
$arguments[$index] = ProvidedArgument::fromNonReflectableParameter($index)
->setReducedArgument($this->reduceArgumentPayloadAction->reduce($argument))
->toArray();
}
return $arguments;
}
$arguments = array_map(
function ($argument) {
return $this->reduceArgumentPayloadAction->reduce($argument);
},
$frameArguments,
);
$argumentsCount = count($arguments);
$hasVariadicParameter = false;
foreach ($parameters as $index => $parameter) {
if ($index + 1 > $argumentsCount) {
$parameter->defaultValueUsed();
} elseif ($parameter->isVariadic) {
$parameter->setReducedArgument(new VariadicReducedArgument(array_slice($arguments, $index)));
$hasVariadicParameter = true;
} else {
$parameter->setReducedArgument($arguments[$index]);
}
$parameters[$index] = $parameter->toArray();
}
if ($this->moreArgumentsProvidedThanParameters($arguments, $parameters, $hasVariadicParameter)) {
for ($i = count($parameters); $i < count($arguments); $i++) {
$parameters[$i] = ProvidedArgument::fromNonReflectableParameter(count($parameters))
->setReducedArgument($arguments[$i])
->toArray();
}
}
return $parameters;
} catch (Throwable $e) {
return null;
}
}
/** @return null|Array<\Spatie\Backtrace\Arguments\ProvidedArgument> */
protected function getParameters(
?string $class,
?string $method
): ?array {
try {
$reflection = $class !== null
? new ReflectionMethod($class, $method)
: new ReflectionFunction($method);
} catch (ReflectionException $e) {
return null;
}
return array_map(
function (ReflectionParameter $reflectionParameter) {
return ProvidedArgument::fromReflectionParameter($reflectionParameter);
},
$reflection->getParameters(),
);
}
protected function moreArgumentsProvidedThanParameters(
array $arguments,
array $parameters,
bool $hasVariadicParameter
): bool {
return count($arguments) > count($parameters) && ! $hasVariadicParameter;
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\ReducedArgument;
class ReducedArgument implements ReducedArgumentContract
{
/** @var mixed */
public $value;
/** @var string */
public $originalType;
/**
* @param mixed $value
*/
public function __construct(
$value,
string $originalType
) {
$this->originalType = $originalType;
$this->value = $value;
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Spatie\Backtrace\Arguments\ReducedArgument;
interface ReducedArgumentContract
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Spatie\Backtrace\Arguments\ReducedArgument;
class TruncatedReducedArgument extends ReducedArgument
{
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Spatie\Backtrace\Arguments\ReducedArgument;
class UnReducedArgument implements ReducedArgumentContract
{
/** @var self|null */
private static $instance = null;
private function __construct()
{
}
public static function create(): self
{
if (self::$instance !== null) {
return self::$instance;
}
return self::$instance = new self();
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Spatie\Backtrace\Arguments\ReducedArgument;
use Exception;
class VariadicReducedArgument extends ReducedArgument
{
public function __construct(array $value)
{
foreach ($value as $key => $item) {
if (! $item instanceof ReducedArgument) {
throw new Exception('VariadicReducedArgument must be an array of ReducedArgument');
}
$value[$key] = $item->value;
}
parent::__construct($value, 'array');
}
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
interface ArgumentReducer
{
/**
* @param mixed $argument
*/
public function execute($argument): ReducedArgumentContract;
}

View File

@@ -0,0 +1,52 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ArgumentReducers;
use Spatie\Backtrace\Arguments\ReduceArgumentPayloadAction;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\TruncatedReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class ArrayArgumentReducer implements ReducedArgumentContract
{
/** @var int */
protected $maxArraySize = 25;
/** @var \Spatie\Backtrace\Arguments\ReduceArgumentPayloadAction */
protected $reduceArgumentPayloadAction;
public function __construct()
{
$this->reduceArgumentPayloadAction = new ReduceArgumentPayloadAction(ArgumentReducers::minimal());
}
public function execute($argument): ReducedArgumentContract
{
if (! is_array($argument)) {
return UnReducedArgument::create();
}
return $this->reduceArgument($argument, 'array');
}
protected function reduceArgument(array $argument, string $originalType): ReducedArgumentContract
{
foreach ($argument as $key => $value) {
$argument[$key] = $this->reduceArgumentPayloadAction->reduce(
$value,
true
)->value;
}
if (count($argument) > $this->maxArraySize) {
return new TruncatedReducedArgument(
array_slice($argument, 0, $this->maxArraySize),
'array'
);
}
return new ReducedArgument($argument, $originalType);
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class BaseTypeArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (is_int($argument)
|| is_float($argument)
|| is_bool($argument)
|| is_string($argument)
|| $argument === null
) {
return new ReducedArgument($argument, get_debug_type($argument));
}
return UnReducedArgument::create();
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Closure;
use ReflectionFunction;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class ClosureArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof Closure) {
return UnReducedArgument::create();
}
$reflection = new ReflectionFunction($argument);
if ($reflection->getFileName() && $reflection->getStartLine() && $reflection->getEndLine()) {
return new ReducedArgument(
"{$reflection->getFileName()}:{$reflection->getStartLine()}-{$reflection->getEndLine()}",
'Closure'
);
}
return new ReducedArgument("{$reflection->getFileName()}", 'Closure');
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use DateTimeInterface;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class DateTimeArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof DateTimeInterface) {
return UnReducedArgument::create();
}
return new ReducedArgument(
$argument->format('d M Y H:i:s e'),
get_class($argument),
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use DateTimeZone;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class DateTimeZoneArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof DateTimeZone) {
return UnReducedArgument::create();
}
return new ReducedArgument(
$argument->getName(),
get_class($argument),
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
use UnitEnum;
class EnumArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof UnitEnum) {
return UnReducedArgument::create();
}
return new ReducedArgument(
get_class($argument).'::'.$argument->name,
get_class($argument),
);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class MinimalArrayArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! is_array($argument)) {
return UnReducedArgument::create();
}
return new ReducedArgument(
'array (size='.count($argument).')',
'array'
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use SensitiveParameterValue;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
class SensitiveParameterArrayReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof SensitiveParameterValue) {
return UnReducedArgument::create();
}
return new ReducedArgument(
'SensitiveParameterValue('.get_debug_type($argument->getValue()).')',
get_class($argument)
);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
use stdClass;
class StdClassArgumentReducer extends ArrayArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof stdClass) {
return UnReducedArgument::create();
}
return parent::reduceArgument((array) $argument, stdClass::class);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
use Stringable;
class StringableArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof Stringable) {
return UnReducedArgument::create();
}
return new ReducedArgument(
(string) $argument,
get_class($argument),
);
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Spatie\Backtrace\Arguments\Reducers;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgument;
use Spatie\Backtrace\Arguments\ReducedArgument\ReducedArgumentContract;
use Spatie\Backtrace\Arguments\ReducedArgument\UnReducedArgument;
use Symfony\Component\HttpFoundation\Request;
class SymphonyRequestArgumentReducer implements ArgumentReducer
{
public function execute($argument): ReducedArgumentContract
{
if (! $argument instanceof Request) {
return UnReducedArgument::create();
}
return new ReducedArgument(
"{$argument->getMethod()} {$argument->getUri()}",
get_class($argument),
);
}
}

View File

@@ -0,0 +1,300 @@
<?php
namespace Spatie\Backtrace;
use Closure;
use Laravel\SerializableClosure\Support\ClosureStream;
use Spatie\Backtrace\Arguments\ArgumentReducers;
use Spatie\Backtrace\Arguments\ReduceArgumentsAction;
use Spatie\Backtrace\Arguments\Reducers\ArgumentReducer;
use Throwable;
class Backtrace
{
/** @var bool */
protected $withArguments = false;
/** @var bool */
protected $reduceArguments = false;
/** @var array<class-string<ArgumentReducer>|ArgumentReducer>|ArgumentReducers|null */
protected $argumentReducers = null;
/** @var bool */
protected $withObject = false;
/** @var bool */
protected $trimFilePaths = false;
/** @var string|null */
protected $applicationPath;
/** @var int */
protected $offset = 0;
/** @var int */
protected $limit = 0;
/** @var \Closure|null */
protected $startingFromFrameClosure = null;
/** @var \Throwable|null */
protected $throwable = null;
public static function create(): self
{
return new static();
}
public static function createForThrowable(Throwable $throwable): self
{
return (new static())->forThrowable($throwable);
}
protected function forThrowable(Throwable $throwable): self
{
$this->throwable = $throwable;
return $this;
}
public function withArguments(
bool $withArguments = true
): self {
$this->withArguments = $withArguments;
return $this;
}
/**
* @param array<class-string<ArgumentReducer>|ArgumentReducer>|ArgumentReducers|null $argumentReducers
*
* @return $this
*/
public function reduceArguments(
$argumentReducers = null
): self {
$this->reduceArguments = true;
$this->argumentReducers = $argumentReducers;
return $this;
}
public function withObject(): self
{
$this->withObject = true;
return $this;
}
public function applicationPath(string $applicationPath): self
{
$this->applicationPath = rtrim($applicationPath, '/');
return $this;
}
public function trimFilePaths(): self
{
$this->trimFilePaths = true;
return $this;
}
public function offset(int $offset): self
{
$this->offset = $offset;
return $this;
}
public function limit(int $limit): self
{
$this->limit = $limit;
return $this;
}
public function startingFromFrame(Closure $startingFromFrameClosure)
{
$this->startingFromFrameClosure = $startingFromFrameClosure;
return $this;
}
/**
* @return \Spatie\Backtrace\Frame[]
*/
public function frames(): array
{
$rawFrames = $this->getRawFrames();
return $this->toFrameObjects($rawFrames);
}
public function firstApplicationFrameIndex(): ?int
{
foreach ($this->frames() as $index => $frame) {
if ($frame->applicationFrame) {
return $index;
}
}
return null;
}
protected function getRawFrames(): array
{
if ($this->throwable) {
return $this->throwable->getTrace();
}
$options = DEBUG_BACKTRACE_PROVIDE_OBJECT;
if (! $this->withArguments) {
$options = $options | DEBUG_BACKTRACE_IGNORE_ARGS;
}
if ($this->withObject) {
$options = $options | DEBUG_BACKTRACE_PROVIDE_OBJECT;
}
$limit = $this->limit;
if ($limit !== 0) {
$limit += 3;
}
return debug_backtrace($options, $limit);
}
/**
* @return \Spatie\Backtrace\Frame[]
*/
protected function toFrameObjects(array $rawFrames): array
{
$currentFile = $this->throwable ? $this->throwable->getFile() : '';
$currentLine = $this->throwable ? $this->throwable->getLine() : 0;
$arguments = $this->withArguments ? [] : null;
$frames = [];
$reduceArgumentsAction = new ReduceArgumentsAction($this->resolveArgumentReducers());
foreach ($rawFrames as $rawFrame) {
$textSnippet = null;
if (
class_exists(ClosureStream::class)
&& substr($currentFile, 0, strlen(ClosureStream::STREAM_PROTO)) === ClosureStream::STREAM_PROTO
) {
$textSnippet = $currentFile;
$currentFile = ClosureStream::STREAM_PROTO.'://function()';
$currentLine -= 1;
}
if ($this->trimFilePaths && $this->applicationPath) {
$trimmedFilePath = str_replace($this->applicationPath, '', $currentFile);
}
$frame = new Frame(
$currentFile,
$currentLine,
$arguments,
$rawFrame['function'] ?? null,
$rawFrame['class'] ?? null,
$this->isApplicationFrame($currentFile),
$textSnippet,
$trimmedFilePath ?? null,
);
$frames[] = $frame;
$arguments = $this->withArguments
? $rawFrame['args'] ?? null
: null;
if ($this->reduceArguments) {
$arguments = $reduceArgumentsAction->execute(
$rawFrame['class'] ?? null,
$rawFrame['function'] ?? null,
$arguments
);
}
$currentFile = $rawFrame['file'] ?? 'unknown';
$currentLine = $rawFrame['line'] ?? 0;
}
$frames[] = new Frame(
$currentFile,
$currentLine,
[],
'[top]'
);
$frames = $this->removeBacktracePackageFrames($frames);
if ($closure = $this->startingFromFrameClosure) {
$frames = $this->startAtFrameFromClosure($frames, $closure);
}
$frames = array_slice($frames, $this->offset, $this->limit === 0 ? PHP_INT_MAX : $this->limit);
return array_values($frames);
}
protected function isApplicationFrame(string $frameFilename): bool
{
$relativeFile = str_replace('\\', DIRECTORY_SEPARATOR, $frameFilename);
if (! empty($this->applicationPath)) {
$relativeFile = array_reverse(explode($this->applicationPath ?? '', $frameFilename, 2))[0];
}
if (strpos($relativeFile, DIRECTORY_SEPARATOR.'vendor') === 0) {
return false;
}
return true;
}
protected function removeBacktracePackageFrames(array $frames): array
{
return $this->startAtFrameFromClosure($frames, function (Frame $frame) {
return $frame->class !== static::class;
});
}
/**
* @param \Spatie\Backtrace\Frame[] $frames
* @param \Closure $closure
*
* @return array
*/
protected function startAtFrameFromClosure(array $frames, Closure $closure): array
{
foreach ($frames as $i => $frame) {
$foundStartingFrame = $closure($frame);
if ($foundStartingFrame) {
return $frames;
}
unset($frames[$i]);
}
return $frames;
}
protected function resolveArgumentReducers(): ArgumentReducers
{
if ($this->argumentReducers === null) {
return ArgumentReducers::default();
}
if ($this->argumentReducers instanceof ArgumentReducers) {
return $this->argumentReducers;
}
return ArgumentReducers::create($this->argumentReducers);
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace Spatie\Backtrace\CodeSnippets;
use RuntimeException;
class CodeSnippet
{
/** @var int */
protected $surroundingLine = 1;
/** @var int */
protected $snippetLineCount = 9;
public function surroundingLine(int $surroundingLine): self
{
$this->surroundingLine = $surroundingLine;
return $this;
}
public function snippetLineCount(int $snippetLineCount): self
{
$this->snippetLineCount = $snippetLineCount;
return $this;
}
public function get(SnippetProvider $provider): array
{
try {
[$startLineNumber, $endLineNumber] = $this->getBounds($provider->numberOfLines());
$code = [];
$line = $provider->getLine($startLineNumber);
$currentLineNumber = $startLineNumber;
while ($currentLineNumber <= $endLineNumber) {
$code[$currentLineNumber] = rtrim(substr($line, 0, 250));
$line = $provider->getNextLine();
$currentLineNumber++;
}
return $code;
} catch (RuntimeException $exception) {
return [];
}
}
public function getAsString(SnippetProvider $provider): string
{
$snippet = $this->get($provider);
$snippetStrings = array_map(function (string $line, string $number) {
return "{$number} {$line}";
}, $snippet, array_keys($snippet));
return implode(PHP_EOL, $snippetStrings);
}
protected function getBounds(int $totalNumberOfLineInFile): array
{
$startLine = max($this->surroundingLine - floor($this->snippetLineCount / 2), 1);
$endLine = $startLine + ($this->snippetLineCount - 1);
if ($endLine > $totalNumberOfLineInFile) {
$endLine = $totalNumberOfLineInFile;
$startLine = max($endLine - ($this->snippetLineCount - 1), 1);
}
return [$startLine, $endLine];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace Spatie\Backtrace\CodeSnippets;
use SplFileObject;
class FileSnippetProvider implements SnippetProvider
{
/** @var \SplFileObject */
protected $file;
public function __construct(string $path)
{
$this->file = new SplFileObject($path);
}
public function numberOfLines(): int
{
$this->file->seek(PHP_INT_MAX);
return $this->file->key() + 1;
}
public function getLine(?int $lineNumber = null): string
{
if (is_null($lineNumber)) {
return $this->getNextLine();
}
$this->file->seek($lineNumber - 1);
return $this->file->current();
}
public function getNextLine(): string
{
$this->file->next();
return $this->file->current();
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Spatie\Backtrace\CodeSnippets;
class LaravelSerializableClosureSnippetProvider implements SnippetProvider
{
/** @var array<string> */
protected $lines;
/** @var int */
protected $counter = 0;
public function __construct(string $snippet)
{
$this->lines = preg_split("/\r\n|\n|\r/", $snippet);
$this->cleanupLines();
}
public function numberOfLines(): int
{
return count($this->lines);
}
public function getLine(?int $lineNumber = null): string
{
if (is_null($lineNumber)) {
return $this->getNextLine();
}
$this->counter = $lineNumber - 1;
return $this->lines[$lineNumber - 1];
}
public function getNextLine(): string
{
$this->counter++;
if ($this->counter >= count($this->lines)) {
return '';
}
return $this->lines[$this->counter];
}
protected function cleanupLines(): void
{
$spacesOrTabsToRemove = PHP_INT_MAX;
for ($i = 1; $i < count($this->lines); $i++) {
if (empty($this->lines[$i])) {
continue;
}
$spacesOrTabsToRemove = min(strspn($this->lines[$i], " \t"), $spacesOrTabsToRemove);
}
if ($spacesOrTabsToRemove === PHP_INT_MAX) {
$spacesOrTabsToRemove = 0;
}
for ($i = 1; $i < count($this->lines); $i++) {
$this->lines[$i] = substr($this->lines[$i], $spacesOrTabsToRemove);
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
namespace Spatie\Backtrace\CodeSnippets;
class NullSnippetProvider implements SnippetProvider
{
public function numberOfLines(): int
{
return 1;
}
public function getLine(?int $lineNumber = null): string
{
return $this->getNextLine();
}
public function getNextLine(): string
{
return "File not found for code snippet";
}
}

View File

@@ -0,0 +1,12 @@
<?php
namespace Spatie\Backtrace\CodeSnippets;
interface SnippetProvider
{
public function numberOfLines(): int;
public function getLine(?int $lineNumber = null): string;
public function getNextLine(): string;
}

104
vendor/spatie/backtrace/src/Frame.php vendored Normal file
View File

@@ -0,0 +1,104 @@
<?php
namespace Spatie\Backtrace;
use Spatie\Backtrace\CodeSnippets\CodeSnippet;
use Spatie\Backtrace\CodeSnippets\FileSnippetProvider;
use Spatie\Backtrace\CodeSnippets\LaravelSerializableClosureSnippetProvider;
use Spatie\Backtrace\CodeSnippets\NullSnippetProvider;
use Spatie\Backtrace\CodeSnippets\SnippetProvider;
class Frame
{
/** @var string */
public $file;
/** @var string|null */
public $trimmedFilePath;
/** @var int */
public $lineNumber;
/** @var array|null */
public $arguments = null;
/** @var bool */
public $applicationFrame;
/** @var string|null */
public $method;
/** @var string|null */
public $class;
/** @var string|null */
protected $textSnippet;
public function __construct(
string $file,
int $lineNumber,
?array $arguments,
?string $method = null,
?string $class = null,
bool $isApplicationFrame = false,
?string $textSnippet = null,
?string $trimmedFilePath = null
) {
$this->file = $file;
$this->trimmedFilePath = $trimmedFilePath;
$this->lineNumber = $lineNumber;
$this->arguments = $arguments;
$this->method = $method;
$this->class = $class;
$this->applicationFrame = $isApplicationFrame;
$this->textSnippet = $textSnippet;
}
public function getSnippet(int $lineCount): array
{
return (new CodeSnippet())
->surroundingLine($this->lineNumber)
->snippetLineCount($lineCount)
->get($this->getCodeSnippetProvider());
}
public function getSnippetAsString(int $lineCount): string
{
return (new CodeSnippet())
->surroundingLine($this->lineNumber)
->snippetLineCount($lineCount)
->getAsString($this->getCodeSnippetProvider());
}
public function getSnippetProperties(int $lineCount): array
{
$snippet = $this->getSnippet($lineCount);
return array_map(function (int $lineNumber) use ($snippet) {
return [
'line_number' => $lineNumber,
'text' => $snippet[$lineNumber],
];
}, array_keys($snippet));
}
protected function getCodeSnippetProvider(): SnippetProvider
{
if ($this->textSnippet) {
return new LaravelSerializableClosureSnippetProvider($this->textSnippet);
}
if (file_exists($this->file)) {
return new FileSnippetProvider($this->file);
}
return new NullSnippetProvider();
}
}

View File

@@ -0,0 +1,35 @@
<?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);

View File

@@ -0,0 +1,76 @@
# Changelog
All notable changes to `error-solutions` will be documented in this file.
## 1.1.1 - 2024-07-25
### What's Changed
* Fix OpenAI response text links by @Lukaaashek in https://github.com/spatie/error-solutions/pull/9
### New Contributors
* @Lukaaashek made their first contribution in https://github.com/spatie/error-solutions/pull/9
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.1.0...1.1.1
## 1.1.0 - 2024-07-22
### What's Changed
* Allow to customize OpenAI Model by @arnebr in https://github.com/spatie/error-solutions/pull/7
### New Contributors
* @arnebr made their first contribution in https://github.com/spatie/error-solutions/pull/7
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.5...1.1.0
## 1.0.5 - 2024-07-09
### What's Changed
* Legacy `RunnableSolution` should continue to extend legacy `Solution` by @duncanmcclean in https://github.com/spatie/error-solutions/pull/6
### New Contributors
* @duncanmcclean made their first contribution in https://github.com/spatie/error-solutions/pull/6
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.4...1.0.5
## 1.0.4 - 2024-06-28
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.3...1.0.4
## 1.0.3 - 2024-06-27
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.2...1.0.3
## 1.0.2 - 2024-06-26
### What's Changed
* Fix AI solutions
* Bump dependabot/fetch-metadata from 1.6.0 to 2.1.0 by @dependabot in https://github.com/spatie/error-solutions/pull/1
### New Contributors
* @dependabot made their first contribution in https://github.com/spatie/error-solutions/pull/1
**Full Changelog**: https://github.com/spatie/error-solutions/compare/0.0.1...1.0.2
## 1.0.1 - 2024-06-21
- Add the legacy string comperator
**Full Changelog**: https://github.com/spatie/error-solutions/compare/1.0.0...1.0.1
## 1.0.0 - 2024-06-12
- Initial release
**Full Changelog**: https://github.com/spatie/error-solutions/compare/0.0.1...1.0.0
## 0.0.1 - 2024-06-11
**Full Changelog**: https://github.com/spatie/error-solutions/commits/0.0.1

View File

@@ -0,0 +1,21 @@
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.

57
vendor/spatie/error-solutions/README.md vendored Normal file
View File

@@ -0,0 +1,57 @@
# Error solutions
[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/error-solutions.svg?style=flat-square)](https://packagist.org/packages/spatie/error-solutions)
[![Tests](https://img.shields.io/github/actions/workflow/status/spatie/error-solutions/run-tests.yml?branch=main&label=tests&style=flat-square)](https://github.com/spatie/error-solutions/actions/workflows/run-tests.yml)
[![Total Downloads](https://img.shields.io/packagist/dt/spatie/error-solutions.svg?style=flat-square)](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.

View File

@@ -0,0 +1,69 @@
{
"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
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Contracts;
class BaseSolution extends \Spatie\ErrorSolutions\Contracts\BaseSolution implements Solution
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Contracts;
interface HasSolutionsForThrowable extends \Spatie\ErrorSolutions\Contracts\HasSolutionsForThrowable
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Contracts;
interface ProvidesSolution extends \Spatie\ErrorSolutions\Contracts\ProvidesSolution
{
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Spatie\Ignition\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;
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Contracts;
interface Solution extends \Spatie\ErrorSolutions\Contracts\Solution
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Spatie\Ignition\Contracts;
interface SolutionProviderRepository extends \Spatie\ErrorSolutions\Contracts\SolutionProviderRepository
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Spatie\Ignition\Solutions\OpenAi;
class DummyCache extends \Spatie\ErrorSolutions\Solutions\OpenAi\DummyCache
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Solutions\OpenAi;
class OpenAiPromptViewModel extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiPromptViewModel
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\Ignition\Solutions\OpenAi;
use Spatie\Ignition\Contracts\Solution;
class OpenAiSolution extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolution implements Solution
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\Ignition\Solutions\OpenAi;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
class OpenAiSolutionProvider extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionProvider implements HasSolutionsForThrowable
{
}

View File

@@ -0,0 +1,8 @@
<?php
namespace Spatie\Ignition\Solutions\OpenAi;
class OpenAiSolutionResponse extends \Spatie\ErrorSolutions\Solutions\OpenAi\OpenAiSolutionResponse
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\Ignition\Solutions\SolutionProviders;
use Spatie\ErrorSolutions\SolutionProviders\BadMethodCallSolutionProvider as BaseBadMethodCallSolutionProviderAlias;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
class BadMethodCallSolutionProvider extends BaseBadMethodCallSolutionProviderAlias implements HasSolutionsForThrowable
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\Ignition\Solutions\SolutionProviders;
use Spatie\ErrorSolutions\SolutionProviders\MergeConflictSolutionProvider as BaseMergeConflictSolutionProviderAlias;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
class MergeConflictSolutionProvider extends BaseMergeConflictSolutionProviderAlias implements HasSolutionsForThrowable
{
}

View File

@@ -0,0 +1,10 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\Ignition\Solutions\SolutionProviders;
use Spatie\ErrorSolutions\SolutionProviders\UndefinedPropertySolutionProvider as BaseUndefinedPropertySolutionProviderAlias;
use Spatie\Ignition\Contracts\HasSolutionsForThrowable;
class UndefinedPropertySolutionProvider extends BaseUndefinedPropertySolutionProviderAlias implements HasSolutionsForThrowable
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Spatie\Ignition\Solutions;
class SolutionTransformer extends \Spatie\ErrorSolutions\Solutions\SolutionTransformer
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\Ignition\Solutions;
use Spatie\ErrorSolutions\Solutions\SuggestCorrectVariableNameSolution as BaseSuggestCorrectVariableNameSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestCorrectVariableNameSolution extends BaseSuggestCorrectVariableNameSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\Ignition\Solutions;
use Spatie\ErrorSolutions\Solutions\SuggestImportSolution as BaseSuggestImportSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestImportSolution extends BaseSuggestImportSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\GenerateAppKeySolution as BaseGenerateAppKeySolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class GenerateAppKeySolution extends BaseGenerateAppKeySolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\LivewireDiscoverSolution as BaseLivewireDiscoverSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class LivewireDiscoverSolution extends BaseLivewireDiscoverSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\MakeViewVariableOptionalSolution as BaseMakeViewVariableOptionalSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class MakeViewVariableOptionalSolution extends BaseMakeViewVariableOptionalSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\RunMigrationsSolution as BaseRunMigrationsSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class RunMigrationsSolution extends BaseRunMigrationsSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,12 @@
<?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
{
}

View File

@@ -0,0 +1,12 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?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
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\SuggestCorrectVariableNameSolution as BaseSuggestCorrectVariableNameSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestCorrectVariableNameSolution extends BaseSuggestCorrectVariableNameSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\SuggestImportSolution as BaseSuggestImportSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestImportSolution extends BaseSuggestImportSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewireMethodNameSolution as BaseSuggestLivewireMethodNameSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestLivewireMethodNameSolution extends BaseSuggestLivewireMethodNameSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\SuggestLivewirePropertyNameSolution as BaseSuggestLivewirePropertyNameSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestLivewirePropertyNameSolution extends BaseSuggestLivewirePropertyNameSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingCorrectDbNameSolution as BaseSuggestUsingCorrectDbNameSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestUsingCorrectDbNameSolution extends BaseSuggestUsingCorrectDbNameSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMariadbDatabaseSolution as BaseSuggestUsingMariadbDatabaseSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestUsingMariadbDatabaseSolution extends BaseSuggestUsingMariadbDatabaseSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\SuggestUsingMysql8DatabaseSolution as BaseSuggestUsingMysql8DatabaseSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class SuggestUsingMysql8DatabaseSolution extends BaseSuggestUsingMysql8DatabaseSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\LaravelIgnition\Solutions;
use Spatie\ErrorSolutions\Solutions\Laravel\UseDefaultValetDbCredentialsSolution as BaseUseDefaultValetDbCredentialsSolutionAlias;
use Spatie\Ignition\Contracts\Solution;
class UseDefaultValetDbCredentialsSolution extends BaseUseDefaultValetDbCredentialsSolutionAlias implements Solution
{
}

View File

@@ -0,0 +1,10 @@
<?php
namespace Spatie\LaravelIgnition\Support;
use Spatie\ErrorSolutions\Support\Laravel\StringComparator as BaseStringComparator;
class StringComparator extends BaseStringComparator
{
}

View File

@@ -0,0 +1,181 @@
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

View File

@@ -0,0 +1,11 @@
includes:
- phpstan-baseline.neon
parameters:
level: 8
paths:
- src
tmpDir: build/phpstan
checkMissingIterableValueType: true

View File

@@ -0,0 +1,36 @@
<?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() ?>

View File

@@ -0,0 +1,65 @@
<?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;
}
}

View File

@@ -0,0 +1,16 @@
<?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;
}

View File

@@ -0,0 +1,11 @@
<?php
namespace Spatie\ErrorSolutions\Contracts;
/**
* Interface to be used on exceptions that provide their own solution.
*/
interface ProvidesSolution
{
public function getSolution(): Solution;
}

View File

@@ -0,0 +1,16 @@
<?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;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace Spatie\ErrorSolutions\Contracts;
interface Solution
{
public function getSolutionTitle(): string;
public function getSolutionDescription(): string;
/** @return array<string, string> */
public function getDocumentationLinks(): array;
}

View File

@@ -0,0 +1,36 @@
<?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;
}

Some files were not shown because too many files have changed in this diff Show More