Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3234495

Browse files
committedMar 3, 2025·
Laravel 12 support
1 parent 43c9e98 commit 3234495

File tree

10 files changed

+146
-77
lines changed

10 files changed

+146
-77
lines changed
 

‎.github/workflows/static-analysis.yml

+38-36
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,48 @@ name: Static Analysis
33
on: [ push ]
44

55
jobs:
6-
PHPUnit:
6+
PHPStan:
77
strategy:
88
matrix:
99
include:
10-
# Laravel 10.*
11-
- php: 8.1
12-
laravel: 10.*
13-
composer-flag: '--prefer-stable'
14-
- php: 8.2
15-
laravel: 10.*
16-
composer-flag: '--prefer-stable'
17-
- php: 8.3
18-
laravel: 10.*
19-
composer-flag: '--prefer-stable'
20-
- php: 8.1
21-
laravel: 10.*
22-
composer-flag: '--prefer-lowest'
23-
- php: 8.2
24-
laravel: 10.*
25-
composer-flag: '--prefer-lowest'
26-
- php: 8.3
27-
laravel: 10.*
28-
composer-flag: '--prefer-lowest'
2910
# Laravel 11.*
30-
- php: 8.2
31-
laravel: 11.*
32-
testbench: 9.*
33-
composer-flag: '--prefer-stable'
34-
- php: 8.3
35-
laravel: 11.*
36-
testbench: 9.*
37-
composer-flag: '--prefer-stable'
38-
- php: 8.2
39-
laravel: 11.*
40-
testbench: 9.*
41-
composer-flag: '--prefer-lowest'
42-
- php: 8.2
43-
laravel: 11.*
44-
testbench: 9.*
45-
composer-flag: '--prefer-lowest'
11+
- php: 8.2
12+
laravel: 11.*
13+
testbench: 9.*
14+
composer-flag: '--prefer-stable'
15+
- php: 8.3
16+
laravel: 11.*
17+
testbench: 9.*
18+
composer-flag: '--prefer-stable'
19+
- php: 8.4
20+
laravel: 11.*
21+
testbench: 9.*
22+
composer-flag: '--prefer-stable'
23+
# Laravel 12.*
24+
- php: 8.2
25+
laravel: 12.*
26+
testbench: 10.*
27+
composer-flag: '--prefer-stable'
28+
- php: 8.3
29+
laravel: 12.*
30+
testbench: 10.*
31+
composer-flag: '--prefer-stable'
32+
- php: 8.4
33+
laravel: 12.*
34+
testbench: 10.*
35+
composer-flag: '--prefer-stable'
36+
- php: 8.2
37+
laravel: 12.*
38+
testbench: 10.*
39+
composer-flag: '--prefer-lowest'
40+
- php: 8.3
41+
laravel: 12.*
42+
testbench: 10.*
43+
composer-flag: '--prefer-lowest'
44+
- php: 8.4
45+
laravel: 12.*
46+
testbench: 10.*
47+
composer-flag: '--prefer-lowest'
4648

4749
runs-on: ubuntu-latest
4850

‎.github/workflows/unittests.yml

