phpstan-typo3
phpstan-typo3 copied to clipboard
Having a class called …Repository should not mandate it being an Extbase repository
The repository pattern existed before Extbase and is useful w/o Extbase, so having a check that lets PhpStan fail if a class called SomethingRepository
does not (directly or via a parent class) implement RepositoryInterface
seems unnecessarily strict to me.
@sascha-egerer What do you think? Should we loosen this check here? I would vote +1 for it.
Makes sense
@andreaswolf Could you create a PR for that?
I have the relevant changes ready, I'm just not sure enough they don't break anything… I tried writing a test for a plain repository, but the only type I get for any findBy* method is "*ERROR*
".
Help greatly appreciated :)
@andreaswolf Could you provide more details?
@sascha-egerer see the WIP commits on the 124-… branch in my fork. The two latest fixups are failed attempts to fix the issue.
I think it may be better to just remove the \PHPStan\ShouldNotHappenException
in translateRepositoryNameToModelName
instead, if the current class is not a RepositoryInterface::class
. I've run into several issues, where a repository extended an abstract repository of another extension which implemented TYPO3\CMS\Extbase\Persistence\Repository
, but phpstan kept throwing the exception, that the repository does not implement RepositoryInterface
.
I'll try to check that soon.