Skip to content

Commit a238641

Browse files
authored
Add PHP 8.2 support, drop PHP 8.0 support (#553)
1 parent 1a0a86e commit a238641

17 files changed

+50
-161
lines changed

.github/workflows/integrate.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ jobs:
1515
strategy:
1616
matrix:
1717
php-version:
18-
- "8.0"
18+
- "8.1"
1919

2020
steps:
2121
- name: "Checkout"
22-
uses: "actions/checkout@v2"
22+
uses: "actions/checkout@v3"
2323

2424
- name: "Install PHP"
2525
uses: "shivammathur/setup-php@v2"
@@ -33,7 +33,7 @@ jobs:
3333
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
3434

3535
- name: "Cache dependencies"
36-
uses: actions/cache@v2
36+
uses: "actions/cache@v3"
3737
with:
3838
path: ${{ steps.composercache.outputs.dir }}
3939
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
@@ -62,8 +62,8 @@ jobs:
6262
strategy:
6363
matrix:
6464
php-version:
65-
- "8.0"
6665
- "8.1"
66+
- "8.2"
6767

6868
env:
6969
IMAP_SERVER_NAME: dovecot.travis.dev
@@ -74,7 +74,7 @@ jobs:
7474

7575
steps:
7676
- name: "Checkout"
77-
uses: "actions/checkout@v2"
77+
uses: "actions/checkout@v3"
7878

7979
- name: "Start IMAPd services"
8080
run: "sh .github/dovecot_install.sh"
@@ -94,7 +94,7 @@ jobs:
9494
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
9595

9696
- name: "Cache dependencies"
97-
uses: actions/cache@v2
97+
uses: "actions/cache@v3"
9898
with:
9999
path: ${{ steps.composercache.outputs.dir }}
100100
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
@@ -104,17 +104,17 @@ jobs:
104104
run: "composer update --no-interaction --no-progress"
105105

106106
- name: "Run tests without coverage"
107-
if: ${{ matrix.php-version != '8.0' }}
107+
if: ${{ matrix.php-version != '8.1' }}
108108
timeout-minutes: 3
109109
run: "vendor/bin/phpunit --no-coverage --no-logging"
110110

111111
- name: "Run tests with coverage"
112-
if: ${{ matrix.php-version == '8.0' }}
112+
if: ${{ matrix.php-version == '8.1' }}
113113
timeout-minutes: 3
114114
run: "vendor/bin/phpunit --no-coverage --coverage-clover=coverage.xml"
115115

116116
- name: "Send code coverage report to Codecov.io"
117-
if: ${{ matrix.php-version == '8.0' }}
117+
if: ${{ matrix.php-version == '8.1' }}
118118
uses: codecov/codecov-action@v1
119119
with:
120120
token: ${{ secrets.CODECOV_TOKEN }}
@@ -129,11 +129,11 @@ jobs:
129129
strategy:
130130
matrix:
131131
php-version:
132-
- "8.0"
132+
- "8.1"
133133

134134
steps:
135135
- name: "Checkout"
136-
uses: "actions/checkout@v2"
136+
uses: "actions/checkout@v3"
137137

138138
- name: "Install PHP"
139139
uses: "shivammathur/setup-php@v2"
@@ -146,7 +146,7 @@ jobs:
146146
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
147147

148148
- name: "Cache dependencies"
149-
uses: actions/cache@v2
149+
uses: "actions/cache@v3"
150150
with:
151151
path: ${{ steps.composercache.outputs.dir }}
152152
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}
@@ -166,11 +166,11 @@ jobs:
166166
strategy:
167167
matrix:
168168
php-version:
169-
- "8.0"
169+
- "8.1"
170170

171171
steps:
172172
- name: "Checkout"
173-
uses: "actions/checkout@v2"
173+
uses: "actions/checkout@v3"
174174

175175
- name: "Install PHP"
176176
uses: "shivammathur/setup-php@v2"
@@ -184,7 +184,7 @@ jobs:
184184
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
185185

186186
- name: "Cache dependencies"
187-
uses: actions/cache@v2
187+
uses: "actions/cache@v3"
188188
with:
189189
path: ${{ steps.composercache.outputs.dir }}
190190
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ matrix.dependencies }}-composer-${{ hashFiles('**/composer.json') }}

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PHP_DOCKER_VERSION := thecodingmachine/php:8.0-v4-cli
1+
PHP_DOCKER_VERSION := thecodingmachine/php:8.1-v4-cli
22
PHP_BIN := docker run -it --rm \
33
--network=ddeboer_imap_network \
44
--env IMAP_SERVER_NAME=ddeboer_imap_server \
@@ -15,6 +15,7 @@ all: csfix static-analysis test
1515

1616
vendor: composer.json
1717
$(PHP_BIN) composer update
18+
$(PHP_BIN) composer bump
1819
touch vendor
1920

2021
.PHONY: csfix
@@ -23,7 +24,7 @@ csfix: vendor
2324

2425
.PHONY: static-analysis
2526
static-analysis: vendor
26-
$(PHP_BIN) vendor/bin/phpstan analyse
27+
$(PHP_BIN) vendor/bin/phpstan analyse $(PHPSTAN_FLAGS)
2728

2829
wait-for-it:
2930
wget -O wait-for-it "https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh"

README.md

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

88
A PHP IMAP library to read and process e-mails over IMAP protocol, built with robust Object-Oriented architecture.
99

10-
This library requires PHP >= 7.4 with [IMAP](https://www.php.net/manual/en/book.imap.php),
10+
This library requires PHP >= 8.1 with [IMAP](https://www.php.net/manual/en/book.imap.php),
1111
[iconv](https://www.php.net/manual/en/book.iconv.php) and
1212
[Multibyte String](https://www.php.net/manual/en/book.mbstring.php) extensions installed.
1313

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@
2222
}
2323
],
2424
"require": {
25-
"php": "^8.0.1",
25+
"php": "~8.1.0 || ~8.2.0",
2626
"ext-iconv": "*",
2727
"ext-imap": "*",
2828
"ext-mbstring": "*"
2929
},
3030
"require-dev": {
31-
"friendsofphp/php-cs-fixer": "^3.11",
32-
"laminas/laminas-mail": "^2.17",
33-
"phpstan/phpstan": "^1.8.4",
34-
"phpstan/phpstan-phpunit": "^1.1.1",
35-
"phpstan/phpstan-strict-rules": "^1.4.3",
36-
"phpunit/phpunit": "^9.5.24"
31+
"friendsofphp/php-cs-fixer": "^3.13.2",
32+
"laminas/laminas-mail": "^2.21.1",
33+
"phpstan/phpstan": "^1.9.8",
34+
"phpstan/phpstan-phpunit": "^1.3.3",
35+
"phpstan/phpstan-strict-rules": "^1.4.4",
36+
"phpunit/phpunit": "^9.5.27"
3737
},
3838
"autoload": {
3939
"psr-4": {

phpstan-baseline.neon

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,10 @@
11
parameters:
22
ignoreErrors:
3-
-
4-
message: "#^Class IMAP\\\\Connection not found\\.$#"
5-
count: 1
6-
path: src/ImapResource.php
7-
83
-
94
message: "#^If condition is always false\\.$#"
105
count: 1
116
path: src/ImapResource.php
127

13-
-
14-
message: "#^Instanceof between resource and IMAP\\\\Connection will always evaluate to false\\.$#"
15-
count: 1
16-
path: src/ImapResource.php
17-
18-
-
19-
message: "#^Parameter \\$resource of method Ddeboer\\\\Imap\\\\ImapResource\\:\\:__construct\\(\\) has invalid type IMAP\\\\Connection\\.$#"
20-
count: 1
21-
path: src/ImapResource.php
22-
23-
-
24-
message: "#^Property Ddeboer\\\\Imap\\\\ImapResource\\:\\:\\$resource \\(resource\\) does not accept IMAP\\\\Connection\\|resource\\.$#"
25-
count: 1
26-
path: src/ImapResource.php
27-
288
-
299
message: "#^Parameter \\#2 \\$array of function implode expects array\\<string\\>, array\\<int, Ddeboer\\\\Imap\\\\MessageInterface\\|int\\|string\\> given\\.$#"
3010
count: 1
@@ -160,11 +140,6 @@ parameters:
160140
count: 2
161141
path: tests/ConnectionTest.php
162142

163-
-
164-
message: "#^Parameter \\#1 \\$resource of class Ddeboer\\\\Imap\\\\ImapResource constructor expects IMAP\\\\Connection\\|resource, string given\\.$#"
165-
count: 1
166-
path: tests/ConnectionTest.php
167-
168143
-
169144
message: "#^Call to static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) with 'date' and \\*NEVER\\* will always evaluate to true\\.$#"
170145
count: 1

src/ConnectionInterface.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
use Ddeboer\Imap\Exception\CreateMailboxException;
88
use Ddeboer\Imap\Exception\DeleteMailboxException;
9-
use Ddeboer\Imap\Exception\InvalidResourceException;
109
use Ddeboer\Imap\Exception\MailboxDoesNotExistException;
1110

1211
/**
@@ -31,8 +30,6 @@ public function close(int $flag = 0): bool;
3130

3231
/**
3332
* Check if the connection is still active.
34-
*
35-
* @throws InvalidResourceException If connection was closed
3633
*/
3734
public function ping(): bool;
3835

src/Exception/InvalidResourceException.php

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/ImapResource.php

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

55
namespace Ddeboer\Imap;
66

7-
use Ddeboer\Imap\Exception\InvalidResourceException;
87
use Ddeboer\Imap\Exception\ReopenMailboxException;
98
use IMAP\Connection;
109

@@ -13,33 +12,21 @@
1312
*/
1413
final class ImapResource implements ImapResourceInterface
1514
{
16-
/**
17-
* @var resource
18-
*/
19-
private $resource;
15+
private Connection $resource;
2016
private ?MailboxInterface $mailbox = null;
2117
private static ?string $lastMailboxUsedCache = null;
2218

2319
/**
2420
* Constructor.
25-
*
26-
* @param Connection|resource $resource
2721
*/
28-
public function __construct($resource, MailboxInterface $mailbox = null)
22+
public function __construct(Connection $resource, MailboxInterface $mailbox = null)
2923
{
3024
$this->resource = $resource;
3125
$this->mailbox = $mailbox;
3226
}
3327

34-
public function getStream()
28+
public function getStream(): Connection
3529
{
36-
if (
37-
!$this->resource instanceof Connection
38-
&& (false === \is_resource($this->resource) || 'imap' !== \get_resource_type($this->resource))
39-
) {
40-
throw new InvalidResourceException('Supplied resource is not a valid imap resource');
41-
}
42-
4330
$this->initMailbox();
4431

4532
return $this->resource;
@@ -76,10 +63,8 @@ private function initMailbox(): void
7663

7764
/**
7865
* Check whether the current mailbox is open.
79-
*
80-
* @param resource $resource
8166
*/
82-
private static function isMailboxOpen(MailboxInterface $mailbox, $resource): bool
67+
private static function isMailboxOpen(MailboxInterface $mailbox, Connection $resource): bool
8368
{
8469
$currentMailboxName = $mailbox->getFullEncodedName();
8570
if ($currentMailboxName === self::$lastMailboxUsedCache) {

src/ImapResourceInterface.php

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

55
namespace Ddeboer\Imap;
66

7-
use Ddeboer\Imap\Exception\InvalidResourceException;
7+
use IMAP\Connection;
88

99
interface ImapResourceInterface
1010
{
1111
/**
1212
* Get IMAP resource stream.
13-
*
14-
* @throws InvalidResourceException
15-
*
16-
* @return resource
1713
*/
18-
public function getStream();
14+
public function getStream(): Connection;
1915

2016
/**
2117
* Clear last mailbox used cache.

src/Mailbox.php

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

55
namespace Ddeboer\Imap;
66

7-
use DateTimeInterface;
87
use Ddeboer\Imap\Exception\ImapNumMsgException;
98
use Ddeboer\Imap\Exception\ImapStatusException;
109
use Ddeboer\Imap\Exception\InvalidSearchCriteriaException;
@@ -196,7 +195,7 @@ public function getIterator(): MessageIteratorInterface
196195
return $this->getMessages();
197196
}
198197

199-
public function addMessage(string $message, string $options = null, DateTimeInterface $internalDate = null): bool
198+
public function addMessage(string $message, string $options = null, \DateTimeInterface $internalDate = null): bool
200199
{
201200
$arguments = [
202201
$this->resource->getStream(),

0 commit comments

Comments
 (0)