Skip to content

Commit

Permalink
get() by alias actually returns a HelperInterface or a callable
Browse files Browse the repository at this point in the history
Signed-off-by: George Steel <[email protected]>
  • Loading branch information
gsteel committed Jul 19, 2022
1 parent 62dbaeb commit 696a4f0
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 8 deletions.
2 changes: 1 addition & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1594,7 +1594,7 @@
<code>$container</code>
</MixedAssignment>
<MixedInferredReturnType occurrences="1">
<code>($name is class-string ? T : callable)</code>
<code>($name is class-string ? T : HelperInterface|callable)</code>
</MixedInferredReturnType>
<MixedMethodCall occurrences="8">
<code>get</code>
Expand Down
2 changes: 1 addition & 1 deletion src/HelperPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public function validatePlugin($instance)
* @param class-string<T>|string $name Service name of plugin to retrieve.
* @param null|array<mixed> $options Options to use when creating the instance.
* @return HelperInterface|callable
* @psalm-return ($name is class-string ? T : callable)
* @psalm-return ($name is class-string ? T : HelperInterface|callable)
*/
public function get($name, ?array $options = null)
{
Expand Down
6 changes: 0 additions & 6 deletions test/StaticAnalysis/PluginRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ public function retrieveHelperByClassName(string $email): string
return ($this->pluginManager->get(GravatarImage::class))($email);
}

public function retrievalByAliasAssumesCallable(): void
{
$helper = $this->pluginManager->get('something');
$helper();
}

public function retrievalByClassNameInfersKnownMethods(): string
{
$helper = $this->pluginManager->get(Layout::class);
Expand Down

0 comments on commit 696a4f0

Please sign in to comment.