Skip to content

Commit

Permalink
fix: Correctly type functions
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jan 27, 2025
1 parent 1a8670e commit 6af2766
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
6 changes: 3 additions & 3 deletions apps/files_external/lib/Command/Notify.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,20 @@ private function logUpdate(IChange $change, OutputInterface $output): void {
}

private function getStorageIds(int $mountId, string $path): array {
$pathHash = md5(trim((string)\OC_Util::normalizeUnicode($path), '/'));
$pathHash = md5(trim(\OC_Util::normalizeUnicode($path), '/'));
$qb = $this->connection->getQueryBuilder();
return $qb
->select('storage_id', 'user_id')
->from('mounts', 'm')
->innerJoin('m', 'filecache', 'f', $qb->expr()->eq('m.storage_id', 'f.storage'))
->where($qb->expr()->eq('mount_id', $qb->createNamedParameter($mountId, IQueryBuilder::PARAM_INT)))
->andWhere($qb->expr()->eq('path_hash', $qb->createNamedParameter($pathHash, IQueryBuilder::PARAM_STR)))
->execute()
->executeQuery()
->fetchAll();
}

private function updateParent(array $storageIds, string $parent): int {
$pathHash = md5(trim((string)\OC_Util::normalizeUnicode($parent), '/'));
$pathHash = md5(trim(\OC_Util::normalizeUnicode($parent), '/'));
$qb = $this->connection->getQueryBuilder();
return $qb
->update('filecache')
Expand Down
6 changes: 0 additions & 6 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,6 @@
</InvalidNullableReturnType>
<InvalidScalarArgument>
<code><![CDATA[$path]]></code>
<code><![CDATA[\OC_Util::normalizeUnicode($path)]]></code>
</InvalidScalarArgument>
<NullableReturnStatement>
<code><![CDATA[null]]></code>
Expand Down Expand Up @@ -2026,11 +2025,6 @@
</NoInterfaceProperties>
</file>
<file src="lib/private/Files/Storage/Wrapper/Encoding.php">
<InvalidArgument>
<code><![CDATA[\Normalizer::FORM_C]]></code>
<code><![CDATA[\Normalizer::FORM_C]]></code>
<code><![CDATA[\Normalizer::FORM_D]]></code>
</InvalidArgument>
<UndefinedInterfaceMethod>
<code><![CDATA[$this->namesCache]]></code>
<code><![CDATA[$this->namesCache]]></code>
Expand Down
8 changes: 4 additions & 4 deletions lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -937,18 +937,18 @@ public static function getTheme() {
}

/**
* Normalize a unicode string
* Normalize a unicode string.
*
* @param string $value a not normalized string
* @return bool|string
* @return string The normalized string or the input if the normalization failed
*/
public static function normalizeUnicode($value) {
public static function normalizeUnicode(string $value): string {
if (Normalizer::isNormalized($value)) {
return $value;
}

$normalizedValue = Normalizer::normalize($value);
if ($normalizedValue === null || $normalizedValue === false) {
if ($normalizedValue === false) {
\OCP\Server::get(LoggerInterface::class)->warning('normalizing failed for "' . $value . '"', ['app' => 'core']);
return $value;
}
Expand Down

0 comments on commit 6af2766

Please sign in to comment.