Skip to content

Commit

Permalink
Merge pull request #10128 from nextcloud/refactor/rector-php-sets
Browse files Browse the repository at this point in the history
refactor: Apply PHP5.6-7.3 rector sets
  • Loading branch information
ChristophWurst committed Sep 17, 2024
2 parents 6f31954 + 3a2cefa commit 83854dd
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lib/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/ExportAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('<info>Account ' . $account->getId() . ':</info>');
$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());
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/AiIntegrations/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
6 changes: 3 additions & 3 deletions lib/Service/Attachment/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}
3 changes: 3 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@
->withPreparedSets(
phpunitCodeQuality: true,
phpunit: true,
)
->withPhpSets(
php73: true,
);
2 changes: 1 addition & 1 deletion tests/Integration/Db/CollectedAddressMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Db/RecipientMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function testUpdateRecipients(): void {
$penny->setEmail('[email protected]');
$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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Command/CreateAccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Controller/AliasesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Controller/AutoCompleteControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 1 addition & 4 deletions tests/Unit/Http/AttachmentDownloadResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Http/ProxyDownloadResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 83854dd

Please sign in to comment.