-
-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IModel->getRepository() support #18
Comments
I tried to solve it via
|
What does it mean to "act slike with IRepository"?
which may be more correct. |
It's the type phpstorm shows when I am inspecting property type via ctrl and mouse pointer over Check the following example - in comments are types which phpstorm thinks variables have use Nextras\Orm\Model\IModel;
use OriCMF\Core\User\UserRepository;
final class Test
{
private IModel $model;
private UserRepository $userRepository;
public function __construct(IModel $model)
{
$this->model = $model;
$this->userRepository = $model->getRepository(UserRepository::class);
}
public function test(): void
{
// $this->userRepository is IRepository|UserRepository
// $user1 is IEntity
$user1 = $this->userRepository->getByIdChecked(1);
// $collection is ICollection
$collection = $this->userRepository->findAll();
// $user is mixed
foreach ($collection as $user) {
}
}
} Your syntax has the same problem. I think it should even be equal, mine is just syntax sugar from newer phpstorm release. |
phpstorm meta just helped me to get rid of warning |
Thanks for detailed description, the failing resolution over class property was plugin's bug. |
Released as 0.8.0. Either wait for the review from JB, or use the zip in the release: |
Thanks, it works as expected, in combination with .phpstorm.meta.php |
I just found that one minor issue is still left, assignment of repository to variable is needed. With variable assignment,
Without variable assignment,
|
Create new issue please. |
Phpstorm meta added to repo: nextras/orm@f0d67ae |
Would it please be possible to add support for
$userRepository = $model->getRepository(UserRepository::class);
? Currently it's justIRepository
for phpstorm.I can't add annotations to an extended Model class and find myself quite often in situation with 3-6 repositories where replacing them with model would reduce boilerplate significantly.
Thank you for consideration :)
The text was updated successfully, but these errors were encountered: