Skip to content

Commit

Permalink
minor #126 [PhpStan] Fix @template boundaries (ogizanagi)
Browse files Browse the repository at this point in the history
This PR was merged into the 0.x-dev branch.

Discussion
----------

[PhpStan] Fix `@template` boundaries

See https://arnaud.le-blanc.net/post/phpstan-generics.html#bounds

With this, PhpStan properly detects the return type of `ContentManagerInterface::getContent(Foo::class, 'foo')` is of type `Foo` and not just `object`

Commits
-------

9f4184d [PhpStan] Fix `@template` boundaries
  • Loading branch information
ogizanagi committed Feb 3, 2022
2 parents 5c7848f + 9f4184d commit fa793c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ContentManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ContentManagerInterface
/**
* List all content for the given type
*
* @template T
* @template T of object
*
* @param class-string<T> $type Model FQCN e.g. "App/Model/Article"
* @param string|array|callable $sortBy String, array or callable
Expand All @@ -31,7 +31,7 @@ public function getContents(string $type, $sortBy = null, $filterBy = null): arr
/**
* Fetch a specific content
*
* @template T
* @template T of object
*
* @param class-string<T> $type Model FQCN e.g. "App/Model/Article"
* @param string $id Unique identifier (slug)
Expand Down

0 comments on commit fa793c9

Please sign in to comment.