diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 3afd09d..1123891 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -41,7 +41,7 @@ jobs: php-version: '8.4' coverage: none - run: composer update --prefer-dist --no-interaction --no-progress - - run: vendor/bin/pint --test + - run: vendor/bin/laranail-pint --test rector: name: Rector diff --git a/config/pdf.php b/config/pdf.php index de5e935..17d9c20 100644 --- a/config/pdf.php +++ b/config/pdf.php @@ -43,7 +43,7 @@ ], 'dompdf' => [ - 'paper' => env('LARANAIL_PDF_DOMPDF_PAPER', 'a4'), + 'paper' => env('LARANAIL_PDF_DOMPDF_PAPER', 'a4'), 'orientation' => env('LARANAIL_PDF_DOMPDF_ORIENTATION', 'portrait'), /* @@ -61,7 +61,7 @@ */ 'options' => [ 'isRemoteEnabled' => env('LARANAIL_PDF_DOMPDF_REMOTE', false), - 'defaultFont' => 'DejaVu Sans', + 'defaultFont' => 'DejaVu Sans', ], ], diff --git a/rector.php b/rector.php index f330885..6fe5954 100644 --- a/rector.php +++ b/rector.php @@ -7,8 +7,8 @@ return RectorConfig::configure() ->withPaths([ - __DIR__.'/src', - __DIR__.'/tests', + __DIR__ . '/src', + __DIR__ . '/tests', ]) // Pinned to the php84 set, matching the ^8.4.1 floor this package inherits from // laranail/console. The pin is the point rather than the level: it stops anything @@ -21,6 +21,6 @@ typeDeclarations: true, ) ->withSkip([ - __DIR__.'/tests/Fixtures', + __DIR__ . '/tests/Fixtures', ]) ->withImportNames(removeUnusedImports: true); diff --git a/src/Commands/DoctorCommand.php b/src/Commands/DoctorCommand.php index 2266ef4..acc1636 100644 --- a/src/Commands/DoctorCommand.php +++ b/src/Commands/DoctorCommand.php @@ -4,15 +4,15 @@ namespace Simtabi\Laranail\Pdf\Commands; -use Simtabi\Laranail\Console\Tools\Commands\Command; -use Simtabi\Laranail\Console\Tools\Commands\Concerns\SupportsNamespacedNames; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Throwable; use Simtabi\Laranail\Pdf\DriverRegistry; -use Simtabi\Laranail\Pdf\Exceptions\PdfException; -use Simtabi\Laranail\Pdf\Support\DriverReport; -use Simtabi\Laranail\Pdf\Support\PdfConfig; use Simtabi\Laranail\Pdf\Support\UrlGuard; -use Throwable; +use Simtabi\Laranail\Pdf\Support\PdfConfig; +use Simtabi\Laranail\Pdf\Support\DriverReport; +use Simtabi\Laranail\Pdf\Exceptions\PdfException; +use Simtabi\Laranail\Console\Tools\Commands\Command; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Simtabi\Laranail\Console\Tools\Commands\Concerns\SupportsNamespacedNames; /** * Answers what is actually wrong, not what the config file looks like. @@ -52,7 +52,7 @@ public function handle(DriverRegistry $registry, UrlGuard $guard, PdfConfig $con } if ($reports === []) { - $this->error('No matching driver. Registered: '.implode(', ', $registry->names()).'.'); + $this->error('No matching driver. Registered: ' . implode(', ', $registry->names()) . '.'); return self::FAILURE; } @@ -124,7 +124,7 @@ private function probe(RendersHtml $driver, DriverReport $report): DriverReport private function inspectSecurity(UrlGuard $guard, PdfConfig $config): array { return [ - 'allowed_hosts' => $config->strings('security.allowed_hosts'), + 'allowed_hosts' => $config->strings('security.allowed_hosts'), 'block_private_addresses' => $config->bool('security.block_private_addresses', true), // Not a config read but an actual question put to the guard, so a // rule that stops covering this stops claiming to. @@ -133,15 +133,15 @@ private function inspectSecurity(UrlGuard $guard, PdfConfig $config): array } /** - * @param list $reports - * @param array $security + * @param list $reports + * @param array $security */ private function render(string $default, array $reports, array $security): void { $this->table( ['Driver', 'Available', 'Capabilities', 'Probe', 'Why not'], array_map(static fn (DriverReport $r): array => [ - $r->name.($r->name === $default ? ' (default)' : ''), + $r->name . ($r->name === $default ? ' (default)' : ''), $r->available ? 'yes' : 'no', $r->describeCapabilities(), $r->describeProbe(), @@ -155,20 +155,20 @@ private function render(string $default, array $reports, array $security): void /** @var list $hosts */ $hosts = $security['allowed_hosts']; - $this->line(' allowed hosts: '.($hosts === [] ? 'any' : implode(', ', $hosts))); - $this->line(' private blocked: '.($security['block_private_addresses'] === true ? 'yes' : 'NO')); + $this->line(' allowed hosts: ' . ($hosts === [] ? 'any' : implode(', ', $hosts))); + $this->line(' private blocked: ' . ($security['block_private_addresses'] === true ? 'yes' : 'NO')); if ($security['metadata_endpoint_refused'] !== true) { $this->warn( ' The cloud metadata endpoint (169.254.169.254) is reachable by the URL renderer. ' - .'If any caller can influence the URL, that is credential disclosure.', + . 'If any caller can influence the URL, that is credential disclosure.', ); } if ($hosts === []) { $this->line( ' Note: the private-address check is lexical, so a hostname resolving to an ' - .'internal address still passes it. Fill in allowed_hosts if callers can influence the URL.', + . 'internal address still passes it. Fill in allowed_hosts if callers can influence the URL.', ); } } diff --git a/src/Commands/InstallCommand.php b/src/Commands/InstallCommand.php index 3853d2e..9cbe290 100644 --- a/src/Commands/InstallCommand.php +++ b/src/Commands/InstallCommand.php @@ -4,9 +4,9 @@ namespace Simtabi\Laranail\Pdf\Commands; +use Simtabi\Laranail\Pdf\DriverRegistry; use Simtabi\Laranail\Console\Tools\Commands\Command; use Simtabi\Laranail\Console\Tools\Commands\Concerns\SupportsNamespacedNames; -use Simtabi\Laranail\Pdf\DriverRegistry; /** * Publishes the config and says what is still needed. @@ -29,7 +29,7 @@ final class InstallCommand extends Command public function handle(DriverRegistry $registry): int { $this->callSilently('vendor:publish', array_filter([ - '--tag' => 'pdf-config', + '--tag' => 'pdf-config', '--force' => (bool) $this->option('force'), ])); @@ -46,7 +46,7 @@ public function handle(DriverRegistry $registry): int } $missing[] = $name; - $this->line(" ✗ {$name} — ".$driver->unavailableReason()); + $this->line(" ✗ {$name} — " . $driver->unavailableReason()); } if ($missing === []) { diff --git a/src/Commands/RenderCommand.php b/src/Commands/RenderCommand.php index d3c341a..34c8d10 100644 --- a/src/Commands/RenderCommand.php +++ b/src/Commands/RenderCommand.php @@ -4,12 +4,12 @@ namespace Simtabi\Laranail\Pdf\Commands; -use Simtabi\Laranail\Console\Tools\Commands\Command; -use Simtabi\Laranail\Console\Tools\Commands\Concerns\SupportsNamespacedNames; -use Simtabi\Laranail\Pdf\Exceptions\PdfException; use Simtabi\Laranail\Pdf\PdfManager; +use Simtabi\Laranail\Pdf\Exceptions\PdfException; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; +use Simtabi\Laranail\Console\Tools\Commands\Command; use Simtabi\Laranail\Pdf\ValueObjects\RenderOptions; +use Simtabi\Laranail\Console\Tools\Commands\Concerns\SupportsNamespacedNames; /** * Render one thing to one file, from the shell. @@ -110,6 +110,6 @@ private function describeSize(string $path): string $bytes = filesize($path); - return $bytes === false ? 'unknown size' : number_format($bytes / 1024, 1).' KB'; + return $bytes === false ? 'unknown size' : number_format($bytes / 1024, 1) . ' KB'; } } diff --git a/src/Contracts/Capabilities/MergesPdfs.php b/src/Contracts/Capabilities/MergesPdfs.php index 0e810ca..ba22437 100644 --- a/src/Contracts/Capabilities/MergesPdfs.php +++ b/src/Contracts/Capabilities/MergesPdfs.php @@ -17,7 +17,7 @@ interface MergesPdfs extends PdfDriver { /** - * @param list $paths + * @param list $paths */ public function merge(array $paths, ?RenderOptions $options = null): PdfDocument; } diff --git a/src/DriverRegistry.php b/src/DriverRegistry.php index 558acc8..3767a5b 100644 --- a/src/DriverRegistry.php +++ b/src/DriverRegistry.php @@ -5,15 +5,15 @@ namespace Simtabi\Laranail\Pdf; use Closure; +use Simtabi\Laranail\Pdf\Enums\Capability; use Illuminate\Contracts\Container\Container; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; use Simtabi\Laranail\Pdf\Contracts\PdfDriver; -use Simtabi\Laranail\Pdf\Enums\Capability; use Simtabi\Laranail\Pdf\Exceptions\DriverNotFound; use Simtabi\Laranail\Pdf\Exceptions\UnsupportedCapability; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; /** * Resolves a driver by name, and refuses to hand back one that cannot do the @@ -51,7 +51,7 @@ public function __construct( /** * Register a driver factory under a name. * - * @param Closure(Container): PdfDriver $factory + * @param Closure(Container): PdfDriver $factory */ public function extend(string $name, Closure $factory): self { diff --git a/src/Drivers/DompdfDriver.php b/src/Drivers/DompdfDriver.php index d83ca49..70091a2 100644 --- a/src/Drivers/DompdfDriver.php +++ b/src/Drivers/DompdfDriver.php @@ -4,16 +4,16 @@ namespace Simtabi\Laranail\Pdf\Drivers; +use Throwable; use Dompdf\Dompdf; use Dompdf\Options; +use RuntimeException; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\StreamInterface; -use RuntimeException; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; use Simtabi\Laranail\Pdf\ValueObjects\RenderOptions; -use Throwable; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; /** * Dompdf — HTML only, in-process, no external service. @@ -58,7 +58,7 @@ final class DompdfDriver extends Driver implements RendersHtml ]; /** - * @param array $options passed to Dompdf\Options + * @param array $options passed to Dompdf\Options */ public function __construct( private readonly array $options = [], diff --git a/src/Drivers/Driver.php b/src/Drivers/Driver.php index 8e91716..7907f5a 100644 --- a/src/Drivers/Driver.php +++ b/src/Drivers/Driver.php @@ -4,8 +4,8 @@ namespace Simtabi\Laranail\Pdf\Drivers; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\Enums\Capability; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\Exceptions\DriverUnavailable; /** diff --git a/src/Drivers/GotenbergDriver.php b/src/Drivers/GotenbergDriver.php index e4fdd31..c30ccaa 100644 --- a/src/Drivers/GotenbergDriver.php +++ b/src/Drivers/GotenbergDriver.php @@ -5,22 +5,22 @@ namespace Simtabi\Laranail\Pdf\Drivers; use Closure; +use Throwable; +use Gotenberg\Stream; use Gotenberg\Gotenberg; use Gotenberg\Modules\ChromiumPdf; -use Gotenberg\Stream; use Psr\Http\Client\ClientInterface; -use Psr\Http\Message\RequestInterface; use Psr\Http\Message\StreamInterface; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; -use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; -use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; +use Psr\Http\Message\RequestInterface; use Simtabi\Laranail\Pdf\Support\UrlGuard; +use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; +use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; use Simtabi\Laranail\Pdf\ValueObjects\RenderOptions; -use Throwable; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; /** * Gotenberg — the driver that can do everything. @@ -126,7 +126,7 @@ function () use ($path, $options): RequestInterface { ['path' => $path], ), $options, - basename($path, '.'.pathinfo($path, PATHINFO_EXTENSION)).'.pdf', + basename($path, '.' . pathinfo($path, PATHINFO_EXTENSION)) . '.pdf', ); } @@ -169,8 +169,8 @@ function () use ($paths, $options): RequestInterface { /** * Build the request, send it, and return the response body. * - * @param Closure():RequestInterface $build - * @param array $context + * @param Closure():RequestInterface $build + * @param array $context */ private function send(Closure $build, string $operation, array $context = []): StreamInterface { @@ -240,7 +240,7 @@ private function applyPaperSize(ChromiumPdf $builder, RenderOptions $options): C } /** - * @param Closure():StreamInterface $resolver + * @param Closure():StreamInterface $resolver */ private function document(Closure $resolver, RenderOptions $options, ?string $fallback = null): PdfDocument { diff --git a/src/Drivers/PaperSize.php b/src/Drivers/PaperSize.php index bdc0aad..41dd47f 100644 --- a/src/Drivers/PaperSize.php +++ b/src/Drivers/PaperSize.php @@ -17,14 +17,14 @@ final class PaperSize { /** @var array */ private const array SIZES = [ - 'a3' => [11.7, 16.5], - 'a4' => [8.27, 11.7], - 'a5' => [5.83, 8.27], - 'a6' => [4.13, 5.83], - 'letter' => [8.5, 11.0], - 'legal' => [8.5, 14.0], + 'a3' => [11.7, 16.5], + 'a4' => [8.27, 11.7], + 'a5' => [5.83, 8.27], + 'a6' => [4.13, 5.83], + 'letter' => [8.5, 11.0], + 'legal' => [8.5, 14.0], 'tabloid' => [11.0, 17.0], - 'ledger' => [17.0, 11.0], + 'ledger' => [17.0, 11.0], ]; /** diff --git a/src/Enums/Capability.php b/src/Enums/Capability.php index a7743ab..8e0db58 100644 --- a/src/Enums/Capability.php +++ b/src/Enums/Capability.php @@ -4,11 +4,11 @@ namespace Simtabi\Laranail\Pdf\Enums; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; /** * The four things a PDF driver might be able to do. @@ -43,10 +43,10 @@ public static function of(PdfDriver $driver): array public function contract(): string { return match ($this) { - self::Html => RendersHtml::class, - self::Url => RendersUrl::class, + self::Html => RendersHtml::class, + self::Url => RendersUrl::class, self::Office => ConvertsDocuments::class, - self::Merge => MergesPdfs::class, + self::Merge => MergesPdfs::class, }; } @@ -58,10 +58,10 @@ public function isImplementedBy(PdfDriver $driver): bool public function label(): string { return match ($this) { - self::Html => 'HTML to PDF', - self::Url => 'URL to PDF', + self::Html => 'HTML to PDF', + self::Url => 'URL to PDF', self::Office => 'Office document to PDF', - self::Merge => 'Merge PDFs', + self::Merge => 'Merge PDFs', }; } } diff --git a/src/Exceptions/DriverNotFound.php b/src/Exceptions/DriverNotFound.php index 299d684..2608365 100644 --- a/src/Exceptions/DriverNotFound.php +++ b/src/Exceptions/DriverNotFound.php @@ -7,7 +7,7 @@ final class DriverNotFound extends PdfException { /** - * @param list $registered + * @param list $registered */ public static function named(string $name, array $registered): self { diff --git a/src/Exceptions/InvalidSource.php b/src/Exceptions/InvalidSource.php index 03c552a..39df50d 100644 --- a/src/Exceptions/InvalidSource.php +++ b/src/Exceptions/InvalidSource.php @@ -35,12 +35,12 @@ public static function malformedUrl(string $url): self } /** - * @param list $allowed + * @param list $allowed */ public static function disallowedScheme(string $url, string $scheme, array $allowed): self { $e = new self( - "The URL [{$url}] uses the [{$scheme}] scheme; only ".implode('/', $allowed).' is allowed.', + "The URL [{$url}] uses the [{$scheme}] scheme; only " . implode('/', $allowed) . ' is allowed.', 6008, ); $e->context = ['url' => $url, 'scheme' => $scheme, 'allowed' => $allowed]; @@ -52,7 +52,7 @@ public static function credentialsInUrl(string $url): self { $e = new self( 'A URL carrying a username or password will not be fetched: the credentials would be ' - .'sent by the renderer, logged by it, and are almost never what the caller intended.', + . 'sent by the renderer, logged by it, and are almost never what the caller intended.', 6009, ); $e->context = ['url' => $url]; @@ -61,12 +61,12 @@ public static function credentialsInUrl(string $url): self } /** - * @param list $allowed + * @param list $allowed */ public static function hostNotAllowed(string $host, array $allowed): self { $e = new self( - "The host [{$host}] is not in laranail.pdf.security.allowed_hosts (".implode(', ', $allowed).').', + "The host [{$host}] is not in laranail.pdf.security.allowed_hosts (" . implode(', ', $allowed) . ').', 6010, ); $e->context = ['host' => $host, 'allowed' => $allowed]; diff --git a/src/Exceptions/RenderFailed.php b/src/Exceptions/RenderFailed.php index 440aa95..2d903c4 100644 --- a/src/Exceptions/RenderFailed.php +++ b/src/Exceptions/RenderFailed.php @@ -16,7 +16,7 @@ final class RenderFailed extends PdfException { /** - * @param array $context + * @param array $context */ public static function from(string $driver, string $operation, Throwable $previous, array $context = []): self { diff --git a/src/Exceptions/UnsupportedCapability.php b/src/Exceptions/UnsupportedCapability.php index d850bca..aece512 100644 --- a/src/Exceptions/UnsupportedCapability.php +++ b/src/Exceptions/UnsupportedCapability.php @@ -16,7 +16,7 @@ final class UnsupportedCapability extends PdfException { /** - * @param list $alternatives + * @param list $alternatives */ public static function for(string $driver, Capability $capability, array $alternatives = []): self { @@ -24,12 +24,12 @@ public static function for(string $driver, Capability $capability, array $altern $message .= $alternatives === [] ? ' No installed driver does.' - : ' Drivers that do: '.implode(', ', $alternatives).'.'; + : ' Drivers that do: ' . implode(', ', $alternatives) . '.'; $e = new self($message, 6002); $e->context = [ - 'driver' => $driver, - 'capability' => $capability->value, + 'driver' => $driver, + 'capability' => $capability->value, 'alternatives' => $alternatives, ]; diff --git a/src/Facades/Pdf.php b/src/Facades/Pdf.php index b2c261e..6b77f9c 100644 --- a/src/Facades/Pdf.php +++ b/src/Facades/Pdf.php @@ -5,11 +5,11 @@ namespace Simtabi\Laranail\Pdf\Facades; use Closure; +use Simtabi\Laranail\Pdf\PdfManager; use Illuminate\Support\Facades\Facade; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\DriverRegistry; use Simtabi\Laranail\Pdf\Enums\Capability; -use Simtabi\Laranail\Pdf\PdfManager; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; use Simtabi\Laranail\Pdf\ValueObjects\RenderOptions; diff --git a/src/PdfManager.php b/src/PdfManager.php index c531384..40f89d4 100644 --- a/src/PdfManager.php +++ b/src/PdfManager.php @@ -5,9 +5,9 @@ namespace Simtabi\Laranail\Pdf; use Closure; +use Simtabi\Laranail\Pdf\Enums\Capability; use Illuminate\Contracts\Container\Container; use Simtabi\Laranail\Pdf\Contracts\PdfDriver; -use Simtabi\Laranail\Pdf\Enums\Capability; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; use Simtabi\Laranail\Pdf\ValueObjects\RenderOptions; @@ -25,7 +25,7 @@ public function __construct(private DriverRegistry $registry) {} /** - * @param array|RenderOptions|null $options + * @param array|RenderOptions|null $options */ public function html(string $html, array|RenderOptions|null $options = null, ?string $driver = null): PdfDocument { @@ -33,7 +33,7 @@ public function html(string $html, array|RenderOptions|null $options = null, ?st } /** - * @param array|RenderOptions|null $options + * @param array|RenderOptions|null $options */ public function url(string $url, array|RenderOptions|null $options = null, ?string $driver = null): PdfDocument { @@ -41,7 +41,7 @@ public function url(string $url, array|RenderOptions|null $options = null, ?stri } /** - * @param array|RenderOptions|null $options + * @param array|RenderOptions|null $options */ public function convert(string $path, array|RenderOptions|null $options = null, ?string $driver = null): PdfDocument { @@ -49,8 +49,8 @@ public function convert(string $path, array|RenderOptions|null $options = null, } /** - * @param list $paths - * @param array|RenderOptions|null $options + * @param list $paths + * @param array|RenderOptions|null $options */ public function merge(array $paths, array|RenderOptions|null $options = null, ?string $driver = null): PdfDocument { @@ -64,9 +64,9 @@ public function merge(array $paths, array|RenderOptions|null $options = null, ?s * alternative is `Pdf::html(view('invoice', $data)->render())` at every call * site. * - * @param view-string $view - * @param array $data - * @param array|RenderOptions|null $options + * @param view-string $view + * @param array $data + * @param array|RenderOptions|null $options */ public function view(string $view, array $data = [], array|RenderOptions|null $options = null, ?string $driver = null): PdfDocument { @@ -84,7 +84,7 @@ public function registry(): DriverRegistry } /** - * @param Closure(Container): PdfDriver $factory + * @param Closure(Container): PdfDriver $factory */ public function extend(string $name, Closure $factory): self { @@ -107,7 +107,7 @@ public function drivers(): array } /** - * @param array|RenderOptions|null $options + * @param array|RenderOptions|null $options */ private function options(array|RenderOptions|null $options): ?RenderOptions { diff --git a/src/Providers/PdfServiceProvider.php b/src/Providers/PdfServiceProvider.php index d5ceb25..e4e5138 100644 --- a/src/Providers/PdfServiceProvider.php +++ b/src/Providers/PdfServiceProvider.php @@ -4,24 +4,24 @@ namespace Simtabi\Laranail\Pdf\Providers; -use GuzzleHttp\Client as GuzzleClient; -use Illuminate\Contracts\Config\Repository as ConfigRepository; -use Illuminate\Contracts\Container\Container; -use Illuminate\Contracts\Foundation\Application; use Override; use Psr\Http\Client\ClientInterface; +use Simtabi\Laranail\Pdf\PdfManager; +use GuzzleHttp\Client as GuzzleClient; +use Simtabi\Laranail\Pdf\DriverRegistry; +use Simtabi\Laranail\Pdf\Support\UrlGuard; use Simtabi\Laranail\Package\Tools\Package; -use Simtabi\Laranail\Package\Tools\Providers\PackageServiceProvider; -use Simtabi\Laranail\Pdf\Commands\DoctorCommand; -use Simtabi\Laranail\Pdf\Commands\InstallCommand; -use Simtabi\Laranail\Pdf\Commands\RenderCommand; +use Simtabi\Laranail\Pdf\Support\PdfConfig; +use Illuminate\Contracts\Container\Container; use Simtabi\Laranail\Pdf\Contracts\PdfDriver; -use Simtabi\Laranail\Pdf\DriverRegistry; use Simtabi\Laranail\Pdf\Drivers\DompdfDriver; +use Illuminate\Contracts\Foundation\Application; +use Simtabi\Laranail\Pdf\Commands\DoctorCommand; +use Simtabi\Laranail\Pdf\Commands\RenderCommand; +use Simtabi\Laranail\Pdf\Commands\InstallCommand; use Simtabi\Laranail\Pdf\Drivers\GotenbergDriver; -use Simtabi\Laranail\Pdf\PdfManager; -use Simtabi\Laranail\Pdf\Support\PdfConfig; -use Simtabi\Laranail\Pdf\Support\UrlGuard; +use Illuminate\Contracts\Config\Repository as ConfigRepository; +use Simtabi\Laranail\Package\Tools\Providers\PackageServiceProvider; final class PdfServiceProvider extends PackageServiceProvider { @@ -137,7 +137,7 @@ private function psrClient(Container $container, PdfConfig $config): ?ClientInte return new GuzzleClient([ 'timeout' => $config->float('drivers.gotenberg.timeout', 60.0), - 'verify' => $this->verifyOption($config), + 'verify' => $this->verifyOption($config), ]); } diff --git a/src/Support/DriverReport.php b/src/Support/DriverReport.php index b01e4e7..db676f7 100644 --- a/src/Support/DriverReport.php +++ b/src/Support/DriverReport.php @@ -4,8 +4,8 @@ namespace Simtabi\Laranail\Pdf\Support; -use Illuminate\Contracts\Support\Arrayable; use Simtabi\Laranail\Pdf\Enums\Capability; +use Illuminate\Contracts\Support\Arrayable; /** * What the doctor command found out about one driver. @@ -20,7 +20,7 @@ final readonly class DriverReport implements Arrayable { /** - * @param list $capabilities + * @param list $capabilities */ public function __construct( public string $name, @@ -75,9 +75,9 @@ public function describeCapabilities(): string public function describeProbe(): string { return match ($this->probeOk) { - null => '—', + null => '—', false => 'FAILED', - true => sprintf('ok (%d bytes, %dms)', $this->probeBytes, $this->probeMs), + true => sprintf('ok (%d bytes, %dms)', $this->probeBytes, $this->probeMs), }; } @@ -85,16 +85,16 @@ public function describeProbe(): string public function toArray(): array { $report = [ - 'available' => $this->available, - 'reason' => $this->reason, + 'available' => $this->available, + 'reason' => $this->reason, 'capabilities' => $this->capabilityValues(), ]; if ($this->wasProbed()) { $report['probe'] = array_filter([ - 'ok' => $this->probeOk, + 'ok' => $this->probeOk, 'bytes' => $this->probeBytes, - 'ms' => $this->probeMs, + 'ms' => $this->probeMs, 'error' => $this->probeError, ], static fn (mixed $value): bool => $value !== null); } diff --git a/src/Support/PdfConfig.php b/src/Support/PdfConfig.php index 4e0c0c4..1d1c7ac 100644 --- a/src/Support/PdfConfig.php +++ b/src/Support/PdfConfig.php @@ -92,6 +92,6 @@ public function existingPath(string $key): ?string private function get(string $key): mixed { - return $this->config->get('laranail.pdf.'.$key); + return $this->config->get('laranail.pdf.' . $key); } } diff --git a/src/Support/UrlGuard.php b/src/Support/UrlGuard.php index c167a47..b5e5a00 100644 --- a/src/Support/UrlGuard.php +++ b/src/Support/UrlGuard.php @@ -43,8 +43,8 @@ final readonly class UrlGuard { /** - * @param list $allowedSchemes - * @param list $allowedHosts empty means "any host", subject to the checks below + * @param list $allowedSchemes + * @param list $allowedHosts empty means "any host", subject to the checks below */ public function __construct( private array $allowedSchemes = ['http', 'https'], @@ -53,7 +53,7 @@ public function __construct( ) {} /** - * @param array $config the `laranail.pdf.security` block + * @param array $config the `laranail.pdf.security` block */ public static function fromConfig(array $config): self { diff --git a/src/ValueObjects/PdfDocument.php b/src/ValueObjects/PdfDocument.php index a0de647..8feee09 100644 --- a/src/ValueObjects/PdfDocument.php +++ b/src/ValueObjects/PdfDocument.php @@ -5,12 +5,12 @@ namespace Simtabi\Laranail\Pdf\ValueObjects; use Closure; -use Illuminate\Contracts\Support\Responsable; -use Illuminate\Support\Facades\Storage; -use Psr\Http\Message\StreamInterface; use RuntimeException; -use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; +use Psr\Http\Message\StreamInterface; +use Illuminate\Support\Facades\Storage; +use Illuminate\Contracts\Support\Responsable; use Symfony\Component\HttpFoundation\Response; +use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; use Symfony\Component\HttpFoundation\StreamedResponse; /** @@ -46,8 +46,8 @@ final class PdfDocument implements Responsable private ?StreamInterface $stream = null; /** - * @param Closure(): StreamInterface $resolver - * @param array $meta + * @param Closure(): StreamInterface $resolver + * @param array $meta */ public function __construct( private readonly Closure $resolver, @@ -105,7 +105,7 @@ public function size(): ?int * `store()` silently writing zero bytes. Call `contents()` once and write * that if you need the same bytes in several places. * - * @param array|string $options + * @param array|string $options */ public function store(string $path, ?string $disk = null, array|string $options = []): string { @@ -215,9 +215,9 @@ private function response(string $disposition, ?string $filename): StreamedRespo $stream = $this->stream(); $headers = [ - 'Content-Type' => 'application/pdf', + 'Content-Type' => 'application/pdf', 'Content-Disposition' => sprintf('%s; filename="%s"', $disposition, addslashes($name)), - 'X-Pdf-Driver' => $this->driver, + 'X-Pdf-Driver' => $this->driver, ]; if (($size = $stream->getSize()) !== null) { diff --git a/src/ValueObjects/RenderOptions.php b/src/ValueObjects/RenderOptions.php index 2f7cfbc..afb4f17 100644 --- a/src/ValueObjects/RenderOptions.php +++ b/src/ValueObjects/RenderOptions.php @@ -17,7 +17,7 @@ final readonly class RenderOptions { /** - * @param array $extra driver-specific settings, passed through untouched + * @param array $extra driver-specific settings, passed through untouched */ public function __construct( public ?string $filename = null, @@ -34,7 +34,7 @@ public function __construct( ) {} /** - * @param array $options + * @param array $options */ public static function fromArray(array $options): self { @@ -77,7 +77,7 @@ public function filenameOr(string $fallback): string } /** - * @param array $options + * @param array $options */ private static function string(array $options, string $key): ?string { @@ -87,7 +87,7 @@ private static function string(array $options, string $key): ?string } /** - * @param array $options + * @param array $options */ private static function float(array $options, string $key): ?float { diff --git a/tests/Arch/LayeringTest.php b/tests/Arch/LayeringTest.php index da2dfee..86a5fff 100644 --- a/tests/Arch/LayeringTest.php +++ b/tests/Arch/LayeringTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -use Illuminate\Support\Facades\Cache; -use Illuminate\Support\Facades\Config; +use PHPUnit\Framework\Assert; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Http; -use Illuminate\Support\Facades\Log; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Storage; -use PHPUnit\Framework\Assert; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; /** diff --git a/tests/Feature/AbsentDependenciesTest.php b/tests/Feature/AbsentDependenciesTest.php index 0cee17f..ae20a3d 100644 --- a/tests/Feature/AbsentDependenciesTest.php +++ b/tests/Feature/AbsentDependenciesTest.php @@ -5,11 +5,11 @@ namespace Simtabi\Laranail\Pdf\Tests\Feature; use PHPUnit\Framework\Attributes\Test; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\DriverRegistry; +use Simtabi\Laranail\Pdf\Tests\TestCase; use Simtabi\Laranail\Pdf\Enums\Capability; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\Exceptions\DriverUnavailable; -use Simtabi\Laranail\Pdf\Tests\TestCase; /** * What happens when the rendering engines are not installed. diff --git a/tests/Feature/CommandsTest.php b/tests/Feature/CommandsTest.php index 827e4fd..df17c45 100644 --- a/tests/Feature/CommandsTest.php +++ b/tests/Feature/CommandsTest.php @@ -4,13 +4,13 @@ namespace Simtabi\Laranail\Pdf\Tests\Feature; +use Simtabi\Laranail\Pdf\PdfManager; +use Simtabi\Laranail\Pdf\Facades\Pdf; use PHPUnit\Framework\Attributes\Test; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; use Simtabi\Laranail\Pdf\DriverRegistry; -use Simtabi\Laranail\Pdf\Facades\Pdf; -use Simtabi\Laranail\Pdf\PdfManager; -use Simtabi\Laranail\Pdf\Support\UrlGuard; use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Support\UrlGuard; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; final class CommandsTest extends TestCase { @@ -124,14 +124,14 @@ public function render_writes_a_pdf_from_stdin_html(): void self::markTestSkipped('dompdf/dompdf is not installed.'); } - $output = sys_get_temp_dir().'/laranail-render-'.bin2hex(random_bytes(6)).'.pdf'; - $input = sys_get_temp_dir().'/laranail-render-'.bin2hex(random_bytes(6)).'.html'; + $output = sys_get_temp_dir() . '/laranail-render-' . bin2hex(random_bytes(6)) . '.pdf'; + $input = sys_get_temp_dir() . '/laranail-render-' . bin2hex(random_bytes(6)) . '.html'; file_put_contents($input, '

