Closed soullivaneuh closed 5 years ago
This is currently not possible because there's no way how to write a @var
above a property that would tell that there's EntityRepository<PowerDNSDomain>
. That would require a lot of coordinated effort across phpstan/phpdoc-parser
and phpstan/phpstan
which is planned for the future but not on the immediate roadmap. cc @JanTvrdik thoughts?
Well, phpstan/phpstan uses DI, so in theory extensions can extend a LOT more stuff, than is officially documented, i.e. phpstan/phpstan-doctrine
can decorate the TypeNodeResolver
service to resolve EntityRepository<PowerDNSDomain>
to EntityRepositoryType
. No changes to phpstan/phpdoc-parser
are required.
That being said, extending and decorating core phpstan services should probably not be encouraged.
That's nice to know! I don't consider TypeNodeResolver as a public API with any BC incentives so I'd rather have an official extension point, but this can be used meanwhile...
@Soullivaneuh @ondrejmirtes it looks like this has already been fixed in newer versions of PHPStan (as proven by #37).
Edit: this comment is actually invalid, PHPStan is not validating the method calls as I expected.
This is now supported, but you have to write @var ObjectRepository<PowerDNSDomain>
.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
In a nutshell, this PHP class:
Produces:
Replacing the line by
$domain = $this->getRepository(PowerDNSDomain::class)->findOneBy(['name' => $nameCanonical]);
directly "solve" the issue.It seems the property assignation of repositories is not handled by the extension.