Skip to content
Open
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: 2 additions & 0 deletions lib/Service/IRecommendation.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ public function hasPreview(): bool;
public function setHasPreview(bool $state);

public function getReason(): string;

public function getEtag(): string;
}
7 changes: 7 additions & 0 deletions lib/Service/RecommendedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
private int $timestamp;
private string $reason;
private bool $hasPreview;
private string $etag;

public function __construct(string $directory,
Node $node,
Expand All @@ -31,6 +32,7 @@
$this->reason = $reason;
$this->timestamp = $timestamp;
$this->hasPreview = false;
$this->etag = $node->getEtag();
}

public function getId(): string {
Expand All @@ -53,6 +55,10 @@
return $this->reason;
}

public function getEtag(): string {
return $this->etag;
}

public function hasPreview(): bool {
return $this->hasPreview;
}
Expand All @@ -62,11 +68,11 @@
}

/**
* @return RecommendationsRecommendedFile

Check failure on line 71 in lib/Service/RecommendedFile.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidReturnType

lib/Service/RecommendedFile.php:71:13: InvalidReturnType: The declared return type 'array{directory: string, extension: string, hasPreview: bool, id: string, mimeType: string, name: string, reason: string, timestamp: int}' for OCA\Recommendations\Service\RecommendedFile::jsonSerialize is incorrect, got 'array{directory: string, etag: string, extension: string, hasPreview: bool, id: string, mimeType: string, name: string, reason: string, timestamp: int}' which is different due to additional array shape fields (etag) (see https://psalm.dev/011)
*/
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return [

Check failure on line 75 in lib/Service/RecommendedFile.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

InvalidReturnStatement

lib/Service/RecommendedFile.php:75:10: InvalidReturnStatement: The inferred type 'array{directory: string, etag: string, extension: string, hasPreview: bool, id: string, mimeType: string, name: string, reason: string, timestamp: int}' does not match the declared return type 'array{directory: string, extension: string, hasPreview: bool, id: string, mimeType: string, name: string, reason: string, timestamp: int}' for OCA\Recommendations\Service\RecommendedFile::jsonSerialize due to additional array shape fields (etag) (see https://psalm.dev/128)
'id' => $this->getId(),
'timestamp' => $this->getTimestamp(),
'name' => $this->node->getName(),
Expand All @@ -75,6 +81,7 @@
'mimeType' => $this->node->getMimetype(),
'hasPreview' => $this->hasPreview(),
'reason' => $this->getReason(),
'etag' => $this->getEtag(),
];
}
}
Loading