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
24 changes: 24 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,27 @@ jobs:

- name: Run tests
run: vendor/bin/phpunit

quality:
runs-on: ubuntu-latest
name: Code quality

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: mbstring, pdo, sqlite3, pdo_sqlite
coverage: none

- name: Install dependencies
run: composer update --prefer-dist --no-interaction --no-progress

- name: Check code style (Pint)
run: composer lint

- name: Run static analysis (PHPStan)
run: composer analyse
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
},
"require-dev": {
"orchestra/testbench": "^9.0|^10.0|^11.0",
"phpunit/phpunit": "^10.5|^11.0|^12.0"
"phpunit/phpunit": "^10.5|^11.0|^12.0",
"laravel/pint": "^1.29",
"larastan/larastan": "^3.10"
},
"autoload": {
"psr-4": {
Expand All @@ -37,6 +39,9 @@
}
},
"scripts": {
"analyse": "vendor/bin/phpstan analyse --memory-limit=1G",
"format": "vendor/bin/pint",
"lint": "vendor/bin/pint --test",
"test": "phpunit"
},
"minimum-stability": "dev",
Expand Down
15 changes: 15 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
includes:
- vendor/larastan/larastan/extension.neon

parameters:
paths:
- src

level: 5

ignoreErrors:
# Package traits are consumed by userland models, not by the
# package itself, so they are never "used" from PHPStan's view.
-
identifier: trait.unused
path: src/Traits/HasApiLogs.php
3 changes: 3 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"preset": "laravel"
}
2 changes: 1 addition & 1 deletion src/Models/ApiLog.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ApiLog extends Model
{
/**
* @inheritdoc
* {@inheritdoc}
*/
protected $fillable = [
'duration',
Expand Down
6 changes: 3 additions & 3 deletions src/Support/Redactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Redactor
*/
public static function redact(array $data, array $keys, string $replacement): array
{
return static::apply($data, static::lookup($keys), $replacement);
return self::apply($data, self::lookup($keys), $replacement);
}

/**
Expand All @@ -19,7 +19,7 @@ public static function redact(array $data, array $keys, string $replacement): ar
*/
public static function redactHeaders(array $headers, array $names, string $replacement): array
{
$lookup = static::lookup($names);
$lookup = self::lookup($names);

foreach ($headers as $name => $values) {
if (isset($lookup[strtolower((string) $name)])) {
Expand All @@ -36,7 +36,7 @@ private static function apply(array $data, array $lookup, string $replacement):
if (isset($lookup[strtolower((string) $key)])) {
$data[$key] = $replacement;
} elseif (is_array($value)) {
$data[$key] = static::apply($value, $lookup, $replacement);
$data[$key] = self::apply($value, $lookup, $replacement);
}
}

Expand Down
Loading