Skip to content

Commit 7889d03

Browse files
authored
feat: support Laravel 12 (#295)
1 parent 033850b commit 7889d03

File tree

10 files changed

+39
-33
lines changed

10 files changed

+39
-33
lines changed

.github/workflows/static.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ jobs:
99
name: Static analysis
1010
uses: monicahq/workflows/.github/workflows/static.yml@v2
1111
with:
12-
php-version: 8.3
12+
php-version: 8.4
13+
with: phpstan

.github/workflows/tests.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ jobs:
2626
name: Run tests
2727
uses: monicahq/workflows/.github/workflows/library.yml@v2
2828
with:
29-
php-versions: "['8.1', '8.2', '8.3']"
30-
laravel-versions: "['^9.0', '^10.0', '^11.0']"
31-
default-php-version: '8.3'
32-
default-laravel-version: '^11.0'
33-
matrix-exclude: "[{'php-version': '8.1', 'laravel-version': '^11.0'}]"
29+
php-versions: "['8.1', '8.2', '8.3', '8.4']"
30+
laravel-versions: "['^9.0', '^10.0', '^11.0', '^12.0']"
31+
default-php-version: '8.4'
32+
default-laravel-version: '^12.0'
33+
matrix-exclude: "[{'php-version': '8.1', 'laravel-version': '^11.0'},{'php-version': '8.1', 'laravel-version': '^12.0'}]"
3434
project: monicahq_laravel-cloudflare
3535
secrets:
3636
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

composer.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
],
2222
"require": {
2323
"php": "^7.4 || ^8.0",
24-
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0"
24+
"illuminate/support": "^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0"
2525
},
2626
"require-dev": {
27+
"brainmaestro/composer-git-hooks": "^3.0",
2728
"guzzlehttp/guzzle": "^6.3 || ^7.0",
28-
"jschaedl/composer-git-hooks": "^4.0",
29-
"larastan/larastan": "^1.0 || ^2.4",
29+
"larastan/larastan": "^1.0 || ^2.4 || ^3.0",
3030
"laravel/pint": "^1.15",
3131
"mockery/mockery": "^1.4",
3232
"ocramius/package-versions": "^1.5 || ^2.1",
33-
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0",
34-
"phpstan/phpstan-deprecation-rules": "^1.0",
35-
"phpstan/phpstan-phpunit": "^1.0",
36-
"phpstan/phpstan-strict-rules": "^1.0",
33+
"orchestra/testbench": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0",
34+
"phpstan/phpstan-deprecation-rules": "^1.0 || ^2.0",
35+
"phpstan/phpstan-phpunit": "^1.0 || ^2.0",
36+
"phpstan/phpstan-strict-rules": "^1.0 || ^2.0",
3737
"phpunit/phpunit": "^9.5 || ^10.0 || ^11.0",
38-
"vimeo/psalm": "^4.0 || ^5.6"
38+
"vimeo/psalm": "^4.0 || ^5.6 || ^6.0"
3939
},
4040
"autoload": {
4141
"psr-4": {

phpstan.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ parameters:
1010
inferPrivatePropertyTypeFromConstructor: true
1111
level: 5
1212
ignoreErrors:
13-
excludes_analyse:

phpunit.xml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" backupStaticAttributes="false" bootstrap="vendor/autoload.php" colors="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage processUncoveredFiles="true">
4-
<include>
5-
<directory suffix=".php">src</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.1/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
87
<testsuites>
9-
<testsuite name="Tests">
10-
<directory suffix="Test.php">./tests/</directory>
8+
<testsuite name="Unit">
9+
<directory suffix="Test.php">./tests</directory>
1110
</testsuite>
1211
</testsuites>
12+
<coverage/>
1313
<php>
1414
<env name="APP_ENV" value="testing"/>
1515
<env name="APP_KEY" value="base64:uA/XEme0vpegJz/rKSk3ys2uzEfXZA0Ca2P0e1M8vRU="/>
1616
</php>
17+
<source>
18+
<include>
19+
<directory suffix=".php">./src</directory>
20+
</include>
21+
</source>
1722
</phpunit>

src/CloudflareProxies.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ class CloudflareProxies
3737
public function __construct(
3838
protected Repository $config,
3939
protected HttpClient $http
40-
) {
41-
}
40+
) {}
4241

4342
/**
4443
* Retrieve Cloudflare proxies list.
@@ -72,6 +71,6 @@ protected function retrieve(string $name): array
7271
throw new UnexpectedValueException('Failed to load trust proxies from Cloudflare server.', 1, $e);
7372
}
7473

75-
return array_filter(explode("\n", $response->body()));
74+
return array_filter(explode("\n", $response->body())); // @phpstan-ignore arrayFilter.strict
7675
}
7776
}

src/Facades/CloudflareProxies.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class CloudflareProxies extends Facade
1414
/**
1515
* Get the registered name of the component.
1616
*/
17+
#[\Override]
1718
protected static function getFacadeAccessor(): string
1819
{
1920
return \Monicahq\Cloudflare\CloudflareProxies::class;

src/TrustedProxyServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ private function registerPublishing(): void
2929
/**
3030
* Register any package services.
3131
*/
32+
#[\Override]
3233
public function register(): void
3334
{
3435
$this->mergeConfigFrom(

tests/Unit/Http/Middleware/TrustProxiesTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function it_sets_trusted_proxies()
1717
->with('cloudflare.proxies', \Closure::class)
1818
->andReturn(['expect']);
1919

20-
$request = new Request();
20+
$request = new Request;
2121

2222
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
2323

@@ -34,7 +34,7 @@ public function it_sets_trusted_proxies_with_cache()
3434
});
3535

3636
try {
37-
$request = new Request();
37+
$request = new Request;
3838

3939
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
4040

@@ -55,7 +55,7 @@ public function it_does_not_sets_trusted_proxies()
5555
->with('cloudflare.proxies', \Closure::class)
5656
->andReturn([]);
5757

58-
$request = new Request();
58+
$request = new Request;
5959

6060
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
6161

@@ -69,7 +69,7 @@ public function it_deactivates_middleware()
6969
{
7070
config(['laravelcloudflare.enabled' => false]);
7171

72-
$request = new Request();
72+
$request = new Request;
7373

7474
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
7575

@@ -84,7 +84,7 @@ public function it_sets_remote_addr()
8484
{
8585
config(['laravelcloudflare.replace_ip' => true]);
8686

87-
$request = new Request();
87+
$request = new Request;
8888
$request->server->set('REMOTE_ADDR', '127.0.0.1');
8989
$request->headers->set('Cf-Connecting-Ip', '127.0.1.1');
9090

tests/Unit/LaravelCloudflareTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function it_call_callback()
2525
});
2626

2727
try {
28-
$request = new Request();
28+
$request = new Request;
2929

3030
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
3131

@@ -45,7 +45,7 @@ public function it_call_load()
4545
->once()
4646
->andReturn(['expect']);
4747

48-
$request = new Request();
48+
$request = new Request;
4949

5050
$this->app->make(TrustProxies::class)->handle($request, fn () => null);
5151

0 commit comments

Comments
 (0)