yiisoft /
demo
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\User; |
||
| 6 | |||
| 7 | use Yiisoft\Access\AccessCheckerInterface; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Yiisoft\User\CurrentUser; |
||
|
0 ignored issues
–
show
The type
Yiisoft\User\CurrentUser 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...
|
|||
| 9 | |||
| 10 | final class UserService |
||
| 11 | { |
||
| 12 | public function __construct( |
||
| 13 | private CurrentUser $currentUser, |
||
| 14 | private UserRepository $repository, |
||
| 15 | private AccessCheckerInterface $accessChecker |
||
| 16 | ) { |
||
| 17 | } |
||
| 18 | |||
| 19 | public function getUser(): ?User |
||
| 20 | { |
||
| 21 | $userId = $this->currentUser->getId(); |
||
| 22 | |||
| 23 | if ($userId === null) { |
||
| 24 | return null; |
||
| 25 | } |
||
| 26 | |||
| 27 | return $this->repository->findById($this->currentUser->getId()); |
||
| 28 | } |
||
| 29 | |||
| 30 | public function hasPermission(string $permission): bool |
||
| 31 | { |
||
| 32 | $userId = $this->currentUser->getId(); |
||
| 33 | |||
| 34 | return null !== $userId && $this->accessChecker->userHasPermission($userId, $permission); |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
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