From 8e9a9cbda3fce38679a1dfb2bbc1430345135200 Mon Sep 17 00:00:00 2001 From: erikn69 Date: Thu, 29 Feb 2024 08:53:48 -0500 Subject: [PATCH] Fix facade::$app could be nullable --- src/Facade/Pdf.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Facade/Pdf.php b/src/Facade/Pdf.php index c32ff02..c03802d 100644 --- a/src/Facade/Pdf.php +++ b/src/Facade/Pdf.php @@ -4,6 +4,7 @@ use Barryvdh\DomPDF\PDF as BasePDF; use Illuminate\Support\Facades\Facade as IlluminateFacade; +use RuntimeException; /** * @method static BasePDF setBaseHost(string $baseHost) @@ -43,14 +44,23 @@ protected static function getFacadeAccessor() } /** - * Resolve a new instance + * Handle dynamic, static calls to the object. + * * @param string $method * @param array $args * @return mixed + * + * @throws \RuntimeException */ public static function __callStatic($method, $args) { - $instance = static::$app->make(static::getFacadeAccessor()); + /** @var \Illuminate\Contracts\Foundation\Application|null */ + $app = static::getFacadeApplication(); + if (! $app) { + throw new RuntimeException('Facade application has not been set.'); + } + + $instance = $app->make(static::getFacadeAccessor()); return $instance->$method(...$args); }