Skip to content

Commit 717d307

Browse files
willpower232MortenDHansenerikn69
authored
🔧 drop php < 8.2 and add laravel 12 (#1006)
* 🔧 Laravel 12 support, drop php < 8.2 Co-authored-by: Morten D. Hansen <[email protected]> Co-authored-by: erikn69 <[email protected]> * Fix tests * Fix composer * ♻️ update tests to not use doc block meta data * ♻️ php 8 constructor promotion * fixup! ♻️ php 8 constructor promotion * fixup! ♻️ php 8 constructor promotion --------- Co-authored-by: Morten D. Hansen <[email protected]> Co-authored-by: erikn69 <[email protected]>
1 parent 7339563 commit 717d307

32 files changed

+525
-1084
lines changed

.github/workflows/phpstan.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan
22

33
on:
4-
push:
4+
pull_request:
55
paths:
66
- '**.php'
77
- 'phpstan.neon.dist'
@@ -10,6 +10,9 @@ jobs:
1010
phpstan:
1111
name: phpstan
1212
runs-on: ubuntu-latest
13+
timeout-minutes: 15
14+
env:
15+
COMPOSER_NO_INTERACTION: 1
1316
steps:
1417
- uses: actions/checkout@v4
1518

@@ -24,8 +27,8 @@ jobs:
2427

2528
- name: Install larastan
2629
run: |
27-
composer require "larastan/larastan" --no-interaction --no-update
28-
composer update --prefer-dist --no-interaction
30+
composer require "larastan/larastan" --no-update
31+
composer update --prefer-dist --no-suggest
2932
3033
- name: Run PHPStan
3134
run: ./vendor/bin/phpstan --error-format=github

.github/workflows/run-tests.yml

Lines changed: 13 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,29 @@ name: run-tests
22

33
on:
44
push:
5-
branches: [master]
6-
pull_request:
7-
branches: [master]
5+
branches:
6+
- '*'
87

98
jobs:
109
run-tests:
1110
runs-on: ubuntu-latest
11+
timeout-minutes: 15
12+
env:
13+
COMPOSER_NO_INTERACTION: 1
1214
strategy:
1315
fail-fast: false
1416
matrix:
15-
php: [7.4, 8.0, 8.1, 8.2, 8.3, 8.4]
16-
laravel: [ 11.*, 10.*, 9.*, 8.*, 7.* ]
17+
php: [ 8.2, 8.3, 8.4 ]
18+
laravel: [ 11.*, 12.* ]
1719
include:
20+
- laravel: 12.*
21+
testbench: 10.*
1822
- laravel: 11.*
1923
testbench: 9.*
20-
- laravel: 10.*
21-
testbench: 8.*
22-
- laravel: 9.*
23-
testbench: 7.*
24-
- laravel: 8.*
25-
testbench: 6.*
26-
- laravel: 7.*
27-
testbench: 5.*
28-
exclude:
29-
- laravel: 11.*
30-
php: 8.1
31-
- laravel: 11.*
32-
php: 8.0
33-
- laravel: 11.*
34-
php: 7.4
35-
- laravel: 10.*
36-
php: 7.4
37-
- laravel: 10.*
38-
php: 8.0
39-
- laravel: 9.*
40-
php: 7.4
41-
- laravel: 9.*
42-
php: 8.4
43-
- laravel: 8.*
44-
php: 8.3
45-
- laravel: 8.*
46-
php: 8.4
47-
- laravel: 7.*
48-
php: 8.1
49-
- laravel: 7.*
50-
php: 8.2
51-
- laravel: 7.*
52-
php: 8.3
53-
- laravel: 7.*
54-
php: 8.4
5524

5625
name: PHP${{ matrix.php }} - Laravel${{ matrix.laravel }} - ${{ matrix.dependency-version }}
5726

5827
steps:
59-
- name: Update apt
60-
run: sudo apt-get update --fix-missing
61-
6228
- name: Checkout code
6329
uses: actions/checkout@v4
6430

@@ -71,11 +37,11 @@ jobs:
7137

7238
- name: Install dependencies
7339
run: |
74-
composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/database:${{ matrix.laravel }}" "illuminate/filesystem:${{ matrix.laravel }}" "nesbot/carbon:^2.62.1" --no-interaction --no-update
75-
composer require "orchestra/testbench:${{ matrix.testbench }}" --dev --no-interaction --no-update
76-
composer update --prefer-dist --no-interaction --no-suggest
40+
composer require "illuminate/console:${{ matrix.laravel }}" "illuminate/database:${{ matrix.laravel }}" "illuminate/filesystem:${{ matrix.laravel }}" --no-update
41+
composer require "orchestra/testbench:${{ matrix.testbench }}" --dev --no-update
42+
composer update --prefer-dist --no-suggest
7743
7844
- name: Execute tests
7945
run: |
8046
vendor/bin/phpunit
81-
vendor/bin/phpunit tests/Unit/AuditTest.php --group command-line-url-resolver
47+
vendor/bin/phpunit tests/Unit/AuditTest.php --group command-line-url-resolver

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<a href="https://discord.gg/csD9ysg"><img src="https://img.shields.io/badge/chat-on%20discord-7289DA.svg" alt="Chat"></a>
1313
</p>
1414

15-
This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.
15+
This package will help you understand changes in your Eloquent models, by providing information about possible discrepancies and anomalies that could indicate business concerns or suspect activities.
1616

1717
Laravel Auditing allows you to keep a history of model changes by simply using a trait. Retrieving the audited data is straightforward, making it possible to display it in various ways.
1818

@@ -26,7 +26,8 @@ Thank you for choosing OwenIt\LaravelAuditing!
2626

2727
Version | Illuminate | Status | PHP Version
2828
:----------|:---------------|:------------------------|:------------
29-
13.x | 7.x.x - 11.x.x | Active support :rocket: | > = 7.3 \| 8.0
29+
14.x | 11.x.x - 12.x.x | Active support :rocket: | > = 8.2
30+
13.x | 7.x.x - 11.x.x | End of life | > = 7.3 \| 8.0
3031
12.x | 6.x.x - 9.x.x | End of life | > = 7.3 \| 8.0
3132
11.x | 5.8.x - 8.x.x | End of life | > = 7.3
3233
10.x | 5.8.x - 7.x.x | End of life | > = 7.2.5

composer.json

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "owen-it/laravel-auditing",
3-
"description": "Audit changes of your Eloquent models in Laravel/Lumen",
3+
"description": "Audit changes of your Eloquent models in Laravel",
44
"keywords": [
55
"accountability",
66
"audit",
@@ -39,17 +39,16 @@
3939
}
4040
],
4141
"require": {
42-
"php": "^7.3|^8.0",
43-
"illuminate/console": "^7.0|^8.0|^9.0|^10.0|^11.0",
44-
"illuminate/database": "^7.0|^8.0|^9.0|^10.0|^11.0",
45-
"illuminate/filesystem": "^7.0|^8.0|^9.0|^10.0|^11.0",
46-
"ext-json": "*"
42+
"php": "^8.2",
43+
"ext-json": "*",
44+
"illuminate/console": "^11.0|^12.0",
45+
"illuminate/database": "^11.0|^12.0",
46+
"illuminate/filesystem": "^11.0|^12.0"
4747
},
4848
"require-dev": {
49-
"phpunit/phpunit": "^9.6|^10.5|^11.0",
50-
"mockery/mockery": "^1.0",
51-
"orchestra/testbench": "^5.0|^6.0|^7.0|^8.0|^9.0",
52-
"laravel/legacy-factories": "*"
49+
"mockery/mockery": "^1.5.1",
50+
"orchestra/testbench": "^9.0|^10.0",
51+
"phpunit/phpunit": "^11.0"
5352
},
5453
"autoload": {
5554
"psr-4": {
@@ -61,19 +60,21 @@
6160
"OwenIt\\Auditing\\Tests\\": "tests/"
6261
}
6362
},
64-
"suggest": {
65-
"irazasyed/larasupport": "Needed to publish the package configuration in Lumen"
66-
},
6763
"extra": {
6864
"branch-alias": {
69-
"dev-master": "v13-dev"
65+
"dev-master": "v14-dev"
7066
},
7167
"laravel": {
7268
"providers": [
7369
"OwenIt\\Auditing\\AuditingServiceProvider"
7470
]
7571
}
7672
},
73+
"scripts": {
74+
"test": "phpunit",
75+
"format": "composer require --dev laravel/pint --quiet && pint --config .pint.json && composer remove --dev laravel/pint --no-update",
76+
"analyse": "composer require --dev larastan/larastan --quiet && phpstan analyse && composer remove --dev larastan/larastan --no-update"
77+
},
7778
"minimum-stability": "dev",
7879
"prefer-stable": true
7980
}

