diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 880cbef406a0f..b5d85c37fd30b 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -8,3 +8,4 @@ aa5f037af71c915424c6dcfd5ad2dc82797dc0d6 # Update to coding-standard 1.2.3 af6de04e9e141466dc229e444ff3f146f4a34765 0bd284cb81b6866338aaaa67aa1d81ef9bfbb2ab +8af7ecb2576071f170ecbb0aa2311b26581e40e2 diff --git a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php index 1593be49a5d16..f9c4d8dcd74be 100644 --- a/apps/dav/lib/BackgroundJob/UserStatusAutomation.php +++ b/apps/dav/lib/BackgroundJob/UserStatusAutomation.php @@ -55,14 +55,14 @@ protected function run($argument) { $userId = $argument['userId']; $user = $this->userManager->get($userId); - if($user === null) { + if ($user === null) { return; } $ooo = $this->coordinator->getCurrentOutOfOfficeData($user); $continue = $this->processOutOfOfficeData($user, $ooo); - if($continue === false) { + if ($continue === false) { return; } @@ -196,7 +196,7 @@ private function processAvailability(string $property, string $userId, bool $has return; } - if(!$hasDndForOfficeHours) { + if (!$hasDndForOfficeHours) { // Office hours are not set to DND, so there is nothing to do. return; } @@ -207,7 +207,7 @@ private function processAvailability(string $property, string $userId, bool $has } private function processOutOfOfficeData(IUser $user, ?IOutOfOfficeData $ooo): bool { - if(empty($ooo)) { + if (empty($ooo)) { // Reset the user status if the absence doesn't exist $this->logger->debug('User has no OOO period in effect, reverting DND status if applicable'); $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND); @@ -215,12 +215,12 @@ private function processOutOfOfficeData(IUser $user, ?IOutOfOfficeData $ooo): bo return true; } - if(!$this->coordinator->isInEffect($ooo)) { + if (!$this->coordinator->isInEffect($ooo)) { // Reset the user status if the absence is (no longer) in effect $this->logger->debug('User has no OOO period in effect, reverting DND status if applicable'); $this->manager->revertUserStatus($user->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND); - if($ooo->getStartDate() > $this->time->getTime()) { + if ($ooo->getStartDate() > $this->time->getTime()) { // Set the next run to take place at the start of the ooo period if it is in the future // This might be overwritten if there is an availability setting, but we can't determine // if this is the case here diff --git a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php index 733e80791118c..de5b1139880e0 100644 --- a/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php +++ b/apps/dav/lib/CalDAV/BirthdayCalendar/EnablePlugin.php @@ -115,7 +115,7 @@ public function httpPost(RequestInterface $request, ResponseInterface $response) } $owner = substr($node->getOwner(), 17); - if($owner !== $this->user->getUID()) { + if ($owner !== $this->user->getUID()) { $this->server->httpResponse->setStatus(403); return false; } diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index e35604e8497e5..43a22651747ad 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -2815,7 +2815,7 @@ public function deleteOutdatedSchedulingObjects(int $modifiedBefore, int $limit) ->setMaxResults($limit); $result = $query->executeQuery(); $count = $result->rowCount(); - if($count === 0) { + if ($count === 0) { return; } $ids = array_map(static function (array $id) { @@ -2827,12 +2827,12 @@ public function deleteOutdatedSchedulingObjects(int $modifiedBefore, int $limit) $deleteQuery = $this->db->getQueryBuilder(); $deleteQuery->delete('schedulingobjects') ->where($deleteQuery->expr()->in('id', $deleteQuery->createParameter('ids'), IQueryBuilder::PARAM_INT_ARRAY)); - foreach(array_chunk($ids, 1000) as $chunk) { + foreach (array_chunk($ids, 1000) as $chunk) { $deleteQuery->setParameter('ids', $chunk, IQueryBuilder::PARAM_INT_ARRAY); $numDeleted += $deleteQuery->executeStatement(); } - if($numDeleted === $limit) { + if ($numDeleted === $limit) { $this->logger->info("Deleted $limit scheduling objects, continuing with next batch"); $this->deleteOutdatedSchedulingObjects($modifiedBefore, $limit); } @@ -3307,7 +3307,7 @@ public function purgeAllCachedEventsForSubscription($subscriptionId) { * @param array $calendarObjectUris */ public function purgeCachedEventsForSubscription(int $subscriptionId, array $calendarObjectIds, array $calendarObjectUris): void { - if(empty($calendarObjectUris)) { + if (empty($calendarObjectUris)) { return; } diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php index d01c2affbc8c9..59a976ca6bc3d 100644 --- a/apps/dav/lib/CalDAV/CalendarHome.php +++ b/apps/dav/lib/CalDAV/CalendarHome.php @@ -149,9 +149,9 @@ public function getChild($name) { // Calendar - this covers all "regular" calendars, but not shared // only check if the method is available - if($this->caldavBackend instanceof CalDavBackend) { + if ($this->caldavBackend instanceof CalDavBackend) { $calendar = $this->caldavBackend->getCalendarByUri($this->principalInfo['uri'], $name); - if(!empty($calendar)) { + if (!empty($calendar)) { return new Calendar($this->caldavBackend, $calendar, $this->l10n, $this->config, $this->logger); } } diff --git a/apps/dav/lib/CalDAV/CalendarImpl.php b/apps/dav/lib/CalDAV/CalendarImpl.php index bba1603c32525..ea2ac0e9a62ac 100644 --- a/apps/dav/lib/CalDAV/CalendarImpl.php +++ b/apps/dav/lib/CalDAV/CalendarImpl.php @@ -84,7 +84,7 @@ public function getSchedulingTimezone(): ?VTimeZone { /** @var VCalendar $vobj */ $vobj = Reader::read($timezoneProp); $components = $vobj->getComponents(); - if(empty($components)) { + if (empty($components)) { return null; } /** @var VTimeZone $vtimezone */ diff --git a/apps/dav/lib/CalDAV/EventComparisonService.php b/apps/dav/lib/CalDAV/EventComparisonService.php index e3c7749a772fd..63395e7ce1c65 100644 --- a/apps/dav/lib/CalDAV/EventComparisonService.php +++ b/apps/dav/lib/CalDAV/EventComparisonService.php @@ -37,14 +37,14 @@ class EventComparisonService { */ private function removeIfUnchanged(VEvent $filterEvent, array &$eventsToFilter): bool { $filterEventData = []; - foreach(self::EVENT_DIFF as $eventDiff) { + foreach (self::EVENT_DIFF as $eventDiff) { $filterEventData[] = IMipService::readPropertyWithDefault($filterEvent, $eventDiff, ''); } /** @var VEvent $component */ foreach ($eventsToFilter as $k => $eventToFilter) { $eventToFilterData = []; - foreach(self::EVENT_DIFF as $eventDiff) { + foreach (self::EVENT_DIFF as $eventDiff) { $eventToFilterData[] = IMipService::readPropertyWithDefault($eventToFilter, $eventDiff, ''); } // events are identical and can be removed @@ -73,23 +73,23 @@ public function findModified(VCalendar $new, ?VCalendar $old): array { $newEventComponents = $new->getComponents(); foreach ($newEventComponents as $k => $event) { - if(!$event instanceof VEvent) { + if (!$event instanceof VEvent) { unset($newEventComponents[$k]); } } - if(empty($old)) { + if (empty($old)) { return ['old' => null, 'new' => $newEventComponents]; } $oldEventComponents = $old->getComponents(); - if(is_array($oldEventComponents) && !empty($oldEventComponents)) { + if (is_array($oldEventComponents) && !empty($oldEventComponents)) { foreach ($oldEventComponents as $k => $event) { - if(!$event instanceof VEvent) { + if (!$event instanceof VEvent) { unset($oldEventComponents[$k]); continue; } - if($this->removeIfUnchanged($event, $newEventComponents)) { + if ($this->removeIfUnchanged($event, $newEventComponents)) { unset($oldEventComponents[$k]); } } diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index 4ac9e83ef0805..b6032e733d991 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -447,7 +447,7 @@ private function writeRemindersToDatabase(array $reminders): void { $uniqueReminders = []; foreach ($reminders as $reminder) { $key = $reminder['notification_date']. $reminder['event_hash'].$reminder['type']; - if(!isset($uniqueReminders[$key])) { + if (!isset($uniqueReminders[$key])) { $uniqueReminders[$key] = $reminder; } } diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 1958531630ade..e46cd039fd5ee 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -94,7 +94,7 @@ public function initialize(DAV\Server $server): void { * @param bool $modified modified */ public function beforeWriteContent($uri, INode $node, $data, $modified): void { - if(!$node instanceof CalendarObject) { + if (!$node instanceof CalendarObject) { return; } /** @var VCalendar $vCalendar */ @@ -151,7 +151,7 @@ public function schedule(Message $iTipMessage) { // No changed events after all - this shouldn't happen if there is significant change yet here we are // The scheduling status is debatable - if(empty($vEvent)) { + if (empty($vEvent)) { $this->logger->warning('iTip message said the change was significant but comparison did not detect any updated VEvents'); $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; return; @@ -163,14 +163,14 @@ public function schedule(Message $iTipMessage) { // we also might not have an old event as this could be a new // invitation, or a new recurrence exception $attendee = $this->imipService->getCurrentAttendee($iTipMessage); - if($attendee === null) { + if ($attendee === null) { $uid = $vEvent->UID ?? 'no UID found'; $this->logger->debug('Could not find recipient ' . $recipient . ' as attendee for event with UID ' . $uid); $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; return; } // Don't send emails to things - if($this->imipService->isRoomOrResource($attendee)) { + if ($this->imipService->isRoomOrResource($attendee)) { $this->logger->debug('No invitation sent as recipient is room or resource', [ 'attendee' => $recipient, ]); diff --git a/apps/dav/lib/CalDAV/Schedule/IMipService.php b/apps/dav/lib/CalDAV/Schedule/IMipService.php index 3d6317e6968f9..a101cb05db302 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipService.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipService.php @@ -88,7 +88,7 @@ private function generateDiffString(VEvent $vevent, VEvent $oldVEvent, string $p return $default; } $newstring = $vevent->$property->getValue(); - if(isset($oldVEvent->$property) && $oldVEvent->$property->getValue() !== $newstring) { + if (isset($oldVEvent->$property) && $oldVEvent->$property->getValue() !== $newstring) { $oldstring = $oldVEvent->$property->getValue(); return sprintf($strikethrough, $oldstring, $newstring); } @@ -143,7 +143,7 @@ public function buildBodyData(VEvent $vEvent, ?VEvent $oldVEvent): array { $data = []; $data['meeting_when'] = $this->generateWhenString($eventReaderCurrent); - foreach(self::STRING_DIFF as $key => $property) { + foreach (self::STRING_DIFF as $key => $property) { $data[$key] = self::readPropertyWithDefault($vEvent, $property, $defaultVal); } @@ -153,7 +153,7 @@ public function buildBodyData(VEvent $vEvent, ?VEvent $oldVEvent): array { $data['meeting_location_html'] = $locationHtml; } - if(!empty($oldVEvent)) { + if (!empty($oldVEvent)) { $oldMeetingWhen = $this->generateWhenString($eventReaderPrevious); $data['meeting_title_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'SUMMARY', $data['meeting_title']); $data['meeting_description_html'] = $this->generateDiffString($vEvent, $oldVEvent, 'DESCRIPTION', $data['meeting_description']); @@ -638,7 +638,7 @@ public function getLastOccurrence(VCalendar $vObject) { return $dtEnd->getDateTime()->getTimeStamp(); } - if(isset($component->DURATION)) { + if (isset($component->DURATION)) { /** @var \DateTime $endDate */ $endDate = clone $dtStart->getDateTime(); // $component->DTEND->getDateTime() returns DateTimeImmutable @@ -646,7 +646,7 @@ public function getLastOccurrence(VCalendar $vObject) { return $endDate->getTimestamp(); } - if(!$dtStart->hasTime()) { + if (!$dtStart->hasTime()) { /** @var \DateTime $endDate */ // $component->DTSTART->getDateTime() returns DateTimeImmutable $endDate = clone $dtStart->getDateTime(); @@ -662,7 +662,7 @@ public function getLastOccurrence(VCalendar $vObject) { * @param Property|null $attendee */ public function setL10n(?Property $attendee = null) { - if($attendee === null) { + if ($attendee === null) { return; } @@ -678,7 +678,7 @@ public function setL10n(?Property $attendee = null) { * @return bool */ public function getAttendeeRsvpOrReqForParticipant(?Property $attendee = null) { - if($attendee === null) { + if ($attendee === null) { return false; } @@ -786,10 +786,10 @@ public function addAttendees(IEMailTemplate $template, VEvent $vevent) { htmlspecialchars($organizer->getNormalizedValue()), htmlspecialchars($organizerName ?: $organizerEmail)); $organizerText = sprintf('%s <%s>', $organizerName, $organizerEmail); - if(isset($organizer['PARTSTAT'])) { + if (isset($organizer['PARTSTAT'])) { /** @var Parameter $partstat */ $partstat = $organizer['PARTSTAT']; - if(strcasecmp($partstat->getValue(), 'ACCEPTED') === 0) { + if (strcasecmp($partstat->getValue(), 'ACCEPTED') === 0) { $organizerHTML .= ' ✔︎'; $organizerText .= ' ✔︎'; } @@ -961,7 +961,7 @@ public function getReplyingAttendee(Message $iTipMessage): ?Property { public function isRoomOrResource(Property $attendee): bool { $cuType = $attendee->offsetGet('CUTYPE'); - if(!$cuType instanceof Parameter) { + if (!$cuType instanceof Parameter) { return false; } $type = $cuType->getValue() ?? 'INDIVIDUAL'; diff --git a/apps/dav/lib/CalDAV/Status/StatusService.php b/apps/dav/lib/CalDAV/Status/StatusService.php index 382621f1ba0e1..56eec5007b8a3 100644 --- a/apps/dav/lib/CalDAV/Status/StatusService.php +++ b/apps/dav/lib/CalDAV/Status/StatusService.php @@ -39,23 +39,23 @@ public function __construct(private ITimeFactory $timeFactory, public function processCalendarStatus(string $userId): void { $user = $this->userManager->get($userId); - if($user === null) { + if ($user === null) { return; } $availability = $this->availabilityCoordinator->getCurrentOutOfOfficeData($user); - if($availability !== null && $this->availabilityCoordinator->isInEffect($availability)) { + if ($availability !== null && $this->availabilityCoordinator->isInEffect($availability)) { $this->logger->debug('An Absence is in effect, skipping calendar status check', ['user' => $userId]); return; } $calendarEvents = $this->cache->get($userId); - if($calendarEvents === null) { + if ($calendarEvents === null) { $calendarEvents = $this->getCalendarEvents($user); $this->cache->set($userId, $calendarEvents, 300); } - if(empty($calendarEvents)) { + if (empty($calendarEvents)) { try { $this->userStatusService->revertUserStatus($userId, IUserStatus::MESSAGE_CALENDAR_BUSY); } catch (Exception $e) { @@ -81,7 +81,7 @@ public function processCalendarStatus(string $userId): void { $currentStatus = null; } - if(($currentStatus !== null && $currentStatus->getMessageId() === IUserStatus::MESSAGE_CALL) + if (($currentStatus !== null && $currentStatus->getMessageId() === IUserStatus::MESSAGE_CALL) || ($currentStatus !== null && $currentStatus->getStatus() === IUserStatus::DND) || ($currentStatus !== null && $currentStatus->getStatus() === IUserStatus::INVISIBLE)) { // We don't overwrite the call status, DND status or Invisible status @@ -101,7 +101,7 @@ public function processCalendarStatus(string $userId): void { if (isset($component['DTSTART']) && $userStatusTimestamp !== null) { /** @var DateTimeImmutable $dateTime */ $dateTime = $component['DTSTART'][0]; - if($dateTime instanceof DateTimeImmutable && $userStatusTimestamp > $dateTime->getTimestamp()) { + if ($dateTime instanceof DateTimeImmutable && $userStatusTimestamp > $dateTime->getTimestamp()) { return false; } } @@ -112,7 +112,7 @@ public function processCalendarStatus(string $userId): void { return true; }); - if(empty($applicableEvents)) { + if (empty($applicableEvents)) { try { $this->userStatusService->revertUserStatus($userId, IUserStatus::MESSAGE_CALENDAR_BUSY); } catch (Exception $e) { @@ -130,7 +130,7 @@ public function processCalendarStatus(string $userId): void { } // Only update the status if it's neccesary otherwise we mess up the timestamp - if($currentStatus === null || $currentStatus->getMessageId() !== IUserStatus::MESSAGE_CALENDAR_BUSY) { + if ($currentStatus === null || $currentStatus->getMessageId() !== IUserStatus::MESSAGE_CALENDAR_BUSY) { // One event that fulfills all status conditions is enough // 1. Not an OOO event // 2. Current user status (that is not a calendar status) was not set after the start of this event @@ -148,7 +148,7 @@ public function processCalendarStatus(string $userId): void { private function getCalendarEvents(User $user): array { $calendars = $this->calendarManager->getCalendarsForPrincipal('principals/users/' . $user->getUID()); - if(empty($calendars)) { + if (empty($calendars)) { return []; } @@ -172,7 +172,7 @@ private function getCalendarEvents(User $user): array { $dtEnd = DateTimeImmutable::createFromMutable($this->timeFactory->getDateTime('+5 minutes')); // Only query the calendars when there's any to search - if($query instanceof CalendarQuery && !empty($query->getCalendarUris())) { + if ($query instanceof CalendarQuery && !empty($query->getCalendarUris())) { // Query the next hour $query->setTimerangeStart($dtStart); $query->setTimerangeEnd($dtEnd); diff --git a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php index 1f2c006cdfe97..47fd785d632ca 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php @@ -44,12 +44,12 @@ public function refreshSubscription(string $principalUri, string $uri) { } // Check the refresh rate if there is any - if(!empty($subscription['{http://apple.com/ns/ical/}refreshrate'])) { + if (!empty($subscription['{http://apple.com/ns/ical/}refreshrate'])) { // add the refresh interval to the lastmodified timestamp $refreshInterval = new \DateInterval($subscription['{http://apple.com/ns/ical/}refreshrate']); $updateTime = $this->time->getDateTime(); $updateTime->setTimestamp($subscription['lastmodified'])->add($refreshInterval); - if($updateTime->getTimestamp() > $this->time->getTime()) { + if ($updateTime->getTimestamp() > $this->time->getTime()) { return; } } @@ -136,7 +136,7 @@ public function refreshSubscription(string $principalUri, string $uri) { return $dataSet['uri']; }, $localData); - if(!empty($ids) && !empty($uris)) { + if (!empty($ids) && !empty($uris)) { // Clean up on aisle 5 // The only events left over in the $localData array should be those that don't exist upstream // All deleted VObjects from upstream are removed diff --git a/apps/dav/lib/DAV/Sharing/Backend.php b/apps/dav/lib/DAV/Sharing/Backend.php index 2e1a84b6bc80a..3dac1cf18be15 100644 --- a/apps/dav/lib/DAV/Sharing/Backend.php +++ b/apps/dav/lib/DAV/Sharing/Backend.php @@ -58,7 +58,7 @@ public function updateShares(IShareable $shareable, array $add, array $remove, a } // Don't add share for owner - if($shareable->getOwner() !== null && strcasecmp($shareable->getOwner(), $principal) === 0) { + if ($shareable->getOwner() !== null && strcasecmp($shareable->getOwner(), $principal) === 0) { continue; } @@ -83,7 +83,7 @@ public function updateShares(IShareable $shareable, array $add, array $remove, a } // Don't add unshare for owner - if($shareable->getOwner() !== null && strcasecmp($shareable->getOwner(), $principal) === 0) { + if ($shareable->getOwner() !== null && strcasecmp($shareable->getOwner(), $principal) === 0) { continue; } @@ -92,7 +92,7 @@ public function updateShares(IShareable $shareable, array $add, array $remove, a // Check if a user has a groupshare that they're trying to free themselves from // If so we need to add a self::ACCESS_UNSHARED row - if(!str_contains($principal, 'group') + if (!str_contains($principal, 'group') && $this->service->hasGroupShare($oldShares) ) { $this->service->unshare($shareable->getResourceId(), $principal); @@ -130,7 +130,7 @@ public function getShares(int $resourceId): array { $rows = $this->service->getShares($resourceId); $shares = []; - foreach($rows as $row) { + foreach ($rows as $row) { $p = $this->principalBackend->getPrincipalByPath($row['principaluri']); $shares[] = [ 'href' => "principal:{$row['principaluri']}", @@ -155,7 +155,7 @@ public function preloadShares(array $resourceIds): void { $rows = $this->service->getSharesForIds($resourceIds); $sharesByResource = array_fill_keys($resourceIds, []); - foreach($rows as $row) { + foreach ($rows as $row) { $resourceId = (int)$row['resourceid']; $p = $this->principalBackend->getPrincipalByPath($row['principaluri']); $sharesByResource[$resourceId][] = [ diff --git a/apps/dav/lib/Migration/Version1027Date20230504122946.php b/apps/dav/lib/Migration/Version1027Date20230504122946.php index 7b49c64453e87..9e1d1701934d1 100644 --- a/apps/dav/lib/Migration/Version1027Date20230504122946.php +++ b/apps/dav/lib/Migration/Version1027Date20230504122946.php @@ -31,7 +31,7 @@ public function __construct(private SyncService $syncService, * @param array $options */ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void { - if($this->userManager->countSeenUsers() > 100 || array_sum($this->userManager->countUsers()) > 100) { + if ($this->userManager->countSeenUsers() > 100 || array_sum($this->userManager->countUsers()) > 100) { $this->config->setAppValue('dav', 'needs_system_address_book_sync', 'yes'); $output->info('Could not sync system address books during update - too many user records have been found. Please call occ dav:sync-system-addressbook manually.'); return; diff --git a/apps/dav/lib/Migration/Version1029Date20221114151721.php b/apps/dav/lib/Migration/Version1029Date20221114151721.php index 05b04486c88ba..dba5e0b1a488a 100644 --- a/apps/dav/lib/Migration/Version1029Date20221114151721.php +++ b/apps/dav/lib/Migration/Version1029Date20221114151721.php @@ -28,7 +28,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt /** @var ISchemaWrapper $schema */ $schema = $schemaClosure(); $calendarObjectsTable = $schema->getTable('calendarobjects'); - if(!$calendarObjectsTable->hasIndex('calobj_clssfction_index')) { + if (!$calendarObjectsTable->hasIndex('calobj_clssfction_index')) { $calendarObjectsTable->addIndex(['classification'], 'calobj_clssfction_index'); return $schema; } diff --git a/apps/files/lib/Command/Delete.php b/apps/files/lib/Command/Delete.php index f59b636079b27..d984f839c91d9 100644 --- a/apps/files/lib/Command/Delete.php +++ b/apps/files/lib/Command/Delete.php @@ -70,7 +70,7 @@ public function execute(InputInterface $input, OutputInterface $output): int { $output->writeln(''); foreach ($filesByUsers as $user => $filesByUser) { $output->writeln($user . ':'); - foreach($filesByUser as $file) { + foreach ($filesByUser as $file) { $output->writeln(' - ' . $file->getPath()); } } diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index e3d4c0a6aa053..c402a4c5bedd3 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -166,7 +166,7 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal try { // If view is files, we use the directory, otherwise we use the root storage $storageInfo = $this->getStorageInfo(($view === 'files' && $dir) ? $dir : '/'); - } catch(\Exception $e) { + } catch (\Exception $e) { $storageInfo = $this->getStorageInfo(); } diff --git a/apps/files_external/tests/Storage/SmbTest.php b/apps/files_external/tests/Storage/SmbTest.php index 1040158cf19ed..437ef9a1cdf68 100644 --- a/apps/files_external/tests/Storage/SmbTest.php +++ b/apps/files_external/tests/Storage/SmbTest.php @@ -75,7 +75,7 @@ public function testStorageId() { public function testNotifyGetChanges() { $lastError = null; - for($i = 0; $i < 5; $i++) { + for ($i = 0; $i < 5; $i++) { try { $this->tryTestNotifyGetChanges(); return; diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 6808cf48ce1da..ea2bb3fa6688e 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -2108,7 +2108,7 @@ public function sendShareEmail(string $id, $password = ''): DataResponse { $provider->sendMailNotification($share); return new DataResponse(); - } catch(OCSBadRequestException $e) { + } catch (OCSBadRequestException $e) { throw $e; } catch (Exception $e) { throw new OCSException($this->l->t('Error while sending mail notification')); diff --git a/apps/files_trashbin/lib/Command/RestoreAllFiles.php b/apps/files_trashbin/lib/Command/RestoreAllFiles.php index cd86ede93cb48..969791379c153 100644 --- a/apps/files_trashbin/lib/Command/RestoreAllFiles.php +++ b/apps/files_trashbin/lib/Command/RestoreAllFiles.php @@ -173,7 +173,7 @@ protected function restoreDeletedFiles(string $uid, int $scope, ?int $since, ?in $prepMsg = $dryRun ? 'Would restore' : 'Preparing to restore'; $output->writeln("$prepMsg $trashCount files..."); $count = 0; - foreach($userTrashItems as $trashItem) { + foreach ($userTrashItems as $trashItem) { $filename = $trashItem->getName(); $humanTime = $this->l10n->l('datetime', $trashItem->getDeletedTime()); // We use getTitle() here instead of getOriginalLocation() because diff --git a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php index 222e49e971231..db9a43be6fc48 100644 --- a/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php +++ b/apps/files_trashbin/lib/Listeners/SyncLivePhotosListener.php @@ -112,7 +112,7 @@ private function handleRestore(BeforeNodeRestoredEvent $event, Node $peerFile): * TODO: This should be replaced by a proper method in the TrashManager. */ private function getTrashItem(array $trashFolder, string $path): ?ITrashItem { - foreach($trashFolder as $trashItem) { + foreach ($trashFolder as $trashItem) { if (str_starts_with($path, 'files_trashbin/files'.$trashItem->getTrashPath())) { if ($path === 'files_trashbin/files'.$trashItem->getTrashPath()) { return $trashItem; diff --git a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php index 31945e3830b7c..4092acecab8e3 100644 --- a/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php +++ b/apps/settings/lib/Settings/Admin/ArtificialIntelligence.php @@ -141,7 +141,7 @@ public function getForm() { $json = $this->config->getAppValue('core', $key, ''); if ($json !== '') { $value = json_decode($json, true); - switch($key) { + switch ($key) { case 'ai.taskprocessing_provider_preferences': case 'ai.textprocessing_provider_preferences': // fill $value with $defaultValue values diff --git a/apps/theming/lib/Service/ThemeInjectionService.php b/apps/theming/lib/Service/ThemeInjectionService.php index f65dde076bca2..3c7bf1ce544cc 100644 --- a/apps/theming/lib/Service/ThemeInjectionService.php +++ b/apps/theming/lib/Service/ThemeInjectionService.php @@ -52,12 +52,12 @@ public function injectHeaders(): void { $this->addThemeHeaders($defaultTheme); // Themes applied by media queries - foreach($mediaThemes as $theme) { + foreach ($mediaThemes as $theme) { $this->addThemeHeaders($theme, true, $theme->getMediaQuery()); } // Themes - foreach($this->themesService->getThemes() as $theme) { + foreach ($this->themesService->getThemes() as $theme) { // Ignore default theme as already processed first if ($theme->getId() === $this->defaultTheme->getId()) { continue; @@ -99,9 +99,9 @@ private function addThemeMetaHeaders(array $themes): void { $metaHeaders = []; // Meta headers - foreach($this->themesService->getThemes() as $theme) { + foreach ($this->themesService->getThemes() as $theme) { if (!empty($theme->getMeta())) { - foreach($theme->getMeta() as $meta) { + foreach ($theme->getMeta() as $meta) { if (!isset($meta['name']) || !isset($meta['content'])) { continue; } @@ -114,7 +114,7 @@ private function addThemeMetaHeaders(array $themes): void { } } - foreach($metaHeaders as $name => $content) { + foreach ($metaHeaders as $name => $content) { \OCP\Util::addHeader('meta', [ 'name' => $name, 'content' => join(' ', array_unique($content)), diff --git a/apps/user_ldap/lib/Connection.php b/apps/user_ldap/lib/Connection.php index d0ec1e447cc58..54dba6d858a30 100644 --- a/apps/user_ldap/lib/Connection.php +++ b/apps/user_ldap/lib/Connection.php @@ -397,8 +397,7 @@ private function doSoftValidation(): void { } foreach (['ldapExpertUUIDUserAttr' => 'ldapUuidUserAttribute', - 'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute'] - as $expertSetting => $effectiveSetting) { + 'ldapExpertUUIDGroupAttr' => 'ldapUuidGroupAttribute'] as $expertSetting => $effectiveSetting) { $uuidOverride = $this->configuration->$expertSetting; if (!empty($uuidOverride)) { $this->configuration->$effectiveSetting = $uuidOverride; diff --git a/apps/user_ldap/lib/LDAP.php b/apps/user_ldap/lib/LDAP.php index 048dba732d5e6..dcf2e6f62e12c 100644 --- a/apps/user_ldap/lib/LDAP.php +++ b/apps/user_ldap/lib/LDAP.php @@ -293,7 +293,7 @@ protected function invokeLDAPMethod(string $func, ...$arguments) { private function preFunctionCall(string $functionName, array $args): void { $this->curArgs = $args; - if(strcasecmp($functionName, 'ldap_bind') === 0 || strcasecmp($functionName, 'ldap_exop_passwd') === 0) { + if (strcasecmp($functionName, 'ldap_bind') === 0 || strcasecmp($functionName, 'ldap_exop_passwd') === 0) { // The arguments are not key value pairs // \OCA\User_LDAP\LDAP::bind passes 3 arguments, the 3rd being the pw // Remove it via direct array access for now, although a better solution could be found mebbe? diff --git a/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php b/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php index 7fe08e9719b59..23dec45292819 100644 --- a/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php +++ b/apps/user_status/lib/Listener/OutOfOfficeStatusListener.php @@ -37,7 +37,7 @@ public function __construct(private IJobList $jobsList, * @inheritDoc */ public function handle(Event $event): void { - if($event instanceof OutOfOfficeClearedEvent) { + if ($event instanceof OutOfOfficeClearedEvent) { $this->manager->revertUserStatus($event->getData()->getUser()->getUID(), IUserStatus::MESSAGE_OUT_OF_OFFICE, IUserStatus::DND); $this->jobsList->scheduleAfter(UserStatusAutomation::class, $this->time->getTime(), ['userId' => $event->getData()->getUser()->getUID()]); return; diff --git a/apps/user_status/lib/Listener/UserLiveStatusListener.php b/apps/user_status/lib/Listener/UserLiveStatusListener.php index fa4ff8e4aba67..ea8d995b8a3ef 100644 --- a/apps/user_status/lib/Listener/UserLiveStatusListener.php +++ b/apps/user_status/lib/Listener/UserLiveStatusListener.php @@ -72,7 +72,7 @@ public function handle(Event $event): void { } // Don't overwrite the "away" calendar status if it's set - if($userStatus->getMessageId() === IUserStatus::MESSAGE_CALENDAR_BUSY) { + if ($userStatus->getMessageId() === IUserStatus::MESSAGE_CALENDAR_BUSY) { $event->setUserStatus(new ConnectorUserStatus($userStatus)); return; } diff --git a/apps/user_status/lib/Service/StatusService.php b/apps/user_status/lib/Service/StatusService.php index 2a761a0f3049d..9adc13e4dbf83 100644 --- a/apps/user_status/lib/Service/StatusService.php +++ b/apps/user_status/lib/Service/StatusService.php @@ -499,10 +499,10 @@ private function addDefaultMessage(UserStatus $status): void { return; } // If there is a custom message, don't overwrite it - if(empty($status->getCustomMessage())) { + if (empty($status->getCustomMessage())) { $status->setCustomMessage($predefinedMessage['message']); } - if(empty($status->getCustomIcon())) { + if (empty($status->getCustomIcon())) { $status->setCustomIcon($predefinedMessage['icon']); } } diff --git a/apps/webhook_listeners/lib/Service/PHPMongoQuery.php b/apps/webhook_listeners/lib/Service/PHPMongoQuery.php index 451488ea22bdc..43429ce9393de 100644 --- a/apps/webhook_listeners/lib/Service/PHPMongoQuery.php +++ b/apps/webhook_listeners/lib/Service/PHPMongoQuery.php @@ -28,14 +28,14 @@ abstract class PHPMongoQuery { * @throws Exception */ public static function find(array $query, array $documents, array $options = []): array { - if(empty($documents) || empty($query)) { + if (empty($documents) || empty($query)) { return []; } $ret = []; $options['_shouldLog'] = !empty($options['logger']) && $options['logger'] instanceof \Psr\Log\LoggerInterface; $options['_debug'] = !empty($options['debug']); foreach ($documents as $doc) { - if(static::_executeQuery($query, $doc, $options)) { + if (static::_executeQuery($query, $doc, $options)) { $ret[] = $doc; } } @@ -56,11 +56,11 @@ public static function find(array $query, array $documents, array $options = []) public static function executeQuery($query, array &$document, array $options = []): bool { $options['_shouldLog'] = !empty($options['logger']) && $options['logger'] instanceof \Psr\Log\LoggerInterface; $options['_debug'] = !empty($options['debug']); - if($options['_debug'] && $options['_shouldLog']) { + if ($options['_debug'] && $options['_shouldLog']) { $options['logger']->debug('executeQuery called', ['query' => $query, 'document' => $document, 'options' => $options]); } - if(!is_array($query)) { + if (!is_array($query)) { return (bool)$query; } @@ -75,10 +75,10 @@ public static function executeQuery($query, array &$document, array $options = [ * @throws Exception */ private static function _executeQuery(array $query, array &$document, array $options = [], string $logicalOperator = '$and'): bool { - if($logicalOperator !== '$and' && (!count($query) || !isset($query[0]))) { + if ($logicalOperator !== '$and' && (!count($query) || !isset($query[0]))) { throw new Exception($logicalOperator.' requires nonempty array'); } - if($options['_debug'] && $options['_shouldLog']) { + if ($options['_debug'] && $options['_shouldLog']) { $options['logger']->debug('_executeQuery called', ['query' => $query, 'document' => $document, 'logicalOperator' => $logicalOperator]); } @@ -87,19 +87,19 @@ private static function _executeQuery(array $query, array &$document, array $opt // to detect an array of key->vals that have numeric IDs vs an array of queries (where keys were not specified) $queryIsIndexedArray = !empty($query) && array_is_list($query); - foreach($query as $k => $q) { + foreach ($query as $k => $q) { $pass = true; - if(is_string($k) && substr($k, 0, 1) === '$') { + if (is_string($k) && substr($k, 0, 1) === '$') { // key is an operator at this level, except $not, which can be at any level - if($k === '$not') { + if ($k === '$not') { $pass = !self::_executeQuery($q, $document, $options); } else { $pass = self::_executeQuery($q, $document, $options, $k); } - } elseif($logicalOperator === '$and') { // special case for $and - if($queryIsIndexedArray) { // $q is an array of query objects + } elseif ($logicalOperator === '$and') { // special case for $and + if ($queryIsIndexedArray) { // $q is an array of query objects $pass = self::_executeQuery($q, $document, $options); - } elseif(is_array($q)) { // query is array, run all queries on field. All queries must match. e.g { 'age': { $gt: 24, $lt: 52 } } + } elseif (is_array($q)) { // query is array, run all queries on field. All queries must match. e.g { 'age': { $gt: 24, $lt: 52 } } $pass = self::_executeQueryOnElement($q, $k, $document, $options); } else { // key value means equality @@ -108,30 +108,30 @@ private static function _executeQuery(array $query, array &$document, array $opt } else { // $q is array of query objects e.g '$or' => [{'fullName' => 'Nick'}] $pass = self::_executeQuery($q, $document, $options, '$and'); } - switch($logicalOperator) { + switch ($logicalOperator) { case '$and': // if any fail, query fails - if(!$pass) { + if (!$pass) { return false; } break; case '$or': // if one succeeds, query succeeds - if($pass) { + if ($pass) { return true; } break; case '$nor': // if one succeeds, query fails - if($pass) { + if ($pass) { return false; } break; default: - if($options['_shouldLog']) { + if ($options['_shouldLog']) { $options['logger']->warning('_executeQuery could not find logical operator', ['query' => $query, 'document' => $document, 'logicalOperator' => $logicalOperator]); } return false; } } - switch($logicalOperator) { + switch ($logicalOperator) { case '$and': // all succeeded, query succeeds return true; case '$or': // all failed, query fails @@ -139,7 +139,7 @@ private static function _executeQuery(array $query, array &$document, array $opt case '$nor': // all failed, query succeeded return true; default: - if($options['_shouldLog']) { + if ($options['_shouldLog']) { $options['logger']->warning('_executeQuery could not find logical operator', ['query' => $query, 'document' => $document, 'logicalOperator' => $logicalOperator]); } return false; @@ -152,12 +152,12 @@ private static function _executeQuery(array $query, array &$document, array $opt * @throws Exception */ private static function _executeQueryOnElement(array $query, string $element, array &$document, array $options = []): bool { - if($options['_debug'] && $options['_shouldLog']) { + if ($options['_debug'] && $options['_shouldLog']) { $options['logger']->debug('_executeQueryOnElement called', ['query' => $query, 'element' => $element, 'document' => $document]); } // iterate through query operators - foreach($query as $op => $opVal) { - if(!self::_executeOperatorOnElement($op, $opVal, $element, $document, $options)) { + foreach ($query as $op => $opVal) { + if (!self::_executeOperatorOnElement($op, $opVal, $element, $document, $options)) { return false; } } @@ -176,10 +176,10 @@ private static function _isEqual($v, $operatorValue): bool { if (is_array($v) && is_array($operatorValue)) { return $v == $operatorValue; } - if(is_array($v)) { + if (is_array($v)) { return in_array($operatorValue, $v); } - if(is_string($operatorValue) && preg_match('/^\/(.*?)\/([a-z]*)$/i', $operatorValue, $matches)) { + if (is_string($operatorValue) && preg_match('/^\/(.*?)\/([a-z]*)$/i', $operatorValue, $matches)) { return (bool)preg_match('/'.$matches[1].'/'.$matches[2], $v); } return $operatorValue === $v; @@ -196,34 +196,34 @@ private static function _isEqual($v, $operatorValue): bool { * @throws Exception Exceptions on invalid operators, invalid unknown operator callback, and invalid operator values */ private static function _executeOperatorOnElement(string $operator, $operatorValue, string $element, array &$document, array $options = []): bool { - if($options['_debug'] && $options['_shouldLog']) { + if ($options['_debug'] && $options['_shouldLog']) { $options['logger']->debug('_executeOperatorOnElement called', ['operator' => $operator, 'operatorValue' => $operatorValue, 'element' => $element, 'document' => $document]); } - if($operator === '$not') { + if ($operator === '$not') { return !self::_executeQueryOnElement($operatorValue, $element, $document, $options); } $elementSpecifier = explode('.', $element); $v = & $document; $exists = true; - foreach($elementSpecifier as $index => $es) { - if(empty($v)) { + foreach ($elementSpecifier as $index => $es) { + if (empty($v)) { $exists = false; break; } - if(isset($v[0])) { + if (isset($v[0])) { // value from document is an array, so we need to iterate through array and test the query on all elements of the array // if any elements match, then return true $newSpecifier = implode('.', array_slice($elementSpecifier, $index)); - foreach($v as $item) { - if(self::_executeOperatorOnElement($operator, $operatorValue, $newSpecifier, $item, $options)) { + foreach ($v as $item) { + if (self::_executeOperatorOnElement($operator, $operatorValue, $newSpecifier, $item, $options)) { return true; } } return false; } - if(isset($v[$es])) { + if (isset($v[$es])) { $v = & $v[$es]; } else { $exists = false; @@ -231,40 +231,40 @@ private static function _executeOperatorOnElement(string $operator, $operatorVal } } - switch($operator) { + switch ($operator) { case '$all': - if(!$exists) { + if (!$exists) { return false; } - if(!is_array($operatorValue)) { + if (!is_array($operatorValue)) { throw new Exception('$all requires array'); } - if(count($operatorValue) === 0) { + if (count($operatorValue) === 0) { return false; } - if(!is_array($v)) { - if(count($operatorValue) === 1) { + if (!is_array($v)) { + if (count($operatorValue) === 1) { return $v === $operatorValue[0]; } return false; } return count(array_intersect($v, $operatorValue)) === count($operatorValue); case '$e': - if(!$exists) { + if (!$exists) { return false; } return self::_isEqual($v, $operatorValue); case '$in': - if(!$exists) { + if (!$exists) { return false; } - if(!is_array($operatorValue)) { + if (!is_array($operatorValue)) { throw new Exception('$in requires array'); } - if(count($operatorValue) === 0) { + if (count($operatorValue) === 0) { return false; } - if(is_array($v)) { + if (is_array($v)) { return count(array_intersect($v, $operatorValue)) > 0; } return in_array($v, $operatorValue); @@ -274,43 +274,43 @@ private static function _executeOperatorOnElement(string $operator, $operatorVal case '$gte': return $exists && $v >= $operatorValue; case '$ne': return (!$exists && $operatorValue !== null) || ($exists && !self::_isEqual($v, $operatorValue)); case '$nin': - if(!$exists) { + if (!$exists) { return true; } - if(!is_array($operatorValue)) { + if (!is_array($operatorValue)) { throw new Exception('$nin requires array'); } - if(count($operatorValue) === 0) { + if (count($operatorValue) === 0) { return true; } - if(is_array($v)) { + if (is_array($v)) { return count(array_intersect($v, $operatorValue)) === 0; } return !in_array($v, $operatorValue); case '$exists': return ($operatorValue && $exists) || (!$operatorValue && !$exists); case '$mod': - if(!$exists) { + if (!$exists) { return false; } - if(!is_array($operatorValue)) { + if (!is_array($operatorValue)) { throw new Exception('$mod requires array'); } - if(count($operatorValue) !== 2) { + if (count($operatorValue) !== 2) { throw new Exception('$mod requires two parameters in array: divisor and remainder'); } return $v % $operatorValue[0] === $operatorValue[1]; default: - if(empty($options['unknownOperatorCallback']) || !is_callable($options['unknownOperatorCallback'])) { + if (empty($options['unknownOperatorCallback']) || !is_callable($options['unknownOperatorCallback'])) { throw new Exception('Operator '.$operator.' is unknown'); } $res = call_user_func($options['unknownOperatorCallback'], $operator, $operatorValue, $element, $document); - if($res === null) { + if ($res === null) { throw new Exception('Operator '.$operator.' is unknown'); } - if(!is_bool($res)) { + if (!is_bool($res)) { throw new Exception('Return value of unknownOperatorCallback must be boolean, actual value '.$res); } return $res; @@ -326,11 +326,11 @@ private static function _executeOperatorOnElement(string $operator, $operatorVal */ public static function getDependentFields(array $query) { $fields = []; - foreach($query as $k => $v) { - if(is_array($v)) { + foreach ($query as $k => $v) { + if (is_array($v)) { $fields = array_merge($fields, static::getDependentFields($v)); } - if(is_int($k) || $k[0] === '$') { + if (is_int($k) || $k[0] === '$') { continue; } $fields[] = $k; diff --git a/build/integration/features/bootstrap/Sharing.php b/build/integration/features/bootstrap/Sharing.php index 9862982931fce..a58a1b4fda365 100644 --- a/build/integration/features/bootstrap/Sharing.php +++ b/build/integration/features/bootstrap/Sharing.php @@ -303,7 +303,7 @@ public function createShare($user, public function isFieldInResponse($field, $contentExpected) { $data = simplexml_load_string($this->response->getBody())->data[0]; if ((string)$field == 'expiration') { - if(!empty($contentExpected)) { + if (!empty($contentExpected)) { $contentExpected = date('Y-m-d', strtotime($contentExpected)) . ' 00:00:00'; } } diff --git a/core/Command/Db/Migrations/PreviewCommand.php b/core/Command/Db/Migrations/PreviewCommand.php index b15f89765b9c7..f5b850fff76e0 100644 --- a/core/Command/Db/Migrations/PreviewCommand.php +++ b/core/Command/Db/Migrations/PreviewCommand.php @@ -94,12 +94,12 @@ private function displayMigrations(Table $table, string $appId, array $data): vo )->addRow(new TableSeparator()); /** @var MigrationAttribute[] $attributes */ - foreach($data as $migration => $attributes) { + foreach ($data as $migration => $attributes) { $attributesStr = []; if (empty($attributes)) { $attributesStr[] = '(metadata not set)'; } - foreach($attributes as $attribute) { + foreach ($attributes as $attribute) { $definition = '' . $attribute->definition() . ''; $definition .= empty($attribute->getDescription()) ? '' : "\n " . $attribute->getDescription(); $definition .= empty($attribute->getNotes()) ? '' : "\n " . implode("\n ", $attribute->getNotes()) . ''; diff --git a/core/Controller/TextProcessingApiController.php b/core/Controller/TextProcessingApiController.php index 82cd088d29ddb..e62389dee1167 100644 --- a/core/Controller/TextProcessingApiController.php +++ b/core/Controller/TextProcessingApiController.php @@ -109,7 +109,7 @@ public function schedule(string $input, string $type, string $appId, string $ide try { try { $this->textProcessingManager->runOrScheduleTask($task); - } catch(TaskFailureException) { + } catch (TaskFailureException) { // noop, because the task object has the failure status set already, we just return the task json } diff --git a/core/Controller/TextToImageApiController.php b/core/Controller/TextToImageApiController.php index c8528c19cc286..241c752ea013d 100644 --- a/core/Controller/TextToImageApiController.php +++ b/core/Controller/TextToImageApiController.php @@ -150,7 +150,7 @@ public function getImage(int $id, int $index): DataResponse|FileDisplayResponse $task = $this->textToImageManager->getUserTask($id, $this->userId); try { $folder = $this->appData->getFolder('text2image'); - } catch(NotFoundException) { + } catch (NotFoundException) { $res = new DataResponse(['message' => $this->l->t('Image not found')], Http::STATUS_NOT_FOUND); $res->throttle(['action' => 'text2image']); return $res; diff --git a/lib/private/AppConfig.php b/lib/private/AppConfig.php index c27150a67dc8c..f6361ff2ac68d 100644 --- a/lib/private/AppConfig.php +++ b/lib/private/AppConfig.php @@ -1378,7 +1378,7 @@ public function getFilteredValues($app) { * @return array */ private function formatAppValues(string $app, array $values, ?bool $lazy = null): array { - foreach($values as $key => $value) { + foreach ($values as $key => $value) { try { $type = $this->getValueType($app, $key, $lazy); } catch (AppConfigUnknownKeyException $e) { diff --git a/lib/private/Comments/Manager.php b/lib/private/Comments/Manager.php index 9237c88469144..8b7f43c03a2e5 100644 --- a/lib/private/Comments/Manager.php +++ b/lib/private/Comments/Manager.php @@ -132,7 +132,7 @@ protected function prepareCommentForDatabaseWrite(IComment $comment): IComment { try { $comment->getCreationDateTime(); - } catch(\LogicException $e) { + } catch (\LogicException $e) { $comment->setCreationDateTime(new \DateTime()); } diff --git a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php index d40934669d741..c3ce28376e34d 100644 --- a/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php +++ b/lib/private/DB/QueryBuilder/Sharded/AutoIncrementHandler.php @@ -34,7 +34,7 @@ public function __construct( } private function getCache(): IMemcache { - if(is_null($this->cache)) { + if (is_null($this->cache)) { $cache = $this->cacheFactory->createDistributed('shared_autoincrement'); if ($cache instanceof IMemcache) { $this->cache = $cache; @@ -118,7 +118,7 @@ private function getNextInner(ShardDefinition $shardDefinition): ?int { $next = $cache->inc($shardDefinition->table); if (is_int($next) && $next >= self::MIN_VALID_KEY) { return $next; - } elseif(is_int($next)) { + } elseif (is_int($next)) { // key got cleared, invalidate and retry $cache->cas($shardDefinition->table, $next, 'empty-placeholder'); return null; diff --git a/lib/private/Files/Cache/SearchBuilder.php b/lib/private/Files/Cache/SearchBuilder.php index 32502cb8258b8..748844b9e1b3e 100644 --- a/lib/private/Files/Cache/SearchBuilder.php +++ b/lib/private/Files/Cache/SearchBuilder.php @@ -290,7 +290,7 @@ private function getExtraOperatorField(ISearchComparison $operator, IMetadataQue $value = $operator->getValue(); $type = $operator->getType(); - switch($operator->getExtra()) { + switch ($operator->getExtra()) { case IMetadataQuery::EXTRA: $metadataQuery->joinIndex($field); // join index table if not joined yet $field = $metadataQuery->getMetadataValueField($field); diff --git a/lib/private/Migration/MetadataManager.php b/lib/private/Migration/MetadataManager.php index 324c169c626f6..cdaa604ce5a02 100644 --- a/lib/private/Migration/MetadataManager.php +++ b/lib/private/Migration/MetadataManager.php @@ -43,7 +43,7 @@ public function extractMigrationAttributes(string $appId): array { $ms = new MigrationService($appId, $this->connection); $metadata = []; - foreach($ms->getAvailableVersions() as $version) { + foreach ($ms->getAvailableVersions() as $version) { $metadata[$version] = []; $class = new ReflectionClass($ms->createInstance($version)); $attributes = $class->getAttributes(); diff --git a/lib/private/Search/SearchQuery.php b/lib/private/Search/SearchQuery.php index a78443922ae64..791edb7a0f709 100644 --- a/lib/private/Search/SearchQuery.php +++ b/lib/private/Search/SearchQuery.php @@ -25,7 +25,7 @@ public function __construct( private int $limit = self::LIMIT_DEFAULT, private int|string|null $cursor = null, private string $route = '', - private array $routeParameters = [], + private array $routeParameters = [], ) { } diff --git a/lib/private/Security/Ip/Address.php b/lib/private/Security/Ip/Address.php index b4f12a7e295fe..1df94e0a9c7aa 100644 --- a/lib/private/Security/Ip/Address.php +++ b/lib/private/Security/Ip/Address.php @@ -33,7 +33,7 @@ public static function isValid(string $ip): bool { } public function matches(IRange... $ranges): bool { - foreach($ranges as $range) { + foreach ($ranges as $range) { if ($range->contains($this)) { return true; } diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 391b77171a964..bb34468db6e3b 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -275,7 +275,7 @@ protected function validateExpirationDateInternal(IShare $share) { // If $expirationDate is falsy, noExpirationDate is true and expiration not enforced // Then skip expiration date validation as null is accepted - if(!$share->getNoExpirationDate() || $isEnforced) { + if (!$share->getNoExpirationDate() || $isEnforced) { if ($expirationDate !== null) { $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); $expirationDate->setTime(0, 0, 0); @@ -353,7 +353,7 @@ protected function validateExpirationDateLink(IShare $share) { // If $expirationDate is falsy, noExpirationDate is true and expiration not enforced // Then skip expiration date validation as null is accepted - if(!($share->getNoExpirationDate() && !$isEnforced)) { + if (!($share->getNoExpirationDate() && !$isEnforced)) { if ($expirationDate !== null) { $expirationDate->setTimezone($this->dateTimeZone->getTimeZone()); $expirationDate->setTime(0, 0, 0); diff --git a/lib/private/TaskProcessing/Manager.php b/lib/private/TaskProcessing/Manager.php index fb0a4da4c4e23..1b170a03ec2c1 100644 --- a/lib/private/TaskProcessing/Manager.php +++ b/lib/private/TaskProcessing/Manager.php @@ -175,7 +175,7 @@ public function process(?string $userId, array $input, callable $reportProgress) } try { return ['output' => $this->provider->process($input['input'])]; - } catch(\RuntimeException $e) { + } catch (\RuntimeException $e) { throw new ProcessingException($e->getMessage(), 0, $e); } } @@ -306,7 +306,7 @@ public function getOptionalOutputShape(): array { public function process(?string $userId, array $input, callable $reportProgress): array { try { $folder = $this->appData->getFolder('text2image'); - } catch(\OCP\Files\NotFoundException) { + } catch (\OCP\Files\NotFoundException) { $folder = $this->appData->newFolder('text2image'); } $resources = []; @@ -994,7 +994,7 @@ public function fillInputFileData(?string $userId, array $input, ...$specs): arr } $newInputOutput = []; $spec = array_reduce($specs, fn ($carry, $spec) => $carry + $spec, []); - foreach($spec as $key => $descriptor) { + foreach ($spec as $key => $descriptor) { $type = $descriptor->getShapeType(); if (!isset($input[$key])) { continue; @@ -1086,7 +1086,7 @@ public function encapsulateOutputFileData(array $output, ...$specs): array { $folder = $this->appData->newFolder('TaskProcessing'); } $spec = array_reduce($specs, fn ($carry, $spec) => $carry + $spec, []); - foreach($spec as $key => $descriptor) { + foreach ($spec as $key => $descriptor) { $type = $descriptor->getShapeType(); if (!isset($output[$key])) { continue; @@ -1231,7 +1231,7 @@ private function storeTask(Task $task): void { private function validateOutputFileIds(array $output, ...$specs): array { $newOutput = []; $spec = array_reduce($specs, fn ($carry, $spec) => $carry + $spec, []); - foreach($spec as $key => $descriptor) { + foreach ($spec as $key => $descriptor) { $type = $descriptor->getShapeType(); if (!isset($output[$key])) { continue; diff --git a/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php b/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php index 823ea09a62217..acec2f46c055d 100644 --- a/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php +++ b/lib/private/TaskProcessing/RemoveOldTasksBackgroundJob.php @@ -65,7 +65,7 @@ protected function run($argument): void { * @return void */ private function clearFilesOlderThan(ISimpleFolder $folder, int $ageInSeconds): void { - foreach($folder->getDirectoryListing() as $file) { + foreach ($folder->getDirectoryListing() as $file) { if ($file->getMTime() < time() - $ageInSeconds) { try { $file->delete(); diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index 55fb348f01b3c..a4984eaf93051 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -281,7 +281,7 @@ public function getConfig(): string { $result = ''; // Echo it - foreach ($array as $setting => $value) { + foreach ($array as $setting => $value) { $result .= 'var '. $setting . '='. $value . ';' . PHP_EOL; } diff --git a/lib/private/TextToImage/Manager.php b/lib/private/TextToImage/Manager.php index 2d6cc6450a11c..88dc108f3801e 100644 --- a/lib/private/TextToImage/Manager.php +++ b/lib/private/TextToImage/Manager.php @@ -119,13 +119,13 @@ public function runTask(Task $task): void { } try { $folder = $this->appData->getFolder('text2image'); - } catch(NotFoundException) { + } catch (NotFoundException) { $this->logger->debug('Creating folder in appdata for Text2Image results'); $folder = $this->appData->newFolder('text2image'); } try { $folder = $folder->getFolder((string)$task->getId()); - } catch(NotFoundException) { + } catch (NotFoundException) { $this->logger->debug('Creating new folder in appdata Text2Image results folder'); $folder = $folder->newFolder((string)$task->getId()); } @@ -162,7 +162,7 @@ public function runTask(Task $task): void { if (isset($files, $files[$i])) { try { $files[$i]->delete(); - } catch(NotPermittedException $e) { + } catch (NotPermittedException $e) { $this->logger->warning('Failed to clean up Text2Image result file after error', ['exception' => $e]); } } diff --git a/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php b/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php index 525d68df22bf2..7d9170090b713 100644 --- a/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php +++ b/lib/private/TextToImage/RemoveOldTasksBackgroundJob.php @@ -55,7 +55,7 @@ protected function run($argument) { } } catch (Exception $e) { $this->logger->warning('Failed to delete stale text to image tasks', ['exception' => $e]); - } catch(NotFoundException) { + } catch (NotFoundException) { // noop } } diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index 96be58a84a2bf..9a84b102a9901 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -751,7 +751,7 @@ public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $queryBuilder->expr()->eq('p.appid', $queryBuilder->expr()->literal('login')), $queryBuilder->expr()->eq('p.configkey', $queryBuilder->expr()->literal('lastLogin'))) ); - if($search !== '') { + if ($search !== '') { $queryBuilder->leftJoin('u', 'preferences', 'p1', $queryBuilder->expr()->andX( $queryBuilder->expr()->eq('p1.userid', 'uid'), $queryBuilder->expr()->eq('p1.appid', $queryBuilder->expr()->literal('settings')), diff --git a/tests/lib/Files/Search/SearchIntegrationTest.php b/tests/lib/Files/Search/SearchIntegrationTest.php index 141eaca238cb8..c1017537a0c6b 100644 --- a/tests/lib/Files/Search/SearchIntegrationTest.php +++ b/tests/lib/Files/Search/SearchIntegrationTest.php @@ -33,7 +33,7 @@ public function testThousandAndOneFilters() { $id = $this->cache->put('file10', ['size' => 1, 'mtime' => 50, 'mimetype' => 'foo/folder']); $comparisons = []; - for($i = 1; $i <= 1001; $i++) { + for ($i = 1; $i <= 1001; $i++) { $comparisons[] = new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'name', "file$i"); } $operator = new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, $comparisons); diff --git a/tests/lib/TaskProcessing/TaskProcessingTest.php b/tests/lib/TaskProcessing/TaskProcessingTest.php index 0fb281a0533b6..624f09ae2d8e6 100644 --- a/tests/lib/TaskProcessing/TaskProcessingTest.php +++ b/tests/lib/TaskProcessing/TaskProcessingTest.php @@ -351,7 +351,7 @@ public function getName(): string { public function generate(string $prompt, array $resources): void { $this->ran = true; - foreach($resources as $resource) { + foreach ($resources as $resource) { fwrite($resource, 'test'); } }