Skip to content

Commit

Permalink
fix: Fix new psalm errors from update
Browse files Browse the repository at this point in the history
Not sure about the SimpleContainer modification, let’s see what CI says
 about that.

Signed-off-by: Côme Chilliet <[email protected]>
  • Loading branch information
come-nc committed Apr 2, 2024
1 parent dd371a3 commit bc13eb7
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 32 deletions.
2 changes: 1 addition & 1 deletion apps/dav/lib/CalDAV/CalDavBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2347,7 +2347,7 @@ public function getCalendarObjectById(string $principalUri, int $id): ?array {
* @param int $syncLevel
* @param int|null $limit
* @param int $calendarType
* @return array
* @return ?array
*/
public function getChangesForCalendar($calendarId, $syncToken, $syncLevel, $limit = null, $calendarType = self::CALENDAR_TYPE_CALENDAR) {
$table = $calendarType === self::CALENDAR_TYPE_CALENDAR ? 'calendars': 'calendarsubscriptions';
Expand Down
2 changes: 1 addition & 1 deletion lib/private/AppFramework/Utility/SimpleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __construct() {
* @psalm-param S $id
* @psalm-return (S is class-string<T> ? T : mixed)
*/
public function get(string $id) {
public function get(string $id): object {
return $this->query($id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,30 @@ public function persist(string $providerId, string $uid, int $enabled): void {
/**
* Delete all provider states of a user and return the provider IDs
*
* @param string $uid
*
* @return list<array{provider_id: string, uid: string, enabled: bool}>
*/
public function deleteByUser(string $uid): array {
$qb1 = $this->conn->getQueryBuilder();
$selectQuery = $qb1->select('*')
->from(self::TABLE_NAME)
->where($qb1->expr()->eq('uid', $qb1->createNamedParameter($uid)));
$selectResult = $selectQuery->execute();
$selectResult = $selectQuery->executeQuery();
$rows = $selectResult->fetchAll();
$selectResult->closeCursor();

$qb2 = $this->conn->getQueryBuilder();
$deleteQuery = $qb2
->delete(self::TABLE_NAME)
->where($qb2->expr()->eq('uid', $qb2->createNamedParameter($uid)));
$deleteQuery->execute();
$deleteQuery->executeStatement();

return array_map(function (array $row) {
return array_values(array_map(function (array $row) {
return [
'provider_id' => $row['provider_id'],
'uid' => $row['uid'],
'enabled' => (int) $row['enabled'] === 1,
'provider_id' => (string)$row['provider_id'],
'uid' => (string)$row['uid'],
'enabled' => $row['enabled'] === 1,
];
}, $rows);
}, $rows));
}

public function deleteAll(string $providerId): void {
Expand Down
5 changes: 1 addition & 4 deletions lib/private/DB/QueryBuilder/Literal.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ public function __construct($literal) {
$this->literal = $literal;
}

/**
* @return string
*/
public function __toString() {
public function __toString(): string {
return (string) $this->literal;
}
}
5 changes: 1 addition & 4 deletions lib/private/DB/QueryBuilder/Parameter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public function __construct($name) {
$this->name = $name;
}

/**
* @return string
*/
public function __toString() {
public function __toString(): string {
return (string) $this->name;
}
}
5 changes: 1 addition & 4 deletions lib/private/DB/QueryBuilder/QueryFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ public function __construct($function) {
$this->function = $function;
}

/**
* @return string
*/
public function __toString() {
public function __toString(): string {
return (string) $this->function;
}
}
8 changes: 3 additions & 5 deletions lib/private/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ public function formatDateRelativeDay($timestamp, $format = 'long', ?\DateTimeZo
*
* @param int|\DateTime $timestamp Either a Unix timestamp or DateTime object
* @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time
* @param \OCP\IL10N $l The locale to use
* @return string Dates returned are:
* < 1 month => Today, Yesterday, n days ago
* < 13 month => last month, n months ago
* >= 13 month => last year, n years ago
* @param \OCP\IL10N $l The locale to use
* @return string Formatted date span
*/
public function formatDateSpan($timestamp, $baseTimestamp = null, ?\OCP\IL10N $l = null) {
$l = $this->getLocale($l);
Expand Down Expand Up @@ -220,15 +219,14 @@ public function formatTime($timestamp, $format = 'medium', ?\DateTimeZone $timeZ
*
* @param int|\DateTime $timestamp Either a Unix timestamp or DateTime object
* @param int|\DateTime $baseTimestamp Timestamp to compare $timestamp against, defaults to current time
* @return string Dates returned are:
* @param \OCP\IL10N $l The locale to use
* @return string Dates returned are:
* < 60 sec => seconds ago
* < 1 hour => n minutes ago
* < 1 day => n hours ago
* < 1 month => Yesterday, n days ago
* < 13 month => last month, n months ago
* >= 13 month => last year, n years ago
* @param \OCP\IL10N $l The locale to use
* @return string Formatted time span
*/
public function formatTimeSpan($timestamp, $baseTimestamp = null, ?\OCP\IL10N $l = null) {
$l = $this->getLocale($l);
Expand Down
2 changes: 1 addition & 1 deletion lib/private/Diagnostics/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public function getDuration() {
return $this->end - $this->start;
}

public function __toString() {
public function __toString(): string {
return $this->getId() . ' ' . $this->getDescription() . ' ' . $this->getDuration();
}
}
2 changes: 1 addition & 1 deletion lib/private/legacy/OC_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ public function data(): ?string {
/**
* @return string - base64 encoded, which is suitable for embedding in a VCard.
*/
public function __toString() {
public function __toString(): string {
return base64_encode($this->data());
}

Expand Down
3 changes: 1 addition & 2 deletions lib/public/Files/LockNotAcquiredException.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,9 @@ public function __construct($path, $lockType, $code = 0, ?\Exception $previous =
/**
* custom string representation of object
*
* @return string
* @since 7.0.0
*/
public function __toString() {
public function __toString(): string {
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}

0 comments on commit bc13eb7

Please sign in to comment.