diff --git a/typo3/sysext/install/Classes/Report/InstallStatusReport.php b/typo3/sysext/install/Classes/Report/InstallStatusReport.php index 0d2ee8d1a6e703716cde4163cff15b31fca18192..f28fba029ac4391aefd948541857778d465d4e95 100644 --- a/typo3/sysext/install/Classes/Report/InstallStatusReport.php +++ b/typo3/sysext/install/Classes/Report/InstallStatusReport.php @@ -31,10 +31,14 @@ use TYPO3\CMS\Reports\StatusProviderInterface; * Provides an installation status report. * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API. */ -class InstallStatusReport implements StatusProviderInterface +final class InstallStatusReport implements StatusProviderInterface { - protected const WRAP_FLAT = 1; - protected const WRAP_NESTED = 2; + private const WRAP_FLAT = 1; + private const WRAP_NESTED = 2; + + public function __construct(private readonly UpgradeWizardsService $upgradeWizardsService) + { + } /** * Compiles a collection of system status checks as a status report. @@ -60,7 +64,7 @@ class InstallStatusReport implements StatusProviderInterface * * @return Status Indicates status of the file system */ - protected function getFileSystemStatus() + private function getFileSystemStatus(): Status { $languageService = $this->getLanguageService(); $value = $languageService->sL('LLL:EXT:install/Resources/Private/Language/Report/locallang.xlf:status_writable'); @@ -160,8 +164,7 @@ class InstallStatusReport implements StatusProviderInterface */ protected function getIncompleteWizards(): array { - $upgradeWizardsService = GeneralUtility::makeInstance(UpgradeWizardsService::class); - $incompleteWizards = $upgradeWizardsService->getUpgradeWizardsList(); + $incompleteWizards = $this->upgradeWizardsService->getUpgradeWizardsList(); $incompleteWizards = array_filter( $incompleteWizards, static function ($wizard) { @@ -176,7 +179,7 @@ class InstallStatusReport implements StatusProviderInterface * * @return Status Represents whether the installation is completely updated yet */ - protected function getRemainingUpdatesStatus() + private function getRemainingUpdatesStatus(): Status { $languageService = $this->getLanguageService(); $value = $languageService->getLL('status_updateComplete'); @@ -201,7 +204,7 @@ class InstallStatusReport implements StatusProviderInterface * * @return Status Represents whether there is a new version available online */ - protected function getNewVersionStatus() + private function getNewVersionStatus(): Status { $typoVersion = GeneralUtility::makeInstance(Typo3Version::class); $languageService = $this->getLanguageService(); @@ -301,7 +304,7 @@ class InstallStatusReport implements StatusProviderInterface return GeneralUtility::makeInstance(Status::class, 'TYPO3', $typoVersion->getVersion(), $message, $status); } - protected function wrapList(array $items, int $style): string + private function wrapList(array $items, int $style): string { if ($style === self::WRAP_NESTED) { return sprintf( @@ -315,7 +318,7 @@ class InstallStatusReport implements StatusProviderInterface ); } - protected function wrapItems(array $items, string $before, string $after): array + private function wrapItems(array $items, string $before, string $after): array { return array_map( static function (string $item) use ($before, $after): string { @@ -325,7 +328,7 @@ class InstallStatusReport implements StatusProviderInterface ); } - protected function getLanguageService(): LanguageService + private function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } diff --git a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php index 857539eb15efad021461ffff120422bfc39523d2..27410ad051557f1b537e1dd04a37eb83c2a70ae7 100644 --- a/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php +++ b/typo3/sysext/install/Classes/Service/UpgradeWizardsService.php @@ -32,18 +32,18 @@ use TYPO3\CMS\Install\Updates\UpgradeWizardInterface; use TYPO3\CMS\Install\Updates\UpgradeWizardRegistry; /** - * Service class helping managing upgrade wizards + * Service class helps to manage upgrade wizards. + * * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API. */ -class UpgradeWizardsService +final class UpgradeWizardsService { - /** - * @var StreamOutput - */ - private $output; + private StreamOutput $output; - public function __construct(private readonly UpgradeWizardRegistry $upgradeWizardRegistry) - { + public function __construct( + private readonly UpgradeWizardRegistry $upgradeWizardRegistry, + private readonly Registry $registry, + ) { $fileName = 'php://temp'; if (($stream = fopen($fileName, 'wb')) === false) { throw new \RuntimeException('Unable to open stream "' . $fileName . '"', 1598341765); @@ -57,9 +57,8 @@ class UpgradeWizardsService public function listOfWizardsDone(): array { $wizardsDoneInRegistry = []; - $registry = GeneralUtility::makeInstance(Registry::class); foreach ($this->upgradeWizardRegistry->getUpgradeWizards() as $identifier => $serviceName) { - if ($registry->get('installUpdate', $serviceName, false)) { + if ($this->registry->get('installUpdate', $serviceName, false)) { $wizardsDoneInRegistry[] = [ 'class' => $serviceName, 'identifier' => $identifier, @@ -77,11 +76,10 @@ class UpgradeWizardsService */ public function listOfRowUpdatersDone(): array { - $registry = GeneralUtility::makeInstance(Registry::class); - $rowUpdatersDoneClassNames = $registry->get('installUpdateRows', 'rowUpdatersDone', []); + $rowUpdatersDoneClassNames = $this->registry->get('installUpdateRows', 'rowUpdatersDone', []); $rowUpdatersDone = []; foreach ($rowUpdatersDoneClassNames as $rowUpdaterClassName) { - // Silently skip non existing DatabaseRowsUpdateWizards + // Silently skip non-existing DatabaseRowsUpdateWizards if (!class_exists($rowUpdaterClassName)) { continue; } @@ -114,17 +112,16 @@ class UpgradeWizardsService { $this->assertIdentifierIsValid($identifier); - $registry = GeneralUtility::makeInstance(Registry::class); $aWizardHasBeenMarkedUndone = false; foreach ($this->listOfWizardsDone() as $wizard) { if ($wizard['identifier'] === $identifier) { $aWizardHasBeenMarkedUndone = true; - $registry->set('installUpdate', $wizard['class'], 0); + $this->registry->set('installUpdate', $wizard['class'], 0); } } if (!$aWizardHasBeenMarkedUndone) { $rowUpdatersDoneList = $this->listOfRowUpdatersDone(); - $registryArray = $registry->get('installUpdateRows', 'rowUpdatersDone', []); + $registryArray = $this->registry->get('installUpdateRows', 'rowUpdatersDone', []); foreach ($rowUpdatersDoneList as $rowUpdater) { if ($rowUpdater['identifier'] === $identifier) { $aWizardHasBeenMarkedUndone = true; @@ -134,7 +131,7 @@ class UpgradeWizardsService break; } } - $registry->set('installUpdateRows', 'rowUpdatersDone', $registryArray); + $this->registry->set('installUpdateRows', 'rowUpdatersDone', $registryArray); } } } @@ -300,7 +297,7 @@ class UpgradeWizardsService */ public function markWizardAsDone(UpgradeWizardInterface $upgradeWizard): void { - GeneralUtility::makeInstance(Registry::class)->set('installUpdate', $upgradeWizard::class, 1); + $this->registry->set('installUpdate', $upgradeWizard::class, 1); } /** @@ -313,7 +310,7 @@ class UpgradeWizardsService { $this->assertIdentifierIsValid($identifier); - return (bool)GeneralUtility::makeInstance(Registry::class)->get( + return (bool)$this->registry->get( 'installUpdate', $this->upgradeWizardRegistry->getUpgradeWizard($identifier)::class, false @@ -353,7 +350,7 @@ class UpgradeWizardsService * * @throws \RuntimeException */ - protected function assertIdentifierIsValid(string $identifier): void + private function assertIdentifierIsValid(string $identifier): void { if ($identifier === '') { throw new \RuntimeException('Empty upgrade wizard identifier given', 1650579934);