Upgrade framework
This commit is contained in:
56
vendor/spatie/flare-client-php/src/FlareMiddleware/AddDocumentationLinks.php
vendored
Normal file
56
vendor/spatie/flare-client-php/src/FlareMiddleware/AddDocumentationLinks.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use ArrayObject;
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class AddDocumentationLinks implements FlareMiddleware
|
||||
{
|
||||
protected ArrayObject $documentationLinkResolvers;
|
||||
|
||||
public function __construct(ArrayObject $documentationLinkResolvers)
|
||||
{
|
||||
$this->documentationLinkResolvers = $documentationLinkResolvers;
|
||||
}
|
||||
|
||||
public function handle(Report $report, Closure $next)
|
||||
{
|
||||
if (! $throwable = $report->getThrowable()) {
|
||||
return $next($report);
|
||||
}
|
||||
|
||||
$links = $this->getLinks($throwable);
|
||||
|
||||
if (count($links)) {
|
||||
$report->addDocumentationLinks($links);
|
||||
}
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
|
||||
/** @return array<int, string> */
|
||||
protected function getLinks(\Throwable $throwable): array
|
||||
{
|
||||
$allLinks = [];
|
||||
|
||||
foreach ($this->documentationLinkResolvers as $resolver) {
|
||||
$resolvedLinks = $resolver($throwable);
|
||||
|
||||
if (is_null($resolvedLinks)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is_string($resolvedLinks)) {
|
||||
$resolvedLinks = [$resolvedLinks];
|
||||
}
|
||||
|
||||
foreach ($resolvedLinks as $link) {
|
||||
$allLinks[] = $link;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($allLinks));
|
||||
}
|
||||
}
|
||||
18
vendor/spatie/flare-client-php/src/FlareMiddleware/AddEnvironmentInformation.php
vendored
Normal file
18
vendor/spatie/flare-client-php/src/FlareMiddleware/AddEnvironmentInformation.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class AddEnvironmentInformation implements FlareMiddleware
|
||||
{
|
||||
public function handle(Report $report, Closure $next)
|
||||
{
|
||||
$report->group('env', [
|
||||
'php_version' => phpversion(),
|
||||
]);
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
89
vendor/spatie/flare-client-php/src/FlareMiddleware/AddGitInformation.php
vendored
Normal file
89
vendor/spatie/flare-client-php/src/FlareMiddleware/AddGitInformation.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Report;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Throwable;
|
||||
|
||||
class AddGitInformation
|
||||
{
|
||||
protected ?string $baseDir = null;
|
||||
|
||||
public function handle(Report $report, Closure $next)
|
||||
{
|
||||
try {
|
||||
$this->baseDir = $this->getGitBaseDirectory();
|
||||
|
||||
if (! $this->baseDir) {
|
||||
return $next($report);
|
||||
}
|
||||
|
||||
$report->group('git', [
|
||||
'hash' => $this->hash(),
|
||||
'message' => $this->message(),
|
||||
'tag' => $this->tag(),
|
||||
'remote' => $this->remote(),
|
||||
'isDirty' => ! $this->isClean(),
|
||||
]);
|
||||
} catch (Throwable) {
|
||||
}
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
|
||||
protected function hash(): ?string
|
||||
{
|
||||
return $this->command("git log --pretty=format:'%H' -n 1") ?: null;
|
||||
}
|
||||
|
||||
protected function message(): ?string
|
||||
{
|
||||
return $this->command("git log --pretty=format:'%s' -n 1") ?: null;
|
||||
}
|
||||
|
||||
protected function tag(): ?string
|
||||
{
|
||||
return $this->command('git describe --tags --abbrev=0') ?: null;
|
||||
}
|
||||
|
||||
protected function remote(): ?string
|
||||
{
|
||||
return $this->command('git config --get remote.origin.url') ?: null;
|
||||
}
|
||||
|
||||
protected function isClean(): bool
|
||||
{
|
||||
return empty($this->command('git status -s'));
|
||||
}
|
||||
|
||||
protected function getGitBaseDirectory(): ?string
|
||||
{
|
||||
/** @var Process $process */
|
||||
$process = Process::fromShellCommandline("echo $(git rev-parse --show-toplevel)")->setTimeout(1);
|
||||
|
||||
$process->run();
|
||||
|
||||
if (! $process->isSuccessful()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$directory = trim($process->getOutput());
|
||||
|
||||
if (! file_exists($directory)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $directory;
|
||||
}
|
||||
|
||||
protected function command($command)
|
||||
{
|
||||
$process = Process::fromShellCommandline($command, $this->baseDir)->setTimeout(1);
|
||||
|
||||
$process->run();
|
||||
|
||||
return trim($process->getOutput());
|
||||
}
|
||||
}
|
||||
28
vendor/spatie/flare-client-php/src/FlareMiddleware/AddGlows.php
vendored
Normal file
28
vendor/spatie/flare-client-php/src/FlareMiddleware/AddGlows.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Glows\GlowRecorder;
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class AddGlows implements FlareMiddleware
|
||||
{
|
||||
protected GlowRecorder $recorder;
|
||||
|
||||
public function __construct(GlowRecorder $recorder)
|
||||
{
|
||||
$this->recorder = $recorder;
|
||||
}
|
||||
|
||||
public function handle(Report $report, Closure $next)
|
||||
{
|
||||
foreach ($this->recorder->glows() as $glow) {
|
||||
$report->addGlow($glow);
|
||||
}
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
17
vendor/spatie/flare-client-php/src/FlareMiddleware/AddNotifierName.php
vendored
Normal file
17
vendor/spatie/flare-client-php/src/FlareMiddleware/AddNotifierName.php
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class AddNotifierName implements FlareMiddleware
|
||||
{
|
||||
public const NOTIFIER_NAME = 'Flare Client';
|
||||
|
||||
public function handle(Report $report, $next)
|
||||
{
|
||||
$report->notifierName(static::NOTIFIER_NAME);
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
30
vendor/spatie/flare-client-php/src/FlareMiddleware/AddSolutions.php
vendored
Normal file
30
vendor/spatie/flare-client-php/src/FlareMiddleware/AddSolutions.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Report;
|
||||
use Spatie\Ignition\Contracts\SolutionProviderRepository;
|
||||
|
||||
class AddSolutions implements FlareMiddleware
|
||||
{
|
||||
protected SolutionProviderRepository $solutionProviderRepository;
|
||||
|
||||
public function __construct(SolutionProviderRepository $solutionProviderRepository)
|
||||
{
|
||||
$this->solutionProviderRepository = $solutionProviderRepository;
|
||||
}
|
||||
|
||||
public function handle(Report $report, Closure $next)
|
||||
{
|
||||
if ($throwable = $report->getThrowable()) {
|
||||
$solutions = $this->solutionProviderRepository->getSolutionsForThrowable($throwable);
|
||||
|
||||
foreach ($solutions as $solution) {
|
||||
$report->addSolution($solution);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
30
vendor/spatie/flare-client-php/src/FlareMiddleware/CensorRequestBodyFields.php
vendored
Normal file
30
vendor/spatie/flare-client-php/src/FlareMiddleware/CensorRequestBodyFields.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class CensorRequestBodyFields implements FlareMiddleware
|
||||
{
|
||||
protected array $fieldNames = [];
|
||||
|
||||
public function __construct(array $fieldNames)
|
||||
{
|
||||
$this->fieldNames = $fieldNames;
|
||||
}
|
||||
|
||||
public function handle(Report $report, $next)
|
||||
{
|
||||
$context = $report->allContext();
|
||||
|
||||
foreach ($this->fieldNames as $fieldName) {
|
||||
if (isset($context['request_data']['body'][$fieldName])) {
|
||||
$context['request_data']['body'][$fieldName] = '<CENSORED>';
|
||||
}
|
||||
}
|
||||
|
||||
$report->userProvidedContext($context);
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
32
vendor/spatie/flare-client-php/src/FlareMiddleware/CensorRequestHeaders.php
vendored
Normal file
32
vendor/spatie/flare-client-php/src/FlareMiddleware/CensorRequestHeaders.php
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class CensorRequestHeaders implements FlareMiddleware
|
||||
{
|
||||
protected array $headers = [];
|
||||
|
||||
public function __construct(array $headers)
|
||||
{
|
||||
$this->headers = $headers;
|
||||
}
|
||||
|
||||
public function handle(Report $report, $next)
|
||||
{
|
||||
$context = $report->allContext();
|
||||
|
||||
foreach ($this->headers as $header) {
|
||||
$header = strtolower($header);
|
||||
|
||||
if (isset($context['headers'][$header])) {
|
||||
$context['headers'][$header] = '<CENSORED>';
|
||||
}
|
||||
}
|
||||
|
||||
$report->userProvidedContext($context);
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
11
vendor/spatie/flare-client-php/src/FlareMiddleware/FlareMiddleware.php
vendored
Normal file
11
vendor/spatie/flare-client-php/src/FlareMiddleware/FlareMiddleware.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Closure;
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
interface FlareMiddleware
|
||||
{
|
||||
public function handle(Report $report, Closure $next);
|
||||
}
|
||||
19
vendor/spatie/flare-client-php/src/FlareMiddleware/RemoveRequestIp.php
vendored
Normal file
19
vendor/spatie/flare-client-php/src/FlareMiddleware/RemoveRequestIp.php
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Spatie\FlareClient\FlareMiddleware;
|
||||
|
||||
use Spatie\FlareClient\Report;
|
||||
|
||||
class RemoveRequestIp implements FlareMiddleware
|
||||
{
|
||||
public function handle(Report $report, $next)
|
||||
{
|
||||
$context = $report->allContext();
|
||||
|
||||
$context['request']['ip'] = null;
|
||||
|
||||
$report->userProvidedContext($context);
|
||||
|
||||
return $next($report);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user