Skip to content
Closed
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
add psalm return type to SimpleContainer::get using templates
this way psalm (and phpstorm) know what `\OC::->get(...)` returns

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Sep 9, 2021
commit 3e2e1e1f387e6c19a42ef46f2b5c68ae37978a52
5 changes: 5 additions & 0 deletions lib/private/AppFramework/Utility/SimpleContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public function __construct() {
$this->container = new Container();
}

/**
* @template T
* @psalm-param class-string<T> $id
* @psalm-return T
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also make it work with parameters like we did for

* @psalm-return ($name is class-string ? T : mixed)
? As in, only specify that it will return an instance of T if $id is a class-string

*/
public function get(string $id) {
return $this->query($id);
}
Expand Down