Skip to content

Commit

Permalink
fix: Apply new coding standard to all files
Browse files Browse the repository at this point in the history
Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 2, 2024
1 parent b074399 commit ec5133b
Show file tree
Hide file tree
Showing 276 changed files with 465 additions and 466 deletions.
18 changes: 9 additions & 9 deletions apps/admin_audit/lib/AuditLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,39 +49,39 @@ public function __construct(ILogFactory $logFactory, IConfig $config) {
$this->parentLogger = $logFactory->getCustomPsrLogger($logFile, $auditType, $auditTag);
}

public function emergency($message, array $context = array()): void {
public function emergency($message, array $context = []): void {
$this->parentLogger->emergency($message, $context);
}

public function alert($message, array $context = array()): void {
public function alert($message, array $context = []): void {
$this->parentLogger->alert($message, $context);
}

public function critical($message, array $context = array()): void {
public function critical($message, array $context = []): void {
$this->parentLogger->critical($message, $context);
}

public function error($message, array $context = array()): void {
public function error($message, array $context = []): void {
$this->parentLogger->error($message, $context);
}

public function warning($message, array $context = array()): void {
public function warning($message, array $context = []): void {
$this->parentLogger->warning($message, $context);
}

public function notice($message, array $context = array()): void {
public function notice($message, array $context = []): void {
$this->parentLogger->notice($message, $context);
}

public function info($message, array $context = array()): void {
public function info($message, array $context = []): void {
$this->parentLogger->info($message, $context);
}

public function debug($message, array $context = array()): void {
public function debug($message, array $context = []): void {
$this->parentLogger->debug($message, $context);
}

public function log($level, $message, array $context = array()): void {
public function log($level, $message, array $context = []): void {
$this->parentLogger->log($level, $message, $context);
}
}
2 changes: 1 addition & 1 deletion apps/cloud_federation_api/lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function getCapabilities() {
$this->provider->setApiVersion(self::API_VERSION);

$pos = strrpos($url, '/');
if (false === $pos) {
if ($pos === false) {
throw new OCMArgumentException('generated route should contains a slash character');
}

Expand Down
2 changes: 1 addition & 1 deletion apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __construct(
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'comments') {
throw new \InvalidArgumentException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function testCleanUp(): void {
$this->assertCount(0, $this->recentContactMapper->findAll('admin'));
}

protected function createRecentContact(string $email = null, string $federatedCloudId = null): RecentContact {
protected function createRecentContact(?string $email = null, ?string $federatedCloudId = null): RecentContact {
$props = [
'URI' => UUIDUtil::getUUID(),
'FN' => 'Foo Bar',
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 @@ -24,7 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
use \OCA\DAV\Direct\ServerFactory;
use OCA\DAV\Direct\ServerFactory;

// no php execution timeout for webdav
if (!str_contains(@ini_get('disable_functions'), 'set_time_limit')) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Activity/Provider/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function __construct(IFactory $languageFactory, IURLGenerator $url, IMana
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar') {
throw new \InvalidArgumentException();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Activity/Provider/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ protected function generateObjectParameter(array $eventData) {
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_event') {
throw new \InvalidArgumentException();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Activity/Provider/Todo.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Todo extends Event {
* @throws \InvalidArgumentException
* @since 11.0.0
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') {
throw new \InvalidArgumentException();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/BirthdayService.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ private function getReminderOffsetForUser(string $userPrincipal):?string {
*/
private function formatTitle(string $field,
string $name,
int $year = null,
?int $year = null,
bool $supports4Byte = true):string {
if ($supports4Byte) {
switch ($field) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2169,7 +2169,7 @@ public function searchPrincipalUri(string $principalUri,
->andWhere($searchOr)
->andWhere($calendarObjectIdQuery->expr()->isNull('deleted_at'));

if ('' !== $pattern) {
if ($pattern !== '') {
if (!$escapePattern) {
$calendarObjectIdQuery->andWhere($calendarObjectIdQuery->expr()->ilike('cob.value', $calendarObjectIdQuery->createNamedParameter($pattern)));
} else {
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Reminder/ReminderService.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ public function onCalendarObjectDelete(array $objectData):void {
private function getRemindersForVAlarm(VAlarm $valarm,
array $objectData,
DateTimeZone $calendarTimeZone,
string $eventHash = null,
string $alarmHash = null,
?string $eventHash = null,
?string $alarmHash = null,
bool $isRecurring = false,
bool $isRecurrenceException = false):array {
if ($eventHash === null) {
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/CalDAV/Schedule/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
use Sabre\VObject\Parameter;
use Sabre\VObject\Property;
use Sabre\VObject\Reader;
use function \Sabre\Uri\split;
use function Sabre\Uri\split;

class Plugin extends \Sabre\CalDAV\Schedule\Plugin {

Expand Down Expand Up @@ -457,7 +457,7 @@ private function getCurrentAttendee(ITip\Message $iTipMessage):?Property {
* @param Property|null $attendee
* @return bool
*/
private function getAttendeeRSVP(Property $attendee = null):bool {
private function getAttendeeRSVP(?Property $attendee = null):bool {
if ($attendee !== null) {
$rsvp = $attendee->offsetGet('RSVP');
if (($rsvp instanceof Parameter) && (strcasecmp($rsvp->getValue(), 'TRUE') === 0)) {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/Status/StatusService.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private function getCalendarEvents(User $user): array {
}

$sct = $calendarObject->getSchedulingTransparency();
if ($sct !== null && ScheduleCalendarTransp::TRANSPARENT == strtolower($sct->getValue())) {
if ($sct !== null && strtolower($sct->getValue()) == ScheduleCalendarTransp::TRANSPARENT) {
// If a calendar is marked as 'transparent', it means we must
// ignore it for free-busy purposes.
continue;
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/Activity/Provider/Addressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(IFactory $languageFactory,
* @return IEvent
* @throws \InvalidArgumentException
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') {
throw new \InvalidArgumentException();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/Activity/Provider/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(IFactory $languageFactory,
* @return IEvent
* @throws \InvalidArgumentException
*/
public function parse($language, IEvent $event, IEvent $previousEvent = null): IEvent {
public function parse($language, IEvent $event, ?IEvent $previousEvent = null): IEvent {
if ($event->getApp() !== 'dav' || $event->getType() !== 'contacts') {
throw new \InvalidArgumentException();
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/CardDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ private function searchByAddressBookIds(array $addressBookIds,
->andWhere($query2->expr()->in('cp.name', $query2->createNamedParameter($searchProperties, IQueryBuilder::PARAM_STR_ARRAY)));

// No need for like when the pattern is empty
if ('' !== $pattern) {
if ($pattern !== '') {
if (!$useWildcards) {
$query2->andWhere($query2->expr()->eq('cp.value', $query2->createNamedParameter($pattern)));
} elseif (!$escapePattern) {
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 @@ -271,7 +271,7 @@ public function getLocalSystemAddressBook() {
return $this->localSystemAddressBook;
}

public function syncInstance(\Closure $progressCallback = null) {
public function syncInstance(?\Closure $progressCallback = null) {
$systemAddressBook = $this->getLocalSystemAddressBook();
$this->userManager->callForAllUsers(function ($user) use ($systemAddressBook, $progressCallback) {
$this->updateUser($user);
Expand Down
6 changes: 3 additions & 3 deletions apps/dav/lib/Command/MoveCalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$calendar = $this->calDav->getCalendarByUri(self::URI_USERS . $userOrigin, $name);

if (null === $calendar) {
if ($calendar === null) {
throw new \InvalidArgumentException("User <$userOrigin> has no calendar named <$name>. You can run occ dav:list-calendars to list calendars URIs for this user.");
}

Expand Down Expand Up @@ -133,7 +133,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
* Check if the calendar exists for user
*/
protected function calendarExists(string $userDestination, string $name): bool {
return null !== $this->calDav->getCalendarByUri(self::URI_USERS . $userDestination, $name);
return $this->calDav->getCalendarByUri(self::URI_USERS . $userDestination, $name) !== null;
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ private function checkShares(array $calendar, string $userOrigin, string $userDe
* Check that user destination is member of the groups which whom the calendar was shared
* If we ask to force the migration, the share with the group is dropped
*/
if ($this->shareManager->shareWithGroupMembersOnly() === true && 'groups' === $prefix && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($this->shareManager->shareWithGroupMembersOnly() === true && $prefix === 'groups' && !$this->groupManager->isInGroup($userDestination, $userOrGroup)) {
if ($force) {
$this->calDav->updateShares(new Calendar($this->calDav, $calendar, $this->l10n, $this->config, $this->logger), [], ['principal:principals/groups/' . $userOrGroup]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Comments/EntityCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getChildren() {
* @param \DateTime|null $datetime
* @return CommentNode[]
*/
public function findChildren($limit = 0, $offset = 0, \DateTime $datetime = null) {
public function findChildren($limit = 0, $offset = 0, ?\DateTime $datetime = null) {
$comments = $this->commentsManager->getForObject($this->name, $this->id, $limit, $offset, $datetime);
$result = [];
foreach ($comments as $comment) {
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 || str_starts_with($nodePath, $path . '/')) {
if ($path === '' || $nodePath == $path || str_starts_with($nodePath, $path . '/')) {
unset($this->cache[$nodePath]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Directory extends \OCA\DAV\Connector\Sabre\Node implements \Sabre\DAV\ICol
/**
* Sets up the node, expects a full path name
*/
public function __construct(View $view, FileInfo $info, ?CachingTree $tree = null, IShareManager $shareManager = null) {
public function __construct(View $view, FileInfo $info, ?CachingTree $tree = null, ?IShareManager $shareManager = null) {
parent::__construct($view, $info, $shareManager);
$this->tree = $tree;
}
Expand Down Expand Up @@ -202,7 +202,7 @@ public function createDirectory($name) {
* @throws \Sabre\DAV\Exception\NotFound
* @throws \Sabre\DAV\Exception\ServiceUnavailable
*/
public function getChild($name, $info = null, IRequest $request = null, IL10N $l10n = null) {
public function getChild($name, $info = null, ?IRequest $request = null, ?IL10N $l10n = null) {
if (!$this->info->isReadable()) {
// avoid detecting files through this way
throw new NotFound();
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Exception/FileLocked.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Exception;

class FileLocked extends \Sabre\DAV\Exception {
public function __construct($message = "", $code = 0, Exception $previous = null) {
public function __construct($message = "", $code = 0, ?Exception $previous = null) {
if ($previous instanceof \OCP\Files\LockNotAcquiredException) {
$message = sprintf('Target file %s is locked by another process.', $previous->path);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Exception/Forbidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Forbidden extends \Sabre\DAV\Exception\Forbidden {
* @param bool $retry
* @param \Exception $previous
*/
public function __construct($message, $retry = false, \Exception $previous = null) {
public function __construct($message, $retry = false, ?\Exception $previous = null) {
parent::__construct($message, 0, $previous);
$this->retry = $retry;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Exception/InvalidPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class InvalidPath extends Exception {
* @param bool $retry
* @param \Exception|null $previous
*/
public function __construct($message, $retry = false, \Exception $previous = null) {
public function __construct($message, $retry = false, ?\Exception $previous = null) {
parent::__construct($message, 0, $previous);
$this->retry = $retry;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class File extends Node implements IFile {
* @param ?IRequest $request
* @param ?IL10N $l10n
*/
public function __construct(View $view, FileInfo $info, IManager $shareManager = null, IRequest $request = null, IL10N $l10n = null) {
public function __construct(View $view, FileInfo $info, ?IManager $shareManager = null, ?IRequest $request = null, ?IL10N $l10n = null) {
parent::__construct($view, $info, $shareManager);

if ($l10n) {
Expand Down
4 changes: 2 additions & 2 deletions apps/dav/lib/Connector/Sabre/FilesPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public function handleUpdateProperties($path, PropPatch $propPatch) {
*/
private function handleUpdatePropertiesMetadata(PropPatch $propPatch, Node $node): void {
$userId = $this->userSession->getUser()?->getUID();
if (null === $userId) {
if ($userId === null) {
return;
}

Expand Down Expand Up @@ -667,7 +667,7 @@ private function getMetadataFileAccessRight(Node $node, string $userId): int {
* @param \Sabre\DAV\INode $node
* @throws \Sabre\DAV\Exception\BadRequest
*/
public function sendFileIdHeader($filePath, \Sabre\DAV\INode $node = null) {
public function sendFileIdHeader($filePath, ?\Sabre\DAV\INode $node = null) {
// chunked upload handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
[$path, $name] = \Sabre\Uri\split($filePath);
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class Node implements \Sabre\DAV\INode {
/**
* Sets up the node, expects a full path name
*/
public function __construct(View $view, FileInfo $info, IManager $shareManager = null) {
public function __construct(View $view, FileInfo $info, ?IManager $shareManager = null) {
$this->fileView = $view;
$this->path = $this->fileView->getRelativePath($info->getPath());
$this->info = $info;
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/DAV/Sharing/Xml/Invite.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Invite implements XmlSerializable {
*
* @param array $users
*/
public function __construct(array $users, array $organizer = null) {
public function __construct(array $users, ?array $organizer = null) {
$this->users = $users;
$this->organizer = $organizer;
}
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ public function changeUser($params) {
}
}

public function firstLogin(IUser $user = null) {
public function firstLogin(?IUser $user = null) {
if (!is_null($user)) {
$principal = 'principals/users/' . $user->getUID();
if ($this->calDav->getCalendarsForUserCount($principal) === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ private function getTemplateMock():IEMailTemplate {
* @param array|null $replyTo
* @return IMessage
*/
private function getMessageMock(string $toMail, IEMailTemplate $templateMock, array $replyTo = null):IMessage {
private function getMessageMock(string $toMail, IEMailTemplate $templateMock, ?array $replyTo = null):IMessage {
$message = $this->createMock(IMessage::class);
$i = 0;

Expand Down
Loading

0 comments on commit ec5133b

Please sign in to comment.