Skip to content

Commit

Permalink
[TASK] Resolve v12 phpstan errors
Browse files Browse the repository at this point in the history
Only the `findAll()` QueryResultInterface return type is kept,
as we do not return an array here.
  • Loading branch information
bnf committed Oct 17, 2024
1 parent fa00afa commit f9869d0
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 37 deletions.
34 changes: 2 additions & 32 deletions Build/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
parameters:
ignoreErrors:
-
message: "#^Call to method addHeaderContent\\(\\) on an unknown class TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\ModifyPageLayoutContentEvent\\.$#"
message: "#^Return type \\(TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\QueryResultInterface\\) of method T3G\\\\AgencyPack\\\\Blog\\\\Domain\\\\Repository\\\\PostRepository\\:\\:findAll\\(\\) should be covariant with return type \\(iterable\\<object\\>\\) of method TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\RepositoryInterface\\<object\\>\\:\\:findAll\\(\\)$#"
count: 1
path: ../Classes/Listener/ModifyPageLayoutContent.php

-
message: "#^Call to method getRequest\\(\\) on an unknown class TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\ModifyPageLayoutContentEvent\\.$#"
count: 1
path: ../Classes/Listener/ModifyPageLayoutContent.php

-
message: "#^Method T3G\\\\AgencyPack\\\\Blog\\\\Listener\\\\ModifyPageLayoutContent\\:\\:__invoke\\(\\) has no return type specified\\.$#"
count: 1
path: ../Classes/Listener/ModifyPageLayoutContent.php

-
message: "#^Parameter \\$event of method T3G\\\\AgencyPack\\\\Blog\\\\Listener\\\\ModifyPageLayoutContent\\:\\:__invoke\\(\\) has invalid type TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\ModifyPageLayoutContentEvent\\.$#"
count: 1
path: ../Classes/Listener/ModifyPageLayoutContent.php

-
message: "#^Call to method addContentAbove\\(\\) on an unknown class TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\RenderAdditionalContentToRecordListEvent\\.$#"
count: 1
path: ../Classes/Listener/RenderAdditionalContentToRecordList.php

-
message: "#^Call to method getRequest\\(\\) on an unknown class TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\RenderAdditionalContentToRecordListEvent\\.$#"
count: 1
path: ../Classes/Listener/RenderAdditionalContentToRecordList.php

-
message: "#^Parameter \\$event of method T3G\\\\AgencyPack\\\\Blog\\\\Listener\\\\RenderAdditionalContentToRecordList\\:\\:__invoke\\(\\) has invalid type TYPO3\\\\CMS\\\\Backend\\\\Controller\\\\Event\\\\RenderAdditionalContentToRecordListEvent\\.$#"
count: 1
path: ../Classes/Listener/RenderAdditionalContentToRecordList.php
path: ../Classes/Domain/Repository/PostRepository.php
2 changes: 1 addition & 1 deletion Classes/Controller/PostController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct(
}

/**
* @param ViewInterface|\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view
* @param ViewInterface $view
*/
protected function initializeView($view): void
{
Expand Down
6 changes: 4 additions & 2 deletions Classes/Domain/Model/Author.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ public function initializeObject(): void

public function getAvatarProvider(): AvatarProviderInterface
{
$avatarProvider = trim($this->avatarProvider) !== ''
? GeneralUtility::makeInstance($this->avatarProvider)
/** @var class-string<object>|'' $avatarProviderClassName */
$avatarProviderClassName = trim($this->avatarProvider);
$avatarProvider = $avatarProviderClassName !== ''
? GeneralUtility::makeInstance($avatarProviderClassName)
: GeneralUtility::makeInstance(GravatarProvider::class);

if (!$avatarProvider instanceof AvatarProviderInterface) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Validator/GoogleCaptchaValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GoogleCaptchaValidator extends AbstractValidator
{
protected $acceptsEmptyValues = false;

public function isValid($value): void
public function isValid(mixed $value): void
{
$action = 'form';
$controller = 'Comment';
Expand Down
2 changes: 1 addition & 1 deletion Classes/Listener/ModifyPageLayoutContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(BlogPostHeaderContentRenderer $blogPostHeaderContent
$this->blogPostHeaderContentRenderer = $blogPostHeaderContentRenderer;
}

public function __invoke(ModifyPageLayoutContentEvent $event)
public function __invoke(ModifyPageLayoutContentEvent $event): void
{
$request = $event->getRequest();
$content = $this->blogPostHeaderContentRenderer->render($request);
Expand Down
1 change: 1 addition & 0 deletions Classes/Notification/NotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function notify(NotificationInterface $notification): void
$notificationId = $notification->getNotificationId();
if (\is_array($this->visitorsRegistry[$notificationId] ?? null)) {
foreach ($this->visitorsRegistry[$notificationId] as $visitorClassName) {
/** @var class-string<object> $visitorClassName */
$instance = GeneralUtility::makeInstance($visitorClassName);
if ($instance instanceof ProcessorInterface) {
$instance->process($notification);
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/AvatarProvider/GravatarProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class GravatarProviderTest extends FunctionalTestCase

public function testGetAvatarUrlReturnsOriginalGravatarComUrl(): void
{
/** @phpstan-ignore-next-line */
$frontendTypoScript = new FrontendTypoScript(new RootNode(), [], [], []);
$frontendTypoScript->setSetupArray([]);
$request = (new ServerRequest())
Expand All @@ -49,6 +50,7 @@ public function testGetAvatarUrlReturnsOriginalGravatarComUrl(): void
public function testGetAvatarUrlReturnsTypo3TempUrl(): void
{
$GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['blog']['enableGravatarProxy'] = '1';
/** @phpstan-ignore-next-line */
$frontendTypoScript = new FrontendTypoScript(new RootNode(), [], [], []);
$frontendTypoScript->setSetupArray([]);
$request = (new ServerRequest())
Expand Down
2 changes: 2 additions & 0 deletions Tests/Functional/SiteBasedTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ protected function createTestSite(): void

GeneralUtility::rmdir($this->instancePath . '/typo3conf/sites/' . $identifier, true);
if ((new Typo3Version())->getMajorVersion() >= 13) {
/** @phpstan-ignore-next-line */
$this->get(SiteWriter::class)->write($identifier, $configuration);
} else {
/** @phpstan-ignore-next-line */
$this->get(SiteConfiguration::class)->write($identifier, $configuration);
}
}
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/ViewHelpers/GravatarViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ final class GravatarViewHelperTest extends FunctionalTestCase
#[DataProvider('renderDataProvider')]
public function render(string $template, string $expected): void
{
/** @phpstan-ignore-next-line */
$frontendTypoScript = new FrontendTypoScript(new RootNode(), [], [], []);
$frontendTypoScript->setSetupArray([]);
$request = (new ServerRequest())
Expand Down
1 change: 1 addition & 0 deletions Tests/Functional/ViewHelpers/Uri/AvatarViewHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class AvatarViewHelperTest extends FunctionalTestCase
#[DataProvider('renderDataProvider')]
public function render(string $template, string $expected): void
{
/** @phpstan-ignore-next-line */
$frontendTypoScript = new FrontendTypoScript(new RootNode(), [], [], []);
$frontendTypoScript->setSetupArray([]);
$request = (new ServerRequest())
Expand Down

0 comments on commit f9869d0

Please sign in to comment.