Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v1/webdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use Psr\Log\LoggerInterface;

// no php execution timeout for webdav
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@set_time_limit(0);
}
ignore_user_abort(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v2/direct.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
use \OCA\DAV\Direct\ServerFactory;

// no php execution timeout for webdav
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@set_time_limit(0);
}
ignore_user_abort(true);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v2/remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
*/
// no php execution timeout for webdav
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
@set_time_limit(0);
}
ignore_user_abort(true);
Expand Down
6 changes: 3 additions & 3 deletions apps/dav/lib/CalDAV/Activity/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,9 +455,9 @@ public function onTouchCalendarObject($action, array $calendarData, array $share

$action = $action . '_' . $object['type'];

if ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'COMPLETED') {
if ($object['type'] === 'todo' && str_starts_with($action, Event::SUBJECT_OBJECT_UPDATE) && $object['status'] === 'COMPLETED') {
$action .= '_completed';
} elseif ($object['type'] === 'todo' && strpos($action, Event::SUBJECT_OBJECT_UPDATE) === 0 && $object['status'] === 'NEEDS-ACTION') {
} elseif ($object['type'] === 'todo' && str_starts_with($action, Event::SUBJECT_OBJECT_UPDATE) && $object['status'] === 'NEEDS-ACTION') {
$action .= '_needs_action';
}

Expand Down Expand Up @@ -491,7 +491,7 @@ public function onTouchCalendarObject($action, array $calendarData, array $share
],
];

if ($object['type'] === 'event' && strpos($action, Event::SUBJECT_OBJECT_DELETE) === false && $this->appManager->isEnabledForUser('calendar')) {
if ($object['type'] === 'event' && !str_contains($action, Event::SUBJECT_OBJECT_DELETE) && $this->appManager->isEnabledForUser('calendar')) {
$params['object']['link']['object_uri'] = $objectData['uri'];
$params['object']['link']['calendar_uri'] = $calendarData['uri'];
$params['object']['link']['owner'] = $owner;
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Integration/ExternalCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ final public function createDirectory($name) {
* @return bool
*/
public static function isAppGeneratedCalendar(string $calendarUri):bool {
return strpos($calendarUri, self::PREFIX) === 0 && substr_count($calendarUri, self::DELIMITER) >= 2;
return str_starts_with($calendarUri, self::PREFIX) && substr_count($calendarUri, self::DELIMITER) >= 2;
}

/**
Expand Down Expand Up @@ -126,6 +126,6 @@ public static function splitAppGeneratedCalendarUri(string $calendarUri):array {
* @return bool
*/
public static function doesViolateReservedName(string $calendarUri):bool {
return strpos($calendarUri, self::PREFIX) === 0;
return str_starts_with($calendarUri, self::PREFIX);
}
}
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Publishing/PublishPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
$path = $request->getPath();

// Only handling xml
$contentType = $request->getHeader('Content-Type');
if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
$contentType = (string) $request->getHeader('Content-Type');
if (!str_contains($contentType, 'application/xml') && !str_contains($contentType, 'text/xml')) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getPrincipalsByPrefix($prefixPath): array {
* @return array
*/
public function getPrincipalByPath($path) {
if (strpos($path, $this->principalPrefix) !== 0) {
if (!str_starts_with($path, $this->principalPrefix)) {
return null;
}
[, $name] = \Sabre\Uri\split($path);
Expand Down Expand Up @@ -443,7 +443,7 @@ public function findByUri($uri, $principalPrefix): ?string {
}
$usersGroups = $this->groupManager->getUserGroupIds($user);

if (strpos($uri, 'mailto:') === 0) {
if (str_starts_with($uri, 'mailto:')) {
$email = substr($uri, 7);
$query = $this->db->getQueryBuilder();
$query->select(['id', 'backend_id', 'resource_id', 'email', 'displayname', 'group_restrictions'])
Expand All @@ -463,9 +463,9 @@ public function findByUri($uri, $principalPrefix): ?string {
return $this->rowToPrincipal($row)['uri'];
}

if (strpos($uri, 'principal:') === 0) {
if (str_starts_with($uri, 'principal:')) {
$path = substr($uri, 10);
if (strpos($path, $this->principalPrefix) !== 0) {
if (!str_starts_with($path, $this->principalPrefix)) {
return null;
}

Expand Down
6 changes: 3 additions & 3 deletions apps/dav/lib/CalDAV/Schedule/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,10 @@ public function propFindDefaultCalendarUrl(PropFind $propFind, INode $node) {
return null;
}

$isResourceOrRoom = strpos($principalUrl, 'principals/calendar-resources') === 0 ||
strpos($principalUrl, 'principals/calendar-rooms') === 0;
$isResourceOrRoom = str_starts_with($principalUrl, 'principals/calendar-resources') ||
str_starts_with($principalUrl, 'principals/calendar-rooms');

if (strpos($principalUrl, 'principals/users') === 0) {
if (str_starts_with($principalUrl, 'principals/users')) {
[, $userId] = split($principalUrl);
$uri = $this->config->getUserValue($userId, 'dav', 'defaultCalendar', CalDavBackend::PERSONAL_CALENDAR_URI);
$displayName = CalDavBackend::PERSONAL_CALENDAR_NAME;
Expand Down
10 changes: 5 additions & 5 deletions apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ private function readBlob($cardData, &$modified = false) {

// Micro optimisation
// don't loop through
if (strpos($cardData, 'PHOTO:data:') === 0) {
if (str_starts_with($cardData, 'PHOTO:data:')) {
return $cardData;
}

Expand All @@ -1022,16 +1022,16 @@ private function readBlob($cardData, &$modified = false) {
$cardDataFiltered = [];
$removingPhoto = false;
foreach ($cardDataArray as $line) {
if (strpos($line, 'PHOTO:data:') === 0
&& strpos($line, 'PHOTO:data:image/') !== 0) {
if (str_starts_with($line, 'PHOTO:data:')
&& !str_starts_with($line, 'PHOTO:data:image/')) {
// Filter out PHOTO data of non-images
$removingPhoto = true;
$modified = true;
continue;
}

if ($removingPhoto) {
if (strpos($line, ' ') === 0) {
if (str_starts_with($line, ' ')) {
continue;
}
// No leading space means this is a new property
Expand Down Expand Up @@ -1131,7 +1131,7 @@ private function searchByAddressBookIds(array $addressBookIds,
$propertyOr = $query2->expr()->orX();
foreach ($searchProperties as $property) {
if ($escapePattern) {
if ($property === 'EMAIL' && strpos($pattern, ' ') !== false) {
if ($property === 'EMAIL' && str_contains($pattern, ' ')) {
// There can be no spaces in emails
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CardDAV/HasPhotoPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public function propFind(PropFind $propFind, INode $node) {
return $vcard instanceof VCard
&& $vcard->PHOTO
// Either the PHOTO is a url (doesn't start with data:) or the mimetype has to start with image/
&& (strpos($vcard->PHOTO->getValue(), 'data:') !== 0
|| strpos($vcard->PHOTO->getValue(), 'data:image/') === 0)
&& (!str_starts_with($vcard->PHOTO->getValue(), 'data:')
|| str_starts_with($vcard->PHOTO->getValue(), 'data:image/'))
;
});
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ final public function createDirectory($name) {
* @return bool
*/
public static function isAppGeneratedAddressBook(string $uri): bool {
return strpos($uri, self::PREFIX) === 0 && substr_count($uri, self::DELIMITER) >= 2;
return str_starts_with($uri, self::PREFIX) && substr_count($uri, self::DELIMITER) >= 2;
}

/**
Expand Down Expand Up @@ -121,6 +121,6 @@ public static function splitAppGeneratedAddressBookUri(string $uri): array {
* @return bool
*/
public static function doesViolateReservedName(string $uri): bool {
return strpos($uri, self::PREFIX) === 0;
return str_starts_with($uri, self::PREFIX);
}
}
4 changes: 2 additions & 2 deletions apps/dav/lib/CardDAV/MultiGetExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public function httpReport(RequestInterface $request, ResponseInterface $respons
}

// Only handling xml
$contentType = $response->getHeader('Content-Type');
if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
$contentType = (string) $response->getHeader('Content-Type');
if (!str_contains($contentType, 'application/xml') && !str_contains($contentType, 'text/xml')) {
return;
}

Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CardDAV/PhotoCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ private function getBinaryType(Binary $photo) {
if (isset($params['TYPE']) || isset($params['MEDIATYPE'])) {
/** @var Parameter $typeParam */
$typeParam = isset($params['TYPE']) ? $params['TYPE'] : $params['MEDIATYPE'];
$type = $typeParam->getValue();
$type = (string) $typeParam->getValue();

if (strpos($type, 'image/') === 0) {
if (str_starts_with($type, 'image/')) {
return $type;
} else {
return 'image/' . strtolower($type);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ protected function getClient(string $url, string $userName, string $sharedSecret
$certPath = $this->getCertPath();
$client->setThrowExceptions(true);

if ($certPath !== '' && strpos($url, 'http://') !== 0) {
if ($certPath !== '' && !str_starts_with($url, 'http://')) {
$client->addCurlSetting(CURLOPT_CAINFO, $this->certPath);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/SystemAddressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function getChildren() {
$children = parent::getChildren();
return array_filter($children, function (Card $child) {
// check only for URIs that begin with Guests:
return strpos($child->getName(), 'Guests:') !== 0;
return !str_starts_with($child->getName(), 'Guests:');
});
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Comments/CommentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function __construct(

$methods = get_class_methods($this->comment);
$methods = array_filter($methods, function ($name) {
return strpos($name, 'get') === 0;
return str_starts_with($name, 'get');
});
foreach ($methods as $getter) {
if ($getter === 'getMentions') {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Comments/CommentsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function __construct(ICommentsManager $commentsManager, IUserSession $use
*/
public function initialize(Server $server) {
$this->server = $server;
if (strpos($this->server->getRequestUri(), 'comments/') !== 0) {
if (!str_starts_with($this->server->getRequestUri(), 'comments/')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/AnonymousOptionsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function initialize(\Sabre\DAV\Server $server) {
* @return bool
*/
public function isRequestInRoot($path) {
return $path === '' || (is_string($path) && strpos($path, '/') === false);
return $path === '' || (is_string($path) && !str_contains($path, '/'));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/CachingTree.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function markDirty($path) {
$path = trim($path, '/');
foreach ($this->cache as $nodePath => $node) {
$nodePath = (string) $nodePath;
if ('' === $path || $nodePath == $path || 0 === strpos($nodePath, $path.'/')) {
if ('' === $path || $nodePath == $path || str_starts_with($nodePath, $path . '/')) {
unset($this->cache[$nodePath]);
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Principal.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public function findByUri($uri, $principalPrefix) {
$restrictGroups = $this->groupManager->getUserGroupIds($user);
}

if (strpos($uri, 'mailto:') === 0) {
if (str_starts_with($uri, 'mailto:')) {
if ($principalPrefix === 'principals/users') {
$users = $this->userManager->getByEmail(substr($uri, 7));
if (count($users) !== 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function compressResponse(Request $request, Response $response) {
return $response;
}

if (strpos($header, 'gzip') !== false) {
if (str_contains($header, 'gzip')) {
$body = $response->getBody();
if (is_string($body)) {
$response->setHeader('Content-Encoding', 'gzip');
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/DAV/GroupPrincipalBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public function findByUri($uri, $principalPrefix) {
$restrictGroups = $this->groupManager->getUserGroupIds($user);
}

if (strpos($uri, 'principal:principals/groups/') === 0) {
if (str_starts_with($uri, 'principal:principals/groups/')) {
$name = urlencode(substr($uri, 28));
if ($restrictGroups !== false && !\in_array($name, $restrictGroups, true)) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/DAV/PublicAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function challenge(RequestInterface $request, ResponseInterface $response
private function isRequestPublic(RequestInterface $request) {
$url = $request->getPath();
$matchingUrls = array_filter($this->publicURLs, function ($publicUrl) use ($url) {
return strpos($url, $publicUrl, 0) === 0;
return str_starts_with($url, $publicUrl);
});
return !empty($matchingUrls);
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/DAV/Sharing/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public function httpPost(RequestInterface $request, ResponseInterface $response)
$path = $request->getPath();

// Only handling xml
$contentType = $request->getHeader('Content-Type');
if (strpos($contentType, 'application/xml') === false && strpos($contentType, 'text/xml') === false) {
$contentType = (string) $request->getHeader('Content-Type');
if (!str_contains($contentType, 'application/xml') && !str_contains($contentType, 'text/xml')) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
use Sabre\VObject\Reader;
use Throwable;
use function strlen;
use function strpos;
use function substr;

class CalendarContactInteractionListener implements IEventListener {
Expand Down Expand Up @@ -130,7 +129,7 @@ private function emitFromUri(string $uri, IUser $user): void {
// Invalid principal
return;
}
if (strpos($principal, self::URI_USERS) !== 0) {
if (!str_starts_with($principal, self::URI_USERS)) {
// Not a user principal
return;
}
Expand Down Expand Up @@ -159,7 +158,7 @@ private function emitFromObject(VEvent $vevent, IUser $user): void {
}

$mailTo = $attendee->getValue();
if (strpos($mailTo, 'mailto:') !== 0) {
if (!str_starts_with($mailTo, 'mailto:')) {
// Doesn't look like an email
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use OCP\IConfig;
use Psr\Log\LoggerInterface;
use Throwable;
use function strpos;

/**
* @template-implements IEventListener<\OCA\DAV\Events\CalendarDeletedEvent>
Expand Down Expand Up @@ -61,7 +60,7 @@ public function handle(Event $event): void {

try {
$principalUri = $event->getCalendarData()['principaluri'];
if (strpos($principalUri, 'principals/users') !== 0) {
if (!str_starts_with($principalUri, 'principals/users')) {
$this->logger->debug('Default calendar needs no update because the deleted calendar does not belong to a user principal');
return;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function exec() {
private function requestIsForSubtree(array $subTrees): bool {
foreach ($subTrees as $subTree) {
$subTree = trim($subTree, ' /');
if (strpos($this->server->getRequestUri(), $subTree.'/') === 0) {
if (str_starts_with($this->server->getRequestUri(), $subTree . '/')) {
return true;
}
}
Expand Down