Skip to content

Commit e429d7f

Browse files
Add Supports For Laravel 11 (#28)
* Add support for Laravel 11 * Add support for PHP 8.3 * Drop support for PHP 7.4 * Update package dependencies * Update PHP Unit configuration * Update the test codes from using doc-comment metadata to use PHP 8 attribute * Update Github actions workflow's configuration * Update readme
1 parent 0df21f8 commit e429d7f

14 files changed

+126
-109
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,105 @@ name: Build
22

33
on:
44
push:
5-
paths-ignore: ['*.md']
5+
paths-ignore: ["*.md"]
66
pull_request:
7-
paths-ignore: [ '*.md' ]
8-
branches: [ master ]
7+
paths-ignore: ["*.md"]
8+
branches: [main]
99

1010
jobs:
1111
analysis:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
php: [8.2]
15+
php: [8.3]
1616
steps:
17-
- uses: actions/checkout@v2
17+
- uses: actions/checkout@v4
18+
- name: Setup PHP
19+
uses: shivammathur/setup-php@v2
20+
with:
21+
php-version: ${{ matrix.php }}
22+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, exif, iconv
23+
coverage: none
24+
- name: Get Composer Cache Directory
25+
id: composer-cache
26+
run: |
27+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
1828
- name: Cache composer dependencies
19-
uses: actions/cache@v2
29+
uses: actions/cache@v4
2030
env:
2131
cache-name: laravel-varnishable-analysis
2232
with:
23-
path: ~/.composer
33+
path: ${{ steps.composer-cache.outputs.dir }}
2434
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
2535
restore-keys: |
2636
php-${{ matrix.php }}-build-${{ env.cache-name }}-
27-
php-${{ matrix.php }}-build-
28-
php-${{ matrix.php }}-
29-
- name: Setup PHP
30-
uses: shivammathur/setup-php@v2
31-
with:
32-
php-version: ${{ matrix.php }}
33-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
34-
coverage: none
3537
- name: Install composer dependencies
3638
run: composer install --no-interaction --prefer-dist
37-
- name: Run statuc analysis
39+
- name: Run static analysis
3840
run: composer analyse
3941
test:
4042
name: Test (PHP ${{ matrix.php }})
4143
needs: [analysis]
4244
runs-on: ubuntu-latest
4345
strategy:
4446
matrix:
45-
php: [7.4, 8.0, 8.1]
47+
php: [8.0, 8.1, 8.2]
4648
steps:
47-
- uses: actions/checkout@v2
49+
- uses: actions/checkout@v4
4850
- name: Setup PHP
4951
uses: shivammathur/setup-php@v2
5052
with:
5153
php-version: ${{ matrix.php }}
52-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
54+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, exif, iconv
5355
coverage: none
5456
- name: Remove some dev dependencies
55-
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" "sebastian/phpcpd" --dev --no-update
57+
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" --dev --no-update
58+
- name: Get Composer Cache Directory
59+
id: composer-cache
60+
run: |
61+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
5662
- name: Cache composer dependencies
57-
uses: actions/cache@v2
63+
uses: actions/cache@v4
5864
env:
5965
cache-name: laravel-varnishable-test
6066
with:
61-
path: ~/.composer
67+
path: ${{ steps.composer-cache.outputs.dir }}
6268
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
6369
restore-keys: |
6470
php-${{ matrix.php }}-build-${{ env.cache-name }}-
65-
php-${{ matrix.php }}-build-
66-
php-${{ matrix.php }}-
6771
- name: Install composer dependencies
6872
run: composer install --no-interaction --prefer-dist
6973
- name: Run the test suite
7074
run: vendor/bin/phpunit
7175
test-coverage:
7276
name: Test (PHP ${{ matrix.php }})
73-
needs: [ analysis ]
77+
needs: [analysis]
7478
runs-on: ubuntu-latest
7579
strategy:
7680
matrix:
77-
php: [ 8.2 ]
81+
php: [8.3]
7882
steps:
79-
- uses: actions/checkout@v2
83+
- uses: actions/checkout@v4
84+
- name: Setup PHP
85+
uses: shivammathur/setup-php@v2
86+
with:
87+
php-version: ${{ matrix.php }}
88+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, exif, iconv
89+
- name: Remove some dev dependencies
90+
run: composer remove "ekino/phpstan-banned-code" "nunomaduro/larastan" "phpmd/phpmd" "phpstan/phpstan-deprecation-rules" --dev --no-update
91+
- name: Get Composer Cache Directory
92+
id: composer-cache
93+
run: |
94+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
8095
- name: Cache composer dependencies
81-
uses: actions/cache@v2
96+
uses: actions/cache@v4
8297
env:
8398
cache-name: laravel-varnishable-test
8499
with:
85-
path: ~/.composer
100+
path: ${{ steps.composer-cache.outputs.dir }}
86101
key: php-${{ matrix.php }}-build-${{ env.cache-name }}-${{ hashFiles('**/composer.json') }}
87102
restore-keys: |
88103
php-${{ matrix.php }}-build-${{ env.cache-name }}-
89-
php-${{ matrix.php }}-build-
90-
php-${{ matrix.php }}-
91-
- name: Setup PHP
92-
uses: shivammathur/setup-php@v2
93-
with:
94-
php-version: ${{ matrix.php }}
95-
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
96104
- name: Install composer dependencies
97105
run: composer install --no-interaction --prefer-dist
98106
- name: Run the Coverage test suite

composer.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,20 @@
2121
"source": "https://github.com/richan-fongdasen/laravel-varnishable"
2222
},
2323
"require": {
24-
"php": "^7.4|^8.0",
24+
"php": "^8.0",
2525
"guzzlehttp/guzzle": "^7.0",
26-
"illuminate/database": "^8.0|^9.0|^10.0",
27-
"illuminate/support": "^8.0|^9.0|^10.0"
26+
"illuminate/database": "^8.0|^9.0|^10.0|^11.0",
27+
"illuminate/support": "^8.0|^9.0|^10.0|^11.0"
2828
},
2929
"require-dev": {
3030
"ekino/phpstan-banned-code": "^1.0",
31+
"larastan/larastan": "^1.0|^2.0",
3132
"mockery/mockery": "^1.4",
32-
"nunomaduro/larastan": "^1.0|^2.0",
33-
"orchestra/database": "^6.0|dev-master",
34-
"orchestra/testbench": "^6.0|^7.0|^8.0",
33+
"orchestra/testbench": "^6.0|^7.0|^8.0|9.x-dev",
3534
"phpmd/phpmd": "^2.11",
3635
"phpstan/phpstan-deprecation-rules": "^1.0",
3736
"phpstan/phpstan-strict-rules": "^1.0",
38-
"phpunit/phpunit": "^9.5",
39-
"sebastian/phpcpd": "^6.0"
37+
"phpunit/phpunit": "^9.5|^10.0|^11.0"
4038
},
4139
"config": {
4240
"sort-packages": true
@@ -66,8 +64,7 @@
6664
"analyse": [
6765
"composer check-syntax",
6866
"composer phpstan-analysis",
69-
"composer phpmd-analysis",
70-
"vendor/bin/phpcpd --min-lines=3 --min-tokens=36 src/"
67+
"composer phpmd-analysis"
7168
],
7269
"check-syntax": [
7370
"! find src -type f -name \"*.php\" -exec php -l {} \\; | grep -v 'No syntax errors'",

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
includes:
2-
- vendor/nunomaduro/larastan/extension.neon
2+
- vendor/larastan/larastan/extension.neon
33
- vendor/phpstan/phpstan-strict-rules/rules.neon
44
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
55
- vendor/ekino/phpstan-banned-code/extension.neon

phpunit.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3-
<coverage>
4-
<include>
5-
<directory suffix=".php">src/</directory>
6-
</include>
7-
</coverage>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
83
<testsuites>
94
<testsuite name="Laravel Varnishable Test Suite">
105
<directory suffix="Tests.php">./tests/</directory>
116
</testsuite>
127
</testsuites>
8+
<source>
9+
<include>
10+
<directory suffix=".php">src/</directory>
11+
</include>
12+
</source>
1313
</phpunit>

readme.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build](https://github.com/richan-fongdasen/laravel-varnishable/actions/workflows/main.yml/badge.svg?branch=master)](https://github.com/richan-fongdasen/laravel-varnishable/actions/workflows/main.yml)
1+
[![Build](https://github.com/richan-fongdasen/laravel-varnishable/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/richan-fongdasen/laravel-varnishable/actions/workflows/main.yml)
22
[![codecov](https://codecov.io/gh/richan-fongdasen/laravel-varnishable/branch/master/graph/badge.svg)](https://codecov.io/gh/richan-fongdasen/laravel-varnishable)
33
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/richan-fongdasen/laravel-varnishable/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/richan-fongdasen/laravel-varnishable/?branch=master)
44
[![StyleCI Analysis Status](https://github.styleci.io/repos/135787392/shield?branch=master)](https://github.styleci.io/repos/135787392)
@@ -34,14 +34,15 @@ $ composer require richan-fongdasen/laravel-varnishable
3434
### Laravel version compatibility
3535

3636
| Laravel version | Varnishable version |
37-
|:----------------|:--------------------|
37+
| :-------------- | :------------------ |
3838
| 5.1.x - 5.4.x | 0.x |
3939
| 5.5.x - 5.8.x | 1.0.x - 1.1.x |
4040
| 6.x | 1.2.x |
4141
| 7.x | 1.3.x |
4242
| 8.x | ^1.4.x |
4343
| 9.x | 2.0.x |
4444
| 10.x | 2.1.x |
45+
| 11.x | 2.2.x |
4546

4647
> If you are using Laravel version 5.5+ then you can skip registering the service provider in your Laravel application.
4748

tests/Concerns/InvalidateVarnishCacheTests.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use GuzzleHttp\Client;
66
use GuzzleHttp\Psr7\Response;
77
use Illuminate\Container\Container;
8+
use PHPUnit\Framework\Attributes\Test;
89
use RichanFongdasen\Varnishable\Tests\TestCase;
910
use RichanFongdasen\Varnishable\VarnishableService;
1011

@@ -36,7 +37,7 @@ class InvalidateVarnishCacheTests extends TestCase
3637
*
3738
* @return void
3839
*/
39-
public function setUp() :void
40+
public function setUp(): void
4041
{
4142
parent::setUp();
4243

@@ -49,7 +50,7 @@ public function setUp() :void
4950
$this->response = Container::getInstance()->make(Response::class, []);
5051
}
5152

52-
/** @test */
53+
#[Test]
5354
public function it_can_send_fullban_request_to_flush_the_entire_cache()
5455
{
5556
$options = ['headers' => ['X-Ban-Host' => 'localhost:8000']];
@@ -65,7 +66,7 @@ public function it_can_send_fullban_request_to_flush_the_entire_cache()
6566
$this->service->flush('localhost:8000');
6667
}
6768

68-
/** @test */
69+
#[Test]
6970
public function it_can_send_ban_requests_based_on_the_given_regex_patterns()
7071
{
7172
$options1 = ['headers' => [
@@ -96,7 +97,7 @@ public function it_can_send_ban_requests_based_on_the_given_regex_patterns()
9697
]);
9798
}
9899

99-
/** @test */
100+
#[Test]
100101
public function it_can_send_ban_requests_based_on_the_given_urls()
101102
{
102103
$options1 = ['headers' => [
@@ -127,7 +128,7 @@ public function it_can_send_ban_requests_based_on_the_given_urls()
127128
]);
128129
}
129130

130-
/** @test */
131+
#[Test]
131132
public function it_can_generate_varnish_url_correctly()
132133
{
133134
$actual = $this->invokeMethod($this->service, 'getVarnishUrl', ['localhost']);

tests/Concerns/ManageEtagHeaderTests.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace RichanFongdasen\Varnishable\Tests\Concerns;
44

55
use Illuminate\Http\Response;
6+
use PHPUnit\Framework\Attributes\Test;
67
use RichanFongdasen\Varnishable\Tests\TestCase;
78
use RichanFongdasen\Varnishable\VarnishableService;
89

@@ -27,7 +28,7 @@ class ManageEtagHeaderTests extends TestCase
2728
*
2829
* @return void
2930
*/
30-
public function setUp() :void
31+
public function setUp(): void
3132
{
3233
parent::setUp();
3334

@@ -37,7 +38,7 @@ public function setUp() :void
3738
$this->service = app(VarnishableService::class);
3839
}
3940

40-
/** @test */
41+
#[Test]
4142
public function it_can_add_an_etag_header_to_the_current_response_object()
4243
{
4344
$content = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
@@ -47,10 +48,10 @@ public function it_can_add_an_etag_header_to_the_current_response_object()
4748
$this->invokeMethod($this->service, 'addEtagHeader', [$this->response]);
4849

4950
$actual = $this->response->headers->get('etag');
50-
$this->assertEquals('"'. md5($content) .'"', $actual);
51+
$this->assertEquals('"' . md5($content) . '"', $actual);
5152
}
5253

53-
/** @test */
54+
#[Test]
5455
public function it_can_disable_etag_header_at_runtime()
5556
{
5657
$this->service->enableEtag();
@@ -59,7 +60,7 @@ public function it_can_disable_etag_header_at_runtime()
5960
$this->assertFalse($this->service->getConfig('use_etag'));
6061
}
6162

62-
/** @test */
63+
#[Test]
6364
public function it_can_enable_etag_header_at_runtime()
6465
{
6566
$this->service->disableEtag();

tests/Concerns/ManageLastModifiedHeaderTests.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\Carbon;
66
use Illuminate\Http\Response;
7+
use PHPUnit\Framework\Attributes\Test;
78
use RichanFongdasen\Varnishable\Tests\TestCase;
89
use RichanFongdasen\Varnishable\VarnishableService;
910

@@ -28,7 +29,7 @@ class ManageLastModifiedHeaderTests extends TestCase
2829
*
2930
* @return void
3031
*/
31-
public function setUp() :void
32+
public function setUp(): void
3233
{
3334
parent::setUp();
3435

@@ -38,7 +39,7 @@ public function setUp() :void
3839
$this->service = app(VarnishableService::class);
3940
}
4041

41-
/** @test */
42+
#[Test]
4243
public function it_can_add_last_modified_header_to_the_current_response_object()
4344
{
4445
$time = new Carbon('2018-07-16 23:00:00');
@@ -49,7 +50,7 @@ public function it_can_add_last_modified_header_to_the_current_response_object()
4950
$this->assertEquals($time->toRfc7231String(), $this->response->headers->get('Last-Modified'));
5051
}
5152

52-
/** @test */
53+
#[Test]
5354
public function it_can_disable_last_modified_header_at_runtime()
5455
{
5556
$this->service->enableLastModified();
@@ -58,7 +59,7 @@ public function it_can_disable_last_modified_header_at_runtime()
5859
$this->assertFalse($this->service->getConfig('use_last_modified'));
5960
}
6061

61-
/** @test */
62+
#[Test]
6263
public function it_can_enable_last_modified_header_at_runtime()
6364
{
6465
$this->service->disableLastModified();
@@ -67,7 +68,7 @@ public function it_can_enable_last_modified_header_at_runtime()
6768
$this->assertTrue($this->service->getConfig('use_last_modified'));
6869
}
6970

70-
/** @test */
71+
#[Test]
7172
public function it_returns_last_modified_value_correctly()
7273
{
7374
$time = new Carbon('2018-07-16 23:00:00');
@@ -80,7 +81,7 @@ public function it_returns_last_modified_value_correctly()
8081
$this->assertEquals($time->getTimestamp(), $actual->getTimestamp());
8182
}
8283

83-
/** @test */
84+
#[Test]
8485
public function it_can_set_last_modified_header_with_the_newest_timestamp()
8586
{
8687
$times = [

0 commit comments

Comments
 (0)