Merge pull request #10128 from nextcloud/refactor/rector-php-sets

refactor: Apply PHP5.6-7.3 rector sets
This commit is contained in:
Christoph Wurst 2024-09-17 22:55:02 +02:00 коммит произвёл GitHub
Родитель 6f3195427f 3a2cefa509
Коммит 83854dd4c6
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
13 изменённых файлов: 17 добавлений и 17 удалений

Просмотреть файл

@ -230,7 +230,7 @@ class Cache extends Horde_Imap_Client_Cache_Backend {
* @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);
}

Просмотреть файл

@ -83,7 +83,7 @@ class ExportAccount extends Command {
$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());

Просмотреть файл

@ -55,7 +55,7 @@ class Cache {
* @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);
}

Просмотреть файл

@ -24,20 +24,20 @@ class UploadedFile {
* @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';
}
}

Просмотреть файл

@ -20,4 +20,7 @@ return RectorConfig::configure()
->withPreparedSets(
phpunitCodeQuality: true,
phpunit: true,
)
->withPhpSets(
php73: true,
);

Просмотреть файл

@ -104,7 +104,7 @@ class CollectedAddressMapperTest extends TestCase {
$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++;

Просмотреть файл

@ -172,7 +172,7 @@ class RecipientMapperTest extends TestCase {
$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);

Просмотреть файл

@ -151,7 +151,7 @@ class MailTransmissionIntegrationTest extends TestCase {
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);

Просмотреть файл

@ -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();

Просмотреть файл

@ -40,7 +40,7 @@ class AliasesControllerTest extends TestCase {
$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();

Просмотреть файл

@ -21,7 +21,7 @@ class AutoCompleteControllerTest extends TestCase {
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(

Просмотреть файл

@ -14,11 +14,8 @@ use OCA\Mail\Http\AttachmentDownloadResponse;
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());

Просмотреть файл

@ -25,7 +25,7 @@ class ProxyDownloadResponseTest extends TestCase {
$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);
}