From 193372eeb8f65f89761f3a01d8014bbca728fb57 Mon Sep 17 00:00:00 2001 From: James King Date: Wed, 15 Oct 2025 18:07:35 +0100 Subject: [PATCH 1/6] Remove PWA category It was removed from lighthouse in 2023 (https://github.com/GoogleChrome/lighthouse/issues/15535) Lighthouse v13 now errors if any unknown category is present (https://github.com/GoogleChrome/lighthouse/pull/16720) --- src/Enums/Category.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Enums/Category.php b/src/Enums/Category.php index 00da146..527f2bd 100644 --- a/src/Enums/Category.php +++ b/src/Enums/Category.php @@ -12,5 +12,4 @@ enum Category: string case Accessibility = 'accessibility'; case BestPractices = 'best-practices'; case Seo = 'seo'; - case ProgressiveWebApp = 'pwa'; } From 0e1ce370c5a36e1df9df71f685e394c37ba9709e Mon Sep 17 00:00:00 2001 From: James King Date: Thu, 16 Oct 2025 10:24:58 +0100 Subject: [PATCH 2/6] Update tests to no longer expect pwa results --- tests/IntegrationTest.php | 1 - tests/LighthouseResultTest.php | 2 -- ...thouseTest__it_will_use_the_default_config_by_default__1.yml | 2 +- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php index 8bd850d..b7f0464 100644 --- a/tests/IntegrationTest.php +++ b/tests/IntegrationTest.php @@ -12,7 +12,6 @@ // remove "performance" as that key is sometimes empty // on GitHub actions due to less powerful hardware $expectedCategories = Arr::without(Category::values(), Category::Performance->value); - $expectedCategories = Arr::without($expectedCategories, Category::ProgressiveWebApp->value); expect($scores)->toHaveKeys($expectedCategories); }); diff --git a/tests/LighthouseResultTest.php b/tests/LighthouseResultTest.php index b0475c5..ee0112f 100644 --- a/tests/LighthouseResultTest.php +++ b/tests/LighthouseResultTest.php @@ -21,7 +21,6 @@ 'accessibility' => 92, 'best-practices' => 100, 'seo' => 91, - 'pwa' => 30, ]); }); @@ -35,7 +34,6 @@ 'accessibility' => 92, 'best-practices' => 100, 'seo' => 91, - 'pwa' => 30, ]); }); diff --git a/tests/__snapshots__/LighthouseTest__it_will_use_the_default_config_by_default__1.yml b/tests/__snapshots__/LighthouseTest__it_will_use_the_default_config_by_default__1.yml index 7055e18..d07ebc4 100644 --- a/tests/__snapshots__/LighthouseTest__it_will_use_the_default_config_by_default__1.yml +++ b/tests/__snapshots__/LighthouseTest__it_will_use_the_default_config_by_default__1.yml @@ -3,6 +3,6 @@ chromeOptions: chromeFlags: ['--headless'] lighthouseConfig: extends: 'lighthouse:default' - settings: { onlyCategories: [performance, accessibility, best-practices, seo, pwa], formFactor: desktop, output: [json, html], disableNetworkThrottling: true, disableCpuThrottling: true, throttlingMethod: provided, screenEmulation: { disabled: true } } + settings: { onlyCategories: [performance, accessibility, best-practices, seo], formFactor: desktop, output: [json, html], disableNetworkThrottling: true, disableCpuThrottling: true, throttlingMethod: provided, screenEmulation: { disabled: true } } timeout: 59300 maxWaitForLoad: null From 634c88295b19854ce4879ce3043335e4af3c8327 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 20 Oct 2025 15:26:16 +0200 Subject: [PATCH 3/6] wip --- .github/workflows/run-tests.yml | 2 +- .gitignore | 1 + composer.json | 9 +++--- phpunit.xml.dist | 51 +++++++++------------------------ 4 files changed, 20 insertions(+), 43 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1b22060..670fb22 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: [8.3, 8.2, 8.1] + php: [8.5, 8.4, 8.3, 8.2] stability: [prefer-stable] name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 5abc4c7..391312d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,5 @@ vendor node_modules yarn.lock tests/temp +.phpunit.cache diff --git a/composer.json b/composer.json index 0a0c8a6..68ecf01 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,12 @@ } ], "require": { - "php": "^8.1", - "symfony/process": "^6.1|^7.0" + "php": "^8.2", + "symfony/process": "^7.0" }, "require-dev": { - "laravel/pint": "^1.2", - "pestphp/pest": "^1.22.1", - "spatie/pest-plugin-snapshots": "^1.1", + "pestphp/pest": "^4.0", + "spatie/pest-plugin-snapshots": "^2.2.1", "spatie/ray": "^1.36", "spatie/temporary-directory": "^2.1.1" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 94c0e39..8425e7b 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,39 +1,16 @@ - - - - tests - - - - - ./src - - - - - - - - - - + + + + tests + + + + + + + + ./src + + From 36c56b6b91fba518c068e4aabb91181b5d93a21f Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 20 Oct 2025 15:27:37 +0200 Subject: [PATCH 4/6] wip --- .github/workflows/run-tests.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 670fb22..cea457f 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - php: [8.5, 8.4, 8.3, 8.2] + php: [8.5, 8.4, 8.3] stability: [prefer-stable] name: P${{ matrix.php }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 68ecf01..51d0853 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "^8.2", + "php": "^8.3", "symfony/process": "^7.0" }, "require-dev": { From bf0f37661737015528e3ec361ba529d96f5cd4f7 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 20 Oct 2025 18:59:59 +0200 Subject: [PATCH 5/6] wip --- .github/workflows/phpstan.yml | 26 ++++++++++++++++++++++++++ composer.json | 4 +++- phpstan.neon | 5 +++++ src/Exceptions/InvalidEnumValue.php | 4 +--- src/Lighthouse.php | 2 -- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/phpstan.yml create mode 100644 phpstan.neon diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..d39a43f --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,26 @@ +name: PHPStan + +on: [push, pull_request] + +jobs: + phpstan: + runs-on: ubuntu-latest + + name: Static Analysis + + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.3 + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Install dependencies + run: composer update --prefer-stable --prefer-dist --no-interaction + + - name: Run PHPStan + run: composer analyse diff --git a/composer.json b/composer.json index 51d0853..f826a0f 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,7 @@ }, "require-dev": { "pestphp/pest": "^4.0", + "phpstan/phpstan": "^2.0", "spatie/pest-plugin-snapshots": "^2.2.1", "spatie/ray": "^1.36", "spatie/temporary-directory": "^2.1.1" @@ -37,7 +38,8 @@ "scripts": { "test": "vendor/bin/pest", "test-coverage": "vendor/bin/pest --coverage", - "format": "vendor/bin/pint" + "format": "vendor/bin/pint", + "analyse": "vendor/bin/phpstan analyse" }, "config": { "sort-packages": true, diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..c6b9644 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + paths: + - src + + level: 2 diff --git a/src/Exceptions/InvalidEnumValue.php b/src/Exceptions/InvalidEnumValue.php index f833f2d..64b4a5f 100644 --- a/src/Exceptions/InvalidEnumValue.php +++ b/src/Exceptions/InvalidEnumValue.php @@ -2,14 +2,12 @@ namespace Spatie\Lighthouse\Exceptions; -use BackedEnum; use Exception; class InvalidEnumValue extends Exception { /** - * @param class-string $enumClass - * @return static + * @phpstan-param class-string<\Spatie\Lighthouse\Enums\Category|\Spatie\Lighthouse\Enums\FormFactor> $enumClass */ public static function make(string $invalidValue, string $enumClass): self { diff --git a/src/Lighthouse.php b/src/Lighthouse.php index dcbbe2e..c8cfb23 100644 --- a/src/Lighthouse.php +++ b/src/Lighthouse.php @@ -23,8 +23,6 @@ class Lighthouse protected ?int $maxWaitForLoadInMs = null; - protected ?array $onlyAudits = null; - public static function url(string $url): self { return new self($url); From 87f06be610ac001a76b958a626c1a8efa38160e6 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Mon, 20 Oct 2025 19:00:44 +0200 Subject: [PATCH 6/6] v2 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index c6b9644..b421618 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,4 +2,4 @@ parameters: paths: - src - level: 2 + level: 5