database/migrations/audits.stub

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ use Illuminate\Database\Migrations\Migration;
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
class CreateAuditsTable extends Migration
7+
return new class extends Migration
88
{
99
/**
1010
* Run the migrations.
11-
*
12-
* @return void
1311
*/
14-
public function up()
12+
public function up(): void
1513
{
1614
$connection = config('audit.drivers.database.connection', config('database.default'));
1715
$table = config('audit.drivers.database.table', 'audits');
@@ -39,14 +37,12 @@ class CreateAuditsTable extends Migration
3937

4038
/**
4139
* Reverse the migrations.
42-
*
43-
* @return void
4440
*/
45-
public function down()
41+
public function down(): void
4642
{
4743
$connection = config('audit.drivers.database.connection', config('database.default'));
4844
$table = config('audit.drivers.database.table', 'audits');
4945

5046
Schema::connection($connection)->drop($table);
5147
}
52-
}
48+
};

phpunit.xml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
44
backupGlobals="false"
5-
backupStaticAttributes="false"
65
bootstrap="vendor/autoload.php"
76
colors="true"
8-
convertErrorsToExceptions="true"
9-
convertNoticesToExceptions="true"
10-
convertWarningsToExceptions="true"
117
processIsolation="false"
128
stopOnError="false"
139
stopOnFailure="true"
14-
verbose="true"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
1512
>
1613
<testsuites>
1714
<testsuite name="Auditing Test Suite">
18-
<directory suffix="Test.php">./tests</directory>
15+
<directory>./tests</directory>
1916
</testsuite>
2017
</testsuites>
2118
<groups>
@@ -27,9 +24,9 @@
2724
<group>command-line-url-resolver</group>
2825
</exclude>
2926
</groups>
30-
<coverage processUncoveredFiles="true">
27+
<source>
3128
<include>
3229
<directory suffix=".php">./src</directory>
3330
</include>
34-
</coverage>
31+
</source>
3532
</phpunit>

