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/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1b22060..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.3, 8.2, 8.1] + php: [8.5, 8.4, 8.3] 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..f826a0f 100644 --- a/composer.json +++ b/composer.json @@ -15,13 +15,13 @@ } ], "require": { - "php": "^8.1", - "symfony/process": "^6.1|^7.0" + "php": "^8.3", + "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", + "phpstan/phpstan": "^2.0", + "spatie/pest-plugin-snapshots": "^2.2.1", "spatie/ray": "^1.36", "spatie/temporary-directory": "^2.1.1" }, @@ -38,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..b421618 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + paths: + - src + + level: 5 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 + + 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'; } 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); 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