Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ vendor
node_modules
yarn.lock
tests/temp
.phpunit.cache

13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parameters:
paths:
- src

level: 5
51 changes: 14 additions & 37 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
<clover outputFile="build/logs/clover.xml"/>
</report>
</coverage>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true" failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Spatie Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
1 change: 0 additions & 1 deletion src/Enums/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ enum Category: string
case Accessibility = 'accessibility';
case BestPractices = 'best-practices';
case Seo = 'seo';
case ProgressiveWebApp = 'pwa';
}
4 changes: 1 addition & 3 deletions src/Exceptions/InvalidEnumValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

namespace Spatie\Lighthouse\Exceptions;

use BackedEnum;
use Exception;

class InvalidEnumValue extends Exception
{
/**
* @param class-string<BackedEnum> $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
{
Expand Down
2 changes: 0 additions & 2 deletions src/Lighthouse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
2 changes: 0 additions & 2 deletions tests/LighthouseResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
'accessibility' => 92,
'best-practices' => 100,
'seo' => 91,
'pwa' => 30,
]);
});

Expand All @@ -35,7 +34,6 @@
'accessibility' => 92,
'best-practices' => 100,
'seo' => 91,
'pwa' => 30,
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading