From a870430ee8e5cfda9369a8ba5fbb37b366b4db93 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 11 Sep 2024 07:31:54 +0200 Subject: [PATCH 1/5] refactor: Apply PHP5.3 sets Signed-off-by: Christoph Wurst --- lib/Command/ExportAccount.php | 2 +- rector.php | 3 +++ tests/Integration/Service/MailTransmissionIntegrationTest.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) 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/rector.php b/rector.php index 433aac517a..b3f7287857 100644 --- a/rector.php +++ b/rector.php @@ -20,4 +20,7 @@ ->withPreparedSets( phpunitCodeQuality: true, phpunit: true, + ) + ->withPhpSets( + php53: true, ); 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); From 78f4a9ed79e6233224adeceeed6f9ca29668ca86 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 11 Sep 2024 07:33:26 +0200 Subject: [PATCH 2/5] refactor: Apply PHP5.5 sets Signed-off-by: Christoph Wurst --- rector.php | 2 +- tests/Integration/Db/CollectedAddressMapperTest.php | 2 +- tests/Unit/Command/CreateAccountTest.php | 2 +- tests/Unit/Controller/AliasesControllerTest.php | 2 +- tests/Unit/Controller/AutoCompleteControllerTest.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/rector.php b/rector.php index b3f7287857..0c2d9f05c2 100644 --- a/rector.php +++ b/rector.php @@ -22,5 +22,5 @@ phpunit: true, ) ->withPhpSets( - php53: true, + php55: 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/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( From de41b51160453fd52c51db143857e3f3e0d5b610 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 11 Sep 2024 07:34:36 +0200 Subject: [PATCH 3/5] refactor: Apply PHP7.0 sets Signed-off-by: Christoph Wurst --- lib/Cache/Cache.php | 2 +- lib/Service/AiIntegrations/Cache.php | 2 +- lib/Service/Attachment/UploadedFile.php | 6 +++--- rector.php | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) 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/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 0c2d9f05c2..33f5bf9510 100644 --- a/rector.php +++ b/rector.php @@ -22,5 +22,5 @@ phpunit: true, ) ->withPhpSets( - php55: true, + php70: true, ); From bfaddda421a6ef1e82ad421305c02ce866698211 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 11 Sep 2024 07:35:36 +0200 Subject: [PATCH 4/5] refactor: Apply PHP7.1 sets Signed-off-by: Christoph Wurst --- rector.php | 2 +- tests/Integration/Db/RecipientMapperTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rector.php b/rector.php index 33f5bf9510..48d4f1efd9 100644 --- a/rector.php +++ b/rector.php @@ -22,5 +22,5 @@ phpunit: true, ) ->withPhpSets( - php70: true, + php71: true, ); 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); From 3a2cefa5090558422db89e7cba7518f177785992 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Wed, 11 Sep 2024 07:37:01 +0200 Subject: [PATCH 5/5] refactor: Apply PHP7.3 sets Signed-off-by: Christoph Wurst --- rector.php | 2 +- tests/Unit/Http/AttachmentDownloadResponseTest.php | 5 +---- tests/Unit/Http/ProxyDownloadResponseTest.php | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/rector.php b/rector.php index 48d4f1efd9..aec92a3cd6 100644 --- a/rector.php +++ b/rector.php @@ -22,5 +22,5 @@ phpunit: true, ) ->withPhpSets( - php71: true, + php73: true, ); 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); }