Skip to content

Commit 18140da

Browse files
committed
main | stricter typing and linting & workflow
1 parent 7508abd commit 18140da

File tree

16 files changed

+129
-20
lines changed

16 files changed

+129
-20
lines changed

.github/workflows/main.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: PHP Composer
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Validate composer.json and composer.lock
21+
run: composer validate --strict
22+
23+
- name: Cache Composer packages
24+
id: composer-cache
25+
uses: actions/cache@v3
26+
with:
27+
path: vendor
28+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
29+
restore-keys: |
30+
${{ runner.os }}-php-
31+
32+
- name: Install dependencies
33+
run: composer install --prefer-dist --no-progress
34+
35+
- name: Run test suite
36+
run: composer test

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,12 @@
5656
}
5757
},
5858
"scripts": {
59-
"refacto": "rector",
59+
"refactor": "rector",
60+
"tidy": [
61+
"@lint",
62+
"@refactor",
63+
"@lint"
64+
],
6065
"lint": "pint",
6166
"test:refacto": "rector --dry-run",
6267
"test:lint": "pint --test",

config/response-compression.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
return [
46

57
/**

pint.json

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"preset": "laravel",
3+
"rules": {
4+
"array_push": true,
5+
"backtick_to_shell_exec": true,
6+
"declare_strict_types": true,
7+
"final_class": true,
8+
"fully_qualified_strict_types": true,
9+
"global_namespace_import": {
10+
"import_classes": true,
11+
"import_constants": true,
12+
"import_functions": true
13+
},
14+
"ordered_class_elements": {
15+
"order": [
16+
"use_trait",
17+
"case",
18+
"constant",
19+
"constant_public",
20+
"constant_protected",
21+
"constant_private",
22+
"property_public",
23+
"property_protected",
24+
"property_private",
25+
"construct",
26+
"destruct",
27+
"magic",
28+
"phpunit",
29+
"method_abstract",
30+
"method_public_static",
31+
"method_public",
32+
"method_protected_static",
33+
"method_protected",
34+
"method_private_static",
35+
"method_private"
36+
],
37+
"sort_algorithm": "none"
38+
},
39+
"ordered_interfaces": true,
40+
"ordered_traits": true,
41+
"protected_to_private": true,
42+
"strict_comparison": true
43+
},
44+
"notPath": ["tests/TestCase.php"]
45+
}

rector.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
declare(strict_types=1);
44

55
use Rector\Config\RectorConfig;
6-
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
76

87
return RectorConfig::configure()
98
->withPaths([
109
__DIR__.'/src',
1110
__DIR__.'/tests',
1211
])
13-
->withSkip([
14-
AddOverrideAttributeToOverriddenMethodsRector::class,
15-
])
1612
->withPreparedSets(
1713
deadCode: true,
1814
codeQuality: true,

src/Contracts/Encoder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Chr15k\ResponseCompression\Contracts;
46

57
use Symfony\Component\HttpFoundation\Response;

src/Encoders/BrotliEncoder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Chr15k\ResponseCompression\Encoders;
46

57
use Chr15k\ResponseCompression\Contracts\Encoder;

src/Encoders/GzipEncoder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Chr15k\ResponseCompression\Encoders;
46

57
use Chr15k\ResponseCompression\Contracts\Encoder;

src/Middleware/CompressResponse.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Chr15k\ResponseCompression\Middleware;
46

57
use Chr15k\ResponseCompression\Encoders\BrotliEncoder;
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Chr15k\ResponseCompression;
46

57
use Illuminate\Support\ServiceProvider;
68

7-
class ResponseCompressionServiceProvider extends ServiceProvider
9+
final class ResponseCompressionServiceProvider extends ServiceProvider
810
{
911
public static string $abstract = 'response-compression';
1012

1113
public function getConfigPath(): string
1214
{
13-
return sprintf('%s/../config/%s.php', __DIR__, static::$abstract);
15+
return sprintf('%s/../config/%s.php', __DIR__, self::$abstract);
1416
}
1517

1618
public function register(): void
1719
{
18-
$this->mergeConfigFrom($this->getConfigPath(), static::$abstract);
20+
$this->mergeConfigFrom($this->getConfigPath(), self::$abstract);
1921
}
2022

2123
public function boot(): void
2224
{
2325
if ($this->app->runningInConsole()) {
2426
$this->publishes([
25-
$this->getConfigPath() => config_path(static::$abstract.'.php'),
26-
], static::$abstract.'-config');
27+
$this->getConfigPath() => config_path(self::$abstract.'.php'),
28+
], self::$abstract.'-config');
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)