diff --git a/lib/Cache/Cache.php b/lib/Cache/Cache.php index fc1cbc8c5c..ea49e80990 100644 --- a/lib/Cache/Cache.php +++ b/lib/Cache/Cache.php @@ -230,7 +230,7 @@ public function getMetaData($mailbox, $uidvalid, $entries) { * @return void */ public function setMetaData($mailbox, $data) { - $this->_loadSliceMap($mailbox, isset($data['uidvalid']) ? $data['uidvalid'] : null); + $this->_loadSliceMap($mailbox, $data['uidvalid'] ?? null); $this->_slicemap[$mailbox]['d'] = array_merge($this->_slicemap[$mailbox]['d'], $data); $this->_toUpdate($mailbox, 'slicemap', true); } diff --git a/lib/Command/ExportAccount.php b/lib/Command/ExportAccount.php index 0b9e74949d..6039dbaf3e 100644 --- a/lib/Command/ExportAccount.php +++ b/lib/Command/ExportAccount.php @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $output->writeln('Account ' . $account->getId() . ':'); $output->writeln('- E-Mail: ' . $account->getEmail()); $output->writeln('- Name: ' . $account->getName()); - $output->writeln('- Provision: ' . ($account->getMailAccount()->getProvisioningId() ? 'set' : 'none'). ' ID: ' . ($account->getMailAccount()->getProvisioningId() ? $account->getMailAccount()->getProvisioningId():'N/A')); + $output->writeln('- Provision: ' . ($account->getMailAccount()->getProvisioningId() ? 'set' : 'none'). ' ID: ' . ($account->getMailAccount()->getProvisioningId() ?: 'N/A')); $output->writeln('- IMAP user: ' . $account->getMailAccount()->getInboundUser()); $output->writeln('- IMAP host: ' . $account->getMailAccount()->getInboundHost() . ':' . $account->getMailAccount()->getInboundPort() . ', security: ' . $account->getMailAccount()->getInboundSslMode()); $output->writeln('- SMTP user: ' . $account->getMailAccount()->getOutboundUser()); diff --git a/lib/Service/AiIntegrations/Cache.php b/lib/Service/AiIntegrations/Cache.php index 1d9d6775f2..c4905f61b9 100644 --- a/lib/Service/AiIntegrations/Cache.php +++ b/lib/Service/AiIntegrations/Cache.php @@ -55,7 +55,7 @@ public function getValue(string $key) { * @return void */ public function addValue(string $key, ?string $value): void { - $this->cache->set($key, $value === null ? false : $value, self::CACHE_TTL); + $this->cache->set($key, $value ?? false, self::CACHE_TTL); } diff --git a/lib/Service/Attachment/UploadedFile.php b/lib/Service/Attachment/UploadedFile.php index 7a1d88eaf5..f31bb6334b 100644 --- a/lib/Service/Attachment/UploadedFile.php +++ b/lib/Service/Attachment/UploadedFile.php @@ -24,20 +24,20 @@ public function __construct(array $fileData) { * @return string|null */ public function getFileName() { - return isset($this->fileData['name']) ? $this->fileData['name'] : null; + return $this->fileData['name'] ?? null; } /** * @return string|null */ public function getTempPath() { - return isset($this->fileData['tmp_name']) ? $this->fileData['tmp_name'] : null; + return $this->fileData['tmp_name'] ?? null; } /** * @return string */ public function getMimeType() { - return isset($this->fileData['type']) ? $this->fileData['type'] : 'application/octet-stream'; + return $this->fileData['type'] ?? 'application/octet-stream'; } } diff --git a/rector.php b/rector.php index 433aac517a..aec92a3cd6 100644 --- a/rector.php +++ b/rector.php @@ -20,4 +20,7 @@ ->withPreparedSets( phpunitCodeQuality: true, phpunit: true, + ) + ->withPhpSets( + php73: true, ); diff --git a/tests/Integration/Db/CollectedAddressMapperTest.php b/tests/Integration/Db/CollectedAddressMapperTest.php index 3b1a915652..76ebd09a9b 100644 --- a/tests/Integration/Db/CollectedAddressMapperTest.php +++ b/tests/Integration/Db/CollectedAddressMapperTest.php @@ -104,7 +104,7 @@ public function testFindMatching($query, $result) { $this->assertCount(\count($result), $matches); $i = 0; foreach ($matches as $match) { - $this->assertInstanceOf('\OCA\Mail\Db\CollectedAddress', $match); + $this->assertInstanceOf(\OCA\Mail\Db\CollectedAddress::class, $match); $this->assertContains($match->getEmail(), $result); $this->assertEquals($this->userId, $match->getUserId()); $i++; diff --git a/tests/Integration/Db/RecipientMapperTest.php b/tests/Integration/Db/RecipientMapperTest.php index 96b3d73119..3422621e25 100644 --- a/tests/Integration/Db/RecipientMapperTest.php +++ b/tests/Integration/Db/RecipientMapperTest.php @@ -172,7 +172,7 @@ public function testUpdateRecipients(): void { $penny->setEmail('penny@stardewvalleylibrary.edu'); $penny->setLabel('Penny'); $penny->setType(Recipient::TYPE_TO); - $this->mapper->saveRecipients($message->getId(), [$penny], Recipient::TYPE_BCC); + $this->mapper->saveRecipients($message->getId(), [$penny]); $results = $this->mapper->findByLocalMessageId($message->getId()); $this->assertCount(1, $results); diff --git a/tests/Integration/Service/MailTransmissionIntegrationTest.php b/tests/Integration/Service/MailTransmissionIntegrationTest.php index 2f23543851..66653c1565 100644 --- a/tests/Integration/Service/MailTransmissionIntegrationTest.php +++ b/tests/Integration/Service/MailTransmissionIntegrationTest.php @@ -151,7 +151,7 @@ public function testSendMail() { public function testSendMailWithLocalAttachment() { $file = new UploadedFile([ 'name' => 'text.txt', - 'tmp_name' => dirname(__FILE__) . '/../../data/mail-message-123.txt', + 'tmp_name' => __DIR__ . '/../../data/mail-message-123.txt', ]); $localAttachment = $this->attachmentService->addFile($this->user->getUID(), $file); diff --git a/tests/Unit/Command/CreateAccountTest.php b/tests/Unit/Command/CreateAccountTest.php index d43b7d6f88..e95aba3399 100644 --- a/tests/Unit/Command/CreateAccountTest.php +++ b/tests/Unit/Command/CreateAccountTest.php @@ -41,7 +41,7 @@ class CreateAccountTest extends TestCase { protected function setUp(): void { parent::setUp(); - $this->service = $this->getMockBuilder('\OCA\Mail\Service\AccountService') + $this->service = $this->getMockBuilder(\OCA\Mail\Service\AccountService::class) ->disableOriginalConstructor() ->getMock(); $this->crypto = $this->getMockBuilder('\OCP\Security\ICrypto')->getMock(); diff --git a/tests/Unit/Controller/AliasesControllerTest.php b/tests/Unit/Controller/AliasesControllerTest.php index 9c75f01353..51e36e7933 100644 --- a/tests/Unit/Controller/AliasesControllerTest.php +++ b/tests/Unit/Controller/AliasesControllerTest.php @@ -40,7 +40,7 @@ public function setUp(): void { $this->request = $this->getMockBuilder('OCP\IRequest') ->getMock(); - $this->alias = $this->getMockBuilder('\OCA\Mail\Db\Alias') + $this->alias = $this->getMockBuilder(\OCA\Mail\Db\Alias::class) ->disableOriginalConstructor() ->getMock(); diff --git a/tests/Unit/Controller/AutoCompleteControllerTest.php b/tests/Unit/Controller/AutoCompleteControllerTest.php index 960b1fcdb0..ed60301f1d 100644 --- a/tests/Unit/Controller/AutoCompleteControllerTest.php +++ b/tests/Unit/Controller/AutoCompleteControllerTest.php @@ -21,7 +21,7 @@ protected function setUp(): void { parent::setUp(); $this->request = $this->getMockBuilder('OCP\IRequest')->getMock(); - $this->service = $this->getMockBuilder('OCA\Mail\Service\AutoCompletion\AutoCompleteService') + $this->service = $this->getMockBuilder(\OCA\Mail\Service\AutoCompletion\AutoCompleteService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = new AutoCompleteController( diff --git a/tests/Unit/Http/AttachmentDownloadResponseTest.php b/tests/Unit/Http/AttachmentDownloadResponseTest.php index bcdd441e6f..f63ef75886 100644 --- a/tests/Unit/Http/AttachmentDownloadResponseTest.php +++ b/tests/Unit/Http/AttachmentDownloadResponseTest.php @@ -14,11 +14,8 @@ class AttachmentDownloadResponseTest extends TestCase { /** * @dataProvider providesResponseData - * @param $content - * @param $filename - * @param $contentType */ - public function testIt($content, $filename, $contentType) { + public function testIt(string $content, string $filename, string $contentType) { $resp = new AttachmentDownloadResponse($content, $filename, $contentType); $headers = $resp->getHeaders(); $this->assertEquals($content, $resp->render()); diff --git a/tests/Unit/Http/ProxyDownloadResponseTest.php b/tests/Unit/Http/ProxyDownloadResponseTest.php index 42668596c9..a24d3c403d 100644 --- a/tests/Unit/Http/ProxyDownloadResponseTest.php +++ b/tests/Unit/Http/ProxyDownloadResponseTest.php @@ -25,7 +25,7 @@ public function testIt($content, $filename, $contentType) { $this->assertArrayHasKey('Content-Type', $headers); $this->assertEquals($contentType, $headers['Content-Type']); $this->assertArrayHasKey('Content-Disposition', $headers); - $pos = strpos($headers['Content-Disposition'], $filename); + $pos = strpos($headers['Content-Disposition'], (string)$filename); $this->assertTrue($pos > 0); }