Skip to content

Commit 51b6ac2

Browse files
refactor: apply Rector
Signed-off-by: Christoph Wurst <[email protected]>
1 parent da7e4a6 commit 51b6ac2

File tree

8 files changed

+14
-20
lines changed

8 files changed

+14
-20
lines changed

lib/Controller/ProxyController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public function __construct(string $appName,
5757
public function redirect(string $src): TemplateResponse {
5858
$authorizedRedirect = false;
5959

60-
if (strpos($src, 'http://') !== 0
61-
&& strpos($src, 'https://') !== 0
62-
&& strpos($src, 'ftp://') !== 0) {
60+
if (!str_starts_with($src, 'http://')
61+
&& !str_starts_with($src, 'https://')
62+
&& !str_starts_with($src, 'ftp://')) {
6363
throw new Exception('URL is not valid.', 1);
6464
}
6565

lib/IMAP/Threading/Message.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(string $subject,
3636
}
3737

3838
public function hasReSubject(): bool {
39-
return strpos($this->getSubject(), 'Re:') === 0;
39+
return str_starts_with($this->getSubject(), 'Re:');
4040
}
4141

4242
public function getSubject(): string {

lib/Search/Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getName(): string {
6161

6262
#[\Override]
6363
public function getOrder(string $route, array $routeParameters): int {
64-
if (strpos($route, Application::APP_ID . '.') === 0) {
64+
if (str_starts_with($route, Application::APP_ID . '.')) {
6565
// Active app, prefer Mail results
6666
return -1;
6767
}

lib/Service/ContactsIntegration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function getPhoto(string $email) {
159159
*/
160160
private function getPhotoUri(string $raw) {
161161
$uriPrefix = 'VALUE=uri:';
162-
if (substr($raw, 0, strlen($uriPrefix)) === $uriPrefix) {
162+
if (str_starts_with($raw, $uriPrefix)) {
163163
return substr($raw, strpos($raw, 'http'));
164164
} else {
165165
// ignore contacts >= 1.0 binary images

lib/Service/HtmlPurify/TransformStyleURLs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(IURLGenerator $urlGenerator) {
3333
*/
3434
#[\Override]
3535
public function transform($attr, $config, $context) {
36-
if (!isset($attr['style']) || strpos($attr['style'], 'url(') === false) {
36+
if (!isset($attr['style']) || !str_contains($attr['style'], 'url(')) {
3737
return $attr;
3838
}
3939

@@ -47,7 +47,7 @@ public function transform($attr, $config, $context) {
4747
}
4848

4949
[$name, $value] = explode(':', $cssAttribute, 2);
50-
if (strpos($value, 'url(') !== false) {
50+
if (str_contains($value, 'url(')) {
5151
// Replace image URL
5252
$value = preg_replace('/url\(("|\')?http.*\)/i',
5353
'url(' . $this->urlGenerator->imagePath('mail', 'blocked-image.png') . ')',

lib/Service/Search/FilterStringParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function parse(?string $filter): SearchQuery {
2626
}
2727

2828
private function parseFilterToken(SearchQuery $query, string $token): bool {
29-
if (strpos($token, ':') === false) {
29+
if (!str_contains($token, ':')) {
3030
return false;
3131
}
3232

lib/Sieve/SieveUtils.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static function escapeString(string $subject): string {
3131
* @see https://www.rfc-editor.org/rfc/rfc5228#section-2.4.2.1
3232
*/
3333
public static function stringList(array $values): string {
34-
$values = array_map([__CLASS__, 'escapeString'], $values);
34+
$values = array_map([self::class, 'escapeString'], $values);
3535

3636
return '["' . implode('", "', $values) . '"]';
3737
}

tests/Unit/Service/Sync/SyncServiceTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,9 @@ class SyncServiceTest extends TestCase {
3434
/** @var ImapToDbSynchronizer */
3535
private $synchronizer;
3636

37-
/** @var FilterStringParser */
38-
private $filterStringParser;
39-
4037
/** @var MessageMapper */
4138
private $messageMapper;
4239

43-
/** @var PreviewEnhancer */
44-
private $previewEnhancer;
45-
4640
/** @var LoggerInterface */
4741
private $loggerInterface;
4842

@@ -58,18 +52,18 @@ protected function setUp(): void {
5852
$this->clientFactory = $this->createMock(IMAPClientFactory::class);
5953
$this->client = $this->createMock(Horde_Imap_Client_Socket::class);
6054
$this->synchronizer = $this->createMock(ImapToDbSynchronizer::class);
61-
$this->filterStringParser = $this->createMock(FilterStringParser::class);
55+
$filterStringParser = $this->createMock(FilterStringParser::class);
6256
$this->messageMapper = $this->createMock(MessageMapper::class);
63-
$this->previewEnhancer = $this->createMock(PreviewEnhancer::class);
57+
$previewEnhancer = $this->createMock(PreviewEnhancer::class);
6458
$this->loggerInterface = $this->createMock(LoggerInterface::class);
6559
$this->mailboxSync = $this->createMock(MailboxSync::class);
6660

6761
$this->syncService = new SyncService(
6862
$this->clientFactory,
6963
$this->synchronizer,
70-
$this->filterStringParser,
64+
$filterStringParser,
7165
$this->messageMapper,
72-
$this->previewEnhancer,
66+
$previewEnhancer,
7367
$this->loggerInterface,
7468
$this->mailboxSync
7569
);

0 commit comments

Comments
 (0)