Skip to content

Commit

Permalink
[TASK] Add TYPO3 v13 code phpstan errors for TYPO3v12 to baseline
Browse files Browse the repository at this point in the history
PHPStan does not understand or respect TYPO3
version conditional based code to make code
flows based on the TYPO3 version, which leads
to false-positive error reportings.

Until a better solution can be provided, we need
to add them to the depending phpstan baseline file.

Used command(s):

```bash
Build/Scripts/runTests.sh -t 12 -p 8.2 -s composerUpdate
Build/Scripts/runTests.sh -t 12 -p 8.2 -s phpstanGenerateBaseline
Build/Scripts/runTests.sh -t 13 -p 8.2 -s composerUpdate
Build/Scripts/runTests.sh -t 13 -p 8.2 -s phpstanGenerateBaseline
```
  • Loading branch information
sbuerk committed Dec 19, 2024
1 parent a56b751 commit 2513b34
Show file tree
Hide file tree
Showing 4 changed files with 219 additions and 6 deletions.
1 change: 1 addition & 0 deletions Build/Scripts/composer-for-core-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
composer_cleanup() {
echo -e "💥 Cleanup folders"
rm -Rf \
.cache/phpstan/* \
.Build/vendor/* \
.Build/var/* \
.Build/bin/* \
Expand Down
120 changes: 120 additions & 0 deletions Build/phpstan/Core12/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ parameters:
count: 1
path: ../../../Classes/Service/LanguageService.php

-
message: "#^Call to method write\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteWriter\\.$#"
count: 1
path: ../../../Classes/Upgrades/FormalityUpgradeWizard.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Utility\\\\DeeplBackendUtility\\:\\:buildBackendRoute\\(\\) has parameter \\$parameters with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -105,6 +110,16 @@ parameters:
count: 1
path: ../../../Tests/Functional/Fixtures/Frontend/PhpError.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 7 parameters, 2\\-3 required\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry not found\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Hooks\\\\TranslateHookTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -155,6 +170,26 @@ parameters:
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Parameter \\#2 \\$eventDispatcher of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects Psr\\\\EventDispatcher\\\\EventDispatcherInterface, TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory given\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Parameter \\#3 \\$coreCache of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\PhpFrontend\\|null, TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry given\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 7 parameters, 2\\-3 required\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry not found\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Regression\\\\LocalizationInlineRegressionTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -205,6 +240,26 @@ parameters:
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Parameter \\#2 \\$eventDispatcher of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects Psr\\\\EventDispatcher\\\\EventDispatcherInterface, TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Parameter \\#3 \\$coreCache of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\PhpFrontend\\|null, TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 7 parameters, 2\\-3 required\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry not found\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Regression\\\\PreviewTranslationInformationTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -255,11 +310,31 @@ parameters:
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Parameter \\#2 \\$eventDispatcher of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects Psr\\\\EventDispatcher\\\\EventDispatcherInterface, TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Parameter \\#3 \\$coreCache of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\PhpFrontend\\|null, TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Cannot access property \\$code on DeepL\\\\Language\\|null\\.$#"
count: 7
path: ../../../Tests/Functional/Services/DeeplServiceTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 7 parameters, 2\\-3 required\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry not found\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Services\\\\LanguageServiceTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -310,6 +385,26 @@ parameters:
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Parameter \\#2 \\$eventDispatcher of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects Psr\\\\EventDispatcher\\\\EventDispatcherInterface, TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory given\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Parameter \\#3 \\$coreCache of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\PhpFrontend\\|null, TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry given\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 7 parameters, 2\\-3 required\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry not found\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Updates\\\\FormalityUpgradeWizardTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -359,3 +454,28 @@ parameters:
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Updates\\\\FormalityUpgradeWizardTest\\:\\:writeSiteConfiguration\\(\\) has parameter \\$site with no value type specified in iterable type array\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Parameter \\#2 \\$eventDispatcher of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects Psr\\\\EventDispatcher\\\\EventDispatcherInterface, TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory given\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Parameter \\#3 \\$coreCache of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Cache\\\\Frontend\\\\PhpFrontend\\|null, TYPO3\\\\CMS\\\\Core\\\\Site\\\\Set\\\\SetRegistry given\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Call to method create\\(\\) on an unknown class TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewFactoryInterface\\.$#"
count: 1
path: ../../../Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewFactoryInterface not found\\.$#"
count: 1
path: ../../../Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php

-
message: "#^Instantiated class TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewFactoryData not found\\.$#"
count: 1
path: ../../../Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php
90 changes: 90 additions & 0 deletions Build/phpstan/Core13/phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Frontend\\\\Controller\\\\TypoScriptFrontendController\\:\\:getContext\\(\\)\\.$#"
count: 1
path: ../../../Classes/Event/Listener/RenderTranslatedFlagInFrontendPreviewMode.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Form\\\\Item\\\\SiteConfigSupportedLanguageItemsProcFunc\\:\\:getSupportedLanguageForField\\(\\) has parameter \\$configuration with no value type specified in iterable type array\\.$#"
count: 1
path: ../../../Classes/Form/Item/SiteConfigSupportedLanguageItemsProcFunc.php

-
message: "#^Parameter \\#3 \\$severity of class TYPO3\\\\CMS\\\\Core\\\\Messaging\\\\FlashMessage constructor expects TYPO3\\\\CMS\\\\Core\\\\Type\\\\ContextualFeedbackSeverity, int given\\.$#"
count: 1
path: ../../../Classes/Hooks/AbstractTranslateHook.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Hooks\\\\ButtonBarHook\\:\\:buildParamsArrayForListView\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -105,6 +115,16 @@ parameters:
count: 1
path: ../../../Tests/Functional/Fixtures/Frontend/PhpError.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration\\:\\:write\\(\\)\\.$#"
count: 2
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 3 parameters, 7 required\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Hooks\\\\TranslateHookTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -155,6 +175,21 @@ parameters:
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Parameter \\#2 \\$siteSettingsFactory of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory, Psr\\\\EventDispatcher\\\\EventDispatcherInterface given\\.$#"
count: 1
path: ../../../Tests/Functional/Hooks/TranslateHookTest.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration\\:\\:write\\(\\)\\.$#"
count: 2
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 3 parameters, 7 required\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Regression\\\\LocalizationInlineRegressionTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -205,6 +240,21 @@ parameters:
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Parameter \\#2 \\$siteSettingsFactory of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory, Psr\\\\EventDispatcher\\\\EventDispatcherInterface given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/LocalizationInlineRegressionTest.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration\\:\\:write\\(\\)\\.$#"
count: 2
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 3 parameters, 7 required\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Regression\\\\PreviewTranslationInformationTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -255,11 +305,26 @@ parameters:
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Parameter \\#2 \\$siteSettingsFactory of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory, Psr\\\\EventDispatcher\\\\EventDispatcherInterface given\\.$#"
count: 1
path: ../../../Tests/Functional/Regression/PreviewTranslationInformationTest.php

-
message: "#^Cannot access property \\$code on DeepL\\\\Language\\|null\\.$#"
count: 7
path: ../../../Tests/Functional/Services/DeeplServiceTest.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration\\:\\:write\\(\\)\\.$#"
count: 2
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 3 parameters, 7 required\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Services\\\\LanguageServiceTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -310,6 +375,21 @@ parameters:
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Parameter \\#2 \\$siteSettingsFactory of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory, Psr\\\\EventDispatcher\\\\EventDispatcherInterface given\\.$#"
count: 1
path: ../../../Tests/Functional/Services/LanguageServiceTest.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration\\:\\:write\\(\\)\\.$#"
count: 2
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor invoked with 3 parameters, 7 required\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Updates\\\\FormalityUpgradeWizardTest\\:\\:buildDefaultLanguageConfiguration\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -359,3 +439,13 @@ parameters:
message: "#^Method WebVision\\\\Deepltranslate\\\\Core\\\\Tests\\\\Functional\\\\Updates\\\\FormalityUpgradeWizardTest\\:\\:writeSiteConfiguration\\(\\) has parameter \\$site with no value type specified in iterable type array\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Parameter \\#2 \\$siteSettingsFactory of class TYPO3\\\\CMS\\\\Core\\\\Configuration\\\\SiteConfiguration constructor expects TYPO3\\\\CMS\\\\Core\\\\Site\\\\SiteSettingsFactory, Psr\\\\EventDispatcher\\\\EventDispatcherInterface given\\.$#"
count: 1
path: ../../../Tests/Functional/Updates/FormalityUpgradeWizardTest.php

-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\View\\\\ViewInterface\\:\\:getRenderingContext\\(\\)\\.$#"
count: 3
path: ../../../Tests/Functional/ViewHelpers/ExtensionActiveViewHelperTest.php
14 changes: 8 additions & 6 deletions Classes/Upgrades/FormalityUpgradeWizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
use TYPO3\CMS\Core\Configuration\SiteConfiguration;
use TYPO3\CMS\Core\Configuration\SiteWriter;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Install\Attribute\UpgradeWizard;
use TYPO3\CMS\Install\Updates\ChattyInterface;
Expand Down Expand Up @@ -50,9 +49,9 @@ public function updateNecessary(): bool

public function executeUpdate(): bool
{
$siteConfiguration = (((new Typo3Version())->getMajorVersion() < 13)
? GeneralUtility::makeInstance(SiteConfiguration::class)
: GeneralUtility::makeInstance(SiteWriter::class));
$siteConfiguration = (class_exists(SiteWriter::class))
? GeneralUtility::makeInstance(SiteWriter::class)
: GeneralUtility::makeInstance(SiteConfiguration::class);
$deeplService = GeneralUtility::makeInstance(DeeplService::class);

$globalFormality = 'default';
Expand Down Expand Up @@ -93,8 +92,11 @@ public function executeUpdate(): bool

$explodedSiteConfigPath = explode(DIRECTORY_SEPARATOR, $file->getPath());
$siteIdentifier = array_pop($explodedSiteConfigPath);

$siteConfiguration->write($siteIdentifier, $loadedSiteConfiguration);
if (method_exists($siteConfiguration, 'write')) {
$siteConfiguration->write($siteIdentifier, $loadedSiteConfiguration);
} else {
throw new \RuntimeException(__CLASS__ . ' does not implement write().', 1734624531);
}
}

return true;
Expand Down

0 comments on commit 2513b34

Please sign in to comment.