Skip to content

Commit

Permalink
Add PHP 8.4 support, drop PHP 8.2 (#578)
Browse files Browse the repository at this point in the history
* Add PHP 8.4 support, drop PHP 8.2

* `laminas/laminas-mail` not yet released for PHP 8.4
  • Loading branch information
Slamdunk authored Sep 25, 2024
1 parent 1a6844c commit 2b47a91
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 48 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

steps:
- uses: "actions/checkout@v4"
Expand All @@ -39,11 +39,11 @@ jobs:
strategy:
matrix:
php-version:
- "8.3"
- "8.4"
code-coverage:
- "none"
include:
- php-version: "8.2"
- php-version: "8.3"
code-coverage: "pcov"

env:
Expand All @@ -62,6 +62,8 @@ jobs:
ini-values: "${{ env.INI_VALUES }}"
extensions: "imap"
- uses: "ramsey/composer-install@v3"
with:
composer-options: "--ignore-platform-req=php"

- run: "sh .github/dovecot_install.sh"

Expand Down Expand Up @@ -89,7 +91,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

steps:
- uses: "actions/checkout@v4"
Expand All @@ -108,7 +110,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.2"
- "8.3"

steps:
- uses: "actions/checkout@v4"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PHP_DOCKER_VERSION := thecodingmachine/php:8.2-v4-cli
PHP_DOCKER_VERSION := thecodingmachine/php:8.3-v4-cli
PHP_BIN := docker run -it --rm \
--network=ddeboer_imap_network \
--env IMAP_SERVER_NAME=ddeboer_imap_server \
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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

This library requires PHP >= 8.2 with [IMAP](https://www.php.net/manual/en/book.imap.php),
This library requires PHP >= 8.3 with [IMAP](https://www.php.net/manual/en/book.imap.php),
[iconv](https://www.php.net/manual/en/book.iconv.php) and
[Multibyte String](https://www.php.net/manual/en/book.mbstring.php) extensions installed.

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@
}
],
"require": {
"php": "~8.2.0 || ~8.3.0",
"php": "~8.3.0 || ~8.4.0",
"ext-dom": "*",
"ext-iconv": "*",
"ext-imap": "*",
"ext-libxml": "*",
"ext-mbstring": "*"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.50.0",
"friendsofphp/php-cs-fixer": "^3.64.0",
"laminas/laminas-mail": "^2.25.1",
"phpstan/phpstan": "^1.10.59",
"phpstan/phpstan-phpunit": "^1.3.16",
"phpstan/phpstan-strict-rules": "^1.5.2",
"phpunit/phpunit": "^11.0.3"
"phpstan/phpstan": "^1.12.4",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-strict-rules": "^1.6.1",
"phpunit/phpunit": "^11.3.6"
},
"autoload": {
"psr-4": {
Expand Down
10 changes: 10 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,13 @@ parameters:
message: "#^Cannot access property \\$parts on mixed\\.$#"
count: 2
path: tests/MessageTest.php

-
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayHasKey\\(\\) expects array\\|ArrayAccess\\<\\(int\\|string\\), mixed\\>, Ddeboer\\\\Imap\\\\Message\\\\Headers given\\.$#"
count: 3
path: tests/MessageTest.php

-
message: "#^Parameter \\#2 \\$array of static method PHPUnit\\\\Framework\\\\Assert\\:\\:assertArrayNotHasKey\\(\\) expects array\\|ArrayAccess\\<\\(int\\|string\\), mixed\\>, Ddeboer\\\\Imap\\\\Message\\\\Headers given\\.$#"
count: 2
path: tests/MessageTest.php
9 changes: 0 additions & 9 deletions src/Exception/MessageDeleteException.php

This file was deleted.

9 changes: 0 additions & 9 deletions src/Exception/MessageUndeleteException.php

This file was deleted.

11 changes: 3 additions & 8 deletions src/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@
use Ddeboer\Imap\Exception\ImapFetchheaderException;
use Ddeboer\Imap\Exception\InvalidHeadersException;
use Ddeboer\Imap\Exception\MessageCopyException;
use Ddeboer\Imap\Exception\MessageDeleteException;
use Ddeboer\Imap\Exception\MessageDoesNotExistException;
use Ddeboer\Imap\Exception\MessageMoveException;
use Ddeboer\Imap\Exception\MessageStructureException;
use Ddeboer\Imap\Exception\MessageUndeleteException;

/**
* An IMAP message (e-mail).
Expand Down Expand Up @@ -238,18 +236,15 @@ public function delete(): void
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to true on header
$this->clearHeaders();

if (!\imap_delete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID)) {
throw new MessageDeleteException(\sprintf('Message "%s" cannot be deleted', $this->getNumber()));
}
\imap_delete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID);
}

public function undelete(): void
{
// 'deleted' header changed, force to reload headers, would be better to set deleted flag to false on header
$this->clearHeaders();
if (!\imap_undelete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID)) {
throw new MessageUndeleteException(\sprintf('Message "%s" cannot be undeleted', $this->getNumber()));
}

\imap_undelete($this->resource->getStream(), (string) $this->getNumber(), \FT_UID);
}

public function setFlag(string $flag): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Message/AbstractPart.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __construct(
ImapResourceInterface $resource,
int $messageNumber,
string $partNumber,
\stdClass $structure
\stdClass $structure,
) {
$this->resource = $resource;
$this->messageNumber = $messageNumber;
Expand Down
6 changes: 0 additions & 6 deletions src/MessageInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
namespace Ddeboer\Imap;

use Ddeboer\Imap\Exception\MessageCopyException;
use Ddeboer\Imap\Exception\MessageDeleteException;
use Ddeboer\Imap\Exception\MessageMoveException;
use Ddeboer\Imap\Exception\MessageUndeleteException;

/**
* An IMAP message (e-mail).
Expand Down Expand Up @@ -82,15 +80,11 @@ public function move(MailboxInterface $mailbox): void;

/**
* Delete message.
*
* @throws MessageDeleteException
*/
public function delete(): void;

/**
* Undelete message.
*
* @throws MessageUndeleteException
*/
public function undelete(): void;

Expand Down
2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct(
string $flags = '/imap/ssl/validate-cert',
array $parameters = [],
int $options = 0,
int $retries = 1
int $retries = 1,
) {
if (!\function_exists('imap_open')) {
throw new \RuntimeException('IMAP extension must be enabled');
Expand Down
2 changes: 1 addition & 1 deletion tests/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ final protected function createTestMessage(
?string $contents = null,
?string $encoding = null,
?string $charset = null,
?string $overwriteCharset = null
?string $overwriteCharset = null,
): void {
$bodyPart = new Mime\Part($contents ?? \uniqid($subject));
$bodyPart->setType(Mime\Mime::TYPE_TEXT);
Expand Down

0 comments on commit 2b47a91

Please sign in to comment.