diff --git a/lib/public/Mail/Provider/IMessage.php b/lib/public/Mail/Provider/IMessage.php index ff2b52e5053cac777c2a873f1721a3828483d508..7102198136268a555542c3a8b9ce0043f9445ffb 100644 --- a/lib/public/Mail/Provider/IMessage.php +++ b/lib/public/Mail/Provider/IMessage.php @@ -83,9 +83,9 @@ interface IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all recipient mail address objects + * @param array<int,IAddress> collection of all recipient mail address objects */ - public function getTo(): array | null; + public function getTo(): array; /** * sets the copy to recipient(s) of this message @@ -103,9 +103,9 @@ interface IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all copied recipient mail address objects + * @param array<int,IAddress> collection of all copied recipient mail address objects */ - public function getCc(): array | null; + public function getCc(): array; /** * sets the blind copy to recipient(s) of this message @@ -123,9 +123,9 @@ interface IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all blind copied recipient mail address objects + * @param array<int,IAddress> collection of all blind copied recipient mail address objects */ - public function getBcc(): array | null; + public function getBcc(): array; /** * sets the subject of this message @@ -226,7 +226,7 @@ interface IMessage { * * @since 30.0.0 * - * @return array<int,IAttachment>|null collection of all mail attachment objects + * @return array<int,IAttachment> collection of all mail attachment objects */ - public function getAttachments(): array | null; + public function getAttachments(): array; } diff --git a/lib/public/Mail/Provider/IService.php b/lib/public/Mail/Provider/IService.php index 65056418c679832536a2a0aff7f4bd7e87b15805..677ad8f96589b613598408558e24475464ab8222 100644 --- a/lib/public/Mail/Provider/IService.php +++ b/lib/public/Mail/Provider/IService.php @@ -28,15 +28,24 @@ interface IService { public function id(): string; /** - * checks or retrieves what capabilites the service has + * checks if a service is able of performing an specific action * - * @since 30.0.0 + * @since 4.0.0 + * + * @param string $value required ability e.g. 'MessageSend' + * + * @return bool true/false if ability is supplied and found in collection + */ + public function capable(string $value): bool; + + /** + * retrieves a collection of what actions a service can perfrom * - * @param string $ability required ability e.g. 'MessageSend' + * @since 4.0.0 * - * @return bool|array true/false if ability is supplied, collection of abilities otherwise + * @return array collection of abilities otherwise empty collection */ - public function capable(?string $ability = null): bool | array; + public function capabilities(): array; /** * gets the localized human frendly name of this service diff --git a/lib/public/Mail/Provider/Message.php b/lib/public/Mail/Provider/Message.php index 8bf07b34f70f9269faa3944b6e8908227a3cf3c8..586389636402e0f71a348e4b93efbf35c9de6ad4 100644 --- a/lib/public/Mail/Provider/Message.php +++ b/lib/public/Mail/Provider/Message.php @@ -119,11 +119,11 @@ class Message implements \OCP\Mail\Provider\IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all recipient mail address objects + * @param array<int,IAddress> collection of all recipient mail address objects */ - public function getTo(): array | null { - // evaluate if data store field exists and return value(s) or null otherwise - return (isset($this->data['to'])) ? $this->data['to'] : null; + public function getTo(): array { + // evaluate if data store field exists and return value(s) or empty collection + return (isset($this->data['to'])) ? $this->data['to'] : []; } /** @@ -147,11 +147,11 @@ class Message implements \OCP\Mail\Provider\IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all copied recipient mail address objects + * @param array<int,IAddress> collection of all copied recipient mail address objects */ - public function getCc(): array | null { - // evaluate if data store field exists and return value(s) or null otherwise - return (isset($this->data['cc'])) ? $this->data['cc'] : null; + public function getCc(): array { + // evaluate if data store field exists and return value(s) or empty collection + return (isset($this->data['cc'])) ? $this->data['cc'] : []; } /** @@ -175,11 +175,11 @@ class Message implements \OCP\Mail\Provider\IMessage { * * @since 30.0.0 * - * @param array<int,IAddress>|null collection of all blind copied recipient mail address objects + * @param array<int,IAddress> collection of all blind copied recipient mail address objects */ - public function getBcc(): array | null { - // evaluate if data store field exists and return value(s) or null otherwise - return (isset($this->data['bcc'])) ? $this->data['bcc'] : null; + public function getBcc(): array { + // evaluate if data store field exists and return value(s) or empty collection + return (isset($this->data['bcc'])) ? $this->data['bcc'] : []; } /** diff --git a/tests/lib/Mail/Provider/AddressTest.php b/tests/lib/Mail/Provider/AddressTest.php index 5df22977bff2f017608368bd2907aa56a92b58b7..ee03f6f1e83c45806578c08ef3c75964d792eb7c 100644 --- a/tests/lib/Mail/Provider/AddressTest.php +++ b/tests/lib/Mail/Provider/AddressTest.php @@ -13,8 +13,8 @@ use Test\TestCase; class AddressTest extends TestCase { - /** @var Address*/ - private $address; + /** @var Address&MockObject */ + private Address $address; protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Mail/Provider/AttachmentTest.php b/tests/lib/Mail/Provider/AttachmentTest.php index e5b254aacb96b9babafb4cddd64bb6fafd7f7267..283391650b5890637860ff7ecdfb5a65a4a96243 100644 --- a/tests/lib/Mail/Provider/AttachmentTest.php +++ b/tests/lib/Mail/Provider/AttachmentTest.php @@ -13,8 +13,8 @@ use Test\TestCase; class AttachmentTest extends TestCase { - /** @var Attachment*/ - private $attachment; + /** @var Attachment&MockObject */ + private Attachment $attachment; protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Mail/Provider/ManagerTest.php b/tests/lib/Mail/Provider/ManagerTest.php index 76ed953cfda2048f38414b469c753cb6ac96a071..2658c324521036dff1d9fdcd0d0f2fecdcd5e08f 100644 --- a/tests/lib/Mail/Provider/ManagerTest.php +++ b/tests/lib/Mail/Provider/ManagerTest.php @@ -21,16 +21,16 @@ use Test\TestCase; class ManagerTest extends TestCase { - /** @var CoordinatorMockObject*/ - private $coordinator; - /** @var ContainerInterfaceMockObject*/ - private $container; - /** @var LoggerInterfaceMockObject*/ - private $logger; - /** @var IProviderMockObject*/ - private $provider; - /** @var IServiceMockObject*/ - private $service; + /** @var Coordinator&MockObject */ + private Coordinator $coordinator; + /** @var ContainerInterface&MockObject */ + private ContainerInterface $container; + /** @var LoggerInterface&MockObject */ + private LoggerInterface $logger; + /** @var IProvider&MockObject */ + private IProvider $provider; + /** @var IService&MockObject */ + private IService $service; protected function setUp(): void { parent::setUp(); diff --git a/tests/lib/Mail/Provider/MessageTest.php b/tests/lib/Mail/Provider/MessageTest.php index 546d1f87e32b6cbd44772a7d4e4b838ab7d62058..1791a03421c39f63a5e854c91207e032c3462430 100644 --- a/tests/lib/Mail/Provider/MessageTest.php +++ b/tests/lib/Mail/Provider/MessageTest.php @@ -15,16 +15,16 @@ use Test\TestCase; class MessageTest extends TestCase { - /** @var Message*/ - private $message; - /** @var Address*/ - private $address1; - /** @var Address*/ - private $address2; - /** @var Attachment*/ - private $attachment1; - /** @var Attachment*/ - private $attachment2; + /** @var Message&MockObject */ + private Message $message; + /** @var Address&MockObject */ + private Address $address1; + /** @var Address&MockObject */ + private Address $address2; + /** @var Attachment&MockObject */ + private Attachment $attachment1; + /** @var Attachment&MockObject */ + private Attachment $attachment2; protected function setUp(): void { parent::setUp(); @@ -85,7 +85,7 @@ class MessageTest extends TestCase { public function testTo(): void { // test not set - $this->assertNull($this->message->getTo()); + $this->assertEquals([], $this->message->getTo()); // test set by setter single $this->message->setTo($this->address1); $this->assertEquals([$this->address1], $this->message->getTo()); @@ -98,7 +98,7 @@ class MessageTest extends TestCase { public function testCc(): void { // test not set - $this->assertNull($this->message->getCc()); + $this->assertEquals([], $this->message->getCc()); // test set by setter single $this->message->setCc($this->address1); $this->assertEquals([$this->address1], $this->message->getCc()); @@ -111,7 +111,7 @@ class MessageTest extends TestCase { public function testBcc(): void { // test not set - $this->assertNull($this->message->getBcc()); + $this->assertEquals([], $this->message->getBcc()); // test set by setter single $this->message->setBcc($this->address1); $this->assertEquals([$this->address1], $this->message->getBcc());