Skip to content

Commit e27e2e4

Browse files
authored
Merge pull request #41844 from nextcloud/fix/tp-api-covariance
fix(TextProcessing): Add task type template param to IManager and registerTPProvider
2 parents 546cf0e + fe6d9e3 commit e27e2e4

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

lib/public/TextProcessing/IProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
/**
3232
* This is the interface that is implemented by apps that
3333
* implement a text processing provider
34-
* @template T of ITaskType
34+
* @psalm-template-covariant T of ITaskType
3535
* @since 27.1.0
3636
*/
3737
interface IProvider {

lib/public/TextProcessing/Task.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
/**
2929
* This is a text processing task
3030
* @since 27.1.0
31-
* @psalm-template T of ITaskType
32-
* @psalm-template S as class-string<T>
33-
* @psalm-template P as IProvider<T>
31+
* @psalm-template-covariant T of ITaskType
3432
*/
3533
final class Task implements \JsonSerializable {
3634
protected ?int $id = null;
@@ -74,7 +72,7 @@ final class Task implements \JsonSerializable {
7472
protected int $status = self::STATUS_UNKNOWN;
7573

7674
/**
77-
* @psalm-param S $type
75+
* @psalm-param class-string<T> $type
7876
* @param string $type
7977
* @param string $input
8078
* @param string $appId
@@ -92,7 +90,7 @@ final public function __construct(
9290
}
9391

9492
/**
95-
* @psalm-param P $provider
93+
* @psalm-param IProvider<T> $provider
9694
* @param IProvider $provider
9795
* @return string
9896
* @since 27.1.0
@@ -109,7 +107,7 @@ public function visitProvider(IProvider $provider): string {
109107
}
110108

111109
/**
112-
* @psalm-param P $provider
110+
* @psalm-param IProvider<T> $provider
113111
* @param IProvider $provider
114112
* @return bool
115113
* @since 27.1.0
@@ -119,7 +117,7 @@ public function canUseProvider(IProvider $provider): bool {
119117
}
120118

121119
/**
122-
* @psalm-return S
120+
* @psalm-return class-string<T>
123121
* @since 27.1.0
124122
*/
125123
final public function getType(): string {
@@ -207,7 +205,7 @@ final public function getUserId(): ?string {
207205
}
208206

209207
/**
210-
* @psalm-return array{id: ?int, type: S, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, output: ?string, identifier: string, completionExpectedAt: ?int}
208+
* @psalm-return array{id: ?int, type: class-string<T>, status: 0|1|2|3|4, userId: ?string, appId: string, input: string, output: ?string, identifier: string, completionExpectedAt: ?int}
211209
* @since 27.1.0
212210
*/
213211
public function jsonSerialize(): array {

0 commit comments

Comments
 (0)