src/Events/AuditCustom.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66

77
class AuditCustom
88
{
9-
/**
10-
* The Auditable model.
11-
*
12-
* @var \OwenIt\Auditing\Contracts\Auditable
13-
*/
14-
public $model;
15-
169
/**
1710
* Create a new Auditing event instance.
1811
*/
19-
public function __construct(Auditable $model)
20-
{
21-
$this->model = $model;
12+
public function __construct(
13+
public Auditable $model
14+
) {
15+
//
2216
}
2317
}

src/Events/Audited.php

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,14 @@
88

99
class Audited
1010
{
11-
/**
12-
* The Auditable model.
13-
*
14-
* @var \OwenIt\Auditing\Contracts\Auditable
15-
*/
16-
public $model;
17-
18-
/**
19-
* Audit driver.
20-
*
21-
* @var \OwenIt\Auditing\Contracts\AuditDriver
22-
*/
23-
public $driver;
24-
25-
/**
26-
* The Audit model.
27-
*
28-
* @var \OwenIt\Auditing\Contracts\Audit|null
29-
*/
30-
public $audit;
31-
3211
/**
3312
* Create a new Audited event instance.
3413
*/
35-
public function __construct(Auditable $model, AuditDriver $driver, ?Audit $audit = null)
36-
{
37-
$this->model = $model;
38-
$this->driver = $driver;
39-
$this->audit = $audit;
14+
public function __construct(
15+
public Auditable $model,
16+
public AuditDriver $driver,
17+
public ?Audit $audit = null
18+
) {
19+
//
4020
}
4121
}

src/Events/Auditing.php

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,13 @@
77

88
class Auditing
99
{
10-
/**
11-
* The Auditable model.
12-
*
13-
* @var \OwenIt\Auditing\Contracts\Auditable
14-
*/
15-
public $model;
16-
17-
/**
18-
* Audit driver.
19-
*
20-
* @var \OwenIt\Auditing\Contracts\AuditDriver
21-
*/
22-
public $driver;
23-
2410
/**
2511
* Create a new Auditing event instance.
2612
*/
27-
public function __construct(Auditable $model, AuditDriver $driver)
28-
{
29-
$this->model = $model;
30-
$this->driver = $driver;
13+
public function __construct(
14+
public Auditable $model,
15+
public AuditDriver $driver
16+
) {
17+
//
3118
}
3219
}

src/Events/DispatchAudit.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,13 @@
77

88
class DispatchAudit
99
{
10-
/**
11-
* The Auditable model.
12-
*
13-
* @var Auditable
14-
*/
15-
public $model;
16-
1710
/**
1811
* Create a new DispatchAudit event instance.
1912
*/
20-
public function __construct(Auditable $model)
21-
{
22-
$this->model = $model;
13+
public function __construct(
14+
public Auditable $model
15+
) {
16+
//
2317
}
2418

2519
/**

0 commit comments

Comments
 (0)