Report

'); try { $this->artisan('laranail::pdf.render', [ - 'source' => $input, - 'output' => $output, + 'source' => $input, + 'output' => $output, '--driver' => 'dompdf', ])->assertExitCode(0); @@ -147,17 +147,17 @@ public function render_writes_a_pdf_from_stdin_html(): void public function render_refuses_a_capability_the_driver_lacks(): void { $this->artisan('laranail::pdf.render', [ - 'source' => '/tmp/a.pdf', - 'output' => '/tmp/out.pdf', + 'source' => '/tmp/a.pdf', + 'output' => '/tmp/out.pdf', '--driver' => 'dompdf', - '--merge' => ['/tmp/b.pdf'], + '--merge' => ['/tmp/b.pdf'], ])->assertExitCode(1); } #[Test] public function render_refuses_a_url_the_guard_blocks(): void { - $output = sys_get_temp_dir().'/laranail-render-'.bin2hex(random_bytes(6)).'.pdf'; + $output = sys_get_temp_dir() . '/laranail-render-' . bin2hex(random_bytes(6)) . '.pdf'; $this->artisan('laranail::pdf.render', [ 'source' => 'http://169.254.169.254/latest/meta-data/', diff --git a/tests/Feature/GotenbergIntegrationTest.php b/tests/Feature/GotenbergIntegrationTest.php index 1d24b47..927b273 100644 --- a/tests/Feature/GotenbergIntegrationTest.php +++ b/tests/Feature/GotenbergIntegrationTest.php @@ -4,13 +4,13 @@ namespace Simtabi\Laranail\Pdf\Tests\Feature; +use Simtabi\Laranail\Pdf\Facades\Pdf; +use PHPUnit\Framework\Attributes\Test; use Illuminate\Support\Facades\Storage; use PHPUnit\Framework\Attributes\Group; -use PHPUnit\Framework\Attributes\Test; use Simtabi\Laranail\Pdf\DriverRegistry; -use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; -use Simtabi\Laranail\Pdf\Facades\Pdf; use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; /** * Against a real Gotenberg container. @@ -57,10 +57,10 @@ public function it_honours_paper_size_and_orientation(): void // rather than being silently rejected, which is the failure that // actually happens. $bytes = Pdf::html('

