From 3b9c50fbf43e1883dac682ed4497d405250f9a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marti=CC=81n=20Go=CC=81mez?= Date: Wed, 27 May 2026 18:06:15 +0200 Subject: [PATCH] Add Laravel 13 support and migrate to PHPStan 2 Add illuminate/macroable ^13 and PHPUnit ^12 to supported ranges, and extend the CI matrix accordingly (PHP 8.2 excluded from PHPUnit 12). Migrate to PHPStan 2.0, fixing two stricter findings in Robots and HTMLParser and removing a now-unnecessary inline ignore. Changelog: added --- .github/workflows/run-tests.yml | 6 +++++- README.md | 6 +++--- composer.json | 6 +++--- src/Parser/HTMLParser.php | 5 ++++- src/Tags/Robots.php | 4 ++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9f9f3a4..806fba1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -14,8 +14,12 @@ jobs: matrix: os: [ubuntu-latest] php: [8.2, 8.3, 8.4] - phpunit: [10.*, 11.*] + phpunit: [10.*, 11.*, 12.*] stability: [prefer-lowest, prefer-stable] + exclude: + # PHPUnit 12 requires PHP 8.3+ + - php: 8.2 + phpunit: 12.* name: P${{ matrix.php }} - PHPUnit ${{ matrix.phpunit }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/README.md b/README.md index 69a6bc4..421055f 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ Test meta tags, titles, canonical URLs, Open Graph, Twitter Cards, robots direct ## Requirements -- PHP 8.2+ -- Laravel 11 or 12 -- PHPUnit 10 or 11 +- PHP 8.2+ (8.3+ required when used with Laravel 13) +- Laravel 11, 12, or 13 +- PHPUnit 10, 11, or 12 ## Table of Contents diff --git a/composer.json b/composer.json index f61d5a5..a296dce 100644 --- a/composer.json +++ b/composer.json @@ -26,14 +26,14 @@ ], "require": { "php": "^8.2", - "illuminate/macroable": "^11.0|^12.0", - "phpunit/phpunit": "^10.0|^11.0", + "illuminate/macroable": "^11.0|^12.0|^13.0", + "phpunit/phpunit": "^10.0|^11.0|^12.0", "spatie/url": "^2.0", "symfony/dom-crawler": "^6.1|^7.0" }, "require-dev": { "laravel/pint": "^1.18", - "phpstan/phpstan": "^1.8" + "phpstan/phpstan": "^2.0" }, "autoload": { "psr-4": { diff --git a/src/Parser/HTMLParser.php b/src/Parser/HTMLParser.php index 3ce9e82..73ec026 100644 --- a/src/Parser/HTMLParser.php +++ b/src/Parser/HTMLParser.php @@ -39,13 +39,16 @@ public function grabAttributeFrom(string $xpath, string|array $attributes) return $this->getArgumentsFromNode($nodes->getNode(0), $attributes); } + /** + * @param string|array|null $attribute + */ public function grabMultiple(string $xpath, string|array|null $attribute = null): array { $result = []; $nodes = $this->crawler->filterXPath($xpath); foreach ($nodes as $node) { - $result[] = $attribute !== null ? $this->getArgumentsFromNode($node, $attribute) : $node->textContent; // @phpstan-ignore argument.templateType + $result[] = $attribute !== null ? $this->getArgumentsFromNode($node, $attribute) : $node->textContent; } return $result; diff --git a/src/Tags/Robots.php b/src/Tags/Robots.php index 5d031bf..90c3b48 100644 --- a/src/Tags/Robots.php +++ b/src/Tags/Robots.php @@ -27,13 +27,13 @@ class Robots implements JsonSerializable, Stringable public const NO_SNIPPET = 'nosnippet'; - /** @var array */ + /** @var array */ private array $parameters; public function __construct( string $content ) { - /** @var array */ + /** @var list $parameters */ $parameters = array_map( 'trim', explode(',', $content)