From 59ece56647fffcfaf36a1a6f82fcff5566bc4f1f Mon Sep 17 00:00:00 2001 From: Nguyen Van Nguyen Date: Tue, 23 Apr 2024 15:25:55 +0700 Subject: [PATCH] WIP Signed-off-by: Nguyen Van Nguyen --- phpstan.neon | 2 ++ src/Admin/Struct/ReindexMailboxInfo.php | 8 ++++++-- src/Common/Struct/WaitSetAddSpec.php | 2 +- src/Mail/Message/CreateWaitSetRequest.php | 3 ++- src/Mail/Message/CreateWaitSetResponse.php | 3 ++- src/Mail/Message/WaitSetRequest.php | 3 ++- src/Mail/Struct/MailSearchParams.php | 6 ++++-- 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index f0609e132..ff66fbfae 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,5 +4,7 @@ parameters: - src/Account/AccountApi.php - src/Admin/AdminApi.php - src/Mail/MailApi.php + ignoreErrors: + - '~has invalid type Doctrine\\Common\\Annotations\\Reader~' paths: - src diff --git a/src/Admin/Struct/ReindexMailboxInfo.php b/src/Admin/Struct/ReindexMailboxInfo.php index 8f67b980c..55905e5e5 100644 --- a/src/Admin/Struct/ReindexMailboxInfo.php +++ b/src/Admin/Struct/ReindexMailboxInfo.php @@ -119,8 +119,12 @@ public function getTypes(): ?string */ public function setTypes(string $types): self { - $types = array_map(static fn ($type) => trim($type), explode(',', $types)); - $types = array_filter($types, static fn ($type) => ReindexType::tryFrom($type)); + $types = array_filter( + array_map( + static fn ($type) => trim($type), explode(',', $types) + ), + static fn ($type) => ReindexType::tryFrom($type) !== null + ); $this->types = implode(',', array_unique($types)); return $this; } diff --git a/src/Common/Struct/WaitSetAddSpec.php b/src/Common/Struct/WaitSetAddSpec.php index e2503168d..46ab82a24 100755 --- a/src/Common/Struct/WaitSetAddSpec.php +++ b/src/Common/Struct/WaitSetAddSpec.php @@ -190,7 +190,7 @@ public function setInterests(string $interests): self { $types = array_filter( explode(',', $interests), - static fn ($type) => InterestType::tryFrom($type) + static fn ($type) => InterestType::tryFrom($type) !== null ); $this->interests = !empty($types) ? implode(',', array_unique($types)) : null; return $this; diff --git a/src/Mail/Message/CreateWaitSetRequest.php b/src/Mail/Message/CreateWaitSetRequest.php index 4f090640a..8e72633a0 100644 --- a/src/Mail/Message/CreateWaitSetRequest.php +++ b/src/Mail/Message/CreateWaitSetRequest.php @@ -153,7 +153,8 @@ public function getDefaultInterests(): string public function setDefaultInterests(string $defaultInterests): self { $types = array_filter( - explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type) + explode(',', $defaultInterests), + static fn ($type) => InterestType::tryFrom($type) !== null ); $this->defaultInterests = implode(',', array_unique($types)); return $this; diff --git a/src/Mail/Message/CreateWaitSetResponse.php b/src/Mail/Message/CreateWaitSetResponse.php index 5bd1d2a9c..361c8f5d1 100644 --- a/src/Mail/Message/CreateWaitSetResponse.php +++ b/src/Mail/Message/CreateWaitSetResponse.php @@ -146,7 +146,8 @@ public function getDefaultInterests(): ?string public function setDefaultInterests(string $defaultInterests): self { $types = array_filter( - explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type) + explode(',', $defaultInterests), + static fn ($type) => InterestType::tryFrom($type) !== null ); $this->defaultInterests = implode(',', array_unique($types)); return $this; diff --git a/src/Mail/Message/WaitSetRequest.php b/src/Mail/Message/WaitSetRequest.php index 0bd5926a0..23595ba75 100644 --- a/src/Mail/Message/WaitSetRequest.php +++ b/src/Mail/Message/WaitSetRequest.php @@ -286,7 +286,8 @@ public function getDefaultInterests(): ?string public function setDefaultInterests(string $defaultInterests): self { $types = array_filter( - explode(',', $defaultInterests), static fn ($type) => InterestType::tryFrom($type) + explode(',', $defaultInterests), + static fn ($type) => InterestType::tryFrom($type) !== null ); $this->defaultInterests = implode(',', array_unique($types)); return $this; diff --git a/src/Mail/Struct/MailSearchParams.php b/src/Mail/Struct/MailSearchParams.php index 2d50c3658..f600f3271 100644 --- a/src/Mail/Struct/MailSearchParams.php +++ b/src/Mail/Struct/MailSearchParams.php @@ -466,7 +466,8 @@ public function getAllowableTaskStatus(): ?string public function setAllowableTaskStatus(string $allowableTaskStatus): self { $taskStatuses = array_filter( - explode(',', $allowableTaskStatus), static fn($status) => TaskStatus::tryFrom(trim($status)) + explode(',', $allowableTaskStatus), + static fn($status) => TaskStatus::tryFrom(trim($status)) !== null ); $this->allowableTaskStatus = implode(',', $taskStatuses); return $this; @@ -579,7 +580,8 @@ public function getSearchTypes(): ?string public function setSearchTypes(string $searchTypes): self { $validTypes = array_filter( - explode(',', $searchTypes), static fn($type) => SearchType::tryFrom(trim($type)) + explode(',', $searchTypes), + static fn($type) => SearchType::tryFrom(trim($type)) !== null ); $this->searchTypes = implode(',', $validTypes); return $this;