yiisoft /
demo
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Blog; |
||
| 6 | |||
| 7 | use App\Exception\NotFoundException; |
||
| 8 | use Yiisoft\Data\Paginator\OffsetPaginator; |
||
|
0 ignored issues
–
show
|
|||
| 9 | use Yiisoft\Data\Paginator\PaginatorInterface; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Data\Paginator\PaginatorInterface was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | |||
| 11 | final class BlogService |
||
| 12 | { |
||
| 13 | private const POSTS_PER_PAGE = 10; |
||
| 14 | private PostRepository $postRepository; |
||
| 15 | |||
| 16 | public function __construct(PostRepository $postRepository) |
||
| 17 | { |
||
| 18 | $this->postRepository = $postRepository; |
||
| 19 | } |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @psalm-return PaginatorInterface<array-key, Post> |
||
| 23 | */ |
||
| 24 | public function getPosts(int $page): PaginatorInterface |
||
| 25 | { |
||
| 26 | $dataReader = $this->postRepository->findAll(); |
||
| 27 | |||
| 28 | /** @psalm-var PaginatorInterface<array-key, Post> */ |
||
| 29 | return (new OffsetPaginator($dataReader)) |
||
| 30 | ->withPageSize(self::POSTS_PER_PAGE) |
||
| 31 | ->withCurrentPage($page); |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @param int $id |
||
| 36 | * |
||
| 37 | * @throws NotFoundException |
||
| 38 | * |
||
| 39 | * @return Post |
||
| 40 | */ |
||
| 41 | public function getPost(int $id): Post |
||
| 42 | { |
||
| 43 | /** |
||
| 44 | * @var Post|null $post |
||
| 45 | */ |
||
| 46 | $post = $this->postRepository->findOne(['id' => $id]); |
||
| 47 | if ($post === null) { |
||
| 48 | throw new NotFoundException(); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $post; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths