Skip to content

Commit 83d589b

Browse files
Support PHP 8.2+ (#2586)
* Support PHP 8.2+ * Changes * Fix PHP Stan * Set connection to sync * Fix styling * Fix PHP Stan Install --------- Co-authored-by: arthurkirkosa <[email protected]>
1 parent a7553a4 commit 83d589b

19 files changed

+117
-74
lines changed

.github/workflows/php-cs-fixer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88

99
steps:
1010
- name: Checkout code
11-
uses: actions/checkout@v2
11+
uses: actions/checkout@v4
1212
with:
1313
ref: ${{ github.head_ref }}
1414

.github/workflows/phpstan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ jobs:
1111
name: phpstan
1212
runs-on: ubuntu-latest
1313
steps:
14-
- uses: actions/checkout@v2
14+
- uses: actions/checkout@v4
1515

1616
- name: Setup PHP
1717
uses: shivammathur/setup-php@v2
1818
with:
19-
php-version: '8.1'
19+
php-version: '8.2'
2020
coverage: none
2121

2222
- name: Install composer dependencies

.github/workflows/release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
if: github.event.pull_request.merged == true
1414
runs-on: "ubuntu-latest"
1515
steps:
16-
- uses: actions/checkout@v2
16+
- uses: actions/checkout@v4
17+
1718
- uses: ncipollo/release-action@v1
1819
with:
1920
name: ${{ github.event.pull_request.title }}

.github/workflows/run-tests.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
11
name: run-tests
22

3-
on:
4-
- push
5-
- pull_request
3+
on: [push, pull_request]
64

75
jobs:
86
test:
97
runs-on: ${{ matrix.os }}
10-
118
strategy:
129
fail-fast: true
1310
matrix:
1411
os: [ubuntu-latest, windows-latest]
15-
php: [8.1, '8.2']
16-
laravel: ['11.0', ^10.0]
12+
php: [8.3, 8.2]
13+
laravel: [10.*, 11.*]
1714
stability: [prefer-stable]
1815
include:
19-
- laravel: ^10.0
20-
testbench: ^8.0
21-
- laravel: '11.0'
22-
testbench: ^9.0
23-
exclude:
24-
- laravel: '11.0'
25-
php: 8.1
16+
- laravel: 10.*
17+
testbench: 8.*
18+
- laravel: 11.*
19+
testbench: 9.*
2620

2721
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
2822

2923
steps:
3024
- name: Checkout code
31-
uses: actions/checkout@v2
25+
uses: actions/checkout@v4
3226

3327
- name: Setup PHP
3428
uses: shivammathur/setup-php@v2
@@ -47,5 +41,11 @@ jobs:
4741
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
4842
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
4943
44+
- name: Clear Composer cache
45+
run: composer clear-cache
46+
47+
- name: Wait for a few seconds
48+
run: sleep 5
49+
5050
- name: Execute tests
51-
run: ./vendor/bin/testbench package:test
51+
run: ./vendor/bin/testbench package:test --no-coverage

.github/workflows/update-changelog.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010

1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
with:
1515
ref: main
1616

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
}
1818
],
1919
"require": {
20-
"php": "^8.0|^8.1",
21-
"illuminate/support": "^9.0|^10.0|^11.0",
20+
"php": "^8.2",
21+
"illuminate/support": "^10.0|^11.0",
2222
"opis/closure": "^3.6"
2323
},
2424
"require-dev": {
25-
"brianium/paratest": "^6.2|^7.0.6",
26-
"nunomaduro/collision": "^5.3|^6.1|^7.0|^8.0",
25+
"brianium/paratest": "^7.0.6",
26+
"nunomaduro/collision": "^7.0|^8.0",
2727
"nunomaduro/larastan": "^2.0",
2828
"orchestra/testbench": "^8.0|^9.0",
2929
"phpstan/extension-installer": "^1.1",
30-
"phpunit/phpunit": "^10.0",
30+
"phpunit/phpunit": "^10.0|^11.0",
3131
"spatie/laravel-ray": "^1.9",
3232
"spatie/test-time": "^1.2"
3333
},

src/Console/Commands/PruneMailatorLogsCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ class PruneMailatorLogsCommand extends Command
1313

1414
public function handle(): void
1515
{
16-
$this->info(MailatorLog::prune(now()->subDays((int)$this->option('days'))) . ' entries pruned.');
16+
$this->info(
17+
MailatorLog::prune(
18+
now()->subDays((int)$this->option('days'))
19+
) . ' entries pruned.'
20+
);
1721
}
1822
}

src/Console/Commands/PruneMailatorScheduleCommand.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class PruneMailatorScheduleCommand extends Command
1313

1414
public function handle(): void
1515
{
16-
$this->info(MailatorSchedule::prune(now()->subDays((int)$this->option('days'))) . ' entries pruned.');
16+
$this->info(
17+
MailatorSchedule::prune(
18+
now()->subDays((int)$this->option('days')),
19+
['logs']
20+
) . ' entries pruned.'
21+
);
1722
}
1823
}

src/Constraints/AfterConstraint.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,44 @@ public function canSend(MailatorSchedule $schedule, Collection $logs): bool
2222
return false;
2323
}
2424

25+
$diff = (int) $schedule->timestamp_target->diffInDays(
26+
now()->floorSeconds(),
27+
absolute: true
28+
);
29+
2530
return $schedule->isOnce()
26-
? $schedule->timestamp_target->diffInDays(now()->floorSeconds()) === $schedule->toDays()
27-
: $schedule->timestamp_target->diffInDays(now()->floorSeconds()) > $schedule->toDays();
31+
? $diff === $schedule->toDays()
32+
: $diff > $schedule->toDays();
2833
}
2934

3035
if ($schedule->toHours() > 0) {
3136
if (now()->floorSeconds()->lt($schedule->timestampTarget()->addHours($schedule->toHours()))) {
3237
return false;
3338
}
3439

40+
$diff = (int) $schedule->timestamp_target->diffInHours(
41+
now()->floorSeconds(),
42+
absolute: true
43+
);
44+
3545
//till ends we should have at least toDays days
3646
return $schedule->isOnce()
37-
? $schedule->timestamp_target->diffInHours(now()->floorSeconds()) === $schedule->toHours()
38-
: $schedule->timestamp_target->diffInHours(now()->floorSeconds()) > $schedule->toHours();
47+
? $diff === $schedule->toHours()
48+
: $diff > $schedule->toHours();
3949
}
4050

4151
if (now()->floorSeconds()->lte($schedule->timestampTarget()->addMinutes($schedule->delay_minutes))) {
4252
return false;
4353
}
4454

55+
$diff = (int) $schedule->timestamp_target->diffInHours(
56+
now()->floorSeconds(),
57+
absolute: true
58+
);
59+
4560
//till ends we should have at least toDays days
4661
return $schedule->isOnce()
47-
? $schedule->timestamp_target->diffInHours(now()->floorSeconds()) === $schedule->delay_minutes
48-
: $schedule->timestamp_target->diffInHours(now()->floorSeconds()) > $schedule->delay_minutes;
62+
? $diff === $schedule->delay_minutes
63+
: $diff > $schedule->delay_minutes;
4964
}
5065
}

src/Constraints/BeforeConstraint.php

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,41 @@ public function canSend(MailatorSchedule $schedule, Collection $logs): bool
2727
return false;
2828
}
2929

30+
$diff = (int) $schedule->timestampTarget()->diffInDays(
31+
now()->floorSeconds(),
32+
absolute: true
33+
);
34+
3035
//till ends we should have at least toDays days
3136
return $schedule->isOnce()
32-
? $schedule->timestampTarget()->diffInDays(now()->floorSeconds()) === $schedule->toDays()
33-
: $schedule->timestampTarget()->diffInDays(now()->floorSeconds()) < $schedule->toDays();
37+
? $diff === $schedule->toDays()
38+
: $diff < $schedule->toDays();
3439
}
3540

3641
if ($schedule->toHours() > 0) {
3742
if (now()->floorSeconds()->gt($schedule->timestampTarget()->addHours($schedule->toHours()))) {
3843
return false;
3944
}
4045

46+
$diff = (int) $schedule->timestamp_target->diffInHours(
47+
now()->floorSeconds(),
48+
absolute: true
49+
);
50+
4151
//till ends we should have at least toHours days
4252
return $schedule->isOnce()
43-
? $schedule->timestamp_target->diffInHours(now()->floorSeconds()) === $schedule->toHours()
44-
: $schedule->timestamp_target->diffInHours(now()->floorSeconds()) < $schedule->toHours();
53+
? $diff === $schedule->toHours()
54+
: $diff < $schedule->toHours();
4555
}
4656

47-
57+
$diff = (int) $schedule->timestampTarget()->diffInDays(
58+
now()->floorSeconds(),
59+
absolute: true
60+
);
4861

4962
//till ends we should have at least toDays days
5063
return $schedule->isOnce()
51-
? $schedule->timestampTarget()->diffInDays(now()->floorSeconds()) === $schedule->toDays()
52-
: $schedule->timestampTarget()->diffInDays(now()->floorSeconds()) < $schedule->toDays();
64+
? $diff === $schedule->toDays()
65+
: $diff < $schedule->toDays();
5366
}
5467
}

0 commit comments

Comments
 (0)