-
+

@yield('code') -

+ -
+
@yield('message')
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Attributes/ErrorBag.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Attributes/ErrorBag.php new file mode 100644 index 0000000..a800e68 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Attributes/ErrorBag.php @@ -0,0 +1,19 @@ +validator; } + $this->configureFromAttributes(); + $factory = $this->container->make(ValidationFactory::class); if (method_exists($this, 'validator')) { - $validator = $this->container->call([$this, 'validator'], compact('factory')); + $validator = $this->container->call($this->validator(...), ['factory' => $factory]); } else { $validator = $this->createDefaultValidator($factory); } @@ -102,11 +118,49 @@ class FormRequest extends Request implements ValidatesWhenResolved )); } + if ($this->shouldFailOnUnknownFields()) { + $validator->after(function (Validator $validator) { + $this->validateNoUnknownFields($validator); + }); + } + $this->setValidator($validator); return $this->validator; } + /** + * Configure the form request from class attributes. + * + * @return void + */ + protected function configureFromAttributes() + { + $reflection = new ReflectionClass($this); + + if ($reflection->getAttributes(StopOnFirstFailure::class) !== []) { + $this->stopOnFirstFailure = true; + } + + $redirectTo = $reflection->getAttributes(RedirectTo::class); + + if ($redirectTo !== []) { + $this->redirect = $redirectTo[0]->newInstance()->url; + } + + $redirectToRoute = $reflection->getAttributes(RedirectToRoute::class); + + if ($redirectToRoute !== []) { + $this->redirectRoute = $redirectToRoute[0]->newInstance()->route; + } + + $errorBag = $reflection->getAttributes(ErrorBag::class); + + if ($errorBag !== []) { + $this->errorBag = $errorBag[0]->newInstance()->name; + } + } + /** * Create the default validator instance. * @@ -153,6 +207,72 @@ class FormRequest extends Request implements ValidatesWhenResolved return method_exists($this, 'rules') ? $this->container->call([$this, 'rules']) : []; } + /** + * Determine if fields not present in rules should fail validation. + * + * @return bool + */ + protected function shouldFailOnUnknownFields(): bool + { + $failOnUnknownFields = (new ReflectionClass($this))->getAttributes(FailOnUnknownFields::class); + + return $failOnUnknownFields !== [] + ? $failOnUnknownFields[0]->newInstance()->value + : static::$globalFailOnUnknownFields; + } + + /** + * Validate that no unknown fields were sent as input. + * + * @param \Illuminate\Contracts\Validation\Validator $validator + * @return void + */ + protected function validateNoUnknownFields(Validator $validator): void + { + $allowedKeys = array_keys($this->validationRules()); + + $input = $this->isJson() ? $this->json()->all() : $this->request->all(); + + foreach (array_keys(Arr::dot($input)) as $inputKey) { + if (! $this->isKnownField($inputKey, $allowedKeys)) { + $validator->errors()->add($inputKey, trans('validation.prohibited', [ + 'attribute' => str_replace('_', ' ', $inputKey), + ])); + } + } + } + + /** + * Determine if the given input key is an allowed key based on the validation rules. + * + * @param string $inputKey + * @param array $allowedKeys + * @return bool + */ + protected function isKnownField(string $inputKey, array $allowedKeys): bool + { + foreach ($allowedKeys as $ruleKey) { + if ($ruleKey === $inputKey) { + return true; + } + + if (str_ends_with($inputKey, '_confirmation') && + $ruleKey === substr($inputKey, 0, -13)) { + return true; + } + + if (str_contains($ruleKey, '*')) { + $pattern = '/^'.str_replace('\*', '[^.]+', preg_quote($ruleKey, '/')).'$/'; + + if (preg_match($pattern, $inputKey)) { + return true; + } + } + } + + return false; + } + /** * Handle a failed validation attempt. * @@ -166,8 +286,8 @@ class FormRequest extends Request implements ValidatesWhenResolved $exception = $validator->getException(); throw (new $exception($validator)) - ->errorBag($this->errorBag) - ->redirectTo($this->getRedirectUrl()); + ->errorBag($this->errorBag) + ->redirectTo($this->getRedirectUrl()); } /** @@ -179,15 +299,12 @@ class FormRequest extends Request implements ValidatesWhenResolved { $url = $this->redirector->getUrlGenerator(); - if ($this->redirect) { - return $url->to($this->redirect); - } elseif ($this->redirectRoute) { - return $url->route($this->redirectRoute); - } elseif ($this->redirectAction) { - return $url->action($this->redirectAction); - } - - return $url->previous(); + return match (true) { + ! empty($this->redirect) => $url->to($this->redirect), + ! empty($this->redirectRoute) => $url->route($this->redirectRoute), + ! empty($this->redirectAction) => $url->action($this->redirectAction), + default => $url->previous(), + }; } /** @@ -223,14 +340,16 @@ class FormRequest extends Request implements ValidatesWhenResolved /** * Get a validated input container for the validated input. * - * @param array|null $keys - * @return \Illuminate\Support\ValidatedInput|array + * @param array|null $keys + * @return ($keys is array ? array : \Illuminate\Support\ValidatedInput) + * + * @throws \Illuminate\Validation\ValidationException */ public function safe(?array $keys = null) { return is_array($keys) - ? $this->validator->safe()->only($keys) - : $this->validator->safe(); + ? $this->validator->safe()->only($keys) + : $this->validator->safe(); } /** @@ -248,7 +367,7 @@ class FormRequest extends Request implements ValidatesWhenResolved /** * Get custom messages for validator errors. * - * @return array + * @return array */ public function messages() { @@ -258,13 +377,24 @@ class FormRequest extends Request implements ValidatesWhenResolved /** * Get custom attributes for validator errors. * - * @return array + * @return array */ public function attributes() { return []; } + /** + * Enable or disable unknown-field rejection globally for all form requests. + * + * @param bool $value + * @return void + */ + public static function failOnUnknownFields(bool $value = true): void + { + static::$globalFailOnUnknownFields = $value; + } + /** * Set the Validator instance. * @@ -303,4 +433,14 @@ class FormRequest extends Request implements ValidatesWhenResolved return $this; } + + /** + * Flush the global state of the form request. + * + * @return void + */ + public static function flushState(): void + { + static::$globalFailOnUnknownFields = false; + } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/HtmlDumper.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/HtmlDumper.php index 2df0901..72663f0 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/HtmlDumper.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/HtmlDumper.php @@ -53,7 +53,6 @@ class HtmlDumper extends BaseHtmlDumper * * @param string $basePath * @param string $compiledViewPath - * @return void */ public function __construct($basePath, $compiledViewPath) { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php index 3443751..3760a4d 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php @@ -12,7 +12,7 @@ use Illuminate\Foundation\Http\Events\RequestHandled; use Illuminate\Routing\Pipeline; use Illuminate\Routing\Router; use Illuminate\Support\Carbon; -use Illuminate\Support\Facades\Facade; +use Illuminate\Support\Facades\Request; use Illuminate\Support\InteractsWithTime; use InvalidArgumentException; use Throwable; @@ -119,7 +119,6 @@ class Kernel implements KernelContract * * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Routing\Router $router - * @return void */ public function __construct(Application $app, Router $router) { @@ -166,14 +165,14 @@ class Kernel implements KernelContract { $this->app->instance('request', $request); - Facade::clearResolvedInstance('request'); + Request::clearResolvedInstance(); $this->bootstrap(); return (new Pipeline($this->app)) - ->send($request) - ->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware) - ->then($this->dispatchToRouter()); + ->send($request) + ->through($this->app->shouldSkipMiddleware() ? [] : $this->middleware) + ->then($this->dispatchToRouter()); } /** @@ -451,6 +450,69 @@ class Kernel implements KernelContract return $this; } + /** + * Add the given middleware to the middleware priority list before other middleware. + * + * @param array|string $before + * @param string $middleware + * @return $this + */ + public function addToMiddlewarePriorityBefore($before, $middleware) + { + return $this->addToMiddlewarePriorityRelative($before, $middleware, after: false); + } + + /** + * Add the given middleware to the middleware priority list after other middleware. + * + * @param array|string $after + * @param string $middleware + * @return $this + */ + public function addToMiddlewarePriorityAfter($after, $middleware) + { + return $this->addToMiddlewarePriorityRelative($after, $middleware); + } + + /** + * Add the given middleware to the middleware priority list relative to other middleware. + * + * @param string|array $existing + * @param string $middleware + * @param bool $after + * @return $this + */ + protected function addToMiddlewarePriorityRelative($existing, $middleware, $after = true) + { + if (! in_array($middleware, $this->middlewarePriority)) { + $index = $after ? 0 : count($this->middlewarePriority); + + foreach ((array) $existing as $existingMiddleware) { + if (in_array($existingMiddleware, $this->middlewarePriority)) { + $middlewareIndex = array_search($existingMiddleware, $this->middlewarePriority); + + if ($after && $middlewareIndex > $index) { + $index = $middlewareIndex + 1; + } elseif ($after === false && $middlewareIndex < $index) { + $index = $middlewareIndex; + } + } + } + + if ($index === 0 && $after === false) { + array_unshift($this->middlewarePriority, $middleware); + } elseif (($after && $index === 0) || $index === count($this->middlewarePriority)) { + $this->middlewarePriority[] = $middleware; + } else { + array_splice($this->middlewarePriority, $index, 0, $middleware); + } + } + + $this->syncMiddlewareToRouter(); + + return $this; + } + /** * Sync the current state of the middleware to the router. * diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php index 32819c4..19c26db 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/HandlePrecognitiveRequests.php @@ -21,7 +21,6 @@ class HandlePrecognitiveRequests * Create a new middleware instance. * * @param \Illuminate\Container\Container $container - * @return void */ public function __construct(Container $container) { @@ -41,12 +40,18 @@ class HandlePrecognitiveRequests return $this->appendVaryHeader($request, $next($request)); } + $bindings = $this->container->getBindings(); + $callableBinding = $bindings[CallableDispatcherContract::class] ?? null; + $controllerBinding = $bindings[ControllerDispatcherContract::class] ?? null; + $this->prepareForPrecognition($request); - return tap($next($request), function ($response) use ($request) { + return tap($next($request), function ($response) use ($request, $callableBinding, $controllerBinding) { $response->headers->set('Precognition', 'true'); $this->appendVaryHeader($request, $response); + + $this->restoreDispatchers($callableBinding, $controllerBinding); }); } @@ -78,4 +83,22 @@ class HandlePrecognitiveRequests 'Precognition', ])))); } + + /** + * Restore the original route dispatcher bindings. + * + * @param array|null $callableBinding + * @param array|null $controllerBinding + * @return void + */ + protected function restoreDispatchers($callableBinding, $controllerBinding) + { + if ($callableBinding) { + $this->container->bind(CallableDispatcherContract::class, $callableBinding['concrete'], $callableBinding['shared']); + } + + if ($controllerBinding) { + $this->container->bind(ControllerDispatcherContract::class, $controllerBinding['concrete'], $controllerBinding['shared']); + } + } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php index 9a80433..9e31e02 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php @@ -4,8 +4,8 @@ namespace Illuminate\Foundation\Http\Middleware; use Closure; use Illuminate\Container\Container; -use Illuminate\Foundation\Defer\DeferredCallbackCollection; use Illuminate\Http\Request; +use Illuminate\Support\Defer\DeferredCallbackCollection; use Symfony\Component\HttpFoundation\Response; class InvokeDeferredCallbacks diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestForgery.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestForgery.php new file mode 100644 index 0000000..dc24742 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestForgery.php @@ -0,0 +1,321 @@ + + */ + protected $except = []; + + /** + * The globally ignored URIs that should be excluded from CSRF verification. + * + * @var array + */ + protected static $neverVerify = []; + + /** + * Indicates whether the XSRF-TOKEN cookie should be set on the response. + * + * @var bool + */ + protected $addHttpCookie = true; + + /** + * Indicates whether requests from the same site should be allowed. + * + * @var bool + */ + protected static $allowSameSite = false; + + /** + * Indicates whether only origin verification should be used. + * + * @var bool + */ + protected static $originOnly = false; + + /** + * Create a new middleware instance. + * + * @param \Illuminate\Contracts\Foundation\Application $app + * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter + */ + public function __construct(Application $app, Encrypter $encrypter) + { + $this->app = $app; + $this->encrypter = $encrypter; + } + + /** + * Handle an incoming request. + * + * @param \Illuminate\Http\Request $request + * @param \Closure $next + * @return mixed + * + * @throws \Illuminate\Session\TokenMismatchException + * @throws \Illuminate\Http\Exceptions\OriginMismatchException + */ + public function handle($request, Closure $next) + { + if ( + $this->isReading($request) || + $this->runningUnitTests() || + $this->inExceptArray($request) || + $this->hasValidOrigin($request) || + $this->tokensMatch($request) + ) { + return tap($next($request), function ($response) use ($request) { + if ($this->shouldAddXsrfTokenCookie()) { + $this->addCookieToResponse($request, $response); + } + }); + } + + throw new TokenMismatchException('CSRF token mismatch.'); + } + + /** + * Determine if the HTTP request uses a ‘read’ verb. + * + * @param \Illuminate\Http\Request $request + * @return bool + */ + protected function isReading($request) + { + return in_array($request->method(), ['HEAD', 'GET', 'OPTIONS']); + } + + /** + * Determine if the application is running unit tests. + * + * @return bool + */ + protected function runningUnitTests() + { + return $this->app->runningInConsole() && $this->app->runningUnitTests(); + } + + /** + * Determine if the request has a valid origin based on the Sec-Fetch-Site header. + * + * @param \Illuminate\Http\Request $request + * @return bool + * + * @throws \Illuminate\Http\Exceptions\OriginMismatchException + */ + protected function hasValidOrigin($request) + { + $secFetchSite = $request->header('Sec-Fetch-Site'); + + if ($secFetchSite === 'same-origin') { + return true; + } + + if ($secFetchSite === 'same-site' && static::$allowSameSite) { + return true; + } + + if (static::$originOnly) { + throw new OriginMismatchException('Origin mismatch.'); + } + + return false; + } + + /** + * Determine if the session and input CSRF tokens match. + * + * @param \Illuminate\Http\Request $request + * @return bool + */ + protected function tokensMatch($request) + { + $token = $this->getTokenFromRequest($request); + + return is_string($request->session()->token()) && + is_string($token) && + hash_equals($request->session()->token(), $token); + } + + /** + * Get the CSRF token from the request. + * + * @param \Illuminate\Http\Request $request + * @return string|null + */ + protected function getTokenFromRequest($request) + { + $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN'); + + if (! $token && $header = $request->header('X-XSRF-TOKEN')) { + try { + $token = CookieValuePrefix::remove($this->encrypter->decrypt($header, static::serialized())); + } catch (DecryptException) { + $token = ''; + } + } + + return $token; + } + + /** + * Determine if the cookie should be added to the response. + * + * @return bool + */ + public function shouldAddXsrfTokenCookie() + { + if (static::$originOnly) { + return false; + } + + return $this->addHttpCookie; + } + + /** + * Add the CSRF token to the response cookies. + * + * @param \Illuminate\Http\Request $request + * @param \Symfony\Component\HttpFoundation\Response $response + * @return \Symfony\Component\HttpFoundation\Response + */ + protected function addCookieToResponse($request, $response) + { + $config = config('session'); + + if ($response instanceof Responsable) { + $response = $response->toResponse($request); + } + + $response->headers->setCookie($this->newCookie($request, $config)); + + return $response; + } + + /** + * Create a new "XSRF-TOKEN" cookie that contains the CSRF token. + * + * @param \Illuminate\Http\Request $request + * @param array $config + * @return \Symfony\Component\HttpFoundation\Cookie + */ + protected function newCookie($request, $config) + { + return new Cookie( + 'XSRF-TOKEN', + $request->session()->token(), + $this->availableAt(60 * $config['lifetime']), + $config['path'], + $config['domain'], + $config['secure'], + false, + false, + $config['same_site'] ?? null, + $config['partitioned'] ?? false + ); + } + + /** + * Indicate that the given URIs should be excluded from CSRF verification. + * + * @param array|string $uris + * @return void + */ + public static function except($uris) + { + static::$neverVerify = array_values(array_unique( + array_merge(static::$neverVerify, Arr::wrap($uris)) + )); + } + + /** + * Indicate that requests from the same site should be allowed. + * + * @param bool $allow + * @return void + */ + public static function allowSameSite($allow = true) + { + static::$allowSameSite = $allow; + } + + /** + * Indicate that only origin verification should be used. + * + * @param bool $originOnly + * @return void + */ + public static function useOriginOnly($originOnly = true) + { + static::$originOnly = $originOnly; + } + + /** + * Get the URIs that should be excluded. + * + * @return array + */ + public function getExcludedPaths() + { + return array_merge($this->except, static::$neverVerify); + } + + /** + * Determine if the cookie contents should be serialized. + * + * @return bool + */ + public static function serialized() + { + return EncryptCookies::serialized('XSRF-TOKEN'); + } + + /** + * Flush the state of the middleware. + * + * @return void + */ + public static function flushState() + { + static::$neverVerify = []; + static::$allowSameSite = false; + static::$originOnly = false; + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php index 6adb87d..c3944d6 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php @@ -39,7 +39,6 @@ class PreventRequestsDuringMaintenance * Create a new middleware instance. * * @param \Illuminate\Contracts\Foundation\Application $app - * @return void */ public function __construct(Application $app) { @@ -83,8 +82,8 @@ class PreventRequestsDuringMaintenance if (isset($data['redirect'])) { $path = $data['redirect'] === '/' - ? $data['redirect'] - : trim($data['redirect'], '/'); + ? $data['redirect'] + : trim($data['redirect'], '/'); if ($request->path() !== $path) { return redirect($path); @@ -128,14 +127,14 @@ class PreventRequestsDuringMaintenance } /** - * Redirect the user back to the root of the application with a maintenance mode bypass cookie. + * Redirect the user to their intended destination with a maintenance mode bypass cookie. * * @param string $secret * @return \Illuminate\Http\RedirectResponse */ protected function bypassResponse(string $secret) { - return redirect('/')->withCookie( + return redirect()->intended('/')->withCookie( MaintenanceModeBypassCookie::create($secret) ); } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php index 80be7a4..942b476 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php @@ -78,7 +78,7 @@ class TrimStrings extends TransformsRequest */ protected function shouldSkip($key, $except) { - return in_array($key, $except, true); + return Str::is($except, $key); } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidateCsrfToken.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidateCsrfToken.php index f49d614..544fa77 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidateCsrfToken.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidateCsrfToken.php @@ -3,9 +3,9 @@ namespace Illuminate\Foundation\Http\Middleware; /** - * Alias of VerifyCsrfToken for consistency. + * @deprecated Use PreventRequestForgery instead. */ -class ValidateCsrfToken extends VerifyCsrfToken +class ValidateCsrfToken extends PreventRequestForgery { // } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php index 5edc53d..8c267c6 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php @@ -2,249 +2,10 @@ namespace Illuminate\Foundation\Http\Middleware; -use Closure; -use Illuminate\Contracts\Encryption\DecryptException; -use Illuminate\Contracts\Encryption\Encrypter; -use Illuminate\Contracts\Foundation\Application; -use Illuminate\Contracts\Support\Responsable; -use Illuminate\Cookie\CookieValuePrefix; -use Illuminate\Cookie\Middleware\EncryptCookies; -use Illuminate\Foundation\Http\Middleware\Concerns\ExcludesPaths; -use Illuminate\Session\TokenMismatchException; -use Illuminate\Support\Arr; -use Illuminate\Support\InteractsWithTime; -use Symfony\Component\HttpFoundation\Cookie; - -class VerifyCsrfToken +/** + * @deprecated Use PreventRequestForgery instead. + */ +class VerifyCsrfToken extends PreventRequestForgery { - use InteractsWithTime, - ExcludesPaths; - - /** - * The application instance. - * - * @var \Illuminate\Contracts\Foundation\Application - */ - protected $app; - - /** - * The encrypter implementation. - * - * @var \Illuminate\Contracts\Encryption\Encrypter - */ - protected $encrypter; - - /** - * The URIs that should be excluded. - * - * @var array - */ - protected $except = []; - - /** - * The globally ignored URIs that should be excluded from CSRF verification. - * - * @var array - */ - protected static $neverVerify = []; - - /** - * Indicates whether the XSRF-TOKEN cookie should be set on the response. - * - * @var bool - */ - protected $addHttpCookie = true; - - /** - * Create a new middleware instance. - * - * @param \Illuminate\Contracts\Foundation\Application $app - * @param \Illuminate\Contracts\Encryption\Encrypter $encrypter - * @return void - */ - public function __construct(Application $app, Encrypter $encrypter) - { - $this->app = $app; - $this->encrypter = $encrypter; - } - - /** - * Handle an incoming request. - * - * @param \Illuminate\Http\Request $request - * @param \Closure $next - * @return mixed - * - * @throws \Illuminate\Session\TokenMismatchException - */ - public function handle($request, Closure $next) - { - if ( - $this->isReading($request) || - $this->runningUnitTests() || - $this->inExceptArray($request) || - $this->tokensMatch($request) - ) { - return tap($next($request), function ($response) use ($request) { - if ($this->shouldAddXsrfTokenCookie()) { - $this->addCookieToResponse($request, $response); - } - }); - } - - throw new TokenMismatchException('CSRF token mismatch.'); - } - - /** - * Determine if the HTTP request uses a ‘read’ verb. - * - * @param \Illuminate\Http\Request $request - * @return bool - */ - protected function isReading($request) - { - return in_array($request->method(), ['HEAD', 'GET', 'OPTIONS']); - } - - /** - * Determine if the application is running unit tests. - * - * @return bool - */ - protected function runningUnitTests() - { - return $this->app->runningInConsole() && $this->app->runningUnitTests(); - } - - /** - * Get the URIs that should be excluded. - * - * @return array - */ - public function getExcludedPaths() - { - return array_merge($this->except, static::$neverVerify); - } - - /** - * Determine if the session and input CSRF tokens match. - * - * @param \Illuminate\Http\Request $request - * @return bool - */ - protected function tokensMatch($request) - { - $token = $this->getTokenFromRequest($request); - - return is_string($request->session()->token()) && - is_string($token) && - hash_equals($request->session()->token(), $token); - } - - /** - * Get the CSRF token from the request. - * - * @param \Illuminate\Http\Request $request - * @return string|null - */ - protected function getTokenFromRequest($request) - { - $token = $request->input('_token') ?: $request->header('X-CSRF-TOKEN'); - - if (! $token && $header = $request->header('X-XSRF-TOKEN')) { - try { - $token = CookieValuePrefix::remove($this->encrypter->decrypt($header, static::serialized())); - } catch (DecryptException) { - $token = ''; - } - } - - return $token; - } - - /** - * Determine if the cookie should be added to the response. - * - * @return bool - */ - public function shouldAddXsrfTokenCookie() - { - return $this->addHttpCookie; - } - - /** - * Add the CSRF token to the response cookies. - * - * @param \Illuminate\Http\Request $request - * @param \Symfony\Component\HttpFoundation\Response $response - * @return \Symfony\Component\HttpFoundation\Response - */ - protected function addCookieToResponse($request, $response) - { - $config = config('session'); - - if ($response instanceof Responsable) { - $response = $response->toResponse($request); - } - - $response->headers->setCookie($this->newCookie($request, $config)); - - return $response; - } - - /** - * Create a new "XSRF-TOKEN" cookie that contains the CSRF token. - * - * @param \Illuminate\Http\Request $request - * @param array $config - * @return \Symfony\Component\HttpFoundation\Cookie - */ - protected function newCookie($request, $config) - { - return new Cookie( - 'XSRF-TOKEN', - $request->session()->token(), - $this->availableAt(60 * $config['lifetime']), - $config['path'], - $config['domain'], - $config['secure'], - false, - false, - $config['same_site'] ?? null, - $config['partitioned'] ?? false - ); - } - - /** - * Indicate that the given URIs should be excluded from CSRF verification. - * - * @param array|string $uris - * @return void - */ - public static function except($uris) - { - static::$neverVerify = array_values(array_unique( - array_merge(static::$neverVerify, Arr::wrap($uris)) - )); - } - - /** - * Determine if the cookie contents should be serialized. - * - * @return bool - */ - public static function serialized() - { - return EncryptCookies::serialized('XSRF-TOKEN'); - } - - /** - * Flush the state of the middleware. - * - * @return void - */ - public static function flushState() - { - static::$neverVerify = []; - } + // } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php b/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php index 0a6dda5..5ed9868 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Inspiring.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation; use Illuminate\Support\Collection; +use Illuminate\Support\Stringable; /* .~))>> @@ -55,9 +56,7 @@ class Inspiring */ public static function quote() { - return static::quotes() - ->map(fn ($quote) => static::formatForConsole($quote)) - ->random(); + return static::formatForConsole(static::quotes()->random()); } /** @@ -67,7 +66,7 @@ class Inspiring */ public static function quotes() { - return Collection::make([ + return new Collection([ 'Act only according to that maxim whereby you can, at the same time, will that it should become a universal law. - Immanuel Kant', 'An unexamined life is not worth living. - Socrates', 'Be present above all else. - Naval Ravikant', @@ -103,10 +102,12 @@ class Inspiring 'Breathing in, I calm body and mind. Breathing out, I smile. - Thich Nhat Hanh', 'Life is available only in the present moment. - Thich Nhat Hanh', 'The best way to take care of the future is to take care of the present moment. - Thich Nhat Hanh', - 'Nothing in life is to be feared, it is only to be understood. Now is the time to understand more, so that we may fear less. - Marie Curie', + 'Nothing in life is to be feared, it is only to be understood. Now is the time to understand more, so that we may fear less. - Maria Skłodowska-Curie', 'The biggest battle is the war against ignorance. - Mustafa Kemal Atatürk', 'Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead', 'You must be the change you wish to see in the world. - Mahatma Gandhi', + 'It always seems impossible until it is done. - Nelson Mandela', + 'We must ship. - Taylor Otwell', ]); } @@ -118,7 +119,7 @@ class Inspiring */ protected static function formatForConsole($quote) { - [$text, $author] = str($quote)->explode('-'); + [$text, $author] = (new Stringable($quote))->explode('-'); return sprintf( "\n “ %s ”\n — %s\n", diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/LaravelCloudJsonFormatter.php b/vendor/laravel/framework/src/Illuminate/Foundation/LaravelCloudJsonFormatter.php new file mode 100644 index 0000000..0501655 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/LaravelCloudJsonFormatter.php @@ -0,0 +1,30 @@ +bound('request')) { + $requestId = $app->make('request')->header('Cloud-Request-ID'); + + if ($requestId !== null) { + $normalized['cloud_request_id'] = $requestId; + } + } + + return $normalized; + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/MaintenanceModeManager.php b/vendor/laravel/framework/src/Illuminate/Foundation/MaintenanceModeManager.php index 4d233f4..bd859f3 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/MaintenanceModeManager.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/MaintenanceModeManager.php @@ -16,6 +16,16 @@ class MaintenanceModeManager extends Manager return new FileBasedMaintenanceMode(); } + /** + * Create an instance of the array based maintenance driver. + * + * @return \Illuminate\Foundation\ArrayMaintenanceMode + */ + protected function createArrayDriver(): ArrayMaintenanceMode + { + return new ArrayMaintenanceMode(); + } + /** * Create an instance of the cache based maintenance driver. * diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php b/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php index 9767feb..d2494db 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php @@ -4,6 +4,7 @@ namespace Illuminate\Foundation; use Exception; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Collection; use Illuminate\Support\Env; class PackageManifest @@ -49,7 +50,6 @@ class PackageManifest * @param \Illuminate\Filesystem\Filesystem $files * @param string $basePath * @param string $manifestPath - * @return void */ public function __construct(Filesystem $files, $basePath, $manifestPath) { @@ -87,9 +87,10 @@ class PackageManifest */ public function config($key) { - return collect($this->getManifest())->flatMap(function ($configuration) use ($key) { - return (array) ($configuration[$key] ?? []); - })->filter()->all(); + return (new Collection($this->getManifest())) + ->flatMap(fn ($configuration) => (array) ($configuration[$key] ?? [])) + ->filter() + ->all(); } /** @@ -128,7 +129,7 @@ class PackageManifest $ignoreAll = in_array('*', $ignore = $this->packagesToIgnore()); - $this->write(collect($packages)->mapWithKeys(function ($package) { + $this->write((new Collection($packages))->mapWithKeys(function ($package) { return [$this->format($package['name']) => $package['extra']['laravel'] ?? []]; })->each(function ($configuration) use (&$ignore) { $ignore = array_merge($ignore, $configuration['dont-discover'] ?? []); diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php b/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php index 75d382d..df76e05 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php @@ -35,7 +35,6 @@ class ProviderRepository * @param \Illuminate\Contracts\Foundation\Application $app * @param \Illuminate\Filesystem\Filesystem $files * @param string $manifestPath - * @return void */ public function __construct(ApplicationContract $app, Filesystem $files, $manifestPath) { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php index 6ed57c7..2ef5fe5 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/ArtisanServiceProvider.php @@ -12,6 +12,8 @@ use Illuminate\Console\Scheduling\ScheduleClearCacheCommand; use Illuminate\Console\Scheduling\ScheduleFinishCommand; use Illuminate\Console\Scheduling\ScheduleInterruptCommand; use Illuminate\Console\Scheduling\ScheduleListCommand; +use Illuminate\Console\Scheduling\SchedulePauseCommand; +use Illuminate\Console\Scheduling\ScheduleResumeCommand; use Illuminate\Console\Scheduling\ScheduleRunCommand; use Illuminate\Console\Scheduling\ScheduleTestCommand; use Illuminate\Console\Scheduling\ScheduleWorkCommand; @@ -39,9 +41,12 @@ use Illuminate\Foundation\Console\ClearCompiledCommand; use Illuminate\Foundation\Console\ComponentMakeCommand; use Illuminate\Foundation\Console\ConfigCacheCommand; use Illuminate\Foundation\Console\ConfigClearCommand; +use Illuminate\Foundation\Console\ConfigMakeCommand; use Illuminate\Foundation\Console\ConfigPublishCommand; use Illuminate\Foundation\Console\ConfigShowCommand; use Illuminate\Foundation\Console\ConsoleMakeCommand; +use Illuminate\Foundation\Console\DevCommand; +use Illuminate\Foundation\Console\DevListCommand; use Illuminate\Foundation\Console\DocsCommand; use Illuminate\Foundation\Console\DownCommand; use Illuminate\Foundation\Console\EnumMakeCommand; @@ -56,6 +61,7 @@ use Illuminate\Foundation\Console\EventMakeCommand; use Illuminate\Foundation\Console\ExceptionMakeCommand; use Illuminate\Foundation\Console\InterfaceMakeCommand; use Illuminate\Foundation\Console\JobMakeCommand; +use Illuminate\Foundation\Console\JobMiddlewareMakeCommand; use Illuminate\Foundation\Console\KeyGenerateCommand; use Illuminate\Foundation\Console\LangPublishCommand; use Illuminate\Foundation\Console\ListenerMakeCommand; @@ -68,6 +74,7 @@ use Illuminate\Foundation\Console\OptimizeCommand; use Illuminate\Foundation\Console\PackageDiscoverCommand; use Illuminate\Foundation\Console\PolicyMakeCommand; use Illuminate\Foundation\Console\ProviderMakeCommand; +use Illuminate\Foundation\Console\ReloadCommand; use Illuminate\Foundation\Console\RequestMakeCommand; use Illuminate\Foundation\Console\ResourceMakeCommand; use Illuminate\Foundation\Console\RouteCacheCommand; @@ -86,6 +93,7 @@ use Illuminate\Foundation\Console\VendorPublishCommand; use Illuminate\Foundation\Console\ViewCacheCommand; use Illuminate\Foundation\Console\ViewClearCommand; use Illuminate\Foundation\Console\ViewMakeCommand; +use Illuminate\Foundation\DevCommands; use Illuminate\Notifications\Console\NotificationTableCommand; use Illuminate\Queue\Console\BatchesTableCommand; use Illuminate\Queue\Console\ClearCommand as QueueClearCommand; @@ -95,9 +103,11 @@ use Illuminate\Queue\Console\ForgetFailedCommand as ForgetFailedQueueCommand; use Illuminate\Queue\Console\ListenCommand as QueueListenCommand; use Illuminate\Queue\Console\ListFailedCommand as ListFailedQueueCommand; use Illuminate\Queue\Console\MonitorCommand as QueueMonitorCommand; +use Illuminate\Queue\Console\PauseCommand as QueuePauseCommand; use Illuminate\Queue\Console\PruneBatchesCommand as QueuePruneBatchesCommand; use Illuminate\Queue\Console\PruneFailedJobsCommand as QueuePruneFailedJobsCommand; use Illuminate\Queue\Console\RestartCommand as QueueRestartCommand; +use Illuminate\Queue\Console\ResumeCommand as QueueResumeCommand; use Illuminate\Queue\Console\RetryBatchCommand as QueueRetryBatchCommand; use Illuminate\Queue\Console\RetryCommand as QueueRetryCommand; use Illuminate\Queue\Console\TableCommand; @@ -148,12 +158,15 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'QueueForget' => ForgetFailedQueueCommand::class, 'QueueListen' => QueueListenCommand::class, 'QueueMonitor' => QueueMonitorCommand::class, + 'QueuePause' => QueuePauseCommand::class, 'QueuePruneBatches' => QueuePruneBatchesCommand::class, 'QueuePruneFailedJobs' => QueuePruneFailedJobsCommand::class, 'QueueRestart' => QueueRestartCommand::class, + 'QueueResume' => QueueResumeCommand::class, 'QueueRetry' => QueueRetryCommand::class, 'QueueRetryBatch' => QueueRetryBatchCommand::class, 'QueueWork' => QueueWorkCommand::class, + 'Reload' => ReloadCommand::class, 'RouteCache' => RouteCacheCommand::class, 'RouteClear' => RouteClearCommand::class, 'RouteList' => RouteListCommand::class, @@ -166,6 +179,8 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ScheduleTest' => ScheduleTestCommand::class, 'ScheduleWork' => ScheduleWorkCommand::class, 'ScheduleInterrupt' => ScheduleInterruptCommand::class, + 'SchedulePause' => SchedulePauseCommand::class, + 'ScheduleResume' => ScheduleResumeCommand::class, 'ShowModel' => ShowModelCommand::class, 'StorageLink' => StorageLinkCommand::class, 'StorageUnlink' => StorageUnlinkCommand::class, @@ -188,9 +203,12 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'ChannelMake' => ChannelMakeCommand::class, 'ClassMake' => ClassMakeCommand::class, 'ComponentMake' => ComponentMakeCommand::class, + 'ConfigMake' => ConfigMakeCommand::class, 'ConfigPublish' => ConfigPublishCommand::class, 'ConsoleMake' => ConsoleMakeCommand::class, 'ControllerMake' => ControllerMakeCommand::class, + 'Dev' => DevCommand::class, + 'DevList' => DevListCommand::class, 'Docs' => DocsCommand::class, 'EnumMake' => EnumMakeCommand::class, 'EventGenerate' => EventGenerateCommand::class, @@ -199,6 +217,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid 'FactoryMake' => FactoryMakeCommand::class, 'InterfaceMake' => InterfaceMakeCommand::class, 'JobMake' => JobMakeCommand::class, + 'JobMiddlewareMake' => JobMiddlewareMakeCommand::class, 'LangPublish' => LangPublishCommand::class, 'ListenerMake' => ListenerMakeCommand::class, 'MailMake' => MailMakeCommand::class, @@ -245,10 +264,19 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid }); } + /** + * Bootstrap the application services. + * + * @return void + */ + public function boot() + { + DevCommands::registerDefaults(); + } + /** * Register the given commands. * - * @param array $commands * @return void */ protected function registerCommands(array $commands) @@ -386,6 +414,18 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid }); } + /** + * Register the command. + * + * @return void + */ + protected function registerConfigMakeCommand() + { + $this->app->singleton(ConfigMakeCommand::class, function ($app) { + return new ConfigMakeCommand($app['files']); + }); + } + /** * Register the command. * @@ -393,7 +433,7 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid */ protected function registerConfigPublishCommand() { - $this->app->singleton(ConfigPublishCommand::class, function ($app) { + $this->app->singleton(ConfigPublishCommand::class, function () { return new ConfigPublishCommand; }); } @@ -506,6 +546,18 @@ class ArtisanServiceProvider extends ServiceProvider implements DeferrableProvid }); } + /** + * Register the command. + * + * @return void + */ + protected function registerJobMiddlewareMakeCommand() + { + $this->app->singleton(JobMiddlewareMakeCommand::class, function ($app) { + return new JobMiddlewareMakeCommand($app['files']); + }); + } + /** * Register the command. * diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php index 6711dd2..691915a 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Providers/FoundationServiceProvider.php @@ -8,12 +8,12 @@ use Illuminate\Contracts\Console\Kernel as ConsoleKernel; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Events\Dispatcher; use Illuminate\Contracts\Foundation\Application; +use Illuminate\Contracts\Foundation\ExceptionRenderer; use Illuminate\Contracts\Foundation\MaintenanceMode as MaintenanceModeContract; use Illuminate\Contracts\View\Factory; use Illuminate\Database\ConnectionInterface; use Illuminate\Database\Grammar; use Illuminate\Foundation\Console\CliDumper; -use Illuminate\Foundation\Defer\DeferredCallbackCollection; use Illuminate\Foundation\Exceptions\Renderer\Listener; use Illuminate\Foundation\Exceptions\Renderer\Mappers\BladeMapper; use Illuminate\Foundation\Exceptions\Renderer\Renderer; @@ -26,7 +26,9 @@ use Illuminate\Http\Request; use Illuminate\Log\Events\MessageLogged; use Illuminate\Queue\Events\JobAttempted; use Illuminate\Support\AggregateServiceProvider; +use Illuminate\Support\Defer\DeferredCallbackCollection; use Illuminate\Support\Facades\URL; +use Illuminate\Support\Uri; use Illuminate\Testing\LoggedExceptionCollection; use Illuminate\Testing\ParallelTestingServiceProvider; use Illuminate\Validation\ValidationException; @@ -69,7 +71,7 @@ class FoundationServiceProvider extends AggregateServiceProvider ], 'laravel-errors'); } - if ($this->app->hasDebugModeEnabled()) { + if ($this->app->hasDebugModeEnabled() && ! $this->app->has(ExceptionRenderer::class)) { $this->app->make(Listener::class)->registerListeners( $this->app->make(Dispatcher::class) ); @@ -89,6 +91,7 @@ class FoundationServiceProvider extends AggregateServiceProvider $this->registerDumper(); $this->registerRequestValidation(); $this->registerRequestSignatureValidation(); + $this->registerUriUrlGeneration(); $this->registerDeferHandler(); $this->registerExceptionTracking(); $this->registerExceptionRenderer(); @@ -139,6 +142,8 @@ class FoundationServiceProvider extends AggregateServiceProvider * Register the "validate" macro on the request. * * @return void + * + * @throws \Illuminate\Validation\ValidationException */ public function registerRequestValidation() { @@ -188,6 +193,16 @@ class FoundationServiceProvider extends AggregateServiceProvider }); } + /** + * Register the URL resolver for the URI generator. + * + * @return void + */ + protected function registerUriUrlGeneration() + { + Uri::setUrlGeneratorResolver(fn () => app('url')); + } + /** * Register the "defer" function termination handler. * @@ -198,13 +213,15 @@ class FoundationServiceProvider extends AggregateServiceProvider $this->app->scoped(DeferredCallbackCollection::class); $this->app['events']->listen(function (CommandFinished $event) { - app(DeferredCallbackCollection::class)->invokeWhen(fn ($callback) => app()->runningInConsole() && ($event->exitCode === 0 || $callback->always) - ); + app(DeferredCallbackCollection::class)->invokeWhen(fn ($callback) => app()->runningInConsole() && ($event->exitCode === 0 || $callback->always)); }); $this->app['events']->listen(function (JobAttempted $event) { - app(DeferredCallbackCollection::class)->invokeWhen(fn ($callback) => $event->connectionName !== 'sync' && ($event->successful() || $callback->always) - ); + if (in_array($event->connectionName, ['sync', 'deferred'])) { + return; + } + + app(DeferredCallbackCollection::class)->invokeWhen(fn ($callback) => ($event->successful() || $callback->always)); }); } @@ -227,7 +244,7 @@ class FoundationServiceProvider extends AggregateServiceProvider $this->app->make('events')->listen(MessageLogged::class, function ($event) { if (isset($event->context['exception'])) { $this->app->make(LoggedExceptionCollection::class) - ->push($event->context['exception']); + ->push($event->context['exception']); } }); } @@ -239,6 +256,8 @@ class FoundationServiceProvider extends AggregateServiceProvider */ protected function registerExceptionRenderer() { + $this->loadViewsFrom(__DIR__.'/../Exceptions/views', 'laravel-exceptions'); + if (! $this->app->hasDebugModeEnabled()) { return; } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Queue/InteractsWithUniqueJobs.php b/vendor/laravel/framework/src/Illuminate/Foundation/Queue/InteractsWithUniqueJobs.php new file mode 100644 index 0000000..064c3f0 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Queue/InteractsWithUniqueJobs.php @@ -0,0 +1,55 @@ + $this->getUniqueJobCacheStore($job), + 'laravel_unique_job_key' => UniqueLock::getKey($job), + ]); + } + } + + /** + * Remove the unique job information from the context. + * + * @param mixed $job + * @return void + */ + public function removeUniqueJobInformationFromContext($job): void + { + if ($job instanceof ShouldBeUnique) { + Context::forgetHidden([ + 'laravel_unique_job_cache_store', + 'laravel_unique_job_key', + ]); + } + } + + /** + * Determine the cache store used by the unique job to acquire locks. + * + * @param mixed $job + * @return string|null + */ + protected function getUniqueJobCacheStore($job): ?string + { + return method_exists($job, 'uniqueVia') + ? $job->uniqueVia()->getName() + : config('cache.default'); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php b/vendor/laravel/framework/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php index 7ed8605..b055d44 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Routing/PrecognitionControllerDispatcher.php @@ -31,6 +31,8 @@ class PrecognitionControllerDispatcher extends ControllerDispatcher * @param object $controller * @param string $method * @return $this + * + * @throws \RuntimeException */ protected function ensureMethodExists($controller, $method) { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php b/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php index 599429e..ac7b3ec 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Support/Providers/EventServiceProvider.php @@ -7,6 +7,7 @@ use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Events\DiscoverEvents; use Illuminate\Support\Arr; use Illuminate\Support\Facades\Event; +use Illuminate\Support\LazyCollection; use Illuminate\Support\ServiceProvider; class EventServiceProvider extends ServiceProvider @@ -42,7 +43,7 @@ class EventServiceProvider extends ServiceProvider /** * The configured event discovery paths. * - * @var array|null + * @var iterable|null */ protected static $eventDiscoveryPaths; @@ -123,8 +124,8 @@ class EventServiceProvider extends ServiceProvider protected function discoveredEvents() { return $this->shouldDiscoverEvents() - ? $this->discoverEvents() - : []; + ? $this->discoverEvents() + : []; } /** @@ -144,22 +145,23 @@ class EventServiceProvider extends ServiceProvider */ public function discoverEvents() { - return collect($this->discoverEventsWithin()) - ->reject(function ($directory) { - return ! is_dir($directory); - }) - ->reduce(function ($discovered, $directory) { - return array_merge_recursive( - $discovered, - DiscoverEvents::within($directory, $this->eventDiscoveryBasePath()) - ); - }, []); + return (new LazyCollection($this->discoverEventsWithin())) + ->flatMap(function ($directory) { + return glob($directory, GLOB_ONLYDIR); + }) + ->reject(function ($directory) { + return ! is_dir($directory); + }) + ->pipe(fn ($directories) => DiscoverEvents::within( + $directories->all(), + $this->eventDiscoveryBasePath(), + )); } /** * Get the listener directories that should be used to discover events. * - * @return array + * @return iterable */ protected function discoverEventsWithin() { @@ -171,23 +173,24 @@ class EventServiceProvider extends ServiceProvider /** * Add the given event discovery paths to the application's event discovery paths. * - * @param string|array $paths + * @param string|iterable $paths * @return void */ - public static function addEventDiscoveryPaths(array|string $paths) + public static function addEventDiscoveryPaths(iterable|string $paths) { - static::$eventDiscoveryPaths = array_values(array_unique( - array_merge(static::$eventDiscoveryPaths, Arr::wrap($paths)) - )); + static::$eventDiscoveryPaths = (new LazyCollection(static::$eventDiscoveryPaths)) + ->merge(is_string($paths) ? [$paths] : $paths) + ->unique() + ->values(); } /** * Set the globally configured event discovery paths. * - * @param array $paths + * @param iterable $paths * @return void */ - public static function setEventDiscoveryPaths(array $paths) + public static function setEventDiscoveryPaths(iterable $paths) { static::$eventDiscoveryPaths = $paths; } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Attributes/Seed.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Attributes/Seed.php new file mode 100644 index 0000000..2f1cd24 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Attributes/Seed.php @@ -0,0 +1,17 @@ +be($user, $guard); } + /** + * Clear the currently logged in user for the application. + * + * @param string|null $guard + * @return $this + */ + public function actingAsGuest($guard = null) + { + $this->app['auth']->guard($guard)->forgetUser(); + + $this->app['auth']->shouldUse($guard); + + return $this; + } + /** * Set the currently logged in user for the application. * diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php index b4aad54..1987539 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithContainer.php @@ -5,7 +5,8 @@ namespace Illuminate\Foundation\Testing\Concerns; use Closure; use Illuminate\Foundation\Mix; use Illuminate\Foundation\Vite; -use Illuminate\Support\Facades\Facade; +use Illuminate\Support\Defer\DeferredCallbackCollection; +use Illuminate\Support\Facades\Vite as ViteFacade; use Illuminate\Support\HtmlString; use Mockery; @@ -25,12 +26,21 @@ trait InteractsWithContainer */ protected $originalMix; + /** + * The original deferred callbacks collection. + * + * @var \Illuminate\Support\Defer\DeferredCallbackCollection|null + */ + protected $originalDeferredCallbacksCollection; + /** * Register an instance of an object in the container. * + * @template TSwap of object + * * @param string $abstract - * @param object $instance - * @return object + * @param TSwap $instance + * @return TSwap */ protected function swap($abstract, $instance) { @@ -40,9 +50,11 @@ trait InteractsWithContainer /** * Register an instance of an object in the container. * + * @template TInstance of object + * * @param string $abstract - * @param object $instance - * @return object + * @param TInstance $instance + * @return TInstance */ protected function instance($abstract, $instance) { @@ -54,9 +66,11 @@ trait InteractsWithContainer /** * Mock an instance of an object in the container. * - * @param string $abstract + * @template TInstance of object + * + * @param string|class-string $abstract * @param \Closure|null $mock - * @return \Mockery\MockInterface + * @return ($abstract is class-string ? TInstance&\Mockery\MockInterface : \Mockery\MockInterface) */ protected function mock($abstract, ?Closure $mock = null) { @@ -66,9 +80,11 @@ trait InteractsWithContainer /** * Mock a partial instance of an object in the container. * - * @param string $abstract + * @template TInstance of object + * + * @param string|class-string $abstract * @param \Closure|null $mock - * @return \Mockery\MockInterface + * @return ($abstract is class-string ? TInstance&\Mockery\MockInterface : \Mockery\MockInterface) */ protected function partialMock($abstract, ?Closure $mock = null) { @@ -78,9 +94,11 @@ trait InteractsWithContainer /** * Spy an instance of an object in the container. * - * @param string $abstract + * @template TInstance of object + * + * @param string|class-string $abstract * @param \Closure|null $mock - * @return \Mockery\MockInterface + * @return ($abstract is class-string ? TInstance&\Mockery\MockInterface : \Mockery\MockInterface) */ protected function spy($abstract, ?Closure $mock = null) { @@ -111,7 +129,7 @@ trait InteractsWithContainer $this->originalVite = app(Vite::class); } - Facade::clearResolvedInstance(Vite::class); + ViteFacade::clearResolvedInstance(); $this->swap(Vite::class, new class extends Vite { @@ -234,4 +252,40 @@ trait InteractsWithContainer return $this; } + + /** + * Execute deferred functions immediately. + * + * @return $this + */ + protected function withoutDefer() + { + if ($this->originalDeferredCallbacksCollection == null) { + $this->originalDeferredCallbacksCollection = $this->app->make(DeferredCallbackCollection::class); + } + + $this->swap(DeferredCallbackCollection::class, new class extends DeferredCallbackCollection + { + public function offsetSet(mixed $offset, mixed $value): void + { + $value(); + } + }); + + return $this; + } + + /** + * Restore deferred functions. + * + * @return $this + */ + protected function withDefer() + { + if ($this->originalDeferredCallbacksCollection) { + $this->app->instance(DeferredCallbackCollection::class, $this->originalDeferredCallbacksCollection); + } + + return $this; + } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php index f216a15..2ab1d1e 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php @@ -4,7 +4,6 @@ namespace Illuminate\Foundation\Testing\Concerns; use Illuminate\Contracts\Support\Jsonable; use Illuminate\Database\Eloquent\Model; -use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Events\QueryExecuted; use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; @@ -19,13 +18,29 @@ trait InteractsWithDatabase /** * Assert that a given where condition exists in the database. * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table + * @param array $data * @param string|null $connection * @return $this */ protected function assertDatabaseHas($table, array $data = [], $connection = null) { + if (is_iterable($table)) { + foreach ($table as $item) { + $this->assertDatabaseHas($item, $data, $connection); + } + + return $this; + } + + if ($data !== [] && array_is_list($data) && array_all($data, fn ($row) => is_array($row))) { + foreach ($data as $row) { + $this->assertDatabaseHas($table, $row, $connection); + } + + return $this; + } + if ($table instanceof Model) { $data = [ $table->getKeyName() => $table->getKey(), @@ -43,13 +58,29 @@ trait InteractsWithDatabase /** * Assert that a given where condition does not exist in the database. * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table + * @param array $data * @param string|null $connection * @return $this */ protected function assertDatabaseMissing($table, array $data = [], $connection = null) { + if (is_iterable($table)) { + foreach ($table as $item) { + $this->assertDatabaseMissing($item, $data, $connection); + } + + return $this; + } + + if ($data !== [] && array_is_list($data) && array_all($data, fn ($row) => is_array($row))) { + foreach ($data as $row) { + $this->assertDatabaseMissing($table, $row, $connection); + } + + return $this; + } + if ($table instanceof Model) { $data = [ $table->getKeyName() => $table->getKey(), @@ -69,7 +100,7 @@ trait InteractsWithDatabase /** * Assert the count of table entries. * - * @param \Illuminate\Database\Eloquent\Model|string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @param int $count * @param string|null $connection * @return $this @@ -86,7 +117,7 @@ trait InteractsWithDatabase /** * Assert that the given table has no entries. * - * @param \Illuminate\Database\Eloquent\Model|string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @param string|null $connection * @return $this */ @@ -102,14 +133,22 @@ trait InteractsWithDatabase /** * Assert the given record has been "soft deleted". * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table + * @param array $data * @param string|null $connection * @param string|null $deletedAtColumn * @return $this */ protected function assertSoftDeleted($table, array $data = [], $connection = null, $deletedAtColumn = 'deleted_at') { + if (is_iterable($table)) { + foreach ($table as $item) { + $this->assertSoftDeleted($item, $data, $connection); + } + + return $this; + } + if ($this->isSoftDeletableModel($table)) { return $this->assertSoftDeleted( $table->getTable(), @@ -119,6 +158,14 @@ trait InteractsWithDatabase ); } + if ($data !== [] && array_is_list($data) && array_all($data, fn ($row) => is_array($row))) { + foreach ($data as $row) { + $this->assertSoftDeleted($table, $row, $connection, $deletedAtColumn); + } + + return $this; + } + $this->assertThat( $this->getTable($table), new SoftDeletedInDatabase( @@ -134,14 +181,22 @@ trait InteractsWithDatabase /** * Assert the given record has not been "soft deleted". * - * @param \Illuminate\Database\Eloquent\Model|string $table - * @param array $data + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table + * @param array $data * @param string|null $connection * @param string|null $deletedAtColumn * @return $this */ protected function assertNotSoftDeleted($table, array $data = [], $connection = null, $deletedAtColumn = 'deleted_at') { + if (is_iterable($table)) { + foreach ($table as $item) { + $this->assertNotSoftDeleted($item, $data, $connection); + } + + return $this; + } + if ($this->isSoftDeletableModel($table)) { return $this->assertNotSoftDeleted( $table->getTable(), @@ -151,6 +206,14 @@ trait InteractsWithDatabase ); } + if ($data !== [] && array_is_list($data) && array_all($data, fn ($row) => is_array($row))) { + foreach ($data as $row) { + $this->assertNotSoftDeleted($table, $row, $connection, $deletedAtColumn); + } + + return $this; + } + $this->assertThat( $this->getTable($table), new NotSoftDeletedInDatabase( @@ -166,7 +229,7 @@ trait InteractsWithDatabase /** * Assert the given model exists in the database. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $model * @return $this */ protected function assertModelExists($model) @@ -177,7 +240,7 @@ trait InteractsWithDatabase /** * Assert the given model does not exist in the database. * - * @param \Illuminate\Database\Eloquent\Model $model + * @param iterable<\Illuminate\Database\Eloquent\Model>|\Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $model * @return $this */ protected function assertModelMissing($model) @@ -194,22 +257,22 @@ trait InteractsWithDatabase */ public function expectsDatabaseQueryCount($expected, $connection = null) { - with($this->getConnection($connection), function ($connectionInstance) use ($expected, $connection) { - $actual = 0; + $connectionInstance = $this->getConnection($connection); - $connectionInstance->listen(function (QueryExecuted $event) use (&$actual, $connectionInstance, $connection) { - if (is_null($connection) || $connectionInstance === $event->connection) { - $actual++; - } - }); + $actual = 0; - $this->beforeApplicationDestroyed(function () use (&$actual, $expected, $connectionInstance) { - $this->assertSame( - $expected, - $actual, - "Expected {$expected} database queries on the [{$connectionInstance->getName()}] connection. {$actual} occurred." - ); - }); + $connectionInstance->listen(function (QueryExecuted $event) use (&$actual, $connectionInstance, $connection) { + if (is_null($connection) || $connectionInstance === $event->connection) { + $actual++; + } + }); + + $this->beforeApplicationDestroyed(function () use (&$actual, $expected, $connectionInstance) { + $this->assertSame( + $expected, + $actual, + "Expected {$expected} database queries on the [{$connectionInstance->getName()}] connection. {$actual} occurred." + ); }); return $this; @@ -223,17 +286,17 @@ trait InteractsWithDatabase */ protected function isSoftDeletableModel($model) { - return $model instanceof Model - && in_array(SoftDeletes::class, class_uses_recursive($model)); + return $model instanceof Model && $model::isSoftDeletable(); } /** * Cast a JSON string to a database compatible type. * * @param array|object|string $value + * @param string|null $connection * @return \Illuminate\Contracts\Database\Query\Expression */ - public function castAsJson($value) + public function castAsJson($value, $connection = null) { if ($value instanceof Jsonable) { $value = $value->toJson(); @@ -241,10 +304,12 @@ trait InteractsWithDatabase $value = json_encode($value); } - $value = DB::connection()->getPdo()->quote($value); + $db = DB::connection($connection); - return DB::raw( - DB::connection()->getQueryGrammar()->compileJsonValueCast($value) + $value = $db->getPdo()->quote($value); + + return $db->raw( + $db->getQueryGrammar()->compileJsonValueCast($value) ); } @@ -252,7 +317,7 @@ trait InteractsWithDatabase * Get the database connection. * * @param string|null $connection - * @param string|null $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string|null $table * @return \Illuminate\Database\Connection */ protected function getConnection($connection = null, $table = null) @@ -267,7 +332,7 @@ trait InteractsWithDatabase /** * Get the table name from the given model or string. * - * @param \Illuminate\Database\Eloquent\Model|string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @return string */ protected function getTable($table) @@ -282,7 +347,7 @@ trait InteractsWithDatabase /** * Get the table connection specified in the given model. * - * @param \Illuminate\Database\Eloquent\Model|string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @return string|null */ protected function getTableConnection($table) @@ -297,7 +362,7 @@ trait InteractsWithDatabase /** * Get the table column name used for soft deletes. * - * @param string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @param string $defaultColumnName * @return string */ @@ -309,7 +374,7 @@ trait InteractsWithDatabase /** * Get the model entity from the given model or string. * - * @param \Illuminate\Database\Eloquent\Model|string $table + * @param \Illuminate\Database\Eloquent\Model|class-string<\Illuminate\Database\Eloquent\Model>|string $table * @return \Illuminate\Database\Eloquent\Model|null */ protected function newModelFor($table) @@ -320,7 +385,7 @@ trait InteractsWithDatabase /** * Seed a given database connection. * - * @param array|string $class + * @param list|class-string<\Illuminate\Database\Seeder>|string $class * @return $this */ public function seed($class = 'Database\\Seeders\\DatabaseSeeder') diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php index 6b9300a..0ad9293 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDeprecationHandling.php @@ -31,6 +31,8 @@ trait InteractsWithDeprecationHandling * Disable deprecation handling for the test. * * @return $this + * + * @throws \ErrorException */ protected function withoutDeprecationHandling() { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php index cb20d97..af1739d 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithExceptionHandling.php @@ -44,7 +44,7 @@ trait InteractsWithExceptionHandling /** * Only handle the given exceptions via the exception handler. * - * @param array $exceptions + * @param list> $exceptions * @return $this */ protected function handleExceptions(array $exceptions) @@ -65,7 +65,7 @@ trait InteractsWithExceptionHandling /** * Disable exception handling for the test. * - * @param array $except + * @param list> $except * @return $this */ protected function withoutExceptionHandling(array $except = []) @@ -87,7 +87,7 @@ trait InteractsWithExceptionHandling * Create a new class instance. * * @param \Illuminate\Contracts\Debug\ExceptionHandler $originalHandler - * @param array $except + * @param list> $except * @return void */ public function __construct($originalHandler, $except = []) @@ -113,7 +113,7 @@ trait InteractsWithExceptionHandling * Determine if the exception should be reported. * * @param \Throwable $e - * @return bool + * @return false */ public function shouldReport(Throwable $e) { @@ -172,7 +172,7 @@ trait InteractsWithExceptionHandling * Assert that the given callback throws an exception with the given message when invoked. * * @param \Closure $test - * @param \Closure|class-string<\Throwable> $expectedClass + * @param (\Closure(\Throwable): bool)|class-string<\Throwable> $expectedClass * @param string|null $expectedMessage * @return $this */ @@ -213,4 +213,31 @@ trait InteractsWithExceptionHandling return $this; } + + /** + * Assert that the given callback does not throw an exception. + * + * @param \Closure $test + * @return $this + */ + protected function assertDoesntThrow(Closure $test) + { + try { + $test(); + + $thrown = false; + } catch (Throwable $exception) { + $thrown = true; + + $exceptionClass = get_class($exception); + $exceptionMessage = $exception->getMessage(); + } + + Assert::assertTrue( + ! $thrown, + sprintf('Unexpected exception of type %s with message %s was thrown.', $exceptionClass ?? null, $exceptionMessage ?? null) + ); + + return $this; + } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php index f6263d2..77b6330 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithRedis.php @@ -3,6 +3,7 @@ namespace Illuminate\Foundation\Testing\Concerns; use Exception; +use Illuminate\Contracts\Redis\Factory as Redis; use Illuminate\Foundation\Application; use Illuminate\Redis\RedisManager; use Illuminate\Support\Env; @@ -43,23 +44,49 @@ trait InteractsWithRedis $port = Env::get('REDIS_PORT', 6379); foreach (static::redisDriverProvider() as $driver) { - $this->redis[$driver[0]] = new RedisManager($app, $driver[0], [ - 'cluster' => false, - 'options' => [ - 'prefix' => 'test_', - ], - 'default' => [ - 'host' => $host, - 'port' => $port, - 'database' => 5, - 'timeout' => 0.5, - 'name' => 'default', - ], - ]); + if (Env::get('REDIS_CLUSTER_HOSTS_AND_PORTS')) { + $config = [ + 'options' => [ + 'cluster' => 'redis', + 'prefix' => 'test_', + ], + 'clusters' => [ + 'default' => array_map( + static fn ($hostAndPort) => [ + 'host' => explode(':', $hostAndPort)[0], + 'port' => explode(':', $hostAndPort)[1], + ], + explode(',', Env::get('REDIS_CLUSTER_HOSTS_AND_PORTS')), + ), + ], + ]; + } else { + $config = [ + 'options' => [ + 'prefix' => 'test_', + ], + 'default' => [ + 'host' => $host, + 'port' => $port, + 'database' => 5, + 'timeout' => 0.5, + 'name' => 'default', + ], + 'cache' => [ + 'host' => $host, + 'port' => $port, + 'database' => 6, + 'timeout' => 0.5, + ], + ]; + } + $this->redis[$driver[0]] = new RedisManager($app, $driver[0], $config); } + $defaultDriver = Env::get('REDIS_CLIENT', 'phpredis'); + try { - $this->redis['phpredis']->connection()->flushdb(); + $this->redis[$defaultDriver]->connection()->flushdb(); } catch (Exception) { if ($host === '127.0.0.1' && $port === 6379 && Env::get('REDIS_HOST') === null) { static::$connectionFailedOnceWithDefaultsSkip = true; @@ -67,6 +94,8 @@ trait InteractsWithRedis $this->markTestSkipped('Trying default host/port failed, please set environment variable REDIS_HOST & REDIS_PORT to enable '.__CLASS__); } } + + $app->instance('redis', $this->redis[$defaultDriver]); } /** @@ -76,6 +105,10 @@ trait InteractsWithRedis */ public function tearDownRedis() { + if (static::$connectionFailedOnceWithDefaultsSkip === true) { + return; + } + if (isset($this->redis['phpredis'])) { $this->redis['phpredis']->connection()->flushdb(); } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php index 3d210cd..8a1145c 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTestCaseLifecycle.php @@ -5,33 +5,48 @@ namespace Illuminate\Foundation\Testing\Concerns; use Carbon\CarbonImmutable; use Illuminate\Console\Application as Artisan; use Illuminate\Cookie\Middleware\EncryptCookies; +use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Migrations\Migrator; use Illuminate\Foundation\Bootstrap\HandleExceptions; use Illuminate\Foundation\Bootstrap\RegisterProviders; use Illuminate\Foundation\Console\AboutCommand; +use Illuminate\Foundation\Http\FormRequest; use Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull; +use Illuminate\Foundation\Http\Middleware\PreventRequestForgery; use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance; use Illuminate\Foundation\Http\Middleware\TrimStrings; -use Illuminate\Foundation\Http\Middleware\ValidateCsrfToken; +use Illuminate\Foundation\Testing\Attributes\SetUp; +use Illuminate\Foundation\Testing\Attributes\TearDown; use Illuminate\Foundation\Testing\DatabaseMigrations; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTruncation; use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Foundation\Testing\WithoutMiddleware; +use Illuminate\Http\Client\Response; +use Illuminate\Http\Middleware\HandleCors; use Illuminate\Http\Middleware\TrustHosts; use Illuminate\Http\Middleware\TrustProxies; +use Illuminate\Http\Resources\Json\JsonResource; +use Illuminate\Http\Resources\JsonApi\JsonApiResource; +use Illuminate\Mail\Markdown; +use Illuminate\Queue\Console\WorkCommand; use Illuminate\Queue\Queue; use Illuminate\Support\Carbon; +use Illuminate\Support\EncodedHtmlString; use Illuminate\Support\Facades\Facade; use Illuminate\Support\Facades\ParallelTesting; +use Illuminate\Support\Lottery; use Illuminate\Support\Once; use Illuminate\Support\Sleep; use Illuminate\Support\Str; +use Illuminate\Validation\Validator; use Illuminate\View\Component; use Mockery; use Mockery\Exception\InvalidCountException; use PHPUnit\Metadata\Annotation\Parser\Registry as PHPUnitRegistry; +use ReflectionClass; use Throwable; trait InteractsWithTestCaseLifecycle @@ -105,6 +120,8 @@ trait InteractsWithTestCaseLifecycle * @internal * * @return void + * + * @throws \Throwable */ protected function tearDownTheTestEnvironment(): void { @@ -167,17 +184,30 @@ trait InteractsWithTestCaseLifecycle Component::forgetComponentsResolver(); Component::forgetFactory(); ConvertEmptyStringsToNull::flushState(); + Factory::flushState(); + FormRequest::flushState(); + EncodedHtmlString::flushState(); EncryptCookies::flushState(); - HandleExceptions::flushState(); + HandleCors::flushState(); + HandleExceptions::flushState($this); + JsonApiResource::flushState(); + JsonResource::flushState(); + Lottery::determineResultsNormally(); + Markdown::flushState(); + Migrator::withoutMigrations([]); Once::flush(); PreventRequestsDuringMaintenance::flushState(); Queue::createPayloadUsing(null); RegisterProviders::flushState(); + Response::flushState(); Sleep::fake(false); + Str::resetFactoryState(); TrimStrings::flushState(); TrustProxies::flushState(); TrustHosts::flushState(); - ValidateCsrfToken::flushState(); + PreventRequestForgery::flushState(); + Validator::flushState(); + WorkCommand::flushState(); if ($this->callbackException) { throw $this->callbackException; @@ -191,7 +221,7 @@ trait InteractsWithTestCaseLifecycle */ protected function setUpTraits() { - $uses = array_flip(class_uses_recursive(static::class)); + $uses = $this->traitsUsedByTest ?? class_uses_recursive(static::class); if (isset($uses[RefreshDatabase::class])) { $this->refreshDatabase(); @@ -225,6 +255,16 @@ trait InteractsWithTestCaseLifecycle if (method_exists($this, $method = 'tearDown'.class_basename($trait))) { $this->beforeApplicationDestroyed(fn () => $this->{$method}()); } + + foreach ((new ReflectionClass($trait))->getMethods() as $method) { + if ($method->getAttributes(SetUp::class) !== []) { + $this->{$method->getName()}(); + } + + if ($method->getAttributes(TearDown::class) !== []) { + $this->beforeApplicationDestroyed(fn () => $this->{$method->getName()}()); + } + } } return $uses; @@ -239,10 +279,12 @@ trait InteractsWithTestCaseLifecycle */ public static function tearDownAfterClassUsingTestCase() { - (function () { - $this->classDocBlocks = []; - $this->methodDocBlocks = []; - })->call(PHPUnitRegistry::getInstance()); + if (class_exists(PHPUnitRegistry::class)) { + (function () { + $this->classDocBlocks = []; + $this->methodDocBlocks = []; + })->call(PHPUnitRegistry::getInstance()); + } } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTime.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTime.php index b431c9b..7090c2a 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTime.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithTime.php @@ -8,25 +8,33 @@ use Illuminate\Support\Carbon; trait InteractsWithTime { /** + * @template TReturn of mixed + * * Freeze time. * - * @param callable|null $callback - * @return mixed + * @param (callable(\Illuminate\Support\Carbon): TReturn)|null $callback + * @return ($callback is null ? \Illuminate\Support\Carbon : TReturn) */ public function freezeTime($callback = null) { - return $this->travelTo(Carbon::now(), $callback); + $result = $this->travelTo($now = Carbon::now(), $callback); + + return is_null($callback) ? $now : $result; } /** + * @template TReturn of mixed + * * Freeze time at the beginning of the current second. * - * @param callable|null $callback - * @return mixed + * @param (callable(\Illuminate\Support\Carbon): TReturn)|null $callback + * @return ($callback is null ? \Illuminate\Support\Carbon : TReturn) */ public function freezeSecond($callback = null) { - return $this->travelTo(Carbon::now()->startOfSecond(), $callback); + $result = $this->travelTo($now = Carbon::now()->startOfSecond(), $callback); + + return is_null($callback) ? $now : $result; } /** @@ -41,11 +49,14 @@ trait InteractsWithTime } /** + * @template TReturn of mixed + * @template TDate of \DateTimeInterface|\Closure|\Illuminate\Support\Carbon|string|bool|null + * * Travel to another time. * - * @param \DateTimeInterface|\Closure|\Illuminate\Support\Carbon|string|bool|null $date - * @param callable|null $callback - * @return mixed + * @param TDate $date + * @param (callable(TDate): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function travelTo($date, $callback = null) { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php index c24799d..0e7b7d1 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php @@ -2,9 +2,12 @@ namespace Illuminate\Foundation\Testing\Concerns; +use BackedEnum; use Illuminate\Contracts\Http\Kernel as HttpKernel; use Illuminate\Cookie\CookieValuePrefix; use Illuminate\Http\Request; +use Illuminate\Support\Collection; +use Illuminate\Support\Uri; use Illuminate\Testing\LoggedExceptionCollection; use Illuminate\Testing\TestResponse; use Symfony\Component\HttpFoundation\File\UploadedFile as SymfonyUploadedFile; @@ -331,11 +334,11 @@ trait MakesHttpRequests /** * Set the referer header and previous URL session value from a given route in order to simulate a previous request. * - * @param string $name + * @param \BackedEnum|string $name * @param mixed $parameters * @return $this */ - public function fromRoute(string $name, $parameters = []) + public function fromRoute(BackedEnum|string $name, $parameters = []) { return $this->from($this->app['url']->route($name, $parameters)); } @@ -353,7 +356,7 @@ trait MakesHttpRequests /** * Visit the given URI with a GET request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $headers * @return \Illuminate\Testing\TestResponse */ @@ -368,7 +371,7 @@ trait MakesHttpRequests /** * Visit the given URI with a GET request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $headers * @param int $options * @return \Illuminate\Testing\TestResponse @@ -381,7 +384,7 @@ trait MakesHttpRequests /** * Visit the given URI with a POST request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @return \Illuminate\Testing\TestResponse @@ -397,7 +400,7 @@ trait MakesHttpRequests /** * Visit the given URI with a POST request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -411,7 +414,7 @@ trait MakesHttpRequests /** * Visit the given URI with a PUT request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @return \Illuminate\Testing\TestResponse @@ -427,7 +430,7 @@ trait MakesHttpRequests /** * Visit the given URI with a PUT request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -441,7 +444,7 @@ trait MakesHttpRequests /** * Visit the given URI with a PATCH request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @return \Illuminate\Testing\TestResponse @@ -457,7 +460,7 @@ trait MakesHttpRequests /** * Visit the given URI with a PATCH request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -471,7 +474,7 @@ trait MakesHttpRequests /** * Visit the given URI with a DELETE request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @return \Illuminate\Testing\TestResponse @@ -487,7 +490,7 @@ trait MakesHttpRequests /** * Visit the given URI with a DELETE request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -501,7 +504,7 @@ trait MakesHttpRequests /** * Visit the given URI with an OPTIONS request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @return \Illuminate\Testing\TestResponse @@ -518,7 +521,7 @@ trait MakesHttpRequests /** * Visit the given URI with an OPTIONS request, expecting a JSON response. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -532,7 +535,7 @@ trait MakesHttpRequests /** * Visit the given URI with a HEAD request. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $headers * @return \Illuminate\Testing\TestResponse */ @@ -549,7 +552,7 @@ trait MakesHttpRequests * Call the given URI with a JSON request. * * @param string $method - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $data * @param array $headers * @param int $options @@ -582,7 +585,7 @@ trait MakesHttpRequests * Call the given URI and return the Response. * * @param string $method - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @param array $parameters * @param array $cookies * @param array $files @@ -615,13 +618,15 @@ trait MakesHttpRequests } /** - * Turn the given URI into a fully qualified URL. + * Turn the given URI into a fully-qualified URL. * - * @param string $uri + * @param \Illuminate\Support\Uri|string $uri * @return string */ protected function prepareUrlForRequest($uri) { + $uri = $uri instanceof Uri ? $uri->value() : $uri; + if (str_starts_with($uri, '/')) { $uri = substr($uri, 1); } @@ -637,7 +642,7 @@ trait MakesHttpRequests */ protected function transformHeadersToServerVars(array $headers) { - return collect(array_merge($this->defaultHeaders, $headers))->mapWithKeys(function ($value, $name) { + return (new Collection(array_merge($this->defaultHeaders, $headers)))->mapWithKeys(function ($value, $name) { $name = strtr(strtoupper($name), '-', '_'); return [$this->formatServerHeaderKey($name) => $value]; @@ -697,9 +702,10 @@ trait MakesHttpRequests return array_merge($this->defaultCookies, $this->unencryptedCookies); } - return collect($this->defaultCookies)->map(function ($value, $key) { - return encrypt(CookieValuePrefix::create($key, app('encrypter')->getKey()).$value, false); - })->merge($this->unencryptedCookies)->all(); + return (new Collection($this->defaultCookies)) + ->map(fn ($value, $key) => encrypt(CookieValuePrefix::create($key, app('encrypter')->getKey()).$value, false)) + ->merge($this->unencryptedCookies) + ->all(); } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactions.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactions.php index 83a686f..0eaa2f0 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactions.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactions.php @@ -13,9 +13,11 @@ trait DatabaseTransactions { $database = $this->app->make('db'); - $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager); + $connections = $this->connectionsToTransact(); - foreach ($this->connectionsToTransact() as $name) { + $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager($connections)); + + foreach ($connections as $name) { $connection = $database->connection($name); $connection->setTransactionManager($transactionsManager); $dispatcher = $connection->getEventDispatcher(); @@ -46,6 +48,7 @@ trait DatabaseTransactions protected function connectionsToTransact() { return property_exists($this, 'connectionsToTransact') - ? $this->connectionsToTransact : [null]; + ? $this->connectionsToTransact + : [null]; } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php index bc54504..4fea491 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTransactionsManager.php @@ -6,6 +6,23 @@ use Illuminate\Database\DatabaseTransactionsManager as BaseManager; class DatabaseTransactionsManager extends BaseManager { + /** + * The names of the connections transacting during tests. + */ + protected array $connectionsTransacting; + + /** + * Create a new database transaction manager instance. + * + * @param array $connectionsTransacting + */ + public function __construct(array $connectionsTransacting) + { + parent::__construct(); + + $this->connectionsTransacting = $connectionsTransacting; + } + /** * Register a transaction callback. * @@ -31,7 +48,7 @@ class DatabaseTransactionsManager extends BaseManager */ public function callbackApplicableTransactions() { - return $this->pendingTransactions->skip(1)->values(); + return $this->pendingTransactions->skip(count($this->connectionsTransacting))->values(); } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTruncation.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTruncation.php index 3f43181..a84c082 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTruncation.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/DatabaseTruncation.php @@ -5,6 +5,8 @@ namespace Illuminate\Foundation\Testing; use Illuminate\Contracts\Console\Kernel; use Illuminate\Database\ConnectionInterface; use Illuminate\Foundation\Testing\Traits\CanConfigureMigrationCommands; +use Illuminate\Support\Arr; +use Illuminate\Support\Collection; trait DatabaseTruncation { @@ -60,7 +62,7 @@ trait DatabaseTruncation { $database = $this->app->make('db'); - collect($this->connectionsToTruncate()) + (new Collection($this->connectionsToTruncate())) ->each(function ($name) use ($database) { $connection = $database->connection($name); @@ -83,32 +85,53 @@ trait DatabaseTruncation $connection->unsetEventDispatcher(); - collect(static::$allTables[$name] ??= $connection->getSchemaBuilder()->getTableListing()) + (new Collection($this->getAllTablesForConnection($connection, $name))) ->when( - property_exists($this, 'tablesToTruncate'), - fn ($tables) => $tables->intersect($this->tablesToTruncate), - fn ($tables) => $tables->diff($this->exceptTables($name)) + $this->tablesToTruncate($connection, $name), + function (Collection $tables, array $tablesToTruncate) { + return $tables->filter(fn (array $table) => $this->tableExistsIn($table, $tablesToTruncate)); + }, + function (Collection $tables) use ($connection, $name) { + $exceptTables = $this->exceptTables($connection, $name); + + return $tables->reject(fn (array $table) => $this->tableExistsIn($table, $exceptTables)); + } ) - ->filter(fn ($table) => $connection->table($this->withoutTablePrefix($connection, $table))->exists()) - ->each(fn ($table) => $connection->table($this->withoutTablePrefix($connection, $table))->truncate()); + ->each(function (array $table) use ($connection) { + $connection->withoutTablePrefix(function ($connection) use ($table) { + $table = $connection->table($table['schema_qualified_name']); + + if ($table->exists()) { + $table->truncate(); + } + }); + }); $connection->setEventDispatcher($dispatcher); } /** - * Remove the table prefix from a table name, if it exists. - * - * @param \Illuminate\Database\ConnectionInterface $connection - * @param string $table - * @return string + * Get all the tables that belong to the connection. */ - protected function withoutTablePrefix(ConnectionInterface $connection, string $table) + protected function getAllTablesForConnection(ConnectionInterface $connection, ?string $name): array { - $prefix = $connection->getTablePrefix(); + if (isset(static::$allTables[$name])) { + return static::$allTables[$name]; + } - return strpos($table, $prefix) === 0 - ? substr($table, strlen($prefix)) - : $table; + $schema = $connection->getSchemaBuilder(); + + return static::$allTables[$name] = Arr::from($schema->getTables($schema->getCurrentSchemaListing())); + } + + /** + * Determine if a table exists in the given list, with or without its schema. + */ + protected function tableExistsIn(array $table, array $tables): bool + { + return $table['schema'] + ? ! empty(array_intersect([$table['name'], $table['schema_qualified_name']], $tables)) + : in_array($table['name'], $tables); } /** @@ -119,36 +142,36 @@ trait DatabaseTruncation protected function connectionsToTruncate(): array { return property_exists($this, 'connectionsToTruncate') - ? $this->connectionsToTruncate : [null]; + ? $this->connectionsToTruncate + : [null]; + } + + /** + * Get the tables that should be truncated. + */ + protected function tablesToTruncate(ConnectionInterface $connection, ?string $connectionName): ?array + { + return property_exists($this, 'tablesToTruncate') && is_array($this->tablesToTruncate) + ? $this->tablesToTruncate[$connectionName] ?? $this->tablesToTruncate + : null; } /** * Get the tables that should not be truncated. - * - * @param string|null $connectionName - * @return array */ - protected function exceptTables(?string $connectionName): array + protected function exceptTables(ConnectionInterface $connection, ?string $connectionName): array { $migrations = $this->app['config']->get('database.migrations'); - $migrationsTable = is_array($migrations) ? ($migrations['table'] ?? null) : $migrations; + $migrationsTable = is_array($migrations) ? ($migrations['table'] ?? 'migrations') : $migrations; + $migrationsTable = $connection->getTablePrefix().$migrationsTable; - if (property_exists($this, 'exceptTables')) { - if (array_is_list($this->exceptTables ?? [])) { - return array_merge( - $this->exceptTables ?? [], - [$migrationsTable], - ); - } - - return array_merge( - $this->exceptTables[$connectionName] ?? [], + return property_exists($this, 'exceptTables') && is_array($this->exceptTables) + ? array_merge( + $this->exceptTables[$connectionName] ?? $this->exceptTables, [$migrationsTable], - ); - } - - return [$migrationsTable]; + ) + : [$migrationsTable]; } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/LazilyRefreshDatabase.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/LazilyRefreshDatabase.php index 194fc3d..6f785e7 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/LazilyRefreshDatabase.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/LazilyRefreshDatabase.php @@ -37,8 +37,10 @@ trait LazilyRefreshDatabase } }; - $database->beforeStartingTransaction($callback); - $database->beforeExecuting($callback); + foreach ($this->connectionsToTransact() as $connection) { + $database->connection($connection)->beforeStartingTransaction($callback); + $database->connection($connection)->beforeExecuting($callback); + } $this->beforeApplicationDestroyed(function () { RefreshDatabaseState::$lazilyRefreshed = false; diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php index 4c4e084..28626ec 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php @@ -18,7 +18,7 @@ trait RefreshDatabase { $this->beforeRefreshingDatabase(); - if ($this->usingInMemoryDatabase()) { + if ($this->usingInMemoryDatabases()) { $this->restoreInMemoryDatabase(); } @@ -28,15 +28,33 @@ trait RefreshDatabase } /** - * Determine if an in-memory database is being used. + * Determine if any of the connections transacting is using in-memory databases. * * @return bool */ - protected function usingInMemoryDatabase() + protected function usingInMemoryDatabases() { - $default = config('database.default'); + foreach ($this->connectionsToTransact() as $name) { + if ($this->usingInMemoryDatabase($name)) { + return true; + } + } - return config("database.connections.$default.database") === ':memory:'; + return false; + } + + /** + * Determine if a given database connection is an in-memory database. + * + * @return bool + */ + protected function usingInMemoryDatabase(?string $name = null) + { + if (is_null($name)) { + $name = config('database.default'); + } + + return config("database.connections.{$name}.database") === ':memory:'; } /** @@ -63,16 +81,44 @@ trait RefreshDatabase protected function refreshTestDatabase() { if (! RefreshDatabaseState::$migrated) { - $this->artisan('migrate:fresh', $this->migrateFreshUsing()); + $this->migrateDatabases(); $this->app[Kernel::class]->setArtisan(null); + $this->updateLocalCacheOfInMemoryDatabases(); + RefreshDatabaseState::$migrated = true; } $this->beginDatabaseTransaction(); } + /** + * Update locally cached in-memory PDO connections after migration. + * + * @return void + */ + protected function updateLocalCacheOfInMemoryDatabases() + { + $database = $this->app->make('db'); + + foreach ($this->connectionsToTransact() as $name) { + if ($this->usingInMemoryDatabase($name)) { + RefreshDatabaseState::$inMemoryConnections[$name] = $database->connection($name)->getPdo(); + } + } + } + + /** + * Migrate the database. + * + * @return void + */ + protected function migrateDatabases() + { + $this->artisan('migrate:fresh', $this->migrateFreshUsing()); + } + /** * Begin a database transaction on the testing database. * @@ -82,14 +128,16 @@ trait RefreshDatabase { $database = $this->app->make('db'); - $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager); + $connections = $this->connectionsToTransact(); - foreach ($this->connectionsToTransact() as $name) { + $this->app->instance('db.transactions', $transactionsManager = new DatabaseTransactionsManager($connections)); + + foreach ($connections as $name) { $connection = $database->connection($name); $connection->setTransactionManager($transactionsManager); - if ($this->usingInMemoryDatabase()) { + if ($this->usingInMemoryDatabase($name)) { RefreshDatabaseState::$inMemoryConnections[$name] ??= $connection->getPdo(); } @@ -106,6 +154,11 @@ trait RefreshDatabase $dispatcher = $connection->getEventDispatcher(); $connection->unsetEventDispatcher(); + + if ($connection->getPdo() && ! $connection->getPdo()->inTransaction()) { + RefreshDatabaseState::$migrated = false; + } + $connection->rollBack(); $connection->setEventDispatcher($dispatcher); $connection->disconnect(); @@ -121,7 +174,8 @@ trait RefreshDatabase protected function connectionsToTransact() { return property_exists($this, 'connectionsToTransact') - ? $this->connectionsToTransact : [null]; + ? $this->connectionsToTransact + : [config('database.default')]; } /** diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php index 1d7a17d..af46b18 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php @@ -4,7 +4,10 @@ namespace Illuminate\Foundation\Testing; use Illuminate\Contracts\Console\Kernel; use Illuminate\Foundation\Application; +use Illuminate\Foundation\Testing\Attributes\UnitTest; use PHPUnit\Framework\TestCase as BaseTestCase; +use ReflectionMethod; +use Throwable; abstract class TestCase extends BaseTestCase { @@ -20,6 +23,20 @@ abstract class TestCase extends BaseTestCase Concerns\InteractsWithTestCaseLifecycle, Concerns\InteractsWithViews; + /** + * The list of trait that this test uses, fetched recursively. + * + * @var array + */ + protected array $traitsUsedByTest; + + /** + * Memoized result of the withoutBootingFramework check. + * + * @var bool|null + */ + protected ?bool $withoutBootingFramework = null; + /** * Creates the application. * @@ -29,6 +46,16 @@ abstract class TestCase extends BaseTestCase { $app = require Application::inferBasePath().'/bootstrap/app.php'; + $this->traitsUsedByTest = class_uses_recursive(static::class); + + if (isset(CachedState::$cachedConfig, $this->traitsUsedByTest[WithCachedConfig::class])) { + $this->markConfigCached($app); + } + + if (isset(CachedState::$cachedRoutes, $this->traitsUsedByTest[WithCachedRoutes::class])) { + $app->booting(fn () => $this->markRoutesCached($app)); + } + $app->make(Kernel::class)->bootstrap(); return $app; @@ -41,6 +68,10 @@ abstract class TestCase extends BaseTestCase */ protected function setUp(): void { + if ($this->withoutBootingFramework()) { + return; + } + $this->setUpTheTestEnvironment(); } @@ -63,9 +94,33 @@ abstract class TestCase extends BaseTestCase */ protected function tearDown(): void { + if ($this->withoutBootingFramework()) { + return; + } + $this->tearDownTheTestEnvironment(); } + /** + * Determine if the test method should boot the framework. + * + * @return bool + * + * @throws \ReflectionException + */ + protected function withoutBootingFramework(): bool + { + if ($this->withoutBootingFramework !== null) { + return $this->withoutBootingFramework; + } + + try { + return $this->withoutBootingFramework = (new ReflectionMethod(static::class, $this->name()))->getAttributes(UnitTest::class) !== []; + } catch (Throwable) { + return $this->withoutBootingFramework = false; + } + } + /** * Clean up the testing environment before the next test case. * diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Traits/CanConfigureMigrationCommands.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Traits/CanConfigureMigrationCommands.php index aafca6f..72b17a7 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Traits/CanConfigureMigrationCommands.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Traits/CanConfigureMigrationCommands.php @@ -2,6 +2,10 @@ namespace Illuminate\Foundation\Testing\Traits; +use Illuminate\Foundation\Testing\Attributes\Seed; +use Illuminate\Foundation\Testing\Attributes\Seeder; +use ReflectionClass; + trait CanConfigureMigrationCommands { /** @@ -49,6 +53,14 @@ trait CanConfigureMigrationCommands */ protected function shouldSeed() { + $class = new ReflectionClass($this); + + do { + if ($class->getAttributes(Seed::class) !== []) { + return true; + } + } while ($class = $class->getParentClass()); + return property_exists($this, 'seed') ? $this->seed : false; } @@ -59,6 +71,16 @@ trait CanConfigureMigrationCommands */ protected function seeder() { + $class = new ReflectionClass($this); + + do { + $seeder = $class->getAttributes(Seeder::class); + + if (count($seeder) > 0) { + return $seeder[0]->newInstance()->class; + } + } while ($class = $class->getParentClass()); + return property_exists($this, 'seeder') ? $this->seeder : false; } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedConfig.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedConfig.php new file mode 100644 index 0000000..e1ed65a --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedConfig.php @@ -0,0 +1,41 @@ +app->make('config')->all(); + } + + $this->markConfigCached($this->app); + } + + /** + * Reset the cached configuration. + * + * This is helpful if some of the tests in the suite apply this trait while others do not. + */ + protected function tearDownWithCachedConfig(): void + { + LoadConfiguration::alwaysUse(null); + } + + /** + * Inform the container that the configuration is cached. + */ + protected function markConfigCached(Application $app): void + { + $app->instance('config_loaded_from_cache', true); + + LoadConfiguration::alwaysUse(static fn () => CachedState::$cachedConfig); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedRoutes.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedRoutes.php new file mode 100644 index 0000000..1a02a37 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/WithCachedRoutes.php @@ -0,0 +1,52 @@ +app['router']->getRoutes(); + + $routes->refreshNameLookups(); + $routes->refreshActionLookups(); + + CachedState::$cachedRoutes = $routes->compile(); + } + + $this->markRoutesCached($this->app); + } + + /** + * Reset the route service provider so it's not defaulting to loading cached routes. + * + * This is helpful if some of the tests in the suite apply this trait while others do not. + * + * @return void + */ + protected function tearDownWithCachedRoutes(): void + { + RouteServiceProvider::loadCachedRoutesUsing(null); + } + + /** + * Inform the container to treat routes as cached. + */ + protected function markRoutesCached(Application $app): void + { + $app->instance('routes.cached', true); + + RouteServiceProvider::loadCachedRoutesUsing( + static fn () => app('router')->setCompiledRoutes(CachedState::$cachedRoutes) + ); + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Wormhole.php b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Wormhole.php index beac013..623aa99 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Wormhole.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Wormhole.php @@ -17,7 +17,6 @@ class Wormhole * Create a new wormhole instance. * * @param int $value - * @return void */ public function __construct($value) { @@ -25,10 +24,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of microseconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function microsecond($callback = null) { @@ -36,10 +37,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of microseconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function microseconds($callback = null) { @@ -49,10 +52,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of milliseconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function millisecond($callback = null) { @@ -60,10 +65,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of milliseconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function milliseconds($callback = null) { @@ -73,10 +80,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of seconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function second($callback = null) { @@ -84,10 +93,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of seconds. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function seconds($callback = null) { @@ -97,10 +108,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of minutes. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function minute($callback = null) { @@ -108,10 +121,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of minutes. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function minutes($callback = null) { @@ -121,10 +136,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of hours. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function hour($callback = null) { @@ -132,10 +149,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of hours. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function hours($callback = null) { @@ -145,10 +164,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of days. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function day($callback = null) { @@ -156,10 +177,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of days. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function days($callback = null) { @@ -169,10 +192,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of weeks. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function week($callback = null) { @@ -180,10 +205,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of weeks. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function weeks($callback = null) { @@ -193,10 +220,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of months. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function month($callback = null) { @@ -204,10 +233,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of months. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function months($callback = null) { @@ -217,10 +248,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of years. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function year($callback = null) { @@ -228,10 +261,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Travel forward the given number of years. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ public function years($callback = null) { @@ -253,10 +288,12 @@ class Wormhole } /** + * @template TReturn of mixed + * * Handle the given optional execution callback. * - * @param callable|null $callback - * @return mixed + * @param (callable(): TReturn)|null $callback + * @return ($callback is null ? void : TReturn) */ protected function handleCallback($callback) { diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php b/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php index 7922f83..9008643 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/Vite.php @@ -97,6 +97,20 @@ class Vite implements Htmlable */ protected static $manifests = []; + /** + * The ViteFonts instance. + * + * @var \Illuminate\Foundation\ViteFonts|null + */ + protected $fonts = null; + + /** + * The name of the font manifest file. + * + * @var string + */ + protected $fontsManifestFilename = 'fonts-manifest.json'; + /** * The prefetching strategy to use. * @@ -175,6 +189,20 @@ class Vite implements Htmlable return $this; } + /** + * Merge additional Vite entry points with the current set. + * + * @param array $entryPoints + * @return $this + */ + public function mergeEntryPoints($entryPoints) + { + return $this->withEntryPoints(array_unique([ + ...$this->entryPoints, + ...$entryPoints, + ])); + } + /** * Set the filename for the manifest file. * @@ -355,7 +383,7 @@ class Vite implements Htmlable */ public function __invoke($entrypoints, $buildDirectory = null) { - $entrypoints = collect($entrypoints); + $entrypoints = new Collection($entrypoints); $buildDirectory ??= $this->buildDirectory; if ($this->isRunningHot()) { @@ -369,8 +397,8 @@ class Vite implements Htmlable $manifest = $this->manifest($buildDirectory); - $tags = collect(); - $preloads = collect(); + $tags = new Collection; + $preloads = new Collection; foreach ($entrypoints as $entrypoint) { $chunk = $this->chunk($manifest, $entrypoint); @@ -382,7 +410,7 @@ class Vite implements Htmlable $manifest, ]); - foreach ($chunk['imports'] ?? [] as $import) { + foreach ($this->resolveImports($manifest, $chunk) as $import) { $preloads->push([ $import, $this->assetPath("{$buildDirectory}/{$manifest[$import]['file']}"), @@ -391,7 +419,7 @@ class Vite implements Htmlable ]); foreach ($manifest[$import]['css'] ?? [] as $css) { - $partialManifest = Collection::make($manifest)->where('file', $css); + $partialManifest = (new Collection($manifest))->where('file', $css); $preloads->push([ $partialManifest->keys()->first(), @@ -417,7 +445,7 @@ class Vite implements Htmlable )); foreach ($chunk['css'] ?? [] as $css) { - $partialManifest = Collection::make($manifest)->where('file', $css); + $partialManifest = (new Collection($manifest))->where('file', $css); $preloads->push([ $partialManifest->keys()->first(), @@ -449,12 +477,12 @@ class Vite implements Htmlable $discoveredImports = []; - return collect($entrypoints) - ->flatMap(fn ($entrypoint) => collect($manifest[$entrypoint]['dynamicImports'] ?? []) + return (new Collection($entrypoints)) + ->flatMap(fn ($entrypoint) => (new Collection($manifest[$entrypoint]['dynamicImports'] ?? [])) ->map(fn ($import) => $manifest[$import]) ->filter(fn ($chunk) => str_ends_with($chunk['file'], '.js') || str_ends_with($chunk['file'], '.css')) ->flatMap($f = function ($chunk) use (&$f, $manifest, &$discoveredImports) { - return collect([...$chunk['imports'] ?? [], ...$chunk['dynamicImports'] ?? []]) + return (new Collection([...$chunk['imports'] ?? [], ...$chunk['dynamicImports'] ?? []])) ->reject(function ($import) use (&$discoveredImports) { if (isset($discoveredImports[$import])) { return true; @@ -465,15 +493,15 @@ class Vite implements Htmlable ->reduce( fn ($chunks, $import) => $chunks->merge( $f($manifest[$import]) - ), collect([$chunk])) - ->merge(collect($chunk['css'] ?? [])->map( - fn ($css) => collect($manifest)->first(fn ($chunk) => $chunk['file'] === $css) ?? [ + ), new Collection([$chunk])) + ->merge((new Collection($chunk['css'] ?? []))->map( + fn ($css) => (new Collection($manifest))->first(fn ($chunk) => $chunk['file'] === $css) ?? [ 'file' => $css, ], )); }) ->map(function ($chunk) use ($buildDirectory, $manifest) { - return collect([ + return (new Collection([ ...$this->resolvePreloadTagAttributes( $chunk['src'] ?? null, $url = $this->assetPath("{$buildDirectory}/{$chunk['file']}"), @@ -483,7 +511,7 @@ class Vite implements Htmlable 'rel' => 'prefetch', 'fetchpriority' => 'low', 'href' => $url, - ])->reject( + ]))->reject( fn ($value) => in_array($value, [null, false], true) )->mapWithKeys(fn ($value, $key) => [ $key = (is_int($key) ? $value : $key) => $value === true ? $key : $value, @@ -525,7 +553,7 @@ class Vite implements Htmlable if (assets.length) { link.onload = () => loadNext(assets, 1) - link.error = () => loadNext(assets, 1) + link.onerror = () => loadNext(assets, 1) } } @@ -550,7 +578,7 @@ class Vite implements Htmlable return link } - const fragment = new DocumentFragment + const fragment = new DocumentFragment; {$assets}.forEach((asset) => fragment.append(makeLink(asset))) document.head.append(fragment) })) @@ -610,7 +638,7 @@ class Vite implements Htmlable } $this->preloadedAssets[$url] = $this->parseAttributes( - Collection::make($attributes)->forget('href')->all() + (new Collection($attributes))->forget('href')->all() ); return 'parseAttributes($attributes)).' />'; @@ -679,6 +707,7 @@ class Vite implements Htmlable 'crossorigin' => $this->resolveStylesheetTagAttributes($src, $url, $chunk, $manifest)['crossorigin'] ?? false, ] : [ 'rel' => 'modulepreload', + 'as' => 'script', 'href' => $url, 'nonce' => $this->nonce ?? false, 'crossorigin' => $this->resolveScriptTagAttributes($src, $url, $chunk, $manifest)['crossorigin'] ?? false, @@ -786,7 +815,7 @@ class Vite implements Htmlable */ protected function isCssPath($path) { - return preg_match('/\.(css|less|sass|scss|styl|stylus|pcss|postcss)$/', $path) === 1; + return preg_match('/\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?[^\.]*)?$/', $path) === 1; } /** @@ -797,7 +826,7 @@ class Vite implements Htmlable */ protected function parseAttributes($attributes) { - return Collection::make($attributes) + return (new Collection($attributes)) ->reject(fn ($value, $key) => in_array($value, [false, null], true)) ->flatMap(fn ($value, $key) => $value === true ? [$key] : [$key => $value]) ->map(fn ($value, $key) => is_int($key) ? $value : $key.'="'.$value.'"') @@ -882,7 +911,7 @@ class Vite implements Htmlable $chunk = $this->chunk($this->manifest($buildDirectory), $asset); - $path = public_path($buildDirectory.'/'.$chunk['file']); + $path = $this->publicPath($buildDirectory.'/'.$chunk['file']); if (! is_file($path) || ! file_exists($path)) { throw new ViteException("Unable to locate file from Vite manifest: {$path}."); @@ -903,6 +932,17 @@ class Vite implements Htmlable return ($this->assetPathResolver ?? asset(...))($path, $secure); } + /** + * Generate a public path for an asset. + * + * @param string $path + * @return string + */ + protected function publicPath($path) + { + return public_path($path); + } + /** * Get the manifest file for the given build directory. * @@ -958,6 +998,35 @@ class Vite implements Htmlable return md5_file($path) ?: null; } + /** + * Recursively resolve all imports for the given chunk. + * + * @param array $manifest + * @param array $chunk + * @param array $seen + * @return array + */ + protected function resolveImports($manifest, $chunk, $seen = []) + { + $imports = []; + + foreach ($chunk['imports'] ?? [] as $import) { + if (isset($seen[$import])) { + continue; + } + + $seen[$import] = true; + + $imports[] = $import; + + if (isset($manifest[$import])) { + $imports = array_merge($imports, $this->resolveImports($manifest, $manifest[$import], $seen)); + } + } + + return $imports; + } + /** * Get the chunk for the given entry point / asset. * @@ -990,6 +1059,160 @@ class Vite implements Htmlable return new HtmlString(' nonce="'.$this->cspNonce().'"'); } + /** + * Render font preload links and inline styles. + * + * @param list|string|null $aliases + * @return \Illuminate\Support\HtmlString + * + * @throws \Illuminate\Foundation\ViteException + */ + public function fonts($aliases = null) + { + $isHot = $this->isRunningHot(); + + $fonts = $this->viteFonts(); + + $manifest = $fonts->manifest($isHot, $this->buildDirectory, $this->fontsManifestFilename, $this->hotFile()); + + if ($manifest === null) { + return new HtmlString(''); + } + + $fonts->ensureValidManifest($manifest); + + $preloads = $manifest['preloads'] ?? []; + + if ($aliases !== null) { + $aliases = is_string($aliases) + ? [$aliases] + : $aliases; + + $fonts->ensureValidFamilies($aliases, $manifest); + + $preloads = array_filter($preloads, fn ($preload) => in_array($preload['alias'] ?? null, $aliases, true)); + } + + $fonts->ensureValidPreloads($preloads, $isHot); + + $preloadsHtml = $this->renderFontPreloads($preloads); + $styleHtml = $this->renderFontStyle($manifest, $aliases); + + return new HtmlString(match (true) { + $preloadsHtml !== '' && $styleHtml !== '' => $preloadsHtml."\n".$styleHtml, + default => $preloadsHtml.$styleHtml, + }); + } + + /** + * Render preload link tags for font entries. + * + * @param list> $preloads + * @return string + */ + protected function renderFontPreloads($preloads) + { + $tags = []; + + foreach ($preloads as $preload) { + $url = $preload['url'] ?? $this->assetPath($this->buildDirectory.'/'.$preload['file']); + + if (isset($this->preloadedAssets[$url])) { + continue; + } + + $attributes = $this->resolveFontPreloadAttributes($url, $preload); + + if ($attributes === false) { + continue; + } + + $this->preloadedAssets[$url] = $this->parseAttributes( + (new Collection($attributes))->forget('href')->all() + ); + + $tags[] = 'parseAttributes($attributes)).' />'; + } + + return implode("\n", $tags); + } + + /** + * Resolve the attributes for a font preload tag. + * + * @param string $url + * @param array $preload + * @return array|false + */ + protected function resolveFontPreloadAttributes($url, $preload) + { + $attributes = [ + 'rel' => 'preload', + 'as' => $preload['as'] ?? 'font', + 'href' => $url, + 'type' => $preload['type'] ?? false, + 'crossorigin' => $preload['crossorigin'] ?? false, + 'nonce' => $this->nonce ?? false, + ]; + + foreach ($this->preloadTagAttributesResolvers as $resolver) { + if (false === ($resolved = $resolver('fonts', $url, [], []))) { + return false; + } + + $attributes = array_merge($attributes, $resolved); + } + + return $attributes; + } + + /** + * Render the inline style block for the font manifest. + * + * @param array $manifest + * @param list|null $aliases + * @return string + */ + protected function renderFontStyle($manifest, $aliases) + { + $css = $this->viteFonts()->resolveStyleContent($manifest, $aliases, $this->buildDirectory); + + if ($css === '') { + return ''; + } + + $attributes = $this->parseAttributes([ + 'nonce' => $this->nonce ?? false, + ]); + + $attributeString = $attributes ? ' '.implode(' ', $attributes) : ''; + + return "\n".trim($css, "\n")."\n"; + } + + /** + * Get the ViteFonts instance. + * + * @return \Illuminate\Foundation\ViteFonts + */ + protected function viteFonts() + { + return $this->fonts ??= new ViteFonts; + } + + /** + * Set the font manifest filename. + * + * @param string $filename + * @return $this + */ + public function useFontsManifestFilename($filename) + { + $this->fontsManifestFilename = $filename; + + return $this; + } + /** * Determine if the HMR server is running. * @@ -1009,4 +1232,18 @@ class Vite implements Htmlable { return $this->__invoke($this->entryPoints)->toHtml(); } + + /** + * Flush state. + * + * @return void + */ + public function flush() + { + $this->preloadedAssets = []; + + $this->fonts?->flush(); + + $this->fonts = null; + } } diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/ViteFonts.php b/vendor/laravel/framework/src/Illuminate/Foundation/ViteFonts.php new file mode 100644 index 0000000..5a0022b --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/ViteFonts.php @@ -0,0 +1,249 @@ +> + */ + protected static $manifests = []; + + /** + * Read the font manifest for the given configuration. + * + * @param bool $isHot + * @param string $buildDirectory + * @param string $manifestFilename + * @param string $hotFile + * @return array|null + * + * @throws \Illuminate\Foundation\ViteException + */ + public function manifest(bool $isHot, string $buildDirectory, string $manifestFilename, string $hotFile) + { + $path = $isHot + ? dirname($hotFile).'/fonts-manifest.dev.json' + : public_path($buildDirectory.'/'.$manifestFilename); + + return $this->readManifest($path); + } + + /** + * Read and decode a manifest file. + * + * @param string $path + * @return array|null + * + * @throws \Illuminate\Foundation\ViteException + */ + protected function readManifest(string $path) + { + if (isset(static::$manifests[$path])) { + return static::$manifests[$path]; + } + + if (! is_file($path)) { + return null; + } + + $contents = file_get_contents($path); + + $manifest = json_decode($contents, true); + + if (json_last_error() !== JSON_ERROR_NONE) { + throw new ViteException("The font manifest at [{$path}] is not valid JSON."); + } + + return static::$manifests[$path] = $manifest; + } + + /** + * Resolve the CSS content from the manifest. + * + * @param array $manifest + * @param list|null $aliases + * @param string $buildDirectory + * @return string + * + * @throws \Illuminate\Foundation\ViteException + */ + public function resolveStyleContent(array $manifest, ?array $aliases, string $buildDirectory) + { + $style = $manifest['style'] ?? null; + + return match (true) { + $style === null => '', + $aliases !== null => $this->resolveFilteredStyleContent($style, $aliases), + isset($style['inline']) => $style['inline'], + isset($style['file']) => $this->readStyleFile($buildDirectory, $style['file']), + default => '', + }; + } + + /** + * Resolve filtered CSS content using per-alias fragments from the manifest. + * + * @param array{inline?: string, file?: string, familyStyles?: array, variables?: array} $style + * @param list $aliases + * @return string + * + * @throws \Illuminate\Foundation\ViteException + */ + protected function resolveFilteredStyleContent(array $style, array $aliases) + { + $familyStyles = $style['familyStyles'] ?? []; + $variables = $style['variables'] ?? []; + + if (! is_array($familyStyles)) { + throw new ViteException( + 'The font manifest [style.familyStyles] must be an object keyed by alias; the manifest was likely produced by an incompatible plugin version.' + ); + } + + if (! is_array($variables)) { + throw new ViteException( + 'The font manifest [style.variables] must be an object keyed by alias; the manifest was likely produced by an incompatible plugin version.' + ); + } + + $parts = []; + + foreach ($aliases as $alias) { + if (isset($familyStyles[$alias])) { + $parts[] = $familyStyles[$alias]; + } + } + + if ($variables !== []) { + $parts[] = $this->filterVariables($variables, $aliases); + } + + return implode("\n\n", $parts); + } + + /** + * Build a `:root` block containing only the CSS variables for the given aliases. + * + * @param array $variables + * @param list $aliases List of aliases in desired emission order. + * @return string + */ + protected function filterVariables(array $variables, array $aliases) + { + $declarations = []; + + foreach ($aliases as $alias) { + if (isset($variables[$alias])) { + $declarations[] = ' '.$variables[$alias]; + } + } + + if ($declarations === []) { + return ''; + } + + return ":root {\n".implode("\n", $declarations)."\n}"; + } + + /** + * Read a CSS file from the build directory. + * + * @param string $buildDirectory + * @param string $file + * @return string + * + * @throws \Illuminate\Foundation\ViteException + */ + protected function readStyleFile(string $buildDirectory, string $file) + { + $path = public_path($buildDirectory.'/'.$file); + + if (! is_file($path)) { + throw new ViteException("Unable to locate font CSS file from manifest: {$path}."); + } + + return file_get_contents($path); + } + + /** + * Validate the font manifest structure. + * + * @param array $manifest + * @return void + * + * @throws \Illuminate\Foundation\ViteException + */ + public function ensureValidManifest(array $manifest) + { + if (! isset($manifest['version'])) { + throw new ViteException('The font manifest is missing the [version] key.'); + } + + if ($manifest['version'] !== 1) { + throw new ViteException("Unsupported font manifest version [{$manifest['version']}]. Supported versions: 1."); + } + + if (! isset($manifest['families']) || ! is_array($manifest['families'])) { + throw new ViteException('The font manifest is missing the [families] key.'); + } + } + + /** + * Validate that the requested aliases exist in the manifest. + * + * @param list $aliases + * @param array $manifest + * @return void + * + * @throws \Illuminate\Foundation\ViteException + */ + public function ensureValidFamilies(array $aliases, array $manifest) + { + $available = array_keys($manifest['families'] ?? []); + + foreach ($aliases as $alias) { + if (! in_array($alias, $available, true)) { + throw new ViteException( + "Font alias [{$alias}] is not defined in the font manifest. Available aliases: ".implode(', ', $available).'.' + ); + } + } + } + + /** + * Validate that each preload entry contains the required keys. + * + * @param list> $preloads + * @param bool $isHot + * @return void + * + * @throws \Illuminate\Foundation\ViteException + */ + public function ensureValidPreloads(array $preloads, bool $isHot) + { + $urlKey = $isHot ? 'url' : 'file'; + + foreach ($preloads as $index => $preload) { + if (! isset($preload['alias'])) { + throw new ViteException("Font manifest preload entry [{$index}] is missing the [alias] key."); + } + + if (! isset($preload[$urlKey])) { + throw new ViteException("Font manifest preload entry [{$index}] for alias [{$preload['alias']}] is missing the [{$urlKey}] key."); + } + } + } + + /** + * Flush cached manifests. + * + * @return void + */ + public function flush() + { + static::$manifests = []; + } +} diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php index 8ce88f4..ece3f6f 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php @@ -1,8 +1,12 @@ action($name, $parameters, $absolute); } @@ -111,10 +124,9 @@ if (! function_exists('app')) { /** * Get the available container instance. * - * @template TClass + * @template TClass of object * * @param string|class-string|null $abstract - * @param array $parameters * @return ($abstract is class-string ? TClass : ($abstract is null ? \Illuminate\Foundation\Application : mixed)) */ function app($abstract = null, array $parameters = []) @@ -132,9 +144,8 @@ if (! function_exists('app_path')) { * Get the path to the application folder. * * @param string $path - * @return string */ - function app_path($path = '') + function app_path($path = ''): string { return app()->path($path); } @@ -146,9 +157,8 @@ if (! function_exists('asset')) { * * @param string $path * @param bool|null $secure - * @return string */ - function asset($path, $secure = null) + function asset($path, $secure = null): string { return app('url')->asset($path, $secure); } @@ -159,9 +169,9 @@ if (! function_exists('auth')) { * Get the available auth instance. * * @param string|null $guard - * @return ($guard is null ? \Illuminate\Contracts\Auth\Factory : \Illuminate\Contracts\Auth\StatefulGuard) + * @return ($guard is null ? \Illuminate\Contracts\Auth\Factory : \Illuminate\Contracts\Auth\Guard) */ - function auth($guard = null) + function auth($guard = null): AuthFactory|Guard { if (is_null($guard)) { return app(AuthFactory::class); @@ -178,9 +188,8 @@ if (! function_exists('back')) { * @param int $status * @param array $headers * @param mixed $fallback - * @return \Illuminate\Http\RedirectResponse */ - function back($status = 302, $headers = [], $fallback = false) + function back($status = 302, $headers = [], $fallback = false): RedirectResponse { return app('redirect')->back($status, $headers, $fallback); } @@ -191,9 +200,8 @@ if (! function_exists('base_path')) { * Get the path to the base of the install. * * @param string $path - * @return string */ - function base_path($path = '') + function base_path($path = ''): string { return app()->basePath($path); } @@ -205,9 +213,8 @@ if (! function_exists('bcrypt')) { * * @param string $value * @param array $options - * @return string */ - function bcrypt($value, $options = []) + function bcrypt($value, $options = []): string { return app('hash')->driver('bcrypt')->make($value, $options); } @@ -217,15 +224,48 @@ if (! function_exists('broadcast')) { /** * Begin broadcasting an event. * - * @param mixed|null $event - * @return \Illuminate\Broadcasting\PendingBroadcast + * @param mixed $event */ - function broadcast($event = null) + function broadcast($event = null): PendingBroadcast { return app(BroadcastFactory::class)->event($event); } } +if (! function_exists('broadcast_if')) { + /** + * Begin broadcasting an event if the given condition is true. + * + * @param bool $boolean + * @param mixed $event + */ + function broadcast_if($boolean, $event = null): PendingBroadcast + { + if ($boolean) { + return app(BroadcastFactory::class)->event(value($event)); + } else { + return new FakePendingBroadcast; + } + } +} + +if (! function_exists('broadcast_unless')) { + /** + * Begin broadcasting an event unless the given condition is true. + * + * @param bool $boolean + * @param mixed $event + */ + function broadcast_unless($boolean, $event = null): PendingBroadcast + { + if (! $boolean) { + return app(BroadcastFactory::class)->event(value($event)); + } else { + return new FakePendingBroadcast; + } + } +} + if (! function_exists('cache')) { /** * Get / set the specified cache value. @@ -254,7 +294,7 @@ if (! function_exists('cache')) { ); } - return app('cache')->put(key($key), reset($key), ttl: $default); + return app('cache')->put(key($key), array_first($key), ttl: $default); } } @@ -287,9 +327,8 @@ if (! function_exists('config_path')) { * Get the configuration path. * * @param string $path - * @return string */ - function config_path($path = '') + function config_path($path = ''): string { return app()->configPath($path); } @@ -330,7 +369,7 @@ if (! function_exists('cookie')) { * @param string|null $sameSite * @return ($name is null ? \Illuminate\Cookie\CookieJar : \Symfony\Component\HttpFoundation\Cookie) */ - function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null) + function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = null, $httpOnly = true, $raw = false, $sameSite = null): CookieJar|Cookie { $cookie = app(CookieFactory::class); @@ -345,10 +384,8 @@ if (! function_exists('cookie')) { if (! function_exists('csrf_field')) { /** * Generate a CSRF token form field. - * - * @return \Illuminate\Support\HtmlString */ - function csrf_field() + function csrf_field(): HtmlString { return new HtmlString(''); } @@ -358,11 +395,9 @@ if (! function_exists('csrf_token')) { /** * Get the CSRF token value. * - * @return string - * * @throws \RuntimeException */ - function csrf_token() + function csrf_token(): ?string { $session = app('session'); @@ -379,9 +414,8 @@ if (! function_exists('database_path')) { * Get the database path. * * @param string $path - * @return string */ - function database_path($path = '') + function database_path($path = ''): string { return app()->databasePath($path); } @@ -405,21 +439,11 @@ if (! function_exists('defer')) { /** * Defer execution of the given callback. * - * @param callable|null $callback - * @param string|null $name - * @param bool $always - * @return \Illuminate\Foundation\Defer\DeferredCallback + * @return ($callback is null ? \Illuminate\Support\Defer\DeferredCallbackCollection : \Illuminate\Support\Defer\DeferredCallback) */ - function defer(?callable $callback = null, ?string $name = null, bool $always = false) + function defer(?callable $callback = null, ?string $name = null, bool $always = false): DeferredCallback|DeferredCallbackCollection { - if ($callback === null) { - return app(DeferredCallbackCollection::class); - } - - return tap( - new DeferredCallback($callback, $name, $always), - fn ($deferred) => app(DeferredCallbackCollection::class)[] = $deferred - ); + return \Illuminate\Support\defer($callback, $name, $always); } } @@ -430,11 +454,11 @@ if (! function_exists('dispatch')) { * @param mixed $job * @return ($job is \Closure ? \Illuminate\Foundation\Bus\PendingClosureDispatch : \Illuminate\Foundation\Bus\PendingDispatch) */ - function dispatch($job) + function dispatch($job): PendingDispatch|PendingClosureDispatch { return $job instanceof Closure - ? new PendingClosureDispatch(CallQueuedClosure::create($job)) - : new PendingDispatch($job); + ? new PendingClosureDispatch(CallQueuedClosure::create($job)) + : new PendingDispatch($job); } } @@ -460,9 +484,8 @@ if (! function_exists('encrypt')) { * * @param mixed $value * @param bool $serialize - * @return string */ - function encrypt($value, $serialize = true) + function encrypt($value, $serialize = true): string { return app('encrypter')->encrypt($value, $serialize); } @@ -488,9 +511,8 @@ if (! function_exists('fake') && class_exists(\Faker\Factory::class)) { * Get a faker instance. * * @param string|null $locale - * @return \Faker\Generator */ - function fake($locale = null) + function fake($locale = null): \Faker\Generator { if (app()->bound('config')) { $locale ??= app('config')->get('app.faker_locale'); @@ -514,45 +536,42 @@ if (! function_exists('info')) { * * @param string $message * @param array $context - * @return void */ - function info($message, $context = []) + function info($message, $context = []): void { app('log')->info($message, $context); } } -if (! function_exists('logger')) { - /** - * Log a debug message to the logs. - * - * @param string|null $message - * @param array $context - * @return ($message is null ? \Illuminate\Log\LogManager : null) - */ - function logger($message = null, array $context = []) - { - if (is_null($message)) { - return app('log'); - } - - return app('log')->debug($message, $context); - } -} - if (! function_exists('lang_path')) { /** * Get the path to the language folder. * * @param string $path - * @return string */ - function lang_path($path = '') + function lang_path($path = ''): string { return app()->langPath($path); } } +if (! function_exists('logger')) { + /** + * Log a debug message to the logs. + * + * @param string|null $message + * @return ($message is null ? \Psr\Log\LoggerInterface : null) + */ + function logger($message = null, array $context = []): ?LoggerInterface + { + if (is_null($message)) { + return app('log'); + } + + return app('log')->debug($message, $context); + } +} + if (! function_exists('logs')) { /** * Get a log driver instance. @@ -560,7 +579,7 @@ if (! function_exists('logs')) { * @param string|null $driver * @return ($driver is null ? \Illuminate\Log\LogManager : \Psr\Log\LoggerInterface) */ - function logs($driver = null) + function logs($driver = null): LoggerInterface|LogManager { return $driver ? app('log')->driver($driver) : app('log'); } @@ -571,9 +590,8 @@ if (! function_exists('method_field')) { * Generate a form field to spoof the HTTP verb used by forms. * * @param string $method - * @return \Illuminate\Support\HtmlString */ - function method_field($method) + function method_field($method): HtmlString { return new HtmlString(''); } @@ -585,11 +603,10 @@ if (! function_exists('mix')) { * * @param string $path * @param string $manifestDirectory - * @return \Illuminate\Support\HtmlString|string * * @throws \Exception */ - function mix($path, $manifestDirectory = '') + function mix($path, $manifestDirectory = ''): HtmlString|string { return app(Mix::class)(...func_get_args()); } @@ -599,12 +616,11 @@ if (! function_exists('now')) { /** * Create a new Carbon instance for the current time. * - * @param \DateTimeZone|string|null $tz - * @return \Illuminate\Support\Carbon + * @param \DateTimeZone|\UnitEnum|string|null $tz */ - function now($tz = null) + function now($tz = null): CarbonInterface { - return Date::now($tz); + return Date::now(enum_value($tz)); } } @@ -613,8 +629,8 @@ if (! function_exists('old')) { * Retrieve an old input item. * * @param string|null $key - * @param mixed $default - * @return mixed + * @param \Illuminate\Database\Eloquent\Model|string|array|null $default + * @return string|array|null */ function old($key = null, $default = null) { @@ -671,9 +687,8 @@ if (! function_exists('public_path')) { * Get the path to the public folder. * * @param string $path - * @return string */ - function public_path($path = '') + function public_path($path = ''): string { return app()->publicPath($path); } @@ -689,7 +704,7 @@ if (! function_exists('redirect')) { * @param bool|null $secure * @return ($to is null ? \Illuminate\Routing\Redirector : \Illuminate\Http\RedirectResponse) */ - function redirect($to = null, $status = 302, $headers = [], $secure = null) + function redirect($to = null, $status = 302, $headers = [], $secure = null): Redirector|RedirectResponse { if (is_null($to)) { return app('redirect'); @@ -704,9 +719,8 @@ if (! function_exists('report')) { * Report an exception. * * @param \Throwable|string $exception - * @return void */ - function report($exception) + function report($exception): void { if (is_string($exception)) { $exception = new Exception($exception); @@ -722,9 +736,8 @@ if (! function_exists('report_if')) { * * @param bool $boolean * @param \Throwable|string $exception - * @return void */ - function report_if($boolean, $exception) + function report_if($boolean, $exception): void { if ($boolean) { report($exception); @@ -738,9 +751,8 @@ if (! function_exists('report_unless')) { * * @param bool $boolean * @param \Throwable|string $exception - * @return void */ - function report_unless($boolean, $exception) + function report_unless($boolean, $exception): void { if (! $boolean) { report($exception); @@ -802,10 +814,9 @@ if (! function_exists('resolve')) { /** * Resolve a service from the container. * - * @template TClass + * @template TClass of object * * @param string|class-string $name - * @param array $parameters * @return ($name is class-string ? TClass : mixed) */ function resolve($name, array $parameters = []) @@ -819,9 +830,8 @@ if (! function_exists('resource_path')) { * Get the path to the resources folder. * * @param string $path - * @return string */ - function resource_path($path = '') + function resource_path($path = ''): string { return app()->resourcePath($path); } @@ -833,10 +843,9 @@ if (! function_exists('response')) { * * @param \Illuminate\Contracts\View\View|string|array|null $content * @param int $status - * @param array $headers * @return ($content is null ? \Illuminate\Contracts\Routing\ResponseFactory : \Illuminate\Http\Response) */ - function response($content = null, $status = 200, array $headers = []) + function response($content = null, $status = 200, array $headers = []): ResponseFactory|IlluminateResponse { $factory = app(ResponseFactory::class); @@ -855,9 +864,8 @@ if (! function_exists('route')) { * @param \BackedEnum|string $name * @param mixed $parameters * @param bool $absolute - * @return string */ - function route($name, $parameters = [], $absolute = true) + function route($name, $parameters = [], $absolute = true): string { return app('url')->route($name, $parameters, $absolute); } @@ -868,9 +876,8 @@ if (! function_exists('secure_asset')) { * Generate an asset path for the application. * * @param string $path - * @return string */ - function secure_asset($path) + function secure_asset($path): string { return asset($path, true); } @@ -919,14 +926,29 @@ if (! function_exists('storage_path')) { * Get the path to the storage folder. * * @param string $path - * @return string */ - function storage_path($path = '') + function storage_path($path = ''): string { return app()->storagePath($path); } } +if (! function_exists('to_action')) { + /** + * Create a new redirect response to a controller action. + * + * @param string|array $action + * @param mixed $parameters + * @param int $status + * @param array $headers + * @return \Illuminate\Http\RedirectResponse + */ + function to_action($action, $parameters = [], $status = 302, $headers = []) + { + return redirect()->action($action, $parameters, $status, $headers); + } +} + if (! function_exists('to_route')) { /** * Create a new redirect response to a named route. @@ -947,12 +969,12 @@ if (! function_exists('today')) { /** * Create a new Carbon instance for the current date. * - * @param \DateTimeZone|string|null $tz + * @param \DateTimeZone|\UnitEnum|string|null $tz * @return \Illuminate\Support\Carbon */ - function today($tz = null) + function today($tz = null): CarbonInterface { - return Date::today($tz); + return Date::today(enum_value($tz)); } } @@ -965,7 +987,7 @@ if (! function_exists('trans')) { * @param string|null $locale * @return ($key is null ? \Illuminate\Contracts\Translation\Translator : array|string) */ - function trans($key = null, $replace = [], $locale = null) + function trans($key = null, $replace = [], $locale = null): Translator|array|string { if (is_null($key)) { return app('translator'); @@ -981,11 +1003,9 @@ if (! function_exists('trans_choice')) { * * @param string $key * @param \Countable|int|float|array $number - * @param array $replace * @param string|null $locale - * @return string */ - function trans_choice($key, $number, array $replace = [], $locale = null) + function trans_choice($key, $number, array $replace = [], $locale = null): string { return app('translator')->choice($key, $number, $replace, $locale); } @@ -998,9 +1018,8 @@ if (! function_exists('__')) { * @param string|null $key * @param array $replace * @param string|null $locale - * @return string|array|null */ - function __($key = null, $replace = [], $locale = null) + function __($key = null, $replace = [], $locale = null): string|array|null { if (is_null($key)) { return $key; @@ -1010,16 +1029,30 @@ if (! function_exists('__')) { } } +if (! function_exists('uri')) { + /** + * Generate a URI for the application. + */ + function uri(UriInterface|Stringable|array|string $uri, mixed $parameters = [], bool $absolute = true): Uri + { + return match (true) { + is_array($uri) || str_contains($uri, '\\') => Uri::action($uri, $parameters, $absolute), + str_contains($uri, '.') && Route::has($uri) => Uri::route($uri, $parameters, $absolute), + default => Uri::of($uri), + }; + } +} + if (! function_exists('url')) { /** - * Generate a url for the application. + * Generate a URL for the application. * * @param string|null $path * @param mixed $parameters * @param bool|null $secure * @return ($path is null ? \Illuminate\Contracts\Routing\UrlGenerator : string) */ - function url($path = null, $parameters = [], $secure = null) + function url($path = null, $parameters = [], $secure = null): UrlGenerator|string { if (is_null($path)) { return app(UrlGenerator::class); @@ -1033,13 +1066,9 @@ if (! function_exists('validator')) { /** * Create a new Validator instance. * - * @param array|null $data - * @param array $rules - * @param array $messages - * @param array $attributes * @return ($data is null ? \Illuminate\Contracts\Validation\Factory : \Illuminate\Contracts\Validation\Validator) */ - function validator(?array $data = null, array $rules = [], array $messages = [], array $attributes = []) + function validator(?array $data = null, array $rules = [], array $messages = [], array $attributes = []): ValidatorContract|ValidationFactory { $factory = app(ValidationFactory::class); @@ -1060,7 +1089,7 @@ if (! function_exists('view')) { * @param array $mergeData * @return ($view is null ? \Illuminate\Contracts\View\Factory : \Illuminate\Contracts\View\View) */ - function view($view = null, $data = [], $mergeData = []) + function view($view = null, $data = [], $mergeData = []): ViewFactory|ViewContract { $factory = app(ViewFactory::class); diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/badge.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/badge.blade.php new file mode 100644 index 0000000..5fedfcf --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/badge.blade.php @@ -0,0 +1,47 @@ +@props(['type' => 'default', 'variant' => 'soft']) + +@php +$baseClasses = 'inline-flex w-fit shrink-0 items-center justify-center gap-1 font-mono leading-3 uppercase transition-colors dark:border [&_svg]:size-2.5 h-6 min-w-5 rounded-md px-1.5 text-xs/none'; + +$types = [ + 'default' => [ + 'soft' => 'bg-black/8 text-neutral-900 dark:border-neutral-700 dark:bg-white/10 dark:text-neutral-100', + 'solid' => 'bg-neutral-600 text-neutral-100 dark:border-neutral-500 dark:bg-neutral-600', + ], + 'success' => [ + 'soft' => 'bg-emerald-200 text-emerald-900 dark:border-emerald-600 dark:bg-emerald-900/70 dark:text-emerald-400', + 'solid' => 'bg-emerald-600 dark:border-emerald-500 dark:bg-emerald-600', + ], + 'primary' => [ + 'soft' => 'bg-blue-100 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-300', + 'solid' => 'bg-blue-700 dark:border-blue-600 dark:bg-blue-700', + ], + 'error' => [ + 'soft' => 'bg-rose-200 text-rose-900 dark:border-rose-900 dark:bg-rose-950 dark:text-rose-100 dark:[&_svg]:!text-white', + 'solid' => 'bg-rose-600 dark:border-rose-500 dark:bg-rose-600', + ], + 'alert' => [ + 'soft' => 'bg-amber-200 text-amber-900 dark:border-amber-800 dark:bg-amber-950 dark:text-amber-300', + 'solid' => 'bg-amber-600 dark:border-amber-500 dark:bg-amber-600', + ], + 'white' => [ + 'soft' => 'bg-white text-neutral-900 dark:border-neutral-700 dark:bg-neutral-800 dark:text-neutral-100', + 'solid' => 'bg-black/10 text-neutral-900 dark:text-neutral-900 dark:bg-white', + ], +]; + +$variants = [ + 'soft' => '', + 'solid' => 'text-white dark:text-white [&_svg]:!text-white', +]; + +$typeClasses = $types[$type][$variant] ?? $types['default']['soft']; +$variantClasses = $variants[$variant] ?? $variants['soft']; + +$classes = implode(' ', [$baseClasses, $typeClasses, $variantClasses]); + +@endphp + +
merge(['class' => $classes]) }}> + {{ $slot }} +
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/card.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/card.blade.php deleted file mode 100644 index 14dcd4f..0000000 --- a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/card.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -
merge(['class' => "@container flex flex-col p-6 sm:p-12 bg-white dark:bg-gray-900/80 text-gray-900 dark:text-gray-100 rounded-lg default:col-span-full default:lg:col-span-6 default:row-span-1 dark:ring-1 dark:ring-gray-800 shadow-xl"]) }} -> - {{ $slot }} -
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/context.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/context.blade.php deleted file mode 100644 index 26fae1a..0000000 --- a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/context.blade.php +++ /dev/null @@ -1,148 +0,0 @@ -@use('Illuminate\Support\Str') - -
- Request -
- -
- {{ $exception->request()->method() }} - {{ Str::start($exception->request()->path(), '/') }} -
- -
- Headers -
- -
- @forelse ($exception->requestHeaders() as $key => $value) -
- - {{ $key }} - - -
{{ $value }}
-
-
- @empty - -
No headers data
-
- @endforelse -
- -
- Body -
- -
-
- -
{!! $exception->requestBody() ?: 'No body data' !!}
-
-
-
- -
- - -
- Application -
- -
- Routing -
- -
- @forelse ($exception->applicationRouteContext() as $name => $value) -
- {{ $name }} - -
{{ $value }}
-
-
- @empty - -
No routing data
-
- @endforelse -
- - @if ($routeParametersContext = $exception->applicationRouteParametersContext()) -
- Routing Parameters -
- -
-
- -
{!! $routeParametersContext !!}
-
-
-
- @endif - -
- Database Queries - - @if (count($exception->applicationQueries()) === 100) - only the first 100 queries are displayed - @endif - -
- -
- @forelse ($exception->applicationQueries() as ['connectionName' => $connectionName, 'sql' => $sql, 'time' => $time]) -
-
- {{ $connectionName }} - -
- -
{{ $sql }}
-
-
- @empty - -
No query data
-
- @endforelse -
-
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/editor.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/editor.blade.php deleted file mode 100644 index 4171fb8..0000000 --- a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/editor.blade.php +++ /dev/null @@ -1,32 +0,0 @@ -@foreach ($exception->frames() as $frame) -
-
-
-
- - @if (config('app.editor')) - - {{ $frame->file() }} - - @else - {{ $frame->file() }} - @endif - - :{{ $frame->line() }} -
-
-
-
-
-
-
-@endforeach diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/empty-state.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/empty-state.blade.php new file mode 100644 index 0000000..9a41f78 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/empty-state.blade.php @@ -0,0 +1,5 @@ +@props(['message']) + +
+ // {{ $message }} +
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/file-with-line.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/file-with-line.blade.php new file mode 100644 index 0000000..99dd9f4 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/file-with-line.blade.php @@ -0,0 +1,21 @@ +@props(['frame', 'direction' => 'ltr']) + +@php + $file = $frame->file(); + $line = $frame->line(); +@endphp + +
merge(['class' => 'truncate font-mono text-xs text-neutral-500 dark:text-neutral-400']) }} + dir="{{ $direction }}" +> + + @if (config('app.editor')) + + {{ $file }}:{{ $line }} + + @else + {{ $file }}:{{ $line }} + @endif + +
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/formatted-source.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/formatted-source.blade.php new file mode 100644 index 0000000..3a5160e --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/formatted-source.blade.php @@ -0,0 +1,23 @@ +@props(['frame']) + +@php + $class = $frame->class(); + $operator = $frame->operator(); + $callable = $frame->callable(); + + if ($class && $operator) { + $source = $class.$operator.$callable.'('.implode(', ', $frame->args()).')'; + } elseif ($callable !== 'throw') { + $source = $callable.'('.implode(', ', $frame->args()).')'; + } else { + $source = $frame->source(); + } +@endphp + + diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame-code.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame-code.blade.php new file mode 100644 index 0000000..23b0220 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame-code.blade.php @@ -0,0 +1,15 @@ +@props(['code', 'highlightedLine']) + +
+ +
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame.blade.php new file mode 100644 index 0000000..a7b9de8 --- /dev/null +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/frame.blade.php @@ -0,0 +1,55 @@ +@props(['frame']) + +
+
+ {{-- Dot --}} +
+
+
+ +
+ + +
+ +
+ +
+
+ + @if($snippet = $frame->snippet()) + + @endif +
diff --git a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/header.blade.php b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/header.blade.php index 4da473e..ffb0c9a 100644 --- a/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/header.blade.php +++ b/vendor/laravel/framework/src/Illuminate/Foundation/resources/exceptions/renderer/components/header.blade.php @@ -1,28 +1,33 @@ - -
-
-
- - - {{ implode(' ', array_slice(explode('\\', $exception->class()), -1)) }} - -
-
- {{ $exception->message() }} -
-
+@props(['exception']) -