sascha-egerer / phpstan-typo3

TYPO3 CMS class reflection extension for PHPStan & framework-specific rules
MIT License
42 stars 22 forks source link

Repository class must implement RepositoryInterface #158

Closed bewital-msa closed 8 months ago

bewital-msa commented 8 months ago

I'll get the following error on my repositories, even though they are extending the default TYPO3 repository.

Internal error: Internal error: Repository class "Company\MyExtension\Domain\Repository\VisitorRepository" must implement "TYPO3\CMS\Extbase\Persistence\RepositoryInterface" while analysing file 

My VisitorRepository extends the class TYPO3\CMS\Extbase\Persistence\Repository. And the default TYPO3 repository implements the corresponding Interface. So this error doesn't make any sense, in my opinion.

<?php

declare(strict_types=1);

namespace Company\MyExtension\Domain\Repository;

use Company\MyExtension\Domain\Model\Event;
use Company\MyExtension\Domain\Model\FrontendUser;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface;
use TYPO3\CMS\Extbase\Persistence\Repository;

class VisitorRepository extends Repository
{

When I remove the include line that includes your extension.neon (in the PHPStan configuration), PHPStan passes without errors.

PHP 8.1 TYPO3 11.5.35 PHPStan-TYPO3 1.10.0 PHPStan 1.10.59

sascha-egerer commented 8 months ago

Hi @bewital-msa,

is your extension installed and are requirements in your extension composer.json set properly?

bewital-msa commented 8 months ago

Hi @sascha-egerer,

yes, the extension is installed and is working fine. Also the requirements are set properly, there are no problems with composer.

The only thing i can think of is, that this projects uses 'helhum/typo3-secure-web' and this package is deprecated. Could this be the problem?

sascha-egerer commented 8 months ago

Hi @sascha-egerer,

yes, the extension is installed and is working fine. Also the requirements are set properly, there are no problems with composer.

The only thing i can think of is, that this projects uses 'helhum/typo3-secure-web' and this package is deprecated. Could this be the problem?

No, thats not related.

It looks like that RepositoryInterface is not available while phpstan does the processing. So i would still say there's something wrong in the composer setup.

Do you run phpstan via your project or directly in your extension?

bewital-msa commented 8 months ago

Hey @sascha-egerer,

I got it, my composer autoload files were broken (some paths in it). I've started from scratch and now it's working. Thank you!