Skip to content

Commit

Permalink
[TASK] Streamline getLanguageService function
Browse files Browse the repository at this point in the history
Many classes in TYPO3 have a function called
getLanguageService(). The function definition
is not always equal and some functions have
a return type or doc comment and others do not.

This patch streamlines the function as following:

* It must always use a return type declaration
* It must not contain a doc comment header

Also, the superfluous override of getLanguageService()
in some subclasses extending AbstractFormElement has
been removed.

Resolves: #96732
Releases: main
Change-Id: Ie4e7fc19b2e84dee78496b4eec674a215a81c00c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73261
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Benni Mack <benni@typo3.org>
Reviewed-by: Oliver Klee <typo3-coding@oliverklee.de>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack <benni@typo3.org>
  • Loading branch information
derhansen authored and bmack committed Feb 2, 2022
1 parent 595ab93 commit 6c3a03d
Show file tree
Hide file tree
Showing 145 changed files with 91 additions and 603 deletions.
5 changes: 0 additions & 5 deletions typo3/sysext/adminpanel/Classes/ModuleApi/AbstractModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,6 @@ protected function getBackendUser(): BackendUserAuthentication
return $GLOBALS['BE_USER'];
}

/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@
*/
abstract class AbstractSubModule implements ModuleInterface, ContentProviderInterface
{
/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,6 @@ protected function getBackendUser(): BackendUserAuthentication
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
5 changes: 0 additions & 5 deletions typo3/sysext/backend/Classes/Clipboard/Clipboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,6 @@ protected function isElements(): bool
return is_array($this->clipData[$this->current]['el'] ?? null) && !empty($this->clipData[$this->current]['el']);
}

/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@ protected function getLabelsFromLocalizationFile($file)
return $labelArray;
}

/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ public function clipboardAction(ServerRequestInterface $request): ResponseInterf
return new JsonResponse([]);
}

/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,7 @@ protected function getBackendUser()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,6 @@ protected function getBackendUser(): BackendUserAuthentication
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService|null
*/
protected function getLanguageService(): ?LanguageService
{
return $GLOBALS['LANG'] ?? null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1012,11 +1012,6 @@ protected function isContentEditable(int $languageId): bool
&& $this->getBackendUser()->checkLanguageAccess($languageId);
}

/**
* Returns LanguageService
*
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* Returns an instance of LanguageService
*
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,7 @@ protected function getModuleIcon($moduleKey, $moduleData)
return '';
}

/**
* Return language service instance
*
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use TYPO3\CMS\Backend\Controller\HelpController;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\File\ImageInfo;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
Expand Down Expand Up @@ -425,12 +426,7 @@ protected function getBackendUser(): BackendUserAuthentication
return $GLOBALS['BE_USER'];
}

/**
* Returns LanguageService
*
* @return \TYPO3\CMS\Core\Localization\LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ public function render()
return $resultArray;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ public function render()
return $resultArray;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,7 @@ public function render()
return $this->nodeFactory->create($data)->render();
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,10 +697,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -688,10 +688,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,7 @@ public function render()
return $this->nodeFactory->create($options)->render();
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,7 @@ public function render()
return $result;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,10 +428,7 @@ protected function isUserNoTableWrappingField($element)
return false;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,7 @@ protected function getBackendUserAuthentication()
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ public function render()
return $resultArray;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,7 @@ protected function appendValueToLabelInDebugMode($label, $value): string
return (string)$label;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
Expand Down
9 changes: 0 additions & 9 deletions typo3/sysext/backend/Classes/Form/Element/GroupElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use TYPO3\CMS\Backend\Form\Behavior\OnFieldChangeTrait;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
Expand Down Expand Up @@ -388,12 +387,4 @@ protected function getBackendUserAuthentication()
{
return $GLOBALS['BE_USER'];
}

/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace TYPO3\CMS\Backend\Form\Element;

use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
Expand Down Expand Up @@ -254,12 +253,4 @@ public function render()
$resultArray['html'] = '<div class="formengine-field-item t3js-formengine-field-item">' . $fieldInformationHtml . $fullElement . '</div>';
return $resultArray;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace TYPO3\CMS\Backend\Form\Element;

use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
Expand Down Expand Up @@ -284,12 +283,4 @@ public function render()
$resultArray['html'] = '<div class="formengine-field-item t3js-formengine-field-item">' . $fieldInformationHtml . $fullElement . '</div>';
return $resultArray;
}

/**
* @return LanguageService
*/
protected function getLanguageService(): LanguageService
{
return $GLOBALS['LANG'];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\LinkHandling\Exception\UnknownLinkHandlerException;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException;
use TYPO3\CMS\Core\Resource\Exception\FolderDoesNotExistException;
Expand Down Expand Up @@ -458,12 +457,4 @@ protected function getLinkExplanation(string $itemValue): array
$data['additionalAttributes'] = '<div class="help-block">' . implode(' - ', $additionalAttributes) . '</div>';
return $data;
}

/**
* @return LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
Loading

0 comments on commit 6c3a03d

Please sign in to comment.