Wide

', [ - 'paperSize' => 'a3', - 'orientation' => 'landscape', + 'paperSize' => 'a3', + 'orientation' => 'landscape', 'printBackground' => true, - 'marginTop' => 0.5, + 'marginTop' => 0.5, ])->contents(); self::assertStringStartsWith('%PDF', $bytes); @@ -131,7 +131,7 @@ public function doctor_probes_successfully_against_the_real_service(): void private function fixture(string $contents, string $extension): string { - $path = sys_get_temp_dir().'/laranail-gotenberg-'.bin2hex(random_bytes(6)).'.'.$extension; + $path = sys_get_temp_dir() . '/laranail-gotenberg-' . bin2hex(random_bytes(6)) . '.' . $extension; file_put_contents($path, $contents); return $path; diff --git a/tests/TestCase.php b/tests/TestCase.php index 4884a5e..2d7df8c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -5,9 +5,9 @@ namespace Simtabi\Laranail\Pdf\Tests; use Override; -use Simtabi\Laranail\Package\Tools\Testing\IsolatedTestCase; use Simtabi\Laranail\Pdf\Facades\Pdf; use Simtabi\Laranail\Pdf\Providers\PdfServiceProvider; +use Simtabi\Laranail\Package\Tools\Testing\IsolatedTestCase; abstract class TestCase extends IsolatedTestCase { diff --git a/tests/Unit/DriverContractTest.php b/tests/Unit/DriverContractTest.php index 8d69949..793fa25 100644 --- a/tests/Unit/DriverContractTest.php +++ b/tests/Unit/DriverContractTest.php @@ -4,21 +4,21 @@ namespace Simtabi\Laranail\Pdf\Tests\Unit; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Test; use ReflectionClass; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; -use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; -use Simtabi\Laranail\Pdf\Contracts\PdfDriver; +use PHPUnit\Framework\Attributes\Test; use Simtabi\Laranail\Pdf\DriverRegistry; -use Simtabi\Laranail\Pdf\Drivers\DompdfDriver; use Simtabi\Laranail\Pdf\Drivers\Driver; -use Simtabi\Laranail\Pdf\Drivers\GotenbergDriver; +use Simtabi\Laranail\Pdf\Tests\TestCase; use Simtabi\Laranail\Pdf\Enums\Capability; +use Simtabi\Laranail\Pdf\Contracts\PdfDriver; +use PHPUnit\Framework\Attributes\DataProvider; +use Simtabi\Laranail\Pdf\Drivers\DompdfDriver; +use Simtabi\Laranail\Pdf\Drivers\GotenbergDriver; use Simtabi\Laranail\Pdf\Exceptions\UnsupportedCapability; -use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\MergesPdfs; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersUrl; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\RendersHtml; +use Simtabi\Laranail\Pdf\Contracts\Capabilities\ConvertsDocuments; /** * The claim this package makes about itself: a driver cannot say it can do @@ -43,7 +43,7 @@ public static function drivers(): array } /** - * @param list $expected + * @param list $expected */ #[Test] #[DataProvider('drivers')] @@ -53,7 +53,7 @@ public function a_driver_declares_exactly_what_it_implements(PdfDriver $driver, } /** - * @param list $expected + * @param list $expected */ #[Test] #[DataProvider('drivers')] diff --git a/tests/Unit/ExceptionContainmentTest.php b/tests/Unit/ExceptionContainmentTest.php index 6d20d8c..840b373 100644 --- a/tests/Unit/ExceptionContainmentTest.php +++ b/tests/Unit/ExceptionContainmentTest.php @@ -4,21 +4,21 @@ namespace Simtabi\Laranail\Pdf\Tests\Unit; +use Throwable; +use RuntimeException; use Gotenberg\Gotenberg; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Client\ClientInterface; +use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use RuntimeException; +use Simtabi\Laranail\Pdf\Tests\TestCase; use Simtabi\Laranail\Pdf\Drivers\DompdfDriver; use Simtabi\Laranail\Pdf\Drivers\GotenbergDriver; -use Simtabi\Laranail\Pdf\Exceptions\DriverUnavailable; -use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; use Simtabi\Laranail\Pdf\Exceptions\PdfException; use Simtabi\Laranail\Pdf\Exceptions\RenderFailed; -use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; -use Throwable; +use Simtabi\Laranail\Pdf\Exceptions\DriverUnavailable; /** * The promise that makes the optional dependencies genuinely optional. @@ -82,10 +82,10 @@ public function every_capability_contains_its_failures(): void try { foreach ([ - 'html' => fn (): PdfDocument => $driver->html('

x

'), - 'url' => fn (): PdfDocument => $driver->url('https://example.com'), + 'html' => fn (): PdfDocument => $driver->html('

x

'), + 'url' => fn (): PdfDocument => $driver->url('https://example.com'), 'office' => fn (): PdfDocument => $driver->convert($file), - 'merge' => fn (): PdfDocument => $driver->merge([$file]), + 'merge' => fn (): PdfDocument => $driver->merge([$file]), ] as $operation => $call) { try { $call()->contents(); @@ -168,10 +168,10 @@ public function merging_nothing_is_refused(): void #[Test] public function every_exception_class_extends_the_package_base(): void { - $directory = __DIR__.'/../../src/Exceptions'; + $directory = __DIR__ . '/../../src/Exceptions'; - foreach (glob($directory.'/*.php') ?: [] as $file) { - $class = 'Simtabi\\Laranail\\Pdf\\Exceptions\\'.basename($file, '.php'); + foreach (glob($directory . '/*.php') ?: [] as $file) { + $class = 'Simtabi\\Laranail\\Pdf\\Exceptions\\' . basename($file, '.php'); if ($class === PdfException::class) { continue; diff --git a/tests/Unit/PdfDocumentTest.php b/tests/Unit/PdfDocumentTest.php index 65f52a5..f772a07 100644 --- a/tests/Unit/PdfDocumentTest.php +++ b/tests/Unit/PdfDocumentTest.php @@ -5,11 +5,11 @@ namespace Simtabi\Laranail\Pdf\Tests\Unit; use GuzzleHttp\Psr7\Utils; -use Illuminate\Support\Facades\Storage; -use PHPUnit\Framework\Attributes\Test; use Psr\Http\Message\StreamInterface; -use Simtabi\Laranail\Pdf\Exceptions\PdfException; +use PHPUnit\Framework\Attributes\Test; +use Illuminate\Support\Facades\Storage; use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Exceptions\PdfException; use Simtabi\Laranail\Pdf\ValueObjects\PdfDocument; use Symfony\Component\HttpFoundation\StreamedResponse; @@ -145,7 +145,7 @@ public function a_failed_save_leaves_no_file_behind(): void #[Test] public function it_saves_to_a_local_path(): void { - $target = sys_get_temp_dir().'/laranail-pdf-'.bin2hex(random_bytes(6)).'.pdf'; + $target = sys_get_temp_dir() . '/laranail-pdf-' . bin2hex(random_bytes(6)) . '.pdf'; try { $this->document('%PDF-1.4 local')->saveTo($target); diff --git a/tests/Unit/UrlGuardTest.php b/tests/Unit/UrlGuardTest.php index 31e6d0a..d715b89 100644 --- a/tests/Unit/UrlGuardTest.php +++ b/tests/Unit/UrlGuardTest.php @@ -4,11 +4,11 @@ namespace Simtabi\Laranail\Pdf\Tests\Unit; -use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\Attributes\Test; -use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; -use Simtabi\Laranail\Pdf\Support\UrlGuard; use Simtabi\Laranail\Pdf\Tests\TestCase; +use Simtabi\Laranail\Pdf\Support\UrlGuard; +use PHPUnit\Framework\Attributes\DataProvider; +use Simtabi\Laranail\Pdf\Exceptions\InvalidSource; /** * "Render this URL" asks a machine inside the network to fetch a URL a caller @@ -29,15 +29,15 @@ protected function setUp(): void public static function privateAddresses(): array { return [ - 'loopback v4' => ['http://127.0.0.1/'], - 'loopback name' => ['http://localhost:8080/'], - 'loopback v6' => ['http://[::1]/'], - 'rfc1918 10/8' => ['http://10.0.0.5/'], - 'rfc1918 172.16/12' => ['http://172.16.4.1/'], + 'loopback v4' => ['http://127.0.0.1/'], + 'loopback name' => ['http://localhost:8080/'], + 'loopback v6' => ['http://[::1]/'], + 'rfc1918 10/8' => ['http://10.0.0.5/'], + 'rfc1918 172.16/12' => ['http://172.16.4.1/'], 'rfc1918 192.168/16' => ['http://192.168.1.1/'], - 'link-local' => ['http://169.254.1.1/'], - 'cgnat' => ['http://100.64.0.1/'], - 'zero' => ['http://0.0.0.0/'], + 'link-local' => ['http://169.254.1.1/'], + 'cgnat' => ['http://100.64.0.1/'], + 'zero' => ['http://0.0.0.0/'], ]; } @@ -49,10 +49,10 @@ public static function privateAddresses(): array public static function badSchemes(): array { return [ - 'file reads local disk' => ['file:///etc/passwd'], + 'file reads local disk' => ['file:///etc/passwd'], 'gopher speaks to any port' => ['gopher://example.com:11211/'], - 'ftp' => ['ftp://example.com/x.pdf'], - 'data' => ['data:text/html,

hi

'], + 'ftp' => ['ftp://example.com/x.pdf'], + 'data' => ['data:text/html,

hi

'], ]; } @@ -229,8 +229,8 @@ public function a_hostname_resolving_privately_is_not_caught(): void public function config_drives_the_guard(): void { $guard = UrlGuard::fromConfig([ - 'allowed_schemes' => ['https'], - 'allowed_hosts' => ['example.com'], + 'allowed_schemes' => ['https'], + 'allowed_hosts' => ['example.com'], 'block_private_addresses' => true, ]);