Comments (10)
I tried to solve it via .phpstorm.meta.php
which resolves warning when assigning to private UserRepository $userRepository;
, but phpstorm still thinks it is UserRepository|IRepository
and acts like with IRepository
<?php declare(strict_types = 1);
namespace PHPSTORM_META;
override(
\Nextras\Orm\Model\IModel::getRepository(0),
type(0)
);
from orm-intellij.
What does it mean to "act slike with IRepository"?
It works for me. Also try please
override(\Nextras\Orm\Model\IModel::getRepository(0), map(['' => '@']));
which may be more correct.
from orm-intellij.
What does it mean to "act slike with IRepository"?
It's the type phpstorm shows when I am inspecting property type via ctrl and mouse pointer over $this->userRepository
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.
from orm-intellij.
phpstorm meta just helped me to get rid of warning Incompatible types: Expected property of type '\OriCMF\Core\User\UserRepository', '\Nextras\Orm\Repository\IRepository' provided
and got the repository-specific methods to work, but calling any findBy*
and getBy*
methods result only into IEntity (even to mixed in ICollection) and also the conditions autocomplete in findBy()
and getBy()
does not work.
I guess the plugin does not play well with the union type? But I understand it's phpstorm error, because the IRepository
type in property with UserRepository
type is impossible.
from orm-intellij.
Thanks for detailed description, the failing resolution over class property was plugin's bug.
from orm-intellij.
Released as 0.8.0. Either wait for the review from JB, or use the zip in the release:
https://github.com/nextras/orm-intellij/releases/tag/v0.8.0
from orm-intellij.
Thanks, it works as expected, in combination with .phpstorm.meta.php
from orm-intellij.
I just found that one minor issue is still left, assignment of repository to variable is needed.
With variable assignment, $user
is User
$userRepository = $this->model->getRepository(UserRepository::class);
$user = $userRepository->getByIdChecked(1);
assert($user instanceof User);
Without variable assignment, $user
is IEntity
$user = $this->model->getRepository(UserRepository::class)->getByIdChecked(1);
assert($user instanceof IEntity);
from orm-intellij.
Create new issue please.
from orm-intellij.
Phpstorm meta added to repo: nextras/orm@f0d67ae
from orm-intellij.
Related Issues (20)
- RuntimeException ClassNotFoundException ModifierHighlighterAnnotator HOT 4
- Fix support for PhpStorm 2018.1 HOT 1
- Fix support for PhpStorm 2019.2 HOT 3
- PhpStorm 2019.2 - unused methods - support for getters HOT 1
- Implement support for Nextras Orm 4 HOT 1
- Check installation without restart
- Autocomplete properties from traits
- No autocompletion when not using this-> HOT 3
- Result of IModel->getRepository() has to be stored in variable to work properly HOT 1
- highlihter: key, values, arrays, strings, other php types
- modifiers: click references for relationship property
- modifier: auto detection of missing modifier symetric relationship + autofix intent
- Plugin fails on PHPStorm 2022.3 EAP HOT 3
- Make sure plugins works with settings sync
- findBy() & getBy() auto type resolution (i.e. ICollection|Book[]) HOT 1
- java.lang.Throwable: AWT events are not allowed inside write action HOT 2
- findBy key property autocompletion. HOT 1
- Support nested findBy reference privider & autocompletion
- Exception occurs on "go to usage" action from phpdoc property declaration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from orm-intellij.