/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
src/Illuminate/Queue/Middleware/FailOnException.php
65 строк
2 KB
Lucas Michot
[13.x] Remove deprecated `StaticCallOnNonStaticToInstanceCallRector` fixer rule (#60670)
06 июл 2026, 18:30
Не верифицирован
06 июл 2026, 18:30
fad91f6
Код
Авторство
О чём код?
<?php namespace Illuminate\Queue\Middleware; use Closure; use Throwable; class FailOnException { /** * The truth-test callback to determine if the job should fail. * * @var \Closure(\Throwable, mixed): bool */ protected Closure $callback; /** * Create a middleware instance. * * @param (\Closure(\Throwable, mixed): bool)|array<array-key, class-string<\Throwable>> $callback */ public function __construct($callback) { if (is_array($callback)) { $callback = $this->failForExceptions($callback); } $this->callback = $callback; } /** * Indicate that the job should fail if it encounters the given exceptions. * * @param array<array-key, class-string<\Throwable>> $exceptions * @return \Closure(\Throwable, mixed): bool */ protected function failForExceptions(array $exceptions) { return static function (Throwable $throwable) use ($exceptions) { return array_any($exceptions, fn ($exception) => $throwable instanceof $exception); }; } /** * Mark the job as failed if an exception is thrown that passes a truth-test callback. * * @param mixed $job * @param callable $next * @return mixed * * @throws \Throwable */ public function handle($job, callable $next) { try { return $next($job); } catch (Throwable $e) { if (call_user_func($this->callback, $e, $job) === true) { $job->fail($e); } throw $e; } } }