Skip to content

Commit

Permalink
Laravel 11 Support (#1036)
Browse files Browse the repository at this point in the history
* Laravel 11 Support

* Fix facade::$app could be nullable
  • Loading branch information
erikn69 authored Mar 1, 2024
1 parent 81227b1 commit 2f1fe26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ jobs:
laravel: [8.*, 7.*, 6.*]
dependency-version: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
php: 8.3
dependency-version: prefer-stable
- laravel: 11.*
php: 8.2
dependency-version: prefer-stable
- laravel: 10.*
php: 8.2
dependency-version: prefer-stable
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"require": {
"php": "^7.2 || ^8.0",
"dompdf/dompdf": "^2.0.3",
"illuminate/support": "^6|^7|^8|^9|^10"
"illuminate/support": "^6|^7|^8|^9|^10|^11"
},
"require-dev": {
"orchestra/testbench": "^4|^5|^6|^7|^8",
"orchestra/testbench": "^4|^5|^6|^7|^8|^9",
"squizlabs/php_codesniffer": "^3.5",
"phpro/grumphp": "^1",
"larastan/larastan": "^1.0|^2.7.0"
Expand Down
15 changes: 13 additions & 2 deletions src/Facade/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -43,14 +44,24 @@ protected static function getFacadeAccessor()
}

/**
* Resolve a new instance
* Handle dynamic, static calls to the object.
*
* @param string $method
* @param array<mixed> $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.');
}

// Resolve a new instance, avoid using a cached instance
$instance = $app->make(static::getFacadeAccessor());

return $instance->$method(...$args);
}
Expand Down

0 comments on commit 2f1fe26

Please sign in to comment.