+47-2
Original file line numberDiff line numberDiff line change
@@ -11,45 +11,90 @@ jobs:
1111
- php: 8.1
1212
laravel: 10.*
1313
testbench: 8.*
14+
phpunit-config: 'phpunit-10.xml'
1415
composer-flag: '--prefer-stable'
1516
- php: 8.2
1617
laravel: 10.*
1718
testbench: 8.*
19+
phpunit-config: 'phpunit-10.xml'
1820
composer-flag: '--prefer-stable'
1921
- php: 8.3
2022
laravel: 10.*
2123
testbench: 8.*
24+
phpunit-config: 'phpunit-10.xml'
2225
composer-flag: '--prefer-stable'
2326
- php: 8.1
2427
laravel: 10.*
2528
testbench: 8.*
29+
phpunit-config: 'phpunit-10.xml'
2630
composer-flag: '--prefer-lowest'
2731
- php: 8.2
2832
laravel: 10.*
2933
testbench: 8.*
34+
phpunit-config: 'phpunit-10.xml'
3035
composer-flag: '--prefer-lowest'
3136
- php: 8.3
3237
laravel: 10.*
3338
testbench: 8.*
39+
phpunit-config: 'phpunit-10.xml'
3440
composer-flag: '--prefer-lowest'
3541
# Laravel 11.*
3642
- php: 8.2
3743
laravel: 11.*
3844
testbench: 9.*
45+
phpunit-config: 'phpunit.xml'
3946
composer-flag: '--prefer-stable'
4047
- php: 8.3
4148
laravel: 11.*
4249
testbench: 9.*
50+
phpunit-config: 'phpunit.xml'
4351
composer-flag: '--prefer-stable'
4452
- php: 8.2
4553
laravel: 11.*
4654
testbench: 9.*
55+
phpunit-config: 'phpunit.xml'
4756
composer-flag: '--prefer-lowest'
4857
- php: 8.2
4958
laravel: 11.*
5059
testbench: 9.*
60+
phpunit-config: 'phpunit.xml'
61+
composer-flag: '--prefer-lowest'
62+
- php: 8.4
63+
laravel: 11.*
64+
testbench: 9.*
65+
phpunit-config: 'phpunit.xml'
66+
composer-flag: '--prefer-stable'
67+
# Laravel 12.*
68+
- php: 8.2
69+
laravel: 12.*
70+
testbench: 10.*
71+
phpunit-config: 'phpunit.xml'
72+
composer-flag: '--prefer-stable'
73+
- php: 8.3
74+
laravel: 12.*
75+
testbench: 10.*
76+
phpunit-config: 'phpunit.xml'
77+
composer-flag: '--prefer-stable'
78+
- php: 8.4
79+
laravel: 12.*
80+
testbench: 10.*
81+
phpunit-config: 'phpunit.xml'
82+
composer-flag: '--prefer-stable'
83+
- php: 8.2
84+
laravel: 12.*
85+
testbench: 10.*
86+
phpunit-config: 'phpunit.xml'
87+
composer-flag: '--prefer-lowest'
88+
- php: 8.3
89+
laravel: 12.*
90+
testbench: 10.*
91+
phpunit-config: 'phpunit.xml'
92+
composer-flag: '--prefer-lowest'
93+
- php: 8.4
94+
laravel: 12.*
95+
testbench: 10.*
96+
phpunit-config: 'phpunit.xml'
5197
composer-flag: '--prefer-lowest'
52-
5398
runs-on: ubuntu-latest
5499

55100
steps:
@@ -69,7 +114,7 @@ jobs:
69114
run: composer update ${{ matrix.composer-flag }} --prefer-dist --no-interaction
70115

71116
- name: Run PHPUnit
72-
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml
117+
run: XDEBUG_MODE=coverage vendor/bin/phpunit --config="${{ matrix.phpunit-config }}" --coverage-text --coverage-clover=coverage.xml
73118

74119
- name: Upload coverage reports to Codecov
75120
uses: codecov/codecov-action@v4

‎README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ composer require korridor/laravel-has-many-merged "^1"
3232
This package is tested for the following Laravel and PHP versions:
3333

3434
- 10.* (PHP 8.1, 8.2, 8.3)
35-
- 11.* (PHP 8.2, 8.3)
35+
- 11.* (PHP 8.2, 8.3, 8.4)
36+
- 12.* (PHP 8.2, 8.3, 8.4)
3637

3738
## Usage
3839

‎composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
],
1818
"require": {
1919
"php": ">=8.1",
20-
"illuminate/database": "^10|^11",
21-
"illuminate/support": "^10|^11"
20+
"illuminate/database": "^10|^11|^12",
21+
"illuminate/support": "^10|^11|^12"
2222
},
2323
"require-dev": {
2424
"friendsofphp/php-cs-fixer": "^3",
25-
"larastan/larastan": "^2.0",
26-
"orchestra/testbench": "^8|^9",
27-
"phpunit/phpunit": "^10.0",
25+
"larastan/larastan": "^2|^3.0",
26+
"orchestra/testbench": "^8|^9|^10",
27+
"phpunit/phpunit": "^10.0|^11.5",
2828
"squizlabs/php_codesniffer": "^3.5"
2929
},
3030
"autoload": {

‎phpstan.neon

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55

66
paths:
77
- src
8-
- tests
8+
# - tests
99

1010
# Level 9 is the highest level
1111
level: 9

‎phpunit-10.xml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
colors="true"
6+
processIsolation="false"
7+
stopOnFailure="false"
8+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
9+
cacheDirectory=".phpunit.cache"
10+
backupStaticProperties="false">
11+
<coverage>
12+
<include>
13+
<directory suffix=".php">src/</directory>
14+
</include>
15+
</coverage>
16+
<testsuites>
17+
<testsuite name="Feature">
18+
<directory>tests</directory>
19+
</testsuite>
20+
</testsuites>
21+
<php>
22+
<env name="APP_ENV" value="testing"/>
23+
<env name="CACHE_DRIVER" value="array"/>
24+
<env name="SESSION_DRIVER" value="array"/>
25+
<env name="QUEUE_DRIVER" value="sync"/>
26+
<env name="DB_CONNECTION" value="sqlite"/>
27+
<env name="DB_DATABASE" value=":memory:"/>
28+
</php>
29+
</phpunit>

‎phpunit.xml

+19-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
bootstrap="vendor/autoload.php"
4-
backupGlobals="false"
5-
colors="true"
6-
processIsolation="false"
7-
stopOnFailure="false"
8-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
9-
cacheDirectory=".phpunit.cache"
10-
backupStaticProperties="false">
11-
<coverage>
12-
<include>
13-
<directory suffix=".php">src/</directory>
14-
</include>
15-
</coverage>
16-
<testsuites>
17-
<testsuite name="Feature">
18-
<directory>tests</directory>
19-
</testsuite>
20-
</testsuites>
21-
<php>
22-
<env name="APP_ENV" value="testing"/>
23-
<env name="CACHE_DRIVER" value="array"/>
24-
<env name="SESSION_DRIVER" value="array"/>
25-
<env name="QUEUE_DRIVER" value="sync"/>
26-
<env name="DB_CONNECTION" value="sqlite"/>
27-
<env name="DB_DATABASE" value=":memory:"/>
28-
</php>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="Feature">
5+
<directory>tests</directory>
6+
</testsuite>
7+
</testsuites>
8+
<php>
9+
<env name="APP_ENV" value="testing"/>
10+
<env name="CACHE_DRIVER" value="array"/>
11+
<env name="SESSION_DRIVER" value="array"/>
12+
<env name="QUEUE_DRIVER" value="sync"/>
13+
<env name="DB_CONNECTION" value="sqlite"/>
14+
<env name="DB_DATABASE" value=":memory:"/>
15+
</php>
16+
<source>
17+
<include>
18+
<directory suffix=".php">src/</directory>
19+
</include>
20+
</source>
2921
</phpunit>

‎src/ServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function boot(): void
2525
'created' => [], 'deleted' => [], 'updated' => [],
2626
];
2727

28-
/** @var HasMany<Model> $this */
28+
/** @var HasMany<Model, Model> $this */
2929

3030
// Get the primary key.
3131
$relatedKeyName = $this->getRelated()->getKeyName();

‎tests/TestEnvironment/Models/Task.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Task extends Model
1515
/**
1616
* The attributes that are mass assignable.
1717
*
18-
* @var array<int, string>
18+
* @var list<string>
1919
*/
2020
protected $fillable = [
2121
'id',
@@ -24,7 +24,7 @@ class Task extends Model
2424
];
2525

2626
/**
27-
* @return BelongsTo<User, Task>
27+
* @return BelongsTo<User, $this>
2828
*/
2929
public function user(): BelongsTo
3030
{

‎tests/TestEnvironment/Models/User.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ class User extends Model
1515
/**
1616
* The attributes that are mass assignable.
1717
*
18-
* @var array<int, string>
18+
* @var list<string>
1919
*/
2020
protected $fillable = [
2121
'name',
2222
];
2323

2424
/**
25-
* @return HasMany<Task>
25+
* @return HasMany<Task, $this>
2626
*/
2727
public function tasks(): HasMany
2828
{

0 commit comments

Comments
 (0)
Please sign in to comment.