From 91610d422441496c6ce77e4c13d65d056b2be65a Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Thu, 17 Mar 2022 10:39:25 +0100 Subject: [PATCH] Add PHP8.1 support Signed-off-by: Christoph Wurst --- .github/workflows/lint.yml | 4 +-- .github/workflows/test.yml | 41 ++++++++++++++++++-------- appinfo/info.xml | 2 +- composer.json | 2 +- composer.lock | 12 ++++---- lib/Account.php | 5 ++-- lib/Address.php | 7 ++--- lib/AddressList.php | 5 ++-- lib/Db/Alias.php | 4 ++- lib/Db/LocalAttachment.php | 2 ++ lib/Db/LocalMessage.php | 5 ++-- lib/Db/Mailbox.php | 2 ++ lib/Db/Message.php | 2 ++ lib/Db/Provisioning.php | 5 ++-- lib/Db/Recipient.php | 4 ++- lib/Db/Tag.php | 6 ++-- lib/Db/TrustedSender.php | 2 ++ lib/IMAP/MailboxStats.php | 2 ++ lib/IMAP/Sync/Response.php | 4 ++- lib/IMAP/Threading/DatabaseMessage.php | 4 ++- lib/IMAP/Threading/Message.php | 4 ++- lib/Model/IMAPMessage.php | 7 ++--- lib/Service/Avatar/Avatar.php | 7 ++--- lib/Service/Quota.php | 2 ++ tests/phpunit.integration.xml | 12 +++++++- tests/phpunit.unit.xml | 12 +++++++- 26 files changed, 108 insertions(+), 56 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 91c309969e..287a934302 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [7.4, 8.0] + php-versions: ['7.4', '8.0', '8.1'] name: php${{ matrix.php-versions }} lint steps: - name: Checkout @@ -41,7 +41,7 @@ jobs: - name: Set up php uses: shivammathur/setup-php@master with: - php-version: 7.4 + php-version: '8.0' coverage: none - name: Install dependencies run: composer i diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59051d6c3e..e2b7d9738a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,16 +12,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [7.4] + php-versions: ['8.0'] nextcloud-versions: ['stable22', 'stable23'] include: - php-versions: 7.4 nextcloud-versions: stable24 - - php-versions: 8.0 - nextcloud-versions: stable24 - - php-versions: 7.4 - nextcloud-versions: master - - php-versions: 8.0 + - php-versions: 8.1 nextcloud-versions: master name: Nextcloud ${{ matrix.nextcloud-versions }} php${{ matrix.php-versions }} unit tests steps: @@ -49,11 +45,18 @@ jobs: - name: Run tests working-directory: nextcloud/apps/mail run: composer run test:unit + if: ${{ matrix.php-versions == '8.0' }} env: XDEBUG_MODE: coverage + - name: Run tests + working-directory: nextcloud/apps/mail + run: composer run test:unit + if: ${{ matrix.php-versions != '8.0' }} + env: + XDEBUG_MODE: off - name: Report coverage uses: codecov/codecov-action@v3.1.0 - if: ${{ always() && matrix.nextcloud-versions == 'master' }} + if: ${{ always() && matrix.php-versions == '8.0' }} with: file: ./nextcloud/apps/mail/tests/clover.unit.xml flags: unittests @@ -63,9 +66,19 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-versions: [7.4, 8.0] + php-versions: ['8.0'] nextcloud-versions: ['master'] db: ['sqlite', 'mysql', 'pgsql'] + include: + - php-versions: 7.4 + nextcloud-versions: stable22 + db: 'mysql' + - php-versions: 8.0 + nextcloud-versions: stable23 + db: 'mysql' + - php-versions: 8.1 + nextcloud-versions: stable24 + db: 'pgsql' name: php${{ matrix.php-versions }}-${{ matrix.db }} integration tests services: mail-service: @@ -138,12 +151,16 @@ jobs: echo "SET GLOBAL log_output = 'table';" | mysql -h 127.0.0.1 -u root -pmy-secret-pw - name: Run tests working-directory: nextcloud/apps/mail - run: | - ss -tunlp - true | openssl s_client -crlf -connect 127.0.0.1:993 - composer run test:integration + if: ${{ matrix.db == 'mysql' }} + run: composer run test:integration env: XDEBUG_MODE: coverage + - name: Run tests + working-directory: nextcloud/apps/mail + if: ${{ matrix.db != 'mysql' }} + run: composer run test:integration + env: + XDEBUG_MODE: off - name: Read slow queries if: ${{ always() }} run: echo "SELECT * FROM mysql.slow_log WHERE sql_text LIKE '%oc_mail%' AND sql_text NOT LIKE '%information_schema%'" | mysql -h 127.0.0.1 -u root -pmy-secret-pw diff --git a/appinfo/info.xml b/appinfo/info.xml index 7ff678d6a2..45d5eec8de 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -29,7 +29,7 @@ https://github.com/nextcloud/mail.git https://user-images.githubusercontent.com/1374172/79554966-278e1600-809f-11ea-82ea-7a0d72a2704f.png - + diff --git a/composer.json b/composer.json index 6734064465..ecb1a7898b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } }, "require": { - "php": ">=7.4", + "php": ">=7.4 <=8.1", "arthurhoaro/favicon": "^1.2", "bamarni/composer-bin-plugin": "^1.4", "bytestream/horde-exception": "^2.1", diff --git a/composer.lock b/composer.lock index ef22860869..6058939928 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b1c307444d66ee5ad260eb0d712b61dc", + "content-hash": "bf60d7f2e2448119556c1841143408d3", "packages": [ { "name": "amphp/amp", @@ -367,12 +367,12 @@ }, "type": "library", "autoload": { - "files": [ - "src/functions.php" - ], "psr-4": { "Amp\\Serialization\\": "src" - } + }, + "files": [ + "src/functions.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -3101,7 +3101,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=7.4 <=8.1" }, "platform-dev": [], "platform-overrides": { diff --git a/lib/Account.php b/lib/Account.php index c6c3bb2f4c..0d285331f8 100644 --- a/lib/Account.php +++ b/lib/Account.php @@ -50,6 +50,7 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\Security\ICrypto; +use ReturnTypeWillChange; class Account implements JsonSerializable { @@ -189,9 +190,7 @@ public function getMailbox($folderId) { ); } - /** - * @return array - */ + #[ReturnTypeWillChange] public function jsonSerialize() { return $this->account->toJson(); } diff --git a/lib/Address.php b/lib/Address.php index 119659b278..abc93d75cc 100644 --- a/lib/Address.php +++ b/lib/Address.php @@ -28,6 +28,7 @@ use Horde_Mail_Rfc822_Address; use JsonSerializable; +use ReturnTypeWillChange; /** * @psalm-immutable @@ -99,10 +100,8 @@ public function toHorde(): Horde_Mail_Rfc822_Address { return $this->wrapped; } - /** - * @return array - */ - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'label' => $this->getLabel(), 'email' => $this->getEmail(), diff --git a/lib/AddressList.php b/lib/AddressList.php index 389395eca0..bb06242db6 100644 --- a/lib/AddressList.php +++ b/lib/AddressList.php @@ -31,6 +31,7 @@ use Horde_Mail_Rfc822_List; use Horde_Mail_Rfc822_Object; use JsonSerializable; +use ReturnTypeWillChange; /** * @psalm-immutable @@ -95,9 +96,7 @@ public function first() { return $this->addresses[0]; } - /** - * @return array - */ + #[ReturnTypeWillChange] public function jsonSerialize() { return array_map(function (Address $address) { return $address->jsonSerialize(); diff --git a/lib/Db/Alias.php b/lib/Db/Alias.php index 8126826785..76ff18aa61 100644 --- a/lib/Db/Alias.php +++ b/lib/Db/Alias.php @@ -25,6 +25,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; /** * @method void setAccountId(int $accountId) @@ -66,7 +67,8 @@ public function isProvisioned(): bool { return $this->getProvisioningId() !== null; } - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'id' => $this->getId(), 'name' => $this->getName(), diff --git a/lib/Db/LocalAttachment.php b/lib/Db/LocalAttachment.php index 9b64bf8559..20771cde1f 100644 --- a/lib/Db/LocalAttachment.php +++ b/lib/Db/LocalAttachment.php @@ -26,6 +26,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; /** * @method string getUserId() @@ -56,6 +57,7 @@ class LocalAttachment extends Entity implements JsonSerializable { /** @var int|null */ protected $localMessageId; + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->id, diff --git a/lib/Db/LocalMessage.php b/lib/Db/LocalMessage.php index 5adf551a01..b555b890da 100644 --- a/lib/Db/LocalMessage.php +++ b/lib/Db/LocalMessage.php @@ -27,6 +27,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; use function array_filter; /** @@ -92,9 +93,7 @@ public function __construct() { $this->addType('html', 'boolean'); } - /** - * @return array - */ + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->getId(), diff --git a/lib/Db/Mailbox.php b/lib/Db/Mailbox.php index 1df1c86a32..a0b78e2e9b 100644 --- a/lib/Db/Mailbox.php +++ b/lib/Db/Mailbox.php @@ -28,6 +28,7 @@ use JsonSerializable; use OCA\Mail\IMAP\MailboxStats; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; use function base64_encode; use function in_array; use function json_decode; @@ -146,6 +147,7 @@ public function getStats(): MailboxStats { return new MailboxStats($this->getMessages(), $this->getUnseen()); } + #[ReturnTypeWillChange] public function jsonSerialize() { $specialUse = $this->getSpecialUseParsed(); return [ diff --git a/lib/Db/Message.php b/lib/Db/Message.php index e989f21f1c..5eb1c5141d 100644 --- a/lib/Db/Message.php +++ b/lib/Db/Message.php @@ -29,6 +29,7 @@ use JsonSerializable; use OCA\Mail\AddressList; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; use function in_array; use function json_decode; use function json_encode; @@ -274,6 +275,7 @@ public function setFlag(string $flag, bool $value = true) { } } + #[ReturnTypeWillChange] public function jsonSerialize() { $tags = $this->getTags(); $indexed = array_combine( diff --git a/lib/Db/Provisioning.php b/lib/Db/Provisioning.php index b29afa91c1..20eec71c5b 100644 --- a/lib/Db/Provisioning.php +++ b/lib/Db/Provisioning.php @@ -28,6 +28,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; use OCP\IUser; +use ReturnTypeWillChange; /** * @method string getProvisioningDomain() @@ -97,9 +98,7 @@ public function __construct() { $this->addType('ldapAliasesProvisioning', 'boolean'); } - /** - * @return array - */ + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->getId(), diff --git a/lib/Db/Recipient.php b/lib/Db/Recipient.php index 5bfb276f80..14d46462e4 100644 --- a/lib/Db/Recipient.php +++ b/lib/Db/Recipient.php @@ -28,6 +28,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; /** * @method int|null getMessageId() @@ -72,7 +73,8 @@ public function __construct() { $this->addType('mailboxType', 'integer'); } - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'id' => $this->getId(), 'messageId' => $this->getMessageId(), diff --git a/lib/Db/Tag.php b/lib/Db/Tag.php index fd32160f43..5a064d1a71 100644 --- a/lib/Db/Tag.php +++ b/lib/Db/Tag.php @@ -27,6 +27,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; /** * @method string getUserId() @@ -56,9 +57,8 @@ class Tag extends Entity implements JsonSerializable { public function __construct() { $this->addType('isDefaultTag', 'boolean'); } - /** - * @return array - */ + + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->getId(), diff --git a/lib/Db/TrustedSender.php b/lib/Db/TrustedSender.php index 3425c056a0..3816b3fa0c 100644 --- a/lib/Db/TrustedSender.php +++ b/lib/Db/TrustedSender.php @@ -27,6 +27,7 @@ use JsonSerializable; use OCP\AppFramework\Db\Entity; +use ReturnTypeWillChange; /** * @method setEmail(string $email): void @@ -47,6 +48,7 @@ class TrustedSender extends Entity implements JsonSerializable { /** @var string */ protected $type; + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'id' => $this->id, diff --git a/lib/IMAP/MailboxStats.php b/lib/IMAP/MailboxStats.php index 9af3c04528..0f66e2b48b 100644 --- a/lib/IMAP/MailboxStats.php +++ b/lib/IMAP/MailboxStats.php @@ -27,6 +27,7 @@ namespace OCA\Mail\IMAP; use JsonSerializable; +use ReturnTypeWillChange; class MailboxStats implements JsonSerializable { @@ -55,6 +56,7 @@ public function getUnread(): int { return $this->unread; } + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'total' => $this->total, diff --git a/lib/IMAP/Sync/Response.php b/lib/IMAP/Sync/Response.php index a1e47675bb..271d81395e 100644 --- a/lib/IMAP/Sync/Response.php +++ b/lib/IMAP/Sync/Response.php @@ -25,6 +25,7 @@ use JsonSerializable; use OCA\Mail\IMAP\MailboxStats; +use ReturnTypeWillChange; /** * @psalm-template T @@ -87,7 +88,8 @@ public function getStats(): MailboxStats { return $this->stats; } - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'newMessages' => $this->newMessages, 'changedMessages' => $this->changedMessages, diff --git a/lib/IMAP/Threading/DatabaseMessage.php b/lib/IMAP/Threading/DatabaseMessage.php index da79522ce3..e158ac7cc4 100644 --- a/lib/IMAP/Threading/DatabaseMessage.php +++ b/lib/IMAP/Threading/DatabaseMessage.php @@ -26,6 +26,7 @@ namespace OCA\Mail\IMAP\Threading; use JsonSerializable; +use ReturnTypeWillChange; use function array_map; use function array_merge; use function json_decode; @@ -104,7 +105,8 @@ public function redact(callable $hash): DatabaseMessage { ); } - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return array_merge( parent::jsonSerialize(), [ diff --git a/lib/IMAP/Threading/Message.php b/lib/IMAP/Threading/Message.php index 8fd7170ae3..8966069324 100644 --- a/lib/IMAP/Threading/Message.php +++ b/lib/IMAP/Threading/Message.php @@ -26,6 +26,7 @@ namespace OCA\Mail\IMAP\Threading; use JsonSerializable; +use ReturnTypeWillChange; use function str_replace; use function strpos; @@ -74,7 +75,8 @@ public function getReferences(): array { return $this->references; } - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'subject' => $this->subject, 'id' => $this->id, diff --git a/lib/Model/IMAPMessage.php b/lib/Model/IMAPMessage.php index 67dac0237d..bc229c1246 100644 --- a/lib/Model/IMAPMessage.php +++ b/lib/Model/IMAPMessage.php @@ -52,6 +52,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\Files\File; use OCP\Files\SimpleFS\ISimpleFile; +use ReturnTypeWillChange; use function fclose; use function in_array; use function mb_convert_encoding; @@ -494,10 +495,8 @@ public function getFullMessage(int $id): array { return $data; } - /** - * @return array - */ - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'uid' => $this->getUid(), 'messageId' => $this->getMessageId(), diff --git a/lib/Service/Avatar/Avatar.php b/lib/Service/Avatar/Avatar.php index c8e11ff00f..fafcbcc26b 100644 --- a/lib/Service/Avatar/Avatar.php +++ b/lib/Service/Avatar/Avatar.php @@ -27,6 +27,7 @@ namespace OCA\Mail\Service\Avatar; use JsonSerializable; +use ReturnTypeWillChange; /** * @psalm-immutable @@ -76,10 +77,8 @@ public function isExternal(): bool { return $this->isExternal; } - /** - * @return array - */ - public function jsonSerialize(): array { + #[ReturnTypeWillChange] + public function jsonSerialize() { return [ 'isExternal' => $this->isExternal, 'mime' => $this->mime, diff --git a/lib/Service/Quota.php b/lib/Service/Quota.php index 2f23aa7505..130cf6a859 100644 --- a/lib/Service/Quota.php +++ b/lib/Service/Quota.php @@ -26,6 +26,7 @@ namespace OCA\Mail\Service; use JsonSerializable; +use ReturnTypeWillChange; class Quota implements JsonSerializable { @@ -49,6 +50,7 @@ public function getLimit(): int { return $this->limit; } + #[ReturnTypeWillChange] public function jsonSerialize() { return [ 'usage' => $this->getUsage(), diff --git a/tests/phpunit.integration.xml b/tests/phpunit.integration.xml index 507e2e9365..8fead61704 100644 --- a/tests/phpunit.integration.xml +++ b/tests/phpunit.integration.xml @@ -19,7 +19,17 @@ ~ You should have received a copy of the GNU Affero General Public License ~ along with this program. If not, see . --> - + ../lib diff --git a/tests/phpunit.unit.xml b/tests/phpunit.unit.xml index a35b99f331..a8ad8445ff 100644 --- a/tests/phpunit.unit.xml +++ b/tests/phpunit.unit.xml @@ -1,5 +1,15 @@ - + ../lib