diff --git a/typo3/sysext/adminpanel/Classes/ViewHelpers/IsArrayViewHelper.php b/typo3/sysext/adminpanel/Classes/ViewHelpers/IsArrayViewHelper.php index cd857bcef5917d3bd158a6c927e3a381592efe52..fc9705acaf43fe4dc46e2283d63975ed74e7c796 100644 --- a/typo3/sysext/adminpanel/Classes/ViewHelpers/IsArrayViewHelper.php +++ b/typo3/sysext/adminpanel/Classes/ViewHelpers/IsArrayViewHelper.php @@ -27,22 +27,13 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; */ final class IsArrayViewHelper extends AbstractViewHelper { - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'mixed', 'The variable being checked', true); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return bool - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ): bool { + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): bool + { return is_array($arguments['value']); } } diff --git a/typo3/sysext/adminpanel/Classes/ViewHelpers/SubModuleRenderViewHelper.php b/typo3/sysext/adminpanel/Classes/ViewHelpers/SubModuleRenderViewHelper.php index 57b725ed2c69e933a8f474e3072bca031e4805e5..fc10839de1ef9354fbe20b5b8b6d5028beb171aa 100644 --- a/typo3/sysext/adminpanel/Classes/ViewHelpers/SubModuleRenderViewHelper.php +++ b/typo3/sysext/adminpanel/Classes/ViewHelpers/SubModuleRenderViewHelper.php @@ -33,9 +33,6 @@ final class SubModuleRenderViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ public function initializeArguments(): void { $this->registerArgument( @@ -49,19 +46,12 @@ final class SubModuleRenderViewHelper extends AbstractViewHelper /** * Resolve user name from backend user id. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string Username or an empty string if there is no user with that UID */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ): string { + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string + { + /** @var ContentProviderInterface $module */ $module = $arguments['module']; - /** @var \TYPO3\CMS\Adminpanel\ModuleApi\ModuleDataStorageCollection $data */ + /** @var ModuleDataStorageCollection $data */ $data = $arguments['data']; $moduleData = $data->contains($module) ? $data->offsetGet($module) : new ModuleData(); return $module->getContent($moduleData); diff --git a/typo3/sysext/backend/Classes/ViewHelpers/ArrayBrowserViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/ArrayBrowserViewHelper.php index 7d83c10bc7f4aa9da67ee90fe0cb4b2def468376..7af8d1bae8c7dc950ec90d6553ef11f975c62937 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/ArrayBrowserViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/ArrayBrowserViewHelper.php @@ -25,6 +25,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * Renders a given array as tree + * * @internal */ final class ArrayBrowserViewHelper extends AbstractViewHelper @@ -38,29 +39,19 @@ final class ArrayBrowserViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument('data', 'array', 'Array which should be rendered'); + $this->registerArgument('data', 'array', 'Array which should be rendered', false, []); } /** * Render unordered list for pages - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $arrayBrowser = GeneralUtility::makeInstance(ArrayBrowser::class); $arrayBrowser->dontLinkVar = true; $arrayBrowser->expAll = true; - return $arrayBrowser->tree($arguments['data'], ''); } } diff --git a/typo3/sysext/backend/Classes/ViewHelpers/AvatarViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/AvatarViewHelper.php index f6a3cdd5cd59b3ed9242f638c35ea97c18c2d5c0..749ac5172e2b9df984ad5b1b53cea3db07f18fb7 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/AvatarViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/AvatarViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -71,10 +73,7 @@ final class AvatarViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('backendUser', 'int', 'uid of the backend user', false, 0); $this->registerArgument('size', 'int', 'width and height of the image', false, 32); @@ -83,13 +82,8 @@ final class AvatarViewHelper extends AbstractViewHelper /** * Resolve user avatar from a given backend user id. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { if ($arguments['backendUser'] > 0) { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('be_users'); diff --git a/typo3/sysext/backend/Classes/ViewHelpers/LanguageColumnViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/LanguageColumnViewHelper.php index b38f0c6eaca69a53e2d4ff045a54f5141f9053b2..480e436af994c813ca54f42a7f74485ab1d4ded1 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/LanguageColumnViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/LanguageColumnViewHelper.php @@ -23,7 +23,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; final class LanguageColumnViewHelper extends AbstractViewHelper { - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('languageColumn', LanguageColumn::class, 'Language column object which is context for column', true); $this->registerArgument('columnNumber', 'int', 'Number (colPos) of column within LanguageColumn to be returned', true); diff --git a/typo3/sysext/backend/Classes/ViewHelpers/Link/EditRecordViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/Link/EditRecordViewHelper.php index 2a8a1a58c87fffe5a96bf6a8db11bc9301f8b1f0..466a24d59feb735076ce8f64e49fd8bd1e3ce4d2 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/Link/EditRecordViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/Link/EditRecordViewHelper.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\ViewHelpers\Link; +use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -64,7 +65,7 @@ final class EditRecordViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'a'; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -75,8 +76,8 @@ final class EditRecordViewHelper extends AbstractTagBasedViewHelper } /** - * @return string - * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException + * @throws \InvalidArgumentException + * @throws RouteNotFoundException */ public function render(): string { diff --git a/typo3/sysext/backend/Classes/ViewHelpers/Link/NewRecordViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/Link/NewRecordViewHelper.php index 5325c420343294fb4c55f53082f2662b2ceb14b7..b39f30f64ea9c7776301fb55e91caa4c979ec650 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/Link/NewRecordViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/Link/NewRecordViewHelper.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\ViewHelpers\Link; +use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; @@ -100,7 +101,7 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'a'; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -112,8 +113,8 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper } /** - * @return string - * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException + * @throws \InvalidArgumentException + * @throws RouteNotFoundException */ public function render(): string { @@ -133,7 +134,7 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper 'returnUrl' => $this->arguments['returnUrl'], ]; - if (is_array($this->arguments['defaultValues']) && $this->arguments['defaultValues'] !== []) { + if ($this->arguments['defaultValues']) { $params['defVals'] = $this->arguments['defaultValues']; } diff --git a/typo3/sysext/backend/Classes/ViewHelpers/Mfa/IfHasStateViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/Mfa/IfHasStateViewHelper.php index 1def15e173b023d27e246266e11f0f6f79151b1c..86366d6ec05db2ea125cb0f133eb7fe5e488fcba 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/Mfa/IfHasStateViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/Mfa/IfHasStateViewHelper.php @@ -40,7 +40,6 @@ final class IfHasStateViewHelper extends AbstractConditionViewHelper { $stateMethod = 'is' . ucfirst($arguments['state']); $provider = $arguments['provider']; - $propertyManager = MfaProviderPropertyManager::create($provider, $GLOBALS['BE_USER']); return is_callable([$provider, $stateMethod]) && $provider->{$stateMethod}($propertyManager); } diff --git a/typo3/sysext/backend/Classes/ViewHelpers/ModuleLinkViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/ModuleLinkViewHelper.php index 6e0c1aad921fca103ab3e5890dabe0a99144c226..67e6db828f3aff0ed92490c5e53a141a2fac93ff 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/ModuleLinkViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/ModuleLinkViewHelper.php @@ -46,10 +46,7 @@ final class ModuleLinkViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('route', 'string', 'The route to link to', true); $this->registerArgument('arguments', 'array', 'Additional link arguments', false, []); @@ -59,11 +56,6 @@ final class ModuleLinkViewHelper extends AbstractViewHelper /** * Render module link with arguments - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { @@ -75,7 +67,6 @@ final class ModuleLinkViewHelper extends AbstractViewHelper if ($arguments['currentUrlParameterName'] !== null) { $parameters[$arguments['currentUrlParameterName']] = $renderingContext->getRequest()->getAttribute('normalizedParams')->getRequestUri(); } - return (string)$uriBuilder->buildUriFromRoute($arguments['route'], $parameters); } } diff --git a/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php index 272d5b2a3b8f55c4511ef0687d76efdf0fa21f25..3a1a89fffc5479871e7409056232b5311ca25d6d 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -74,10 +76,7 @@ final class ThumbnailViewHelper extends AbstractTagBasedViewHelper $this->imageService = GeneralUtility::makeInstance(ImageService::class); } - /** - * Initialize arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -107,9 +106,9 @@ final class ThumbnailViewHelper extends AbstractTagBasedViewHelper } /** - * @return string Rendered tag + * @throws Exception */ - public function render() + public function render(): string { if (($this->arguments['src'] === '' && $this->arguments['image'] === null) || ($this->arguments['src'] !== '' && $this->arguments['image'] !== null)) { throw new Exception('You must either specify a string src or a File object.', 1533290762); diff --git a/typo3/sysext/backend/Classes/ViewHelpers/Uri/EditRecordViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/Uri/EditRecordViewHelper.php index c8e44cec5f13ea56422f92234912aa561c9b782d..5eb754d1de1badfe482484a6c85bcfbad53a6812 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/Uri/EditRecordViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/Uri/EditRecordViewHelper.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\ViewHelpers\Uri; +use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -50,7 +51,7 @@ final class EditRecordViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'uid of record to be edited, 0 for creation', true); $this->registerArgument('table', 'string', 'target database table', true); @@ -59,12 +60,8 @@ final class EditRecordViewHelper extends AbstractViewHelper } /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException + * @throws \InvalidArgumentException + * @throws RouteNotFoundException */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { diff --git a/typo3/sysext/backend/Classes/ViewHelpers/Uri/NewRecordViewHelper.php b/typo3/sysext/backend/Classes/ViewHelpers/Uri/NewRecordViewHelper.php index 0197bf685402d37b2c9a0e83bd514ff77c09d99d..27dcda999f4df69d67a9913cc6d0c50819b14794 100644 --- a/typo3/sysext/backend/Classes/ViewHelpers/Uri/NewRecordViewHelper.php +++ b/typo3/sysext/backend/Classes/ViewHelpers/Uri/NewRecordViewHelper.php @@ -17,6 +17,7 @@ declare(strict_types=1); namespace TYPO3\CMS\Backend\ViewHelpers\Uri; +use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -73,7 +74,7 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper { use CompileWithRenderStatic; - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'uid < 0 will insert the record after the given uid', false); $this->registerArgument('pid', 'int', 'the page id where the record will be created', false); @@ -83,12 +84,8 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper } /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException + * @throws \InvalidArgumentException + * @throws RouteNotFoundException */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { @@ -108,7 +105,7 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper 'returnUrl' => $arguments['returnUrl'], ]; - if (is_array($arguments['defaultValues']) && $arguments['defaultValues'] !== []) { + if ($arguments['defaultValues']) { $params['defVals'] = $arguments['defaultValues']; } diff --git a/typo3/sysext/belog/Classes/ViewHelpers/Be/PagePathViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/Be/PagePathViewHelper.php index 7c02562ce1940f72131da81f0da7819d7fd87b6a..f4f9d53c013ab480fa51c40aa02e8a24ef6cd9d8 100644 --- a/typo3/sysext/belog/Classes/ViewHelpers/Be/PagePathViewHelper.php +++ b/typo3/sysext/belog/Classes/ViewHelpers/Be/PagePathViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -21,14 +23,12 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; /** * Get page path string from page id + * * @internal */ final class PagePathViewHelper extends AbstractBackendViewHelper { - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('pid', 'int', 'Pid of the page', true); @@ -37,26 +37,17 @@ final class PagePathViewHelper extends AbstractBackendViewHelper /** * Resolve page id to page path string (with automatic cropping to maximum given length). - * - * @return string Page path string */ - public function render() + public function render(): string { - return static::renderStatic( + return self::renderStatic( $this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext ); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { return BackendUtility::getRecordPath($arguments['pid'], '', $arguments['titleLimit']); } diff --git a/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php index 28bfa4c6fbbb1ea9ef32fe745b16c0bdec1744db..3a8322518fc3bbdf52424e2b9a99d08a569a589a 100644 --- a/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php +++ b/typo3/sysext/belog/Classes/ViewHelpers/FormatDetailsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -23,16 +25,14 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * Create detail string from log entry + * * @internal */ final class FormatDetailsViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('logEntry', LogEntry::class, '', true); } @@ -45,14 +45,8 @@ final class FormatDetailsViewHelper extends AbstractViewHelper * with the substitutions. * Furthermore, possible files in logData are stripped to their basename if * the action logged was a file action - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string Formatted details */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { /** @var LogEntry $logEntry */ $logEntry = $arguments['logEntry']; @@ -67,17 +61,13 @@ final class FormatDetailsViewHelper extends AbstractViewHelper $detailString = vsprintf($detailString, $substitutes); } // Remove possible pending other %s - $detailString = str_replace('%s', '', $detailString); - return $detailString; + return str_replace('%s', '', $detailString); } /** * Strips path from array of file names - * - * @param array $files - * @return array */ - protected static function stripPathFromFilenames(array $files = []) + protected static function stripPathFromFilenames(array $files = []): array { foreach ($files as $key => $file) { $files[$key] = PathUtility::basename($file); diff --git a/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php index c0b7e50b8a7ab2cb6d8f38c9e76b55e5544a0dea..971c89585a45bb77f33e6758e5bd9913b1e47902 100644 --- a/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php +++ b/typo3/sysext/belog/Classes/ViewHelpers/UsernameViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -22,6 +24,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * Get username from backend user id + * * @internal */ final class UsernameViewHelper extends AbstractViewHelper @@ -38,29 +41,22 @@ final class UsernameViewHelper extends AbstractViewHelper /** * Initializes the arguments */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'Uid of the user', true); } /** - * Resolve user name from backend user id. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string Username or an empty string if there is no user with that UID + * Resolve user name from backend user id. Can return empty string if there is no user with that UID. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $uid = $arguments['uid']; - if (isset(static::$usernameRuntimeCache[$uid])) { - return static::$usernameRuntimeCache[$uid]; + if (isset(self::$usernameRuntimeCache[$uid])) { + return self::$usernameRuntimeCache[$uid]; } - $user = BackendUtility::getRecord('be_users', $uid); - static::$usernameRuntimeCache[$uid] = $user['username'] ?? ''; - return static::$usernameRuntimeCache[$uid]; + self::$usernameRuntimeCache[$uid] = $user['username'] ?? ''; + return self::$usernameRuntimeCache[$uid]; } } diff --git a/typo3/sysext/belog/Classes/ViewHelpers/WorkspaceTitleViewHelper.php b/typo3/sysext/belog/Classes/ViewHelpers/WorkspaceTitleViewHelper.php index f4756ebae25bc8a91810a9b551c25e18116a0b56..eaf29d26c95f0ae3ce499507c59aa5a3c58f7800 100644 --- a/typo3/sysext/belog/Classes/ViewHelpers/WorkspaceTitleViewHelper.php +++ b/typo3/sysext/belog/Classes/ViewHelpers/WorkspaceTitleViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -16,15 +18,15 @@ namespace TYPO3\CMS\Belog\ViewHelpers; use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; -use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * Get workspace title from workspace id + * * @internal */ final class WorkspaceTitleViewHelper extends AbstractViewHelper @@ -33,52 +35,40 @@ final class WorkspaceTitleViewHelper extends AbstractViewHelper /** * First level cache of workspace titles - * - * @var array */ - protected static $workspaceTitleRuntimeCache = []; + protected static array $workspaceTitleRuntimeCache = []; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('uid', 'int', 'UID of the workspace', true); } /** - * Resolve workspace title from UID. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext + * Return resolved workspace title or empty string if it can not be resolved. * - * @return string workspace title or UID * @throws \InvalidArgumentException */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - if (!$renderingContext instanceof RenderingContext) { - throw new \InvalidArgumentException('The given rendering context is not of type "TYPO3\CMS\Fluid\Core\Rendering\RenderingContext"', 1468363946); - } - $uid = $arguments['uid']; - if (isset(static::$workspaceTitleRuntimeCache[$uid])) { - return static::$workspaceTitleRuntimeCache[$uid]; + if (isset(self::$workspaceTitleRuntimeCache[$uid])) { + return self::$workspaceTitleRuntimeCache[$uid]; } - if ($uid === 0) { - static::$workspaceTitleRuntimeCache[$uid] = LocalizationUtility::translate( - 'live', - $renderingContext->getRequest()->getControllerExtensionName() - ); + self::$workspaceTitleRuntimeCache[$uid] = htmlspecialchars(self::getLanguageService()->sL( + 'LLL:EXT:belog/Resources/Private/Language/locallang.xlf:live' + )); } elseif (!ExtensionManagementUtility::isLoaded('workspaces')) { - static::$workspaceTitleRuntimeCache[$uid] = ''; + self::$workspaceTitleRuntimeCache[$uid] = ''; } else { $workspace = BackendUtility::getRecord('sys_workspace', $uid); - static::$workspaceTitleRuntimeCache[$uid] = $workspace['title'] ?? ''; + self::$workspaceTitleRuntimeCache[$uid] = $workspace['title'] ?? ''; } + return self::$workspaceTitleRuntimeCache[$uid]; + } - return static::$workspaceTitleRuntimeCache[$uid]; + protected static function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; } } diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/ArrayElementViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/ArrayElementViewHelper.php index 9de7420eab2a59c2715f19fc28bf787ced03bbb5..7b3864d52a155bee6f471f308bbc6bef70a51342 100644 --- a/typo3/sysext/beuser/Classes/ViewHelpers/ArrayElementViewHelper.php +++ b/typo3/sysext/beuser/Classes/ViewHelpers/ArrayElementViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -22,16 +24,14 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * Get a value from an array by given key. + * * @internal */ final class ArrayElementViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('array', 'array', 'Array to search in', true); $this->registerArgument('key', 'string', 'Key to return its value', true); @@ -41,19 +41,15 @@ final class ArrayElementViewHelper extends AbstractViewHelper /** * Return array element by key. Accessed values must be scalar (string, int, float or double) * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext * @throws Exception - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $array = $arguments['array']; $key = $arguments['key']; $subKey = $arguments['subKey']; $result = ''; - if (is_array($array) && isset($array[$key])) { + if (isset($array[$key])) { $result = $array[$key]; if (is_array($result) && $subKey && isset($result[$subKey])) { $result = $result[$subKey]; diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/Display/TableAccessViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/Display/TableAccessViewHelper.php index c88c0477ac4eda6b524919e0882fa86262620ad7..979241a7ff633431510456a4e23367a06b583e4a 100644 --- a/typo3/sysext/beuser/Classes/ViewHelpers/Display/TableAccessViewHelper.php +++ b/typo3/sysext/beuser/Classes/ViewHelpers/Display/TableAccessViewHelper.php @@ -20,6 +20,9 @@ namespace TYPO3\CMS\Beuser\ViewHelpers\Display; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; +/** + * @internal + */ final class TableAccessViewHelper extends AbstractConditionViewHelper { public function initializeArguments(): void @@ -30,7 +33,7 @@ final class TableAccessViewHelper extends AbstractConditionViewHelper $this->registerArgument('modify', 'array', 'List of allowed tables to modify', false, []); } - public static function verdict(array $arguments, RenderingContextInterface $renderingContext) + public static function verdict(array $arguments, RenderingContextInterface $renderingContext): bool { $table = $arguments['table']; return array_key_exists($table, (array)$arguments['select']) || array_key_exists($table, (array)$arguments['modify']); diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/PermissionsViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/PermissionsViewHelper.php index 090f5e40a584e98f1df6b2b979e9e007b6b3a0b8..ec20c780d1809b97543e8d1628c8555252d1fb2c 100644 --- a/typo3/sysext/beuser/Classes/ViewHelpers/PermissionsViewHelper.php +++ b/typo3/sysext/beuser/Classes/ViewHelpers/PermissionsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -15,7 +17,7 @@ namespace TYPO3\CMS\Beuser\ViewHelpers; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -25,6 +27,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; * * Most of that could be done in fluid directly, but this ViewHelper * is much better performance wise. + * * @internal */ final class PermissionsViewHelper extends AbstractViewHelper @@ -38,40 +41,24 @@ final class PermissionsViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * @var array Cached labels for a single permission mask like "Delete page" - */ - protected static $permissionLabels = []; + protected static array $cachePermissionLabels = []; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('permission', 'int', 'Current permission', true); $this->registerArgument('scope', 'string', '"user" / "group" / "everybody"', true); $this->registerArgument('pageId', 'int', '', true); } - /** - * Return permissions. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $masks = [1, 16, 2, 4, 8]; - if (empty(static::$permissionLabels)) { + if (empty(self::$cachePermissionLabels)) { foreach ($masks as $mask) { - static::$permissionLabels[$mask] = LocalizationUtility::translate( + self::$cachePermissionLabels[$mask] = htmlspecialchars(self::getLanguageService()->sL( 'LLL:EXT:beuser/Resources/Private/Language/locallang_mod_permission.xlf:' . $mask, - 'be_user' - ); + )); } } @@ -85,13 +72,13 @@ final class PermissionsViewHelper extends AbstractViewHelper $mode = 'add'; } - $label = static::$permissionLabels[$mask]; + $label = self::$cachePermissionLabels[$mask]; $icon .= '<button' . ' aria-label="' . htmlspecialchars($label) . ', ' . htmlspecialchars($mode) . ', ' . htmlspecialchars($arguments['scope']) . '"' . ' title="' . htmlspecialchars($label) . '"' . ' data-bs-toggle="tooltip"' - . ' data-page="' . htmlspecialchars($arguments['pageId']) . '"' - . ' data-permissions="' . htmlspecialchars($arguments['permission']) . '"' + . ' data-page="' . htmlspecialchars((string)$arguments['pageId']) . '"' + . ' data-permissions="' . htmlspecialchars((string)$arguments['permission']) . '"' . ' data-who="' . htmlspecialchars($arguments['scope']) . '"' . ' data-bits="' . htmlspecialchars((string)$mask) . '"' . ' data-mode="' . htmlspecialchars($mode) . '"' @@ -100,4 +87,9 @@ final class PermissionsViewHelper extends AbstractViewHelper return '<span id="' . htmlspecialchars($arguments['pageId'] . '_' . $arguments['scope']) . '">' . $icon . '</span>'; } + + protected static function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } } diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php index 55cef6b1a4aa272248d30e37a621b46858fc2d75..c0ed366b07a905e5cc5e031b42ac871a2b1ecdda 100644 --- a/typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php +++ b/typo3/sysext/beuser/Classes/ViewHelpers/SpriteIconForRecordViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -23,6 +25,7 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; /** * Views sprite icon for a record (object) + * * @internal */ final class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper @@ -34,10 +37,7 @@ final class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('table', 'string', '', true); @@ -46,29 +46,18 @@ final class SpriteIconForRecordViewHelper extends AbstractBackendViewHelper /** * Displays spriteIcon for database table and object - * - * @return string - * @see IconFactory::getIconForRecord() */ - public function render() + public function render(): string { - return static::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext); + return self::renderStatic($this->arguments, $this->buildRenderChildrenClosure(), $this->renderingContext); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - * @throws \Exception - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $object = $arguments['object']; $table = $arguments['table']; - if (!is_object($object) || !method_exists($object, 'getUid')) { + if (!method_exists($object, 'getUid')) { return ''; } $row = [ diff --git a/typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php b/typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php index efd0afa4b6ff16fff6001bc7f62ad3eaf119f7f6..279fb7b86e7ab89be1d133e208032dcb61a929e3 100644 --- a/typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php +++ b/typo3/sysext/beuser/Classes/ViewHelpers/SwitchUserViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -19,14 +21,15 @@ use TYPO3\CMS\Beuser\Domain\Model\BackendUser; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * Displays 'SwitchUser' button to change current backend user to target backend user + * Displays 'SwitchUser' button to change current backend user to target backend user. + * * @internal */ final class SwitchUserViewHelper extends AbstractViewHelper @@ -40,24 +43,15 @@ final class SwitchUserViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('backendUser', BackendUser::class, 'Target backendUser to switch active session to', true); } /** * Render link with sprite icon to change current backend user to target - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $targetUser = $arguments['backendUser']; $currentUser = self::getBackendUserAuthentication(); @@ -73,7 +67,7 @@ final class SwitchUserViewHelper extends AbstractViewHelper return ' <typo3-backend-switch-user targetUser="' . htmlspecialchars((string)$targetUser->getUid()) . '"> - <button type="button" class="btn btn-default" title="' . htmlspecialchars(LocalizationUtility::translate('switchBackMode', 'beuser') ?? '') . '">' + <button type="button" class="btn btn-default" title="' . htmlspecialchars(self::getLanguageService()->sL('LLL:EXT:beuser/Resources/Private/Language/locallang.xlf:switchBackMode')) . '">' . $iconFactory->getIcon('actions-system-backend-user-switch', Icon::SIZE_SMALL)->render() . '</button> </typo3-switch-user-button>'; @@ -83,4 +77,9 @@ final class SwitchUserViewHelper extends AbstractViewHelper { return $GLOBALS['BE_USER']; } + + protected static function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } } diff --git a/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php b/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php index 89ea8a36356e545d3c2e97b00aa3017e7a62d63c..f9556412ee552e2af39f4542522d9e3c65fc2e2b 100644 --- a/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php +++ b/typo3/sysext/core/Classes/ViewHelpers/Form/TypoScriptConstantsViewHelper.php @@ -32,10 +32,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder; */ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper { - /** - * @var array - */ - public $viewHelperMapping = [ + protected array $viewHelperMapping = [ 'int' => 'renderIntegerField', 'int+' => 'renderPositiveIntegerField', 'integer' => 'renderIntegerField', @@ -56,10 +53,7 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper */ public $tagName = 'input'; - /** - * Initialize arguments of this ViewHelper - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('name', 'string', 'Name of input tag'); @@ -76,17 +70,12 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Create a fresh instance of $this->tag each time this VH is called. */ - public function initialize() + public function initialize(): void { $this->setTagBuilder(new TagBuilder($this->tagName)); parent::initialize(); } - /** - * Render - * - * @return string the rendered tag - */ public function render(): string { /** @var array $configuration */ @@ -96,15 +85,11 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper } else { $input = $this->{$this->viewHelperMapping['default']}($configuration); } - return $input; } /** * Render field of type color picker - * - * @param array $configuration - * @return string */ protected function renderColorPicker(array $configuration): string { @@ -135,9 +120,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "offset" - * - * @param array $configuration - * @return string */ protected function renderOffsetField(array $configuration): string { @@ -154,9 +136,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "wrap" - * - * @param array $configuration - * @return string */ protected function renderWrapField(array $configuration): string { @@ -173,9 +152,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "option" - * - * @param array $configuration - * @return string */ protected function renderOptionSelect(array $configuration): string { @@ -199,9 +175,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "int+" - * - * @param array $configuration - * @return string */ protected function renderPositiveIntegerField(array $configuration): string { @@ -219,9 +192,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "integer" - * - * @param array $configuration - * @return string */ protected function renderIntegerField(array $configuration): string { @@ -238,9 +208,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "text" - * - * @param array $configuration - * @return string */ protected function renderTextField(array $configuration): string { @@ -257,9 +224,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "small text" - * - * @param array $configuration - * @return string */ protected function renderSmallTextField(array $configuration): string { @@ -268,11 +232,8 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "checkbox" - * - * @param array $configuration - * @return string */ - public function renderCheckbox(array $configuration): string + protected function renderCheckbox(array $configuration): string { $this->tag->addAttribute('type', 'checkbox'); $this->tag->addAttribute('class', 'form-check-input'); @@ -288,9 +249,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render field of type "userFunc" - * - * @param array $configuration - * @return string */ protected function renderUserFunction(array $configuration): string { @@ -305,9 +263,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Get Field Name - * - * @param array $configuration - * @return string */ protected function getFieldName(array $configuration): string { @@ -316,9 +271,6 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper /** * Render a hidden field for empty values - * - * @param array $configuration - * @return string */ protected function renderHiddenFieldForEmptyValue(array $configuration): string { @@ -342,17 +294,15 @@ final class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper } /** - * @return LanguageService|null Returns null if we are in the install tool standalone mode + * @return LanguageService|null Null if we are in the install tool standalone mode @todo: still valid? */ - protected function getLanguageService() + protected function getLanguageService(): ?LanguageService { return $GLOBALS['LANG']; } /** * Build and add id-attribute from $configuration - * - * @param array $configuration */ protected function addIdAttribute(array $configuration): void { diff --git a/typo3/sysext/core/Classes/ViewHelpers/IconForRecordViewHelper.php b/typo3/sysext/core/Classes/ViewHelpers/IconForRecordViewHelper.php index 8a651df6c2b47a62c81de5e23ff0accd0264ca41..f99b36623512a4ae0daa4c861660bd247d8623b4 100644 --- a/typo3/sysext/core/Classes/ViewHelpers/IconForRecordViewHelper.php +++ b/typo3/sysext/core/Classes/ViewHelpers/IconForRecordViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -51,30 +53,20 @@ final class IconForRecordViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('table', 'string', 'the table for the record icon', true); $this->registerArgument('row', 'array', 'the record row', true); $this->registerArgument('size', 'string', 'the icon size', false, Icon::SIZE_SMALL); - $this->registerArgument('alternativeMarkupIdentifier', 'string', 'alternative markup identifier', false, null); + $this->registerArgument('alternativeMarkupIdentifier', 'string', 'alternative markup identifier', false); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $table = $arguments['table']; $size = $arguments['size']; $row = $arguments['row']; $alternativeMarkupIdentifier = $arguments['alternativeMarkupIdentifier']; - /** @var IconFactory $iconFactory */ $iconFactory = GeneralUtility::makeInstance(IconFactory::class); return $iconFactory->getIconForRecord($table, $row, $size)->render($alternativeMarkupIdentifier); } diff --git a/typo3/sysext/core/Classes/ViewHelpers/IconForResourceViewHelper.php b/typo3/sysext/core/Classes/ViewHelpers/IconForResourceViewHelper.php index 79d382e8d5cb958cfa3a452ce55f5b6e78f01a2d..79f0417ddec11da0ea4fa621edefd99c1972761c 100644 --- a/typo3/sysext/core/Classes/ViewHelpers/IconForResourceViewHelper.php +++ b/typo3/sysext/core/Classes/ViewHelpers/IconForResourceViewHelper.php @@ -54,24 +54,15 @@ final class IconForResourceViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('resource', ResourceInterface::class, 'Resource', true); $this->registerArgument('size', 'string', 'The icon size', false, Icon::SIZE_SMALL); $this->registerArgument('overlay', 'string', 'Overlay identifier', false, null); $this->registerArgument('options', 'array', 'An associative array with additional options', false, []); - $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier', false, null); + $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative markup identifier', false); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $resource = $arguments['resource']; diff --git a/typo3/sysext/core/Classes/ViewHelpers/IconViewHelper.php b/typo3/sysext/core/Classes/ViewHelpers/IconViewHelper.php index 619a5c71e2451327d7e15977bb4bc1c5f58bb360..ea1527ba9bafc44716dbe0c876d5348ee4d3a29d 100644 --- a/typo3/sysext/core/Classes/ViewHelpers/IconViewHelper.php +++ b/typo3/sysext/core/Classes/ViewHelpers/IconViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -64,27 +66,19 @@ final class IconViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('identifier', 'string', 'Identifier of the icon as registered in the Icon Registry.', true); $this->registerArgument('size', 'string', 'Desired size of the icon. All values of the Icons.sizes enum are allowed, these are: "small", "default", "large" and "overlay".', false, Icon::SIZE_SMALL); - $this->registerArgument('overlay', 'string', 'Identifier of an overlay icon as registered in the Icon Registry.', false, null); + $this->registerArgument('overlay', 'string', 'Identifier of an overlay icon as registered in the Icon Registry.', false); $this->registerArgument('state', 'string', 'Sets the state of the icon. All values of the Icons.states enum are allowed, these are: "default" and "disabled".', false, IconState::STATE_DEFAULT); - $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative icon identifier. Takes precedence over the identifier if supported by the IconProvider.', false, null); + $this->registerArgument('alternativeMarkupIdentifier', 'string', 'Alternative icon identifier. Takes precedence over the identifier if supported by the IconProvider.', false); } /** * Prints icon html for $identifier key - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $identifier = $arguments['identifier']; $size = $arguments['size']; diff --git a/typo3/sysext/core/Classes/ViewHelpers/NormalizedUrlViewHelper.php b/typo3/sysext/core/Classes/ViewHelpers/NormalizedUrlViewHelper.php index 203318150e365fecfe06780cb52457dd8c65af41..dcdd6aadde2cf6f5273a7b5f8eae71810b036d5e 100644 --- a/typo3/sysext/core/Classes/ViewHelpers/NormalizedUrlViewHelper.php +++ b/typo3/sysext/core/Classes/ViewHelpers/NormalizedUrlViewHelper.php @@ -44,35 +44,27 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderS * Output:: * * /typo3/sysext/core/Resources/Public/Images/typo3_black.svg + * * @internal */ final class NormalizedUrlViewHelper extends AbstractViewHelper { use CompileWithContentArgumentAndRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('pathOrUrl', 'string', 'Absolute path to file using EXT: syntax or URL.'); } /** - * Ouputs what is given as URL or extension relative path as absolute URL - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string + * Output what is given as URL or extension relative path as absolute URL */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - $pathOrUrl = $renderChildrenClosure(); + $pathOrUrl = $arguments['pathOrUrl'] ?? $renderChildrenClosure(); if (PathUtility::hasProtocolAndScheme($pathOrUrl)) { return $pathOrUrl; } - - return GeneralUtility::locationHeaderUrl(PathUtility::getPublicResourceWebPath($pathOrUrl)); + return GeneralUtility::locationHeaderUrl(PathUtility::getPublicResourceWebPath((string)$pathOrUrl)); } } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/Be/TriggerViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/Be/TriggerViewHelper.php index a4fc806e8e3551aee25d827dbe5108500a0381ed..cdeb65349ac9077c4d555b9682d460fadb3e0df9 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/Be/TriggerViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/Be/TriggerViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -40,10 +42,7 @@ final class TriggerViewHelper extends AbstractBackendViewHelper */ protected $escapeOutput = false; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('triggers', 'array', 'Defined triggers to be forwarded to client (e.g. refreshing backend widgets)', false, []); @@ -52,10 +51,8 @@ final class TriggerViewHelper extends AbstractBackendViewHelper /** * Loads some JS inline code based on a list of triggers. This is used to reload the main * menu when modules are loaded/unloaded. - * - * @return string This ViewHelper does not return any content */ - public function render() + public function render(): string { $html = ''; // Handle triggers diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ConstraintsViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ConstraintsViewHelper.php index 7bf131320241c483655743ea357c3ebdcc13f451..a11b15c8d331c14dc8eda4f093f20296a43b5968 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ConstraintsViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ConstraintsViewHelper.php @@ -35,20 +35,15 @@ final class ConstraintsViewHelper extends AbstractViewHelper $this->registerArgument('extension', Extension::class, 'extension to process', true); } - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ): array { + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): array + { $groupedConstraints = []; - foreach ($arguments['extension']->getDependencies() as $dependency) { $groupedConstraints[$dependency->getType()][self::getTransformedIdentifier($dependency->getIdentifier())] = [ 'version' => self::getVersionString($dependency->getLowestVersion(), $dependency->getHighestVersion()), 'versionCompatible' => self::isVersionCompatible($dependency), ]; } - return $groupedConstraints; } @@ -62,7 +57,6 @@ final class ConstraintsViewHelper extends AbstractViewHelper protected static function getVersionString(string $lowestVersion, string $highestVersion): string { $version = ''; - if ($lowestVersion !== '') { $version .= '(' . $lowestVersion; if ($highestVersion !== '') { @@ -70,7 +64,6 @@ final class ConstraintsViewHelper extends AbstractViewHelper } $version .= ')'; } - return $version; } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php index d6d1e6a086f0dbc46756d325e7e8aab15f0d633a..23ee6ac69d814defae60d96005460b676409ff07 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -16,15 +18,16 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers; use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; use TYPO3\CMS\Extbase\Service\ExtensionService; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extensionmanager\Domain\Model\Extension; use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper; /** - * ViewHelper + * Render a link to download an extension. + * * @internal */ final class DownloadExtensionViewHelper extends AbstractFormViewHelper @@ -34,40 +37,21 @@ final class DownloadExtensionViewHelper extends AbstractFormViewHelper */ protected $tagName = 'form'; - /** - * @var \TYPO3\CMS\Extbase\Service\ExtensionService - */ - protected $extensionService; + protected ExtensionService $extensionService; - /** - * @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService - */ - public function injectExtensionService(ExtensionService $extensionService) + public function injectExtensionService(ExtensionService $extensionService): void { $this->extensionService = $extensionService; } - /** - * Initialize arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('extension', Extension::class, '', true); - $this->registerTagAttribute('enctype', 'string', 'MIME type with which the form is submitted'); - $this->registerTagAttribute('method', 'string', 'Transfer type (GET or POST)'); - $this->registerTagAttribute('name', 'string', 'Name of form'); - $this->registerTagAttribute('onreset', 'string', 'JavaScript: On reset of the form'); - $this->registerTagAttribute('onsubmit', 'string', 'JavaScript: On submit of the form'); $this->registerUniversalTagAttributes(); } - /** - * Renders a download link - * - * @return string the rendered a tag - */ - public function render() + public function render(): string { /** @var Extension $extension */ $extension = $this->arguments['extension']; @@ -79,12 +63,11 @@ final class DownloadExtensionViewHelper extends AbstractFormViewHelper foreach ($installPaths as $installPathType => $installPath) { /** @var string $installPathType */ $pathSelector .= '<li> - <input type="radio" id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '" name="' . htmlspecialchars($this->getFieldNamePrefix()) . '[downloadPath]" class="downloadPath" value="' . htmlspecialchars($installPathType) . '" ' . ($installPathType === 'Local' ? 'checked="checked"' : '') . ' /> - <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label> - </li>'; + <input type="radio" id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '" name="' . htmlspecialchars($this->getDefaultFieldNamePrefix()) . '[downloadPath]" class="downloadPath" value="' . htmlspecialchars($installPathType) . '" ' . ($installPathType === 'Local' ? 'checked="checked"' : '') . ' /> + <label for="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadPath-' . htmlspecialchars($installPathType) . '">' . htmlspecialchars($installPathType) . '</label> + </li>'; } $pathSelector .= '</ul>'; - /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->setRequest($this->renderingContext->getRequest()); $action = 'checkDependencies'; @@ -97,57 +80,36 @@ final class DownloadExtensionViewHelper extends AbstractFormViewHelper $automaticInstallation = (bool)GeneralUtility::makeInstance(ExtensionConfiguration::class)->get('extensionmanager', 'automaticInstallation'); $labelKeySuffix = $automaticInstallation ? '' : '.downloadOnly'; + $titleAndValue = $this->getLanguageService()->sL( + 'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.downloadViewHelper.submit' . $labelKeySuffix + ); $label = ' - <div class="btn-group"> - <button - title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '" - type="submit" - class="btn btn-default" - value="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '" - > - <span class="t3-icon fa fa-cloud-download"></span> - </button> - </div>'; + <div class="btn-group"> + <button + title="' . htmlspecialchars($titleAndValue) . '" + type="submit" + class="btn btn-default" + value="' . htmlspecialchars($titleAndValue) . '" + > + <span class="t3-icon fa fa-cloud-download"></span> + </button> + </div>'; $this->tag->setContent($label . $pathSelector); - $this->tag->addAttribute('class', 'download'); + $this->tag->addAttribute('class', $this->arguments['class']); return '<div id="' . htmlspecialchars($extension->getExtensionKey()) . '-downloadFromTer" class="downloadFromTer">' . $this->tag->render() . '</div>'; } /** - * Get the field name prefix - * - * @return string + * Retrieves the field name prefix for this form */ - protected function getFieldNamePrefix() + protected function getDefaultFieldNamePrefix(): string { - if ($this->hasArgument('fieldNamePrefix')) { - return $this->arguments['fieldNamePrefix']; - } - return $this->getDefaultFieldNamePrefix(); + return $this->extensionService->getPluginNamespace('Extensionmanager', 'tools_ExtensionmanagerExtensionmanager'); } - /** - * Retrieves the default field name prefix for this form - * - * @return string default field name prefix - */ - protected function getDefaultFieldNamePrefix() + protected function getLanguageService(): LanguageService { - $request = $this->renderingContext->getRequest(); - if ($this->hasArgument('extensionName')) { - $extensionName = $this->arguments['extensionName']; - } else { - $extensionName = $request->getControllerExtensionName(); - } - if ($this->hasArgument('pluginName')) { - $pluginName = $this->arguments['pluginName']; - } else { - $pluginName = $request->getPluginName(); - } - if ($extensionName !== null && $pluginName != null) { - return $this->extensionService->getPluginNamespace($extensionName, $pluginName); - } - return ''; + return $GLOBALS['LANG']; } } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/InstallationStateCssClassViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/InstallationStateCssClassViewHelper.php index e19bbf0184ed4be962a3848b8837ed921e8c4855..762c5c582e1d730f509fd28ec021eade9931c5b6 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/InstallationStateCssClassViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/InstallationStateCssClassViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,18 +22,15 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * Returns a string meant to be used as css class stating whether an extension is - * available or installed + * Returns a string meant to be used as css class stating whether an extension is available or installed. + * * @internal */ final class InstallationStateCssClassViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('needle', 'string', '', true); $this->registerArgument('haystack', 'array', '', true); @@ -42,14 +41,8 @@ final class InstallationStateCssClassViewHelper extends AbstractViewHelper * 'installed' => if an extension is installed * 'available' => if an extension is available in the system * '' (empty string) => if neither installed nor available - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string the rendered a tag */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $needle = $arguments['needle']; $haystack = $arguments['haystack']; diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ProcessAvailableActionsViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ProcessAvailableActionsViewHelper.php index 8f157adf68bf73222a6b1f5f8562d96149224ee5..abe37df6fa4241e40eda137854460c00fa29a963 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ProcessAvailableActionsViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ProcessAvailableActionsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,39 +22,30 @@ use TYPO3\CMS\Extensionmanager\Event\AvailableActionsForExtensionEvent; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; /** - * ViewHelper to let 3rd-party extensions process the list of available - * actions for a given extension. + * ViewHelper to let 3rd-party extensions process the list of available actions for a given extension. + * * @internal */ final class ProcessAvailableActionsViewHelper extends AbstractTagBasedViewHelper { - /** - * @var EventDispatcherInterface - */ - protected $eventDispatcher; + protected EventDispatcherInterface $eventDispatcher; - public function injectEventDispatcher(EventDispatcherInterface $eventDispatcher) + public function injectEventDispatcher(EventDispatcherInterface $eventDispatcher): void { $this->eventDispatcher = $eventDispatcher; } - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('extension', 'array', '', true); } - /** - * Processes the list of actions. - * - * @return string the rendered list of actions - */ - public function render() + public function render(): string { $html = $this->renderChildren(); $actions = preg_split('#\\n\\s*#s', trim($html)); $actions = is_array($actions) ? $actions : []; - $event = new AvailableActionsForExtensionEvent($this->arguments['extension']['key'], $this->arguments['extension'], $actions); $this->eventDispatcher->dispatch($event); return implode(' ', $event->getActions()); diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php index 13bf760bdfd63a87e12329a9ca2f5173d688062a..fbe3f4f0046571796502a9a97b4a9ff301702d71 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -17,15 +19,16 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Registry; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\PathUtility; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; /** - * ViewHelper for update script link + * Renders a link to re-import the static SQL data of an extension. + * * @internal */ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper @@ -44,12 +47,7 @@ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper $this->registerArgument('extension', 'array', 'Extension key', true); } - /** - * Renders a link to re-import the static SQL data of an extension - * - * @return string The rendered a tag - */ - public function render() + public function render(): string { $extension = $this->arguments['extension']; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); @@ -60,7 +58,7 @@ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper } $registry = GeneralUtility::makeInstance(Registry::class); - $oldMd5Hash = $registry->get(static::$registryNamespace, PathUtility::stripPathSitePrefix($staticSqlDataFile)); + $oldMd5Hash = $registry->get(self::$registryNamespace, PathUtility::stripPathSitePrefix($staticSqlDataFile)); $md5HashIsEqual = true; // We used to only store "1" in the database when data was imported @@ -78,7 +76,6 @@ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper $languageKey = 'extensionList.databaseImport'; } - /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->setRequest($this->renderingContext->getRequest()); $uriBuilder->reset(); @@ -88,9 +85,16 @@ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper 'Action' ); $this->tag->addAttribute('href', $uri); - $this->tag->addAttribute('title', LocalizationUtility::translate($languageKey, 'extensionmanager')); + $this->tag->addAttribute('title', htmlspecialchars($this->getLanguageService()->sL( + 'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:' . $languageKey + ))); $this->tag->setContent($iconFactory->getIcon($iconIdentifier, Icon::SIZE_SMALL)->render()); return $this->tag->render(); } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/RemoveExtensionViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/RemoveExtensionViewHelper.php index d6ce241b3541c004c56e53eb074fc8c20ccfbeea..9d6bd85506665c8f29d4ca084022dc42a4ba5778 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/RemoveExtensionViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/RemoveExtensionViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -17,15 +19,16 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3\CMS\Extensionmanager\Domain\Model\Extension; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; /** - * ViewHelper for displaying a remove extension link + * ViewHelper for displaying a remove extension link. + * * @internal */ final class RemoveExtensionViewHelper extends AbstractTagBasedViewHelper @@ -35,19 +38,14 @@ final class RemoveExtensionViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'a'; - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); $this->registerArgument('extension', 'array', '', true); } - /** - * Renders an install link - * - * @return string the rendered a tag - */ - public function render() + public function render(): string { $extension = $this->arguments['extension']; $iconFactory = GeneralUtility::makeInstance(IconFactory::class); @@ -60,7 +58,6 @@ final class RemoveExtensionViewHelper extends AbstractTagBasedViewHelper ) { return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>'; } - /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriBuilder->setRequest($this->renderingContext->getRequest()); $uriBuilder->reset(); @@ -72,8 +69,15 @@ final class RemoveExtensionViewHelper extends AbstractTagBasedViewHelper ); $this->tag->addAttribute('href', $uri); $this->tag->addAttribute('class', $this->arguments['class']); - $this->tag->addAttribute('title', LocalizationUtility::translate('extensionList.remove', 'extensionmanager')); + $this->tag->addAttribute('title', htmlspecialchars($this->getLanguageService()->sL( + 'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.remove' + ))); $this->tag->setContent($iconFactory->getIcon('actions-edit-delete', Icon::SIZE_SMALL)->render()); return $this->tag->render(); } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php index 98cc6eb69b224763ad577b77a45b07e56c8ffd52..880e553bbcb3909c045a694fe18a045fcda6c990 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -18,14 +20,15 @@ namespace TYPO3\CMS\Extensionmanager\ViewHelpers; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Imaging\Icon; use TYPO3\CMS\Core\Imaging\IconFactory; +use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Package\PackageManager; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder; -use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; /** - * Display a deactivate / activate link + * Render deactivate / activate extension link. + * * @internal */ final class ToggleExtensionInstallationStateViewHelper extends AbstractTagBasedViewHelper @@ -35,22 +38,14 @@ final class ToggleExtensionInstallationStateViewHelper extends AbstractTagBasedV */ protected $tagName = 'a'; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); $this->registerArgument('extension', 'array', '', true); } - /** - * Renders an install link - * - * @return string the rendered a tag - */ - public function render() + public function render(): string { if (Environment::isComposerMode()) { return ''; @@ -76,11 +71,18 @@ final class ToggleExtensionInstallationStateViewHelper extends AbstractTagBasedV ); $this->tag->addAttribute('href', $uri); $label = $extension['installed'] ? 'deactivate' : 'activate'; - $this->tag->addAttribute('title', LocalizationUtility::translate('extensionList.' . $label, 'extensionmanager')); + $this->tag->addAttribute('title', htmlspecialchars($this->getLanguageService()->sL( + 'LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.' . $label + ))); $icon = $extension['installed'] ? 'uninstall' : 'install'; $this->tag->addAttribute('class', 'onClickMaskExtensionManager btn btn-default'); $iconFactory = GeneralUtility::makeInstance(IconFactory::class); $this->tag->setContent($iconFactory->getIcon('actions-system-extension-' . $icon, Icon::SIZE_SMALL)->render()); return $this->tag->render(); } + + protected function getLanguageService(): LanguageService + { + return $GLOBALS['LANG']; + } } diff --git a/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php b/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php index bb01b5b81cdf8854068ab117104fd92e751c361f..9c9fbee9f0366df1ce2ce5e20c6a3ada845cf115 100644 --- a/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php +++ b/typo3/sysext/extensionmanager/Classes/ViewHelpers/Typo3DependencyViewHelper.php @@ -24,7 +24,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * Shows the version numbers of the TYPO3 dependency, if any + * Shows the version numbers of the TYPO3 dependency, if any. * * @internal */ @@ -44,20 +44,8 @@ final class Typo3DependencyViewHelper extends AbstractViewHelper $this->registerArgument('extension', Extension::class, '', true); } - /** - * Finds and returns the suitable TYPO3 versions of an extension - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ): string { + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string + { $dependency = $arguments['extension']->getTypo3Dependency(); if ($dependency === null) { return ''; diff --git a/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerShowVersionsTable.html b/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerShowVersionsTable.html index 3428eae7fe7688f0fcb2d318e51f0ae8af8ce18b..f3e83b0a6553cf527c1ba310b1b5465d097d6abd 100644 --- a/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerShowVersionsTable.html +++ b/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerShowVersionsTable.html @@ -13,7 +13,7 @@ <tbody> <f:for each="{extensions}" as="extension"> <tr> - <td><em:downloadExtension extension="{extension}" /></td> + <td><em:downloadExtension class="download" extension="{extension}" /></td> <td>{extension.title}</th> <td>{extension.version}</td> <td><f:format.nl2br>{extension.updateComment}</f:format.nl2br></td> diff --git a/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerTable.html b/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerTable.html index bdb3db86cfc4427b38897986cce787f223eb03e1..feca9b71617ae809c236c0667a3b0b9e04603908 100644 --- a/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerTable.html +++ b/typo3/sysext/extensionmanager/Resources/Private/Partials/List/TerTable.html @@ -15,7 +15,7 @@ <tbody> <f:for each="{extensions}" as="extension"> <tr class="{em:installationStateCssClass(needle:extension.extensionKey, haystack:availableAndInstalled)}"> - <td><em:downloadExtension extension="{extension}" /></td> + <td><em:downloadExtension class="download" extension="{extension}" /></td> <td> <f:link.action action="showAllVersions" arguments="{extensionKey: extension.extensionKey}" title="{f:translate(key:'extensionList.showAllVersions.label')}"> {extension.title} diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php index efb0082bfe42fb5f4ae86d5318c10ffbf47db70c..2be90bda4af0a80f26262ef0735bcf85908ce8d8 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Asset/CssViewHelper.php @@ -53,20 +53,14 @@ final class CssViewHelper extends AbstractTagBasedViewHelper */ protected $escapeChildren = false; - /** - * @var AssetCollector - */ - protected $assetCollector; + protected AssetCollector $assetCollector; - /** - * @param AssetCollector $assetCollector - */ public function injectAssetCollector(AssetCollector $assetCollector): void { $this->assetCollector = $assetCollector; } - public function initialize() + public function initialize(): void { // Add a tag builder, that does not html encode values, because rendering with encoding happens in AssetRenderer $this->setTagBuilder( @@ -80,9 +74,6 @@ final class CssViewHelper extends AbstractTagBasedViewHelper parent::initialize(); } - /** - * @api - */ public function initializeArguments(): void { parent::initializeArguments(); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Asset/ScriptViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Asset/ScriptViewHelper.php index e5e1d0dc8dbc65799aeae5570e5611f60a67334e..29a02d17500695d3bcfa1a7a826274a74225ce21 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Asset/ScriptViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Asset/ScriptViewHelper.php @@ -51,20 +51,14 @@ final class ScriptViewHelper extends AbstractTagBasedViewHelper */ protected $escapeChildren = false; - /** - * @var AssetCollector - */ - protected $assetCollector; + protected AssetCollector $assetCollector; - /** - * @param AssetCollector $assetCollector - */ public function injectAssetCollector(AssetCollector $assetCollector): void { $this->assetCollector = $assetCollector; } - public function initialize() + public function initialize(): void { // Add a tag builder, that does not html encode values, because rendering with encoding happens in AssetRenderer $this->setTagBuilder( @@ -78,9 +72,6 @@ final class ScriptViewHelper extends AbstractTagBasedViewHelper parent::initialize(); } - /** - * @api - */ public function initializeArguments(): void { parent::initializeArguments(); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/InfoboxViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/InfoboxViewHelper.php index 1befafaf684dd5d4717cfd83e2c234b1da23ba3c..fc730dbd8af8c8f4ec491ac5565e0b994c10ff52 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/InfoboxViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/InfoboxViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -72,12 +74,7 @@ final class InfoboxViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('message', 'string', 'The message of the info box, if NULL tag content is used'); $this->registerArgument('title', 'string', 'The title of the info box'); @@ -86,14 +83,7 @@ final class InfoboxViewHelper extends AbstractViewHelper $this->registerArgument('disableIcon', 'bool', 'If set to TRUE, the icon is not rendered.', false, false); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $title = $arguments['title']; $message = $renderChildrenClosure(); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/LinkViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/LinkViewHelper.php index e4a4b4d8ac7aca9cb84b59cd64c722b05a76e9ab..e78f672c585bc2347ce6a61ef501a722d97175ca 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/LinkViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/LinkViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -33,18 +35,12 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; */ final class LinkViewHelper extends AbstractTagBasedViewHelper { - /** * @var string */ protected $tagName = 'a'; - /** - * Arguments initialization - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('route', 'string', 'The name of the route', true); @@ -65,22 +61,16 @@ final class LinkViewHelper extends AbstractTagBasedViewHelper $this->registerUniversalTagAttributes(); } - /** - * @return string Rendered link - */ - public function render() + public function render(): string { $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $route = $this->arguments['route']; $parameters = $this->arguments['parameters']; $referenceType = $this->arguments['referenceType']; - $uri = $uriBuilder->buildUriFromRoute($route, $parameters, $referenceType); - $this->tag->addAttribute('href', $uri); - $this->tag->setContent($this->renderChildren()); + $this->tag->setContent((string)$this->renderChildren()); $this->tag->forceClosingTag(true); - return $this->tag->render(); } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemGroupViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemGroupViewHelper.php index 8b1047c7533473a3c7d9c4f64ede16e3395bd39c..fefa0ce96a8c81082ecbe5e2364f3eb01e4a803a 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemGroupViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemGroupViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -46,33 +48,17 @@ final class ActionMenuItemGroupViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'optgroup'; - /** - * An array of \TYPO3\CMS\Fluid\Core\Parser\SyntaxTree\AbstractNode - * - * @var array - */ - protected $childNodes = []; - - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); - $this->registerArgument('defaultController', 'string', 'The default controller to be used'); + // @todo: deprecate + $this->registerArgument('defaultController', 'string', 'Unused'); $this->registerArgument('label', 'string', 'The label of the option group', false, ''); } - /** - * @return string - */ - public function render() + public function render(): string { - $label = $this->arguments['label']; - - $this->tag->addAttribute('label', $label); + $this->tag->addAttribute('label', $this->arguments['label']); $options = ''; foreach ($this->childNodes as $childNode) { if ($childNode instanceof ViewHelperNode) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php index f141859dce6110605a4d574c1bb8d86dad8a252b..146dbaa9611b9af2e73bd18f20f277d2ddad3eb9 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/PageInfoViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -36,10 +38,11 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; * <f:be.pageInfo /> * * Page info icon with context menu + * + * @todo: Candidate to deprecate? The page info is typically displayed in doc header, done by ModuleTemplate in controllers. */ final class PageInfoViewHelper extends AbstractBackendViewHelper { - /** * This ViewHelper renders HTML, thus output must not be escaped * @@ -47,28 +50,12 @@ final class PageInfoViewHelper extends AbstractBackendViewHelper */ protected $escapeOutput = false; - /** - * Render javascript in header - * - * @return string the rendered page info icon - */ - public function render() + public function render(): string { - return static::renderStatic( - [], - $this->buildRenderChildrenClosure(), - $this->renderingContext - ); + return self::renderStatic([], $this->buildRenderChildrenClosure(), $this->renderingContext); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $id = GeneralUtility::_GP('id'); $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php index f8a0da5827d828705acd76e9cfa04496634f73d2..96eaad9967f2d44721e5a09f74507e49463b2a7d 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/PagePathViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -35,10 +37,11 @@ use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; * <f:be.pagePath /> * * Current page path, prefixed with "Path:" and wrapped in a span with the class ``typo3-docheader-pagePath``. + * + * @todo: Candidate to deprecate? The page info is typically displayed in doc header, done by ModuleTemplate in controllers. */ final class PagePathViewHelper extends AbstractBackendViewHelper { - /** * This ViewHelper renders HTML, thus output must not be escaped * @@ -46,28 +49,12 @@ final class PagePathViewHelper extends AbstractBackendViewHelper */ protected $escapeOutput = false; - /** - * Renders the current page path - * - * @return string the rendered page path - */ - public function render() + public function render(): string { - return static::renderStatic( - [], - $this->buildRenderChildrenClosure(), - $this->renderingContext - ); + return self::renderStatic([], $this->buildRenderChildrenClosure(), $this->renderingContext); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $id = GeneralUtility::_GP('id'); $pageRecord = BackendUtility::readPageAccess($id, $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)); @@ -78,7 +65,7 @@ final class PagePathViewHelper extends AbstractBackendViewHelper $title = (string)$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; } // Setting the path of the page - $pagePath = htmlspecialchars(static::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">'; + $pagePath = htmlspecialchars(self::getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.path')) . ': <span class="typo3-docheader-pagePath">'; // crop the title to title limit (or 50, if not defined) $cropLength = empty($GLOBALS['BE_USER']->uc['titleLen']) ? 50 : $GLOBALS['BE_USER']->uc['titleLen']; $cropLength = (int)$cropLength; @@ -92,11 +79,8 @@ final class PagePathViewHelper extends AbstractBackendViewHelper return $pagePath; } - /** - * @return LanguageService|null - */ - protected static function getLanguageService(): ?LanguageService + protected static function getLanguageService(): LanguageService { - return $GLOBALS['LANG'] ?? null; + return $GLOBALS['LANG']; } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfAuthenticatedViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfAuthenticatedViewHelper.php index 44cd672064205a7ca35d3aa534342f152d3aee40..8d32ae6c9e0cc138450e157305b5be7810fff962 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfAuthenticatedViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfAuthenticatedViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -53,9 +55,8 @@ final class IfAuthenticatedViewHelper extends AbstractConditionViewHelper * This method decides if the condition is TRUE or FALSE. It can be overridden in extending viewhelpers to adjust functionality. * * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexibility in overriding this method. - * @return bool */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return isset($GLOBALS['BE_USER']) && $GLOBALS['BE_USER']->user['uid'] > 0; } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php index e6e852708695a3de6dfc878cb9ac77b4f73ea8a3..1776de304163cd940d8c68784b4053031f6c276b 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/Security/IfHasRoleViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -67,10 +69,9 @@ final class IfHasRoleViewHelper extends AbstractConditionViewHelper * Renders <f:then> child if the current logged in BE user belongs to the specified role (aka usergroup) * otherwise renders <f:else> child. */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); - $this->registerArgument('role', 'string', 'The usergroup (either the usergroup uid or its title).'); } @@ -78,12 +79,11 @@ final class IfHasRoleViewHelper extends AbstractConditionViewHelper * This method decides if the condition is TRUE or FALSE. It can be overridden in extending viewhelpers to adjust functionality. * * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexibility in overriding this method. - * @return bool */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { $role = $arguments['role']; - if (!is_array($GLOBALS['BE_USER']->userGroups)) { + if (!is_array($GLOBALS['BE_USER']->userGroups) || $arguments['role'] === null) { return false; } if (is_numeric($role)) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/TableListViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/TableListViewHelper.php index c243bf07efcfe0576ce31ff106cf0dcfa05b75b5..7f7521ce12ee7b2be6975439b11e29417480e1ea 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/TableListViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/TableListViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -69,25 +71,14 @@ final class TableListViewHelper extends AbstractBackendViewHelper */ protected $escapeOutput = false; - /** - * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface - */ - protected $configurationManager; + protected ConfigurationManagerInterface $configurationManager; - /** - * @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager - */ - public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager) + public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager): void { $this->configurationManager = $configurationManager; } - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('tableName', 'string', 'name of the database table', true); @@ -101,17 +92,16 @@ final class TableListViewHelper extends AbstractBackendViewHelper $this->registerArgument('readOnly', 'bool', 'if TRUE, the edit icons won\'t be shown. Otherwise edit icons will be shown, if the current BE user has edit rights for the specified table!', false, false); $this->registerArgument('enableClickMenu', 'bool', 'enables context menu', false, true); $this->registerArgument('enableControlPanels', 'bool', 'enables control panels', false, false); - $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info'); + $this->registerArgument('clickTitleMode', 'string', 'one of "edit", "show" (only pages, tt_content), "info', false, ''); } /** * Renders a record list as known from the TYPO3 list module * Note: This feature is experimental! * - * @return string the rendered record list * @see \TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList */ - public function render() + public function render(): string { $tableName = $this->arguments['tableName']; $fieldList = $this->arguments['fieldList']; @@ -136,29 +126,29 @@ final class TableListViewHelper extends AbstractBackendViewHelper // We need to include the language file, since DatabaseRecordList is heavily using ->getLL $this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_mod_web_list.xlf'); - $pageinfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)) ?: []; - $dblist = GeneralUtility::makeInstance(DatabaseRecordList::class); - $dblist->pageRow = $pageinfo; + $pageInfo = BackendUtility::readPageAccess(GeneralUtility::_GP('id'), $GLOBALS['BE_USER']->getPagePermsClause(Permission::PAGE_SHOW)) ?: []; + $dbList = GeneralUtility::makeInstance(DatabaseRecordList::class); + $dbList->pageRow = $pageInfo; if ($readOnly) { - $dblist->setIsEditable(false); + $dbList->setIsEditable(false); } else { - $dblist->calcPerms = new Permission($GLOBALS['BE_USER']->calcPerms($pageinfo)); + $dbList->calcPerms = new Permission($GLOBALS['BE_USER']->calcPerms($pageInfo)); } - $dblist->disableSingleTableView = true; - $dblist->clickTitleMode = $clickTitleMode; - $dblist->clickMenuEnabled = $enableClickMenu; + $dbList->disableSingleTableView = true; + $dbList->clickTitleMode = $clickTitleMode; + $dbList->clickMenuEnabled = $enableClickMenu; if ($storagePid === null) { $frameworkConfiguration = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK); $storagePid = $frameworkConfiguration['persistence']['storagePid']; } - $dblist->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage); + $dbList->start($storagePid, $tableName, (int)GeneralUtility::_GP('pointer'), $filter, $levels, $recordsPerPage); // Column selector is disabled since fields are defined by the "fieldList" argument - $dblist->displayColumnSelector = false; - $dblist->setFields = [$tableName => $fieldList]; - $dblist->noControlPanels = !$enableControlPanels; - $dblist->sortField = $sortField; - $dblist->sortRev = $sortDescending; - return $dblist->generateList(); + $dbList->displayColumnSelector = false; + $dbList->setFields = [$tableName => $fieldList]; + $dbList->noControlPanels = !$enableControlPanels; + $dbList->sortField = $sortField; + $dbList->sortRev = $sortDescending; + return $dbList->generateList(); } protected function getLanguageService(): LanguageService diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Be/UriViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Be/UriViewHelper.php index cfbc05705c2afba5640a76ce32c6f21e9a4e86b6..b016006be1a2d1e5595db77ca3f9e9c0ab1969af 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Be/UriViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Be/UriViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -38,13 +40,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; */ final class UriViewHelper extends AbstractBackendViewHelper { - - /** - * Arguments initialization - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('route', 'string', 'The name of the route', true); @@ -58,18 +54,13 @@ final class UriViewHelper extends AbstractBackendViewHelper ); } - /** - * @return string Rendered link - */ - public function render() + public function render(): string { - /** @var UriBuilder $uriBuilder */ $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $route = $this->arguments['route']; $parameters = $this->arguments['parameters']; $referenceType = $this->arguments['referenceType']; $uri = $uriBuilder->buildUriFromRoute($route, $parameters, $referenceType); - return (string)$uri; } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php index 50e4978d0a8c0899159a40425939b9225f048be2..982d135665e586815160500e2ed1ffd3909037ca 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -103,17 +105,7 @@ final class CObjectViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController contains a backup of the current $GLOBALS['TSFE'] if used in BE mode - */ - protected static $tsfeBackup; - - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('data', 'mixed', 'the data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used'); $this->registerArgument('typoscriptObjectPath', 'string', 'the TypoScript setup path of the TypoScript object to render', true); @@ -124,21 +116,18 @@ final class CObjectViewHelper extends AbstractViewHelper /** * Renders the TypoScript object in the given TypoScript setup path. * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return mixed - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception + * @throws Exception */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - $data = $renderChildrenClosure(); + $data = $arguments['data'] ?? $renderChildrenClosure(); $typoscriptObjectPath = $arguments['typoscriptObjectPath']; $currentValueKey = $arguments['currentValueKey']; $table = $arguments['table']; - $contentObjectRenderer = static::getContentObjectRenderer($renderingContext->getRequest()); + $contentObjectRenderer = self::getContentObjectRenderer($renderingContext->getRequest()); + $tsfeBackup = null; if (!isset($GLOBALS['TSFE']) || !($GLOBALS['TSFE'] instanceof TypoScriptFrontendController)) { - static::simulateFrontendEnvironment(); + $tsfeBackup = self::simulateFrontendEnvironment(); } $currentValue = null; if (is_object($data)) { @@ -155,7 +144,7 @@ final class CObjectViewHelper extends AbstractViewHelper } $pathSegments = GeneralUtility::trimExplode('.', $typoscriptObjectPath); $lastSegment = (string)array_pop($pathSegments); - $setup = static::getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); + $setup = self::getConfigurationManager()->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); foreach ($pathSegments as $segment) { if (!array_key_exists($segment . '.', $setup)) { throw new Exception( @@ -173,7 +162,7 @@ final class CObjectViewHelper extends AbstractViewHelper } $content = self::renderContentObject($contentObjectRenderer, $setup, $typoscriptObjectPath, $lastSegment); if (!isset($GLOBALS['TSFE']) || !($GLOBALS['TSFE'] instanceof TypoScriptFrontendController)) { - static::resetFrontendEnvironment(); + self::resetFrontendEnvironment($tsfeBackup); } return $content; } @@ -208,10 +197,6 @@ final class CObjectViewHelper extends AbstractViewHelper return GeneralUtility::getContainer()->get(ConfigurationManagerInterface::class); } - /** - * @param ServerRequestInterface $request - * @return ContentObjectRenderer - */ protected static function getContentObjectRenderer(ServerRequestInterface $request): ContentObjectRenderer { if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) { @@ -239,20 +224,19 @@ final class CObjectViewHelper extends AbstractViewHelper /** * \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer->cObjGetSingle() relies on $GLOBALS['TSFE'] */ - protected static function simulateFrontendEnvironment() + protected static function simulateFrontendEnvironment(): ?TypoScriptFrontendController { - static::$tsfeBackup = $GLOBALS['TSFE'] ?? null; + $tsfeBackup = $GLOBALS['TSFE'] ?? null; $GLOBALS['TSFE'] = new \stdClass(); $GLOBALS['TSFE']->cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); + return $tsfeBackup; } /** * Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment() - * - * @see simulateFrontendEnvironment() */ - protected static function resetFrontendEnvironment() + protected static function resetFrontendEnvironment(?TypoScriptFrontendController $tsfeBackup): void { - $GLOBALS['TSFE'] = static::$tsfeBackup; + $GLOBALS['TSFE'] = $tsfeBackup; } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Debug/RenderViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Debug/RenderViewHelper.php index f333c4c0a5e11fe8771a93b9f0336fcce9566bca..04ee7507aefa981c5077203738ae59ebb91b3338 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Debug/RenderViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Debug/RenderViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -30,33 +32,24 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; */ final class RenderViewHelper extends AbstractViewHelper { - /** * @var bool */ protected $escapeOutput = false; - /** - * Initializes additional arguments available for this ViewHelper. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('debug', 'boolean', 'If true, the admin panel shows debug information if activated,', false, true); - $this->registerArgument('section', 'string', 'Section to render - combine with partial to render section in partial', false, null); - $this->registerArgument('partial', 'string', 'Partial to render, with or without section', false, null); + $this->registerArgument('section', 'string', 'Section to render - combine with partial to render section in partial', false); + $this->registerArgument('partial', 'string', 'Partial to render, with or without section', false); $this->registerArgument('arguments', 'array', 'Array of variables to be transferred. Use {_all} for all variables', false, []); $this->registerArgument('optional', 'boolean', 'If TRUE, considers the *section* optional. Partial never is.', false, false); - $this->registerArgument('default', 'mixed', 'Value (usually string) to be displayed if the section or partial does not exist', false, null); - $this->registerArgument('contentAs', 'string', 'If used, renders the child content and adds it as a template variable with this name for use in the partial/section', false, null); + $this->registerArgument('default', 'mixed', 'Value (usually string) to be displayed if the section or partial does not exist', false); + $this->registerArgument('contentAs', 'string', 'If used, renders the child content and adds it as a template variable with this name for use in the partial/section', false); } - /** - * Renders the content. - * - * @return string - */ - public function render() + public function render(): string { $isDebug = $this->arguments['debug']; $section = $this->arguments['section']; @@ -79,9 +72,9 @@ final class RenderViewHelper extends AbstractViewHelper } // Replace empty content with default value. If default is // not set, NULL is returned and cast to a new, empty string - // outside of this ViewHelper. + // outside this ViewHelper. if ($content === '') { - $content = $this->arguments['default'] ?? $tagContent; + $content = $this->arguments['default'] ?? (string)$tagContent; } // if debug is disabled, return content diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/DebugViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/DebugViewHelper.php index 561ce70b535a4ea587845b5666f1894d0eeab2f3..ce435dfb2e5e61244bd29fbfc5b63183721c2c61 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/DebugViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/DebugViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -69,12 +71,7 @@ final class DebugViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('title', 'string', 'optional custom title for the debug output'); $this->registerArgument('maxDepth', 'int', 'Sets the max recursion depth of the dump (defaults to 8). De- or increase the number according to your needs and memory limit.', false, 8); @@ -87,15 +84,18 @@ final class DebugViewHelper extends AbstractViewHelper /** * A wrapper for \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(). - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - return DebuggerUtility::var_dump($renderChildrenClosure(), $arguments['title'], $arguments['maxDepth'], (bool)$arguments['plainText'], (bool)$arguments['ansiColors'], (bool)$arguments['inline'], $arguments['blacklistedClassNames'], $arguments['blacklistedPropertyNames']); + return DebuggerUtility::var_dump( + $renderChildrenClosure(), + $arguments['title'], + $arguments['maxDepth'], + $arguments['plainText'], + $arguments['ansiColors'], + $arguments['inline'], + $arguments['blacklistedClassNames'], + $arguments['blacklistedPropertyNames'] + ); } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php index 12c1beba6fa9c465670db169571212de75e43e57..79b7d61eac1d449dc1374ee29d342443e260afd3 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/ButtonViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -49,12 +51,7 @@ final class ButtonViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'button'; - /** - * Initialize the arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute( @@ -97,12 +94,7 @@ final class ButtonViewHelper extends AbstractFormFieldViewHelper $this->registerArgument('type', 'string', 'Specifies the type of button (e.g. "button", "reset" or "submit")', false, 'submit'); } - /** - * Renders the button. - * - * @return string - */ - public function render() + public function render(): string { $type = $this->arguments['type']; $name = $this->getName(); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php index 220c2799c68412e7f7b963de0f82242e5e2f72c5..730c77a8089d9d9c05b3baee858eaddcfbf9ee02 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/CheckboxViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -65,10 +67,7 @@ final class CheckboxViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute( @@ -89,13 +88,7 @@ final class CheckboxViewHelper extends AbstractFormFieldViewHelper $this->registerArgument('multiple', 'bool', 'Specifies whether this checkbox belongs to a multivalue (is part of a checkbox group)', false, false); } - /** - * Renders the checkbox. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - * @return string - */ - public function render() + public function render(): string { $checked = $this->arguments['checked']; $multiple = $this->arguments['multiple']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php index 626a3127369d44f2bba2d8ea0723df09a6216943..f949f900b9fd2392f90d967db584a4c0b97da366 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/HiddenViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -39,10 +41,7 @@ final class HiddenViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -55,16 +54,11 @@ final class HiddenViewHelper extends AbstractFormFieldViewHelper ); } - /** - * Renders the hidden field. - * - * @return string - */ - public function render() + public function render(): string { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); - $this->setRespectSubmittedDataValue((bool)($this->arguments['respectSubmittedDataValue'] ?? true)); + $this->setRespectSubmittedDataValue($this->arguments['respectSubmittedDataValue']); $this->tag->addAttribute('type', 'hidden'); $this->tag->addAttribute('name', $name); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php index f916eadc6e2bb633a24bedd0b24e4fedc122662d..9bd98cfcb3df84b9fdfba0ee4473dd7cf855784b 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -36,10 +38,7 @@ final class PasswordViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute( @@ -66,12 +65,7 @@ final class PasswordViewHelper extends AbstractFormFieldViewHelper $this->registerUniversalTagAttributes(); } - /** - * Renders the password input field. - * - * @return string - */ - public function render() + public function render(): string { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php index 77516549a230c3adf47e9ab9bdc07f810dedf08a..c126f3cc028ad10127e867a5720e4c59e4176aff 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/RadioViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -67,10 +69,7 @@ final class RadioViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument( @@ -90,12 +89,7 @@ final class RadioViewHelper extends AbstractFormFieldViewHelper ); } - /** - * Renders the checkbox. - * - * @return string - */ - public function render() + public function render(): string { $checked = $this->arguments['checked']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptgroupViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptgroupViewHelper.php index 39e98639642bff236eca05cdfe3595595f381da2..2e43fe42381fac5725849520c5ed1fe9f50f4231 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptgroupViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptgroupViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -28,10 +30,7 @@ final class OptgroupViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'optgroup'; - /** - * Initialize additional arguments available for this tag ViewHelper. - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerUniversalTagAttributes(); $this->registerArgument('additionalAttributes', 'array', 'Additional tag attributes. They will be added directly to the resulting HTML tag.'); @@ -40,10 +39,7 @@ final class OptgroupViewHelper extends AbstractFormFieldViewHelper $this->registerTagAttribute('disabled', 'boolean', 'If true, option group is rendered as disabled', false, false); } - /** - * @return string - */ - public function render() + public function render(): string { if ($this->arguments['disabled']) { $this->tag->addAttribute('disabled', 'disabled'); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptionViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptionViewHelper.php index aa55865301e7760dc987585047da4b9a67ebdb2c..78011b22b9e0ca70aba63923cbfbe6d680477073 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptionViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/Select/OptionViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -28,10 +30,7 @@ final class OptionViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'option'; - /** - * Initialize additional arguments available for this tag ViewHelper. - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerUniversalTagAttributes(); $this->registerArgument('selected', 'boolean', 'If set, overrides automatic detection of selected state for this option.'); @@ -40,10 +39,7 @@ final class OptionViewHelper extends AbstractFormFieldViewHelper $this->registerTagAttribute('value', 'mixed', 'Value to be inserted in HTML tag - must be convertible to string!'); } - /** - * @return string - */ - public function render() + public function render(): string { $childContent = $this->renderChildren(); $this->tag->setContent($childContent); @@ -65,10 +61,6 @@ final class OptionViewHelper extends AbstractFormFieldViewHelper return $this->tag->render(); } - /** - * @param string $value - * @return bool - */ protected function isValueSelected(string $value): bool { $selectedValue = $this->renderingContext->getViewHelperVariableContainer()->get(SelectViewHelper::class, 'selectedValue'); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php index ea96081ae10ac7e60f48cdd1ec53927561926aed..471eaefc97c3da98e7925767bd39f1355373765d 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/SelectViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -103,10 +105,7 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper */ protected $selectedValue; - /** - * Initialize arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -125,18 +124,13 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper $this->registerArgument('required', 'boolean', 'If set no empty value is allowed.', false, false); } - /** - * Render the tag. - * - * @return string rendered tag. - */ - public function render() + public function render(): string { - if (isset($this->arguments['required']) && $this->arguments['required']) { + if ($this->arguments['required']) { $this->tag->addAttribute('required', 'required'); } $name = $this->getName(); - if (isset($this->arguments['multiple']) && $this->arguments['multiple']) { + if ($this->arguments['multiple']) { $this->tag->addAttribute('multiple', 'multiple'); $name .= '[]'; } @@ -153,7 +147,7 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper $this->registerFieldNameForFormTokenGeneration($name); // in case it is a multi-select, we need to register the field name // as often as there are elements in the box - if (isset($this->arguments['multiple']) && $this->arguments['multiple']) { + if ($this->arguments['multiple']) { $content .= $this->renderHiddenFieldForEmptyValue(); // Register the field name additional times as required by the total number of // options. Since we already registered it once above, we start the counter at 1 @@ -193,32 +187,27 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper /** * Render prepended option tag - * - * @return string rendered prepended empty option */ - protected function renderPrependOptionTag() + protected function renderPrependOptionTag(): string { $output = ''; if ($this->hasArgument('prependOptionLabel')) { $value = $this->hasArgument('prependOptionValue') ? $this->arguments['prependOptionValue'] : ''; $label = $this->arguments['prependOptionLabel']; - $output .= $this->renderOptionTag($value, $label, false) . LF; + $output .= $this->renderOptionTag((string)$value, (string)$label, false) . LF; } return $output; } /** * Render the option tags. - * - * @param array $options the options for the form. - * @return string rendered tags. */ - protected function renderOptionTags($options) + protected function renderOptionTags(array $options): string { $output = ''; foreach ($options as $value => $label) { $isSelected = $this->isSelected($value); - $output .= $this->renderOptionTag($value, $label, $isSelected) . LF; + $output .= $this->renderOptionTag((string)$value, (string)$label, $isSelected) . LF; } return $output; } @@ -226,9 +215,9 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper /** * Render the option tags. * - * @return array an associative array of options, key will be the value of the option tag + * @return array An associative array of options, key will be the value of the option tag */ - protected function getOptions() + protected function getOptions(): array { if (!is_array($this->arguments['options']) && !$this->arguments['options'] instanceof \Traversable) { return []; @@ -282,9 +271,9 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper * Render the option tags. * * @param mixed $value Value to check for - * @return bool TRUE if the value should be marked a s selected; FALSE otherwise + * @return bool True if the value should be marked as selected. */ - protected function isSelected($value) + protected function isSelected($value): bool { $selectedValue = $this->getSelectedValue(); if ($value === $selectedValue || (string)$value === $selectedValue) { @@ -324,7 +313,7 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper * Get the option value for an object * * @param mixed $valueElement - * @return string + * @return string @todo: Does not always return string ... */ protected function getOptionValueScalar($valueElement) { @@ -346,16 +335,16 @@ final class SelectViewHelper extends AbstractFormFieldViewHelper * * @param string $value value attribute of the option tag (will be escaped) * @param string $label content of the option tag (will be escaped) - * @param bool $isSelected specifies whether or not to add selected attribute + * @param bool $isSelected specifies whether to add selected attribute * @return string the rendered option tag */ - protected function renderOptionTag($value, $label, $isSelected) + protected function renderOptionTag(string $value, string $label, bool $isSelected): string { - $output = '<option value="' . htmlspecialchars((string)$value) . '"'; + $output = '<option value="' . htmlspecialchars($value) . '"'; if ($isSelected) { $output .= ' selected="selected"'; } - $output .= '>' . htmlspecialchars((string)$label) . '</option>'; + $output .= '>' . htmlspecialchars($label) . '</option>'; return $output; } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php index 3bb1e1f1f0c9272e77e4a7d4729839c746ec9f8e..f648f420f12484948ab50c3c660c222cf4f0c139 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/SubmitViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -50,10 +52,7 @@ final class SubmitViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute( @@ -64,12 +63,7 @@ final class SubmitViewHelper extends AbstractFormFieldViewHelper $this->registerUniversalTagAttributes(); } - /** - * Renders the submit button. - * - * @return string - */ - public function render() + public function render(): string { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php index 872cbfbd219317a923b21b2012837849fbffe76b..729143308397158975653d8f904d8cd3de3504ef 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -38,10 +40,7 @@ final class TextareaViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'textarea'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute('autofocus', 'string', 'Specifies that a text area should automatically get focus when the page loads'); @@ -55,14 +54,9 @@ final class TextareaViewHelper extends AbstractFormFieldViewHelper $this->registerUniversalTagAttributes(); } - /** - * Renders the textarea. - * - * @return string - */ - public function render() + public function render(): string { - $required = $this->arguments['required'] ?? false; + $required = $this->arguments['required']; $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); $this->setRespectSubmittedDataValue(true); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php index 396dd1628b34ca72c2dac77339a90a22e5c4c6c3..937777403c8151d11c11433f233c84ba50a990b9 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -36,12 +38,7 @@ final class TextfieldViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute('autofocus', 'string', 'Specifies that an input should automatically get focus when the page loads'); @@ -57,15 +54,10 @@ final class TextfieldViewHelper extends AbstractFormFieldViewHelper $this->registerArgument('type', 'string', 'The field type, e.g. "text", "email", "url" etc.', false, 'text'); } - /** - * Renders the textfield. - * - * @return string - */ - public function render() + public function render(): string { - $required = $this->arguments['required'] ?? false; - $type = $this->arguments['type'] ?? null; + $required = $this->arguments['required']; + $type = $this->arguments['type']; $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php index 966d7dfcbaaa76a0e1e7c428fc18609fd2a4e7c2..4de4255e4360f7a85e751320605c1ddfd758e637 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/UploadViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -37,10 +39,7 @@ final class UploadViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * Initialize the arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads'); @@ -50,12 +49,7 @@ final class UploadViewHelper extends AbstractFormFieldViewHelper $this->registerUniversalTagAttributes(); } - /** - * Renders the upload field. - * - * @return string - */ - public function render() + public function render(): string { $name = $this->getName(); $allowedFields = ['name', 'type', 'tmp_name', 'error', 'size']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php index 0e1187b9906fadd433cac115873f3c4e9c669b24..06aabbf3ea67fdbdd7f99dd3613a64546bdae443 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -78,20 +80,14 @@ final class ValidationResultsViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('for', 'string', 'The name of the error name (e.g. argument name or property name). This can also be a property path (like blog.title), and will then only display the validation errors of that property.', false, ''); $this->registerArgument('as', 'string', 'The name of the variable to store the current error', false, 'validationResults'); } /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return mixed + * @return mixed @todo: Really mixed here, not string? */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php index 3fa1c22f83449eb20eba2ce27b23d8baff3e1e6b..da492bd183f09472cb89ca878f429e8ec5ebe495 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/AbstractEncodingViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -19,7 +21,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; /** * This is the base class for ViewHelpers that work with encodings. - * Currently that are format.htmlentities, format.htmlentitiesDecode and format.htmlspecialchars + * Currently, that are format.htmlentities and format.htmlentitiesDecode */ abstract class AbstractEncodingViewHelper extends AbstractViewHelper { @@ -30,10 +32,8 @@ abstract class AbstractEncodingViewHelper extends AbstractViewHelper /** * Resolve the default encoding. If none is set in Frontend or Backend, uses UTF-8. - * - * @return string the encoding */ - protected static function resolveDefaultEncoding() + protected static function resolveDefaultEncoding(): string { if (self::$defaultEncoding === null) { self::$defaultEncoding = 'UTF-8'; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php index 3fb358a2e1da185f3436a00ed76746fe13209e9c..04e5e428b834fe69c46beff76fb9cac789667c8d 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CaseViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -107,31 +109,23 @@ final class CaseViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize ViewHelper arguments - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument('value', 'string', 'The input value. If not given, the evaluated child nodes will be used.', false, null); + $this->registerArgument('value', 'string', 'The input value. If not given, the evaluated child nodes will be used.', false); $this->registerArgument('mode', 'string', 'The case to apply, must be one of this\' CASE_* constants. Defaults to uppercase application.', false, self::CASE_UPPER); } /** * Changes the case of the input string - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string * @throws Exception */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $value = $arguments['value']; $mode = $arguments['mode']; if ($value === null) { - $value = $renderChildrenClosure(); + $value = (string)$renderChildrenClosure(); } switch ($mode) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php index 308d1015f19c6bdd8625bba08db4f5e683e61dd8..2a45fbeea203b19d0dc2f193240fc898b51437ef 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -97,12 +99,7 @@ final class CropViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('maxCharacters', 'int', 'Place where to truncate the string', true); $this->registerArgument('append', 'string', 'What to append, if truncation happened', false, '…'); @@ -110,15 +107,7 @@ final class CropViewHelper extends AbstractViewHelper $this->registerArgument('respectHtml', 'bool', 'If TRUE the cropped string will respect HTML tags and entities. Technically that means, that cropHTML() is called rather than crop()', false, true); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - * @throws \InvalidArgumentException - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $maxCharacters = $arguments['maxCharacters']; $append = $arguments['append']; @@ -130,7 +119,6 @@ final class CropViewHelper extends AbstractViewHelper // It would be possible to retrieve the "current" content object via ConfigurationManager->getContentObject(), // but both crop() and cropHTML() are "nearly" static and do not depend on current content object settings, so // it is safe to use a fresh instance here directly. - /** @var ContentObjectRenderer $contentObject */ $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); if ($respectHtml) { $content = $contentObject->cropHTML($stringToTruncate, $maxCharacters . '|' . $append . '|' . $respectWordBoundaries); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php index b7b77e7afbd3f89b2eef0420de8aeb1fbab8a7b2..6cc17146dd014482eb205267b8c82daffa010564 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/CurrencyViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -86,12 +88,7 @@ final class CurrencyViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('currencySign', 'string', 'The currency sign, eg $ or €.', false, ''); $this->registerArgument('decimalSeparator', 'string', 'The separator for the decimal point.', false, ','); @@ -102,16 +99,7 @@ final class CurrencyViewHelper extends AbstractViewHelper $this->registerArgument('useDash', 'bool', 'Use the dash instead of decimal 00', false, false); } - /** - * Formats a float to currency formatting - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string the formatted amount - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $currencySign = $arguments['currencySign']; $decimalSeparator = $arguments['decimalSeparator']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php index 1c6f64e661db8917f120a91d1a5310792cc59f93..dea5ecd74b54d7d67856434c2642a69219a014bb 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/DateViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -110,10 +112,7 @@ final class DateViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('date', 'mixed', 'Either an object implementing DateTimeInterface or a string that is accepted by DateTime constructor'); $this->registerArgument('format', 'string', 'Format String which is taken to format the Date/Time', false, ''); @@ -121,14 +120,9 @@ final class DateViewHelper extends AbstractViewHelper } /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string * @throws Exception */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $format = $arguments['format']; $base = $arguments['base'] ?? GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('date', 'timestamp'); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php index 72e7e231f73a4d858a39f7bc111edd16e9490d10..73e41f53ce3c85254687d2d055f570f2aa6cfd15 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -19,6 +21,7 @@ use TYPO3\CMS\Core\Http\ApplicationType; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; +use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; @@ -72,11 +75,6 @@ final class HtmlViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController contains a backup of the current $GLOBALS['TSFE'] if used in BE mode - */ - protected static $tsfeBackup; - /** * Children must not be escaped, to be able to pass {bodytext} directly to it * @@ -91,60 +89,49 @@ final class HtmlViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('parseFuncTSPath', 'string', ' path to TypoScript parseFunc setup.', false, 'lib.parseFunc_RTE'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string the parsed string. - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $parseFuncTSPath = $arguments['parseFuncTSPath']; $isBackendRequest = ApplicationType::fromRequest($renderingContext->getRequest())->isBackend(); if ($isBackendRequest) { - self::simulateFrontendEnvironment(); + $tsfeBackup = self::simulateFrontendEnvironment(); } $value = $renderChildrenClosure(); $contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class); $contentObject->start([]); $content = $contentObject->parseFunc($value, [], '< ' . $parseFuncTSPath); if ($isBackendRequest) { - self::resetFrontendEnvironment(); + self::resetFrontendEnvironment($tsfeBackup); } return $content; } /** - * Copies the specified parseFunc configuration to $GLOBALS['TSFE']->tmpl->setup in Backend mode - * This somewhat hacky work around is currently needed because the parseFunc() function of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer relies on those variables to be set + * Copies the specified parseFunc configuration to $GLOBALS['TSFE']->tmpl->setup in Backend mode. + * This somewhat hacky work around is currently needed because ContentObjectRenderer->parseFunc() relies on those variables to be set. + * + * @return ?TypoScriptFrontendController The 'old' backed up $GLOBALS['TSFE'] or null */ - protected static function simulateFrontendEnvironment() + protected static function simulateFrontendEnvironment(): ?TypoScriptFrontendController { - self::$tsfeBackup = $GLOBALS['TSFE'] ?? null; + $tsfeBackup = $GLOBALS['TSFE'] ?? null; $GLOBALS['TSFE'] = new \stdClass(); $GLOBALS['TSFE']->tmpl = new \stdClass(); $configurationManager = GeneralUtility::makeInstance(ConfigurationManagerInterface::class); $GLOBALS['TSFE']->tmpl->setup = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT); + return $tsfeBackup; } /** * Resets $GLOBALS['TSFE'] if it was previously changed by simulateFrontendEnvironment() - * - * @see simulateFrontendEnvironment() */ - protected static function resetFrontendEnvironment() + protected static function resetFrontendEnvironment(?TypoScriptFrontendController $tsfeBackup): void { - $GLOBALS['TSFE'] = self::$tsfeBackup; + $GLOBALS['TSFE'] = $tsfeBackup; } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesDecodeViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesDecodeViewHelper.php index f58d36f05227904f0c5a2867fe913e2b035d1360..760b50858be56a66067554fc43e3e738b9fbf5e0 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesDecodeViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesDecodeViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -65,10 +67,7 @@ final class HtmlentitiesDecodeViewHelper extends AbstractEncodingViewHelper */ protected $escapeOutput = false; - /** - * Initialize ViewHelper arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('value', 'string', 'string to format'); @@ -80,13 +79,8 @@ final class HtmlentitiesDecodeViewHelper extends AbstractEncodingViewHelper * Converts all HTML entities to their applicable characters as needed using PHPs html_entity_decode() function. * * @see https://www.php.net/html_entity_decode - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $value = $renderChildrenClosure(); $encoding = $arguments['encoding']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesViewHelper.php index 98ba5e8a123b0dd9d75a89f7d9732b3443317c1c..9621d3e122ff10c6887ddff614253b959a2ef2a2 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlentitiesViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -65,10 +67,7 @@ final class HtmlentitiesViewHelper extends AbstractEncodingViewHelper */ protected $escapeChildren = false; - /** - * Initialize ViewHelper arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'string to format'); $this->registerArgument('keepQuotes', 'bool', 'If TRUE, single and double quotes won\'t be replaced (sets ENT_NOQUOTES flag).', false, false); @@ -80,9 +79,6 @@ final class HtmlentitiesViewHelper extends AbstractEncodingViewHelper * Escapes special characters with their escaped counterparts as needed using PHPs htmlentities() function. * * @see https://www.php.net/manual/function.htmlentities.php - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext * @return mixed */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/JsonViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/JsonViewHelper.php index a1127e76e0965b8d47febf83580abb86d57ba52d..fe01fec5c4039dbb9ea0629764a1c4530a6ff0a7 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/JsonViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/JsonViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -13,10 +15,6 @@ * The TYPO3 project - inspiring people to share! */ -/* - * Inspired by and partially taken from the Neos.Form package (www.neos.io) - */ - namespace TYPO3\CMS\Fluid\ViewHelpers\Format; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; @@ -67,10 +65,7 @@ final class JsonViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'mixed', 'The incoming data to convert, or null if VH children should be used'); $this->registerArgument('forceObject', 'bool', 'Outputs an JSON object rather than an array', false, false); @@ -85,11 +80,8 @@ final class JsonViewHelper extends AbstractViewHelper * If $forceObject is TRUE a JSON object is outputted even if the value is a non-associative array * Example: array('foo', 'bar') as input will not be ["foo","bar"] but {"0":"foo","1":"bar"} * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext * @see https://www.php.net/manual/function.json-encode.php - * @return string + * @return string|false */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php index c1041b3acbbd696cf8e95092945cdcec06cefed8..a5dd4b658de0d081b9aa6518e0b91221e8e71fad 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/Nl2brViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -53,26 +55,13 @@ final class Nl2brViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'string to format'); } - /** - * Applies nl2br() on the specified value. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - return nl2br((string)$renderChildrenClosure()); + return nl2br((string)($arguments['value'] ?? $renderChildrenClosure())); } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php index 9c2d3151aa8c116b26381b8744ba3194f388d703..2203171901231382cb896811c53294c4a5ab3582 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/NumberViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -57,34 +59,21 @@ final class NumberViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument('decimals', 'int', 'The number of digits after the decimal point', false, '2'); + $this->registerArgument('decimals', 'int', 'The number of digits after the decimal point', false, 2); $this->registerArgument('decimalSeparator', 'string', 'The decimal point character', false, '.'); $this->registerArgument('thousandsSeparator', 'string', 'The character for grouping the thousand digits', false, ','); } /** - * Format the numeric value as a number with grouped thousands, decimal point and - * precision. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string The formatted number + * Format the numeric value as a number with grouped thousands, decimal point and precision. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $decimals = $arguments['decimals']; $decimalSeparator = $arguments['decimalSeparator']; $thousandsSeparator = $arguments['thousandsSeparator']; - $stringToFormat = $renderChildrenClosure(); return number_format((float)$stringToFormat, $decimals, $decimalSeparator, $thousandsSeparator); } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php index ec5d3f8daa7e1f8799a2261fe49ce37446d4d603..ee27abea90b5c473d3291971e4c66980e9b63868 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/PaddingViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -69,12 +71,7 @@ final class PaddingViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize arguments. - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'string to format'); $this->registerArgument('padLength', 'int', 'Length of the resulting string. If the value of pad_length is negative or less than the length of the input string, no padding takes place.', true); @@ -83,14 +80,9 @@ final class PaddingViewHelper extends AbstractViewHelper } /** - * Pad a string to a certain length with another string - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext - * @return string The formatted value + * Pad a string to a certain length with another string. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $value = $renderChildrenClosure(); $padTypes = [ @@ -103,6 +95,6 @@ final class PaddingViewHelper extends AbstractViewHelper $padType = 'right'; } - return StringUtility::multibyteStringPad((string)$value, $arguments['padLength'], $arguments['padString'], $padTypes[$padType]); + return StringUtility::multibyteStringPad((string)$value, (int)$arguments['padLength'], (string)$arguments['padString'], $padTypes[$padType]); } } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/StripTagsViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/StripTagsViewHelper.php index 0db2ad8413515cddb2f1b7209c0df599ee3edc16..9e41be2bbfc2e504b13b1ff2f20fb03e043867a3 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/StripTagsViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/StripTagsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -80,16 +82,10 @@ final class StripTagsViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize ViewHelper arguments - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'string to format'); - $this->registerArgument('allowedTags', 'string', 'Optional string of allowed tags as required by PHPs strip_tags() f -unction'); + $this->registerArgument('allowedTags', 'string', 'Optional string of allowed tags as required by PHPs strip_tags() function'); } /** @@ -100,20 +96,14 @@ unction'); protected $escapeChildren = false; /** - * Applies strip_tags() on the specified value. + * Applies strip_tags() on the specified value if it's string-able. * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param \TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface $renderingContext * @see https://www.php.net/manual/function.strip-tags.php - * @return string + * @return mixed */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { - $value = $renderChildrenClosure(); + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + { + $value = $arguments['value'] ?? $renderChildrenClosure(); $allowedTags = $arguments['allowedTags']; if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { return $value; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Format/UrlencodeViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Format/UrlencodeViewHelper.php index 746922ec7a5c87f2ae9d426633468f6f98d6ba0f..07b861eccc8ddcce2e38eb58d91f11354175bc6b 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Format/UrlencodeViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Format/UrlencodeViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -17,7 +19,6 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Format; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Exception; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic; /** @@ -60,12 +61,7 @@ final class UrlencodeViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * Initialize ViewHelper arguments - * - * @throws Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('value', 'string', 'string to format'); } @@ -74,15 +70,11 @@ final class UrlencodeViewHelper extends AbstractViewHelper * Escapes special characters with their escaped counterparts as needed using PHPs rawurlencode() function. * * @see https://www.php.net/manual/function.rawurlencode.php - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * * @return mixed */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { - $value = $renderChildrenClosure(); + $value = $arguments['value'] ?? $renderChildrenClosure(); if (!is_string($value) && !(is_object($value) && method_exists($value, '__toString'))) { return $value; } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php index 81aa186d9d2215fd7c2e3ebf7c3711bdd45a5b39..b88dad895907786793a84ce15234bd9e9befcc9d 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -103,10 +105,7 @@ final class ImageViewHelper extends AbstractTagBasedViewHelper $this->imageService = GeneralUtility::makeInstance(ImageService::class); } - /** - * Initialize arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -134,14 +133,12 @@ final class ImageViewHelper extends AbstractTagBasedViewHelper } /** - * Resizes a given image (if required) and renders the respective img tag + * Resizes a given image (if required) and renders the respective img tag. * * @see https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Image/ - * * @throws Exception - * @return string Rendered tag */ - public function render() + public function render(): string { $src = (string)$this->arguments['src']; if (($src === '' && $this->arguments['image'] === null) || ($src !== '' && $this->arguments['image'] !== null)) { @@ -149,7 +146,11 @@ final class ImageViewHelper extends AbstractTagBasedViewHelper } if ((string)$this->arguments['fileExtension'] && !GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], (string)$this->arguments['fileExtension'])) { - throw new Exception('The extension ' . $this->arguments['fileExtension'] . ' is not specified in $GLOBALS[\'TYPO3_CONF_VARS\'][\'GFX\'][\'imagefile_ext\'] as a valid image file extension and can not be processed.', 1618989190); + throw new Exception( + 'The extension ' . $this->arguments['fileExtension'] . ' is not specified in $GLOBALS[\'TYPO3_CONF_VARS\'][\'GFX\'][\'imagefile_ext\']' + . ' as a valid image file extension and can not be processed.', + 1618989190 + ); } try { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php index 0745342b3d15a368ddbc9f60507ddf367d1176fe..6a685a31ba8645c89dfebc88f5d42c0a48f8ee0f 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -61,10 +63,7 @@ final class EmailViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'a'; - /** - * Arguments initialization - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('email', 'string', 'The email address to be turned into a link', true); @@ -75,10 +74,7 @@ final class EmailViewHelper extends AbstractTagBasedViewHelper $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document'); } - /** - * @return string Rendered email link - */ - public function render() + public function render(): string { $email = $this->arguments['email']; if (ApplicationType::fromRequest($this->renderingContext->getRequest())->isFrontend()) { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php index 26f89726c3747b6fb427aeeb42089f3e00e76197..ed9121bea28d99f3aa4ed1cdf7e8ae3a6a1b0e3b 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Link/ExternalViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -52,10 +54,7 @@ final class ExternalViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'a'; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('uri', 'string', 'The URI that will be put in the href attribute of the rendered link tag', true); @@ -67,10 +66,7 @@ final class ExternalViewHelper extends AbstractTagBasedViewHelper $this->registerTagAttribute('target', 'string', 'Specifies where to open the linked document'); } - /** - * @return string Rendered link - */ - public function render() + public function render(): string { $uri = $this->arguments['uri']; $defaultScheme = $this->arguments['defaultScheme']; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Link/TypolinkViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Link/TypolinkViewHelper.php index f021b9de2b076063624dcd4009cca93b662d3e90..d7f47b4e5486f6ad6156a65e644436406a5c1a53 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Link/TypolinkViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Link/TypolinkViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,7 +22,6 @@ use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\Service\TypoLinkCodecService; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Exception; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** @@ -96,18 +97,13 @@ final class TypolinkViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize ViewHelper arguments - * - * @throws Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('parameter', 'string', 'stdWrap.typolink style parameter string', true); $this->registerArgument('target', 'string', 'Define where to display the linked URL', false, ''); $this->registerArgument('class', 'string', 'Define classes for the link element', false, ''); $this->registerArgument('title', 'string', 'Define the title for the link element', false, ''); - $this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false, null); + $this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false); $this->registerArgument('additionalParams', 'string', 'Additional query parameters to be attached to the resulting URL', false, ''); $this->registerArgument('additionalAttributes', 'array', 'Additional tag attributes to be added directly to the resulting HTML tag', false, []); $this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URL', false, false); @@ -118,16 +114,10 @@ final class TypolinkViewHelper extends AbstractViewHelper } /** - * Render - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return mixed|string * @throws \InvalidArgumentException * @throws \UnexpectedValueException */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $parameter = $arguments['parameter'] ?? ''; $partsAs = $arguments['parts-as'] ?? 'typoLinkParts'; @@ -135,7 +125,7 @@ final class TypolinkViewHelper extends AbstractViewHelper $typoLinkCodec = GeneralUtility::makeInstance(TypoLinkCodecService::class); $typoLinkConfiguration = $typoLinkCodec->decode($parameter); // Merge the $parameter with other arguments - $mergedTypoLinkConfiguration = static::mergeTypoLinkConfiguration($typoLinkConfiguration, $arguments); + $mergedTypoLinkConfiguration = self::mergeTypoLinkConfiguration($typoLinkConfiguration, $arguments); $typoLinkParameter = $typoLinkCodec->encode($mergedTypoLinkConfiguration); // expose internal typoLink configuration to Fluid child context @@ -147,7 +137,7 @@ final class TypolinkViewHelper extends AbstractViewHelper $variableProvider->remove($partsAs); if ($parameter) { - $content = static::invokeContentObjectRenderer($arguments, $typoLinkParameter, $content); + $content = self::invokeContentObjectRenderer($arguments, $typoLinkParameter, $content); } return $content; } @@ -157,7 +147,7 @@ final class TypolinkViewHelper extends AbstractViewHelper $addQueryString = $arguments['addQueryString'] ?? false; $addQueryStringExclude = $arguments['addQueryStringExclude'] ?? ''; $absolute = $arguments['absolute'] ?? false; - $aTagParams = static::serializeTagParameters($arguments); + $aTagParams = self::serializeTagParameters($arguments); $instructions = [ 'parameter' => $typoLinkParameter, @@ -195,10 +185,6 @@ final class TypolinkViewHelper extends AbstractViewHelper /** * Merges view helper arguments with typolink parts. - * - * @param array $typoLinkConfiguration - * @param array $arguments - * @return array */ protected static function mergeTypoLinkConfiguration(array $typoLinkConfiguration, array $arguments): array { diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php index ba266003c96713e12edb3c73de70e218af4ebd59..59b8223983411fabe2ba24fa6aacfc41f7f36073 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/MediaViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -73,10 +75,7 @@ final class MediaViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'img'; - /** - * Initialize arguments. - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerUniversalTagAttributes(); @@ -92,12 +91,12 @@ final class MediaViewHelper extends AbstractTagBasedViewHelper } /** - * Render a given media file + * Render a given media file. * - * @return string Rendered tag * @throws \UnexpectedValueException + * @throws Exception */ - public function render() + public function render(): string { $file = $this->arguments['file']; $additionalConfig = (array)$this->arguments['additionalConfig']; @@ -115,7 +114,11 @@ final class MediaViewHelper extends AbstractTagBasedViewHelper } if ((string)$this->arguments['fileExtension'] && !GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], (string)$this->arguments['fileExtension'])) { - throw new Exception('The extension ' . $this->arguments['fileExtension'] . ' is not specified in $GLOBALS[\'TYPO3_CONF_VARS\'][\'GFX\'][\'imagefile_ext\'] as a valid image file extension and can not be processed.', 1619030957); + throw new Exception( + 'The extension ' . $this->arguments['fileExtension'] . ' is not specified in $GLOBALS[\'TYPO3_CONF_VARS\'][\'GFX\'][\'imagefile_ext\']' + . ' as a valid image file extension and can not be processed.', + 1619030957 + ); } $fileRenderer = GeneralUtility::makeInstance(RendererRegistry::class)->getRenderer($file); @@ -137,7 +140,7 @@ final class MediaViewHelper extends AbstractTagBasedViewHelper * @param string|null $fileExtension * @return string Rendered img tag */ - protected function renderImage(FileInterface $image, $width, $height, ?string $fileExtension) + protected function renderImage(FileInterface $image, $width, $height, ?string $fileExtension): string { $cropVariant = $this->arguments['cropVariant'] ?: 'default'; $cropString = $image instanceof FileReference ? $image->getProperty('crop') : ''; @@ -185,12 +188,7 @@ final class MediaViewHelper extends AbstractTagBasedViewHelper return $this->tag->render(); } - /** - * Return an instance of ImageService - * - * @return ImageService - */ - protected function getImageService() + protected function getImageService(): ImageService { return GeneralUtility::makeInstance(ImageService::class); } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php index fd3a961a126f5cf692299f8de07f4171a73d2aa4..f26258945dd5d777456b58cdca6cc58665f18220 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/RenderViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -17,7 +19,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers; final class RenderViewHelper extends \TYPO3Fluid\Fluid\ViewHelpers\RenderViewHelper { - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('debug', 'boolean', 'If true, the admin panel shows debug information if activated,', false, true); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Sanitize/HtmlViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Sanitize/HtmlViewHelper.php index 91b8314f01b1d738f6094257c6dbe48b64627ea2..a13b4f5c5c4c47dbf239483ef8f157888a2a0c56 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Sanitize/HtmlViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Sanitize/HtmlViewHelper.php @@ -23,7 +23,6 @@ use TYPO3\HtmlSanitizer\Builder\BuilderInterface; use TYPO3\HtmlSanitizer\Sanitizer; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Exception; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** @@ -69,32 +68,22 @@ final class HtmlViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * @throws Exception - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument( - 'build', - 'string', - 'preset name or class-like name of sanitization builder', - false, - 'default' - ); + $this->registerArgument('build', 'string', 'preset name or class-like name of sanitization builder', false, 'default'); } /** * @param array{build: string|class-string} $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext - * - * @return string the parsed string. + * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $value = $renderChildrenClosure(); - $build = $arguments['build'] ?? 'default'; - return static::createSanitizer($build)->sanitize((string)$value); + $build = $arguments['build']; + return self::createSanitizer($build)->sanitize((string)$value); } protected static function createSanitizer(string $build): Sanitizer diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfAuthenticatedViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfAuthenticatedViewHelper.php index 6ad365a662aba0938d5ffd9306630b609f904663..1e40347f32c1afc00df8606c418aa4517f166bef 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfAuthenticatedViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfAuthenticatedViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -56,13 +58,7 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractConditionViewHelper; */ final class IfAuthenticatedViewHelper extends AbstractConditionViewHelper { - /** - * This method decides if the condition is TRUE or FALSE. It can be overridden in extending viewhelpers to adjust functionality. - * - * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexibility in overriding this method. - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { return GeneralUtility::makeInstance(Context::class)->getPropertyFromAspect('frontend.user', 'id', 0) > 0; } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php index 5e5c43cddaf33065dd0e985fff5fa6b51f8b6495..b0cdda78febd4168c408db445b5c0d1c4db144a7 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Security/IfHasRoleViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -76,20 +78,13 @@ final class IfHasRoleViewHelper extends AbstractConditionViewHelper * Renders <f:then> child if the current logged in FE user belongs to the specified role (aka usergroup) * otherwise renders <f:else> child. */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); - $this->registerArgument('role', 'string', 'The usergroup (either the usergroup uid or its title).'); } - /** - * This method decides if the condition is TRUE or FALSE. It can be overridden in extending viewhelpers to adjust functionality. - * - * @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexibility in overriding this method. - * @return bool - */ - protected static function evaluateCondition($arguments = null) + protected static function evaluateCondition($arguments = null): bool { $role = $arguments['role']; /** @var UserAspect $userAspect */ diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php index beecc0896a3e32627621b979bbf184e5583abff5..b66288e91bd045b810618c9fd0f348796ddeac1e 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php @@ -21,7 +21,6 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Html\HtmlWorker; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; -use TYPO3Fluid\Fluid\Core\ViewHelper\Exception as ViewHelperException; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** @@ -72,35 +71,19 @@ final class HtmlViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * @throws ViewHelperException - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument( - 'selector', - 'string', - 'comma separated list of node attributes to be considered', - false, - 'a.href' - ); - $this->registerArgument( - 'onFailure', - 'string', - 'behavior on failure, either `removeTag`, `removeAttr`, `removeEnclosure` or `null`', - false, - 'removeEnclosure' - ); + $this->registerArgument('selector', 'string', 'comma separated list of node attributes to be considered', false, 'a.href'); + $this->registerArgument('onFailure', 'string', 'behavior on failure, either `removeTag`, `removeAttr`, `removeEnclosure` or `null`', false, 'removeEnclosure'); } /** * @param array{selector: string} $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext - * * @return string transformed markup */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $content = $renderChildrenClosure(); $worker = GeneralUtility::makeInstance(HtmlWorker::class); diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php index 56cf2d2fc965d5951cb4f290d185111ba89d4f53..f02ade89d8e912503b4c9fd06c87ece670226c4c 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ExternalViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -48,29 +50,16 @@ final class ExternalViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - * - * @throws \TYPO3Fluid\Fluid\Core\ViewHelper\Exception - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('uri', 'string', 'target URI', true); $this->registerArgument('defaultScheme', 'string', 'scheme the href attribute will be prefixed with if specified $uri does not contain a scheme already', false, 'https'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string Rendered URI - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $uri = $arguments['uri']; $defaultScheme = $arguments['defaultScheme']; - $scheme = parse_url($uri, PHP_URL_SCHEME); if ($scheme === null && $defaultScheme !== '') { $uri = $defaultScheme . '://' . $uri; diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php index 9c3ad975b1b465fd9817ed97a51c9b89049d7df0..253f8dc684e21f6216b13670ef82fc59df9b9cb5 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/ImageViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -86,10 +88,7 @@ final class ImageViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('src', 'string', 'src', false, ''); $this->registerArgument('treatIdAsReference', 'bool', 'given src argument is a sys_file_reference record', false, false); @@ -110,13 +109,9 @@ final class ImageViewHelper extends AbstractViewHelper /** * Resizes the image (if required) and returns its path. If the image was not resized, the path will be equal to $src * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string * @throws Exception */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $src = (string)$arguments['src']; $image = $arguments['image']; @@ -173,12 +168,7 @@ final class ImageViewHelper extends AbstractViewHelper } } - /** - * Return an instance of ImageService using object manager - * - * @return ImageService - */ - protected static function getImageService() + protected static function getImageService(): ImageService { return GeneralUtility::makeInstance(ImageService::class); } diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php index f682348a055873540c2e369f685e4015c8423a5d..2ef970e974d12d1ae0e45c0e46fd755a6c074a5f 100644 --- a/typo3/sysext/fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php +++ b/typo3/sysext/fluid/Classes/ViewHelpers/Uri/TypolinkViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -60,37 +62,28 @@ final class TypolinkViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('parameter', 'string', 'stdWrap.typolink style parameter string', true); $this->registerArgument('additionalParams', 'string', 'stdWrap.typolink additionalParams', false, ''); - $this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false, null); + $this->registerArgument('language', 'string', 'link to a specific language - defaults to the current language, use a language ID or "current" to enforce a specific language', false); $this->registerArgument('addQueryString', 'bool', 'If set, the current query parameters will be kept in the URL', false, false); $this->registerArgument('addQueryStringExclude', 'string', 'Define parameters to be excluded from the query string (only active if addQueryString is set)', false, ''); $this->registerArgument('absolute', 'bool', 'Ensure the resulting URL is an absolute URL', false, false); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $parameter = $arguments['parameter']; $typoLinkCodec = GeneralUtility::makeInstance(TypoLinkCodecService::class); $typoLinkConfiguration = $typoLinkCodec->decode($parameter); - $mergedTypoLinkConfiguration = static::mergeTypoLinkConfiguration($typoLinkConfiguration, $arguments); + $mergedTypoLinkConfiguration = self::mergeTypoLinkConfiguration($typoLinkConfiguration, $arguments); $typoLinkParameter = $typoLinkCodec->encode($mergedTypoLinkConfiguration); $content = ''; if ($parameter) { - $content = static::invokeContentObjectRenderer($arguments, $typoLinkParameter); + $content = self::invokeContentObjectRenderer($arguments, $typoLinkParameter); } return $content; } @@ -121,10 +114,6 @@ final class TypolinkViewHelper extends AbstractViewHelper /** * Merges view helper arguments with typolink parts. - * - * @param array $typoLinkConfiguration - * @param array $arguments - * @return array */ protected static function mergeTypoLinkConfiguration(array $typoLinkConfiguration, array $arguments): array { diff --git a/typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Link/ClickEnlargeViewHelper.php b/typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Link/ClickEnlargeViewHelper.php index 0424077021a7b6280dfb279b995c477637afe407..384ab8dcd24c9a60a1ce724fbdda7a26ff8e530a 100644 --- a/typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Link/ClickEnlargeViewHelper.php +++ b/typo3/sysext/fluid_styled_content/Classes/ViewHelpers/Link/ClickEnlargeViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -47,10 +49,7 @@ final class ClickEnlargeViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize ViewHelper arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('image', FileInterface::class, 'The original image file', true); $this->registerArgument( @@ -61,18 +60,11 @@ final class ClickEnlargeViewHelper extends AbstractViewHelper ); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { + /** @var FileInterface $image */ $image = $arguments['image']; - if ($image instanceof FileInterface) { - self::getContentObjectRenderer()->setCurrentFile($image); - } + self::getContentObjectRenderer()->setCurrentFile($image); $objDataBackup = null; if ($renderingContext->getVariableProvider()->exists('data')) { @@ -83,24 +75,18 @@ final class ClickEnlargeViewHelper extends AbstractViewHelper $content = $renderChildrenClosure(); $configuration['enable'] = true; - $result = self::getContentObjectRenderer()->imageLinkWrap($content, $image, $configuration); + $result = self::getContentObjectRenderer()->imageLinkWrap((string)$content, $image, $configuration); if ($objDataBackup) { self::getContentObjectRenderer()->data = $objDataBackup; } return $result; } - /** - * @return ContentObjectRenderer - */ - protected static function getContentObjectRenderer() + protected static function getContentObjectRenderer(): ContentObjectRenderer { return $GLOBALS['TSFE']->cObj; } - /** - * @return TypoScriptService - */ protected static function getTypoScriptService(): TypoScriptService { return GeneralUtility::makeInstance(TypoScriptService::class); diff --git a/typo3/sysext/form/Classes/ViewHelpers/Be/MaximumFileSizeViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/Be/MaximumFileSizeViewHelper.php index 80466e965375cfad9ae2db1f7fd4b1c138c7b535..e9354ed8a51a79457d6c555b2a6574bb96ea95d7 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/Be/MaximumFileSizeViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/Be/MaximumFileSizeViewHelper.php @@ -32,14 +32,7 @@ final class MaximumFileSizeViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - * @internal - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $maxUploadFileSize = GeneralUtility::getMaxUploadFileSize(); // format according to PHP formatting rules (K = kilobytes instead of kibibytes) diff --git a/typo3/sysext/form/Classes/ViewHelpers/Be/RenderContentElementPreviewViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/Be/RenderContentElementPreviewViewHelper.php index ded11e93d7c0569686a1456e0aea9c1a53bfd606..532af6dbff6177068b4c2e8fd422c069f0becd57 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/Be/RenderContentElementPreviewViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/Be/RenderContentElementPreviewViewHelper.php @@ -45,24 +45,12 @@ final class RenderContentElementPreviewViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('contentElementUid', 'int', 'The uid of a content element'); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - * @internal - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $content = ''; $contentElementUid = $arguments['contentElementUid']; diff --git a/typo3/sysext/form/Classes/ViewHelpers/Form/DatePickerViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/Form/DatePickerViewHelper.php index 5abc4a5c13c0177e8870f3860774e8574e40e1ae..f7e7f659586e3a06fc43d200348522c0c4c0b528 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/Form/DatePickerViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/Form/DatePickerViewHelper.php @@ -38,21 +38,13 @@ use TYPO3\CMS\Form\ViewHelpers\RenderRenderableViewHelper; */ final class DatePickerViewHelper extends AbstractFormFieldViewHelper { - /** * @var string */ protected $tagName = 'input'; - /** - * @var \TYPO3\CMS\Extbase\Property\PropertyMapper - */ - protected $propertyMapper; + protected PropertyMapper $propertyMapper; - /** - * @param \TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper - * @internal - */ public function injectPropertyMapper(PropertyMapper $propertyMapper) { $this->propertyMapper = $propertyMapper; @@ -61,7 +53,7 @@ final class DatePickerViewHelper extends AbstractFormFieldViewHelper /** * Initialize the arguments. */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute('size', 'int', 'The size of the input field'); @@ -78,10 +70,8 @@ final class DatePickerViewHelper extends AbstractFormFieldViewHelper /** * Renders the text field, hidden field and required javascript - * - * @return string */ - public function render() + public function render(): string { $enableDatePicker = $this->arguments['enableDatePicker']; $dateFormat = $this->arguments['dateFormat']; @@ -128,17 +118,13 @@ final class DatePickerViewHelper extends AbstractFormFieldViewHelper $this->tag->addAttribute('id', $id); $this->setErrorClassAttribute(); - $content = ''; - $content .= $this->tag->render(); + $content = $this->tag->render(); $content .= '<input type="hidden" name="' . htmlspecialchars($name) . '[dateFormat]" value="' . htmlspecialchars($dateFormat) . '" />'; return $content; } - /** - * @return \DateTime|null - */ - protected function getSelectedDate() + protected function getSelectedDate(): ?\DateTime { /** @var FormRuntime $formRuntime */ $formRuntime = $this->renderingContext @@ -163,10 +149,6 @@ final class DatePickerViewHelper extends AbstractFormFieldViewHelper return null; } - /** - * @param string $dateFormat - * @return string - */ protected function convertDateFormatToDatePickerFormat(string $dateFormat): string { $replacements = [ diff --git a/typo3/sysext/form/Classes/ViewHelpers/Form/TimePickerViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/Form/TimePickerViewHelper.php index 0e1a571518fed9cbbc30ecdf9264de7960b23947..40a8502cd43c8e9f3849f5a627646b6467bf106e 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/Form/TimePickerViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/Form/TimePickerViewHelper.php @@ -33,32 +33,19 @@ use TYPO3\CMS\Form\ViewHelpers\RenderRenderableViewHelper; */ final class TimePickerViewHelper extends AbstractFormFieldViewHelper { - /** * @var string */ protected $tagName = 'select'; - /** - * @var \TYPO3\CMS\Extbase\Property\PropertyMapper - */ - protected $propertyMapper; + protected PropertyMapper $propertyMapper; - /** - * @param \TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper - * @internal - */ public function injectPropertyMapper(PropertyMapper $propertyMapper) { $this->propertyMapper = $propertyMapper; } - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerTagAttribute('size', 'int', 'The size of the select field'); @@ -71,11 +58,9 @@ final class TimePickerViewHelper extends AbstractFormFieldViewHelper } /** - * Renders the select fields for hour & minute - * - * @return string + * Renders the select fields for hour & minute. */ - public function render() + public function render(): string { $name = $this->getName(); $this->registerFieldNameForFormTokenGeneration($name); @@ -85,7 +70,6 @@ final class TimePickerViewHelper extends AbstractFormFieldViewHelper $this->setErrorClassAttribute(); $content = ''; - if ($this->arguments['timeType'] === 'hour') { $content .= $this->buildHourSelector($date); } else { @@ -95,10 +79,7 @@ final class TimePickerViewHelper extends AbstractFormFieldViewHelper return $content; } - /** - * @return \DateTime|null - */ - protected function getSelectedDate() + protected function getSelectedDate(): ?\DateTime { /** @var FormRuntime $formRuntime */ $formRuntime = $this->renderingContext @@ -123,10 +104,6 @@ final class TimePickerViewHelper extends AbstractFormFieldViewHelper return null; } - /** - * @param \DateTime $date - * @return string - */ protected function buildHourSelector(\DateTime $date = null): string { $value = $date !== null ? $date->format('H') : null; @@ -142,10 +119,6 @@ final class TimePickerViewHelper extends AbstractFormFieldViewHelper return $hourSelector->render(); } - /** - * @param \DateTime $date - * @return string - */ protected function buildMinuteSelector(\DateTime $date = null): string { $value = $date !== null ? $date->format('i') : null; diff --git a/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php index ac0b2e39374ea2d1d7eeaa5e15156b2a6c3e6ab4..2185a060d742a49e32a531fb394c877f9093bb35 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/Form/UploadedResourceViewHelper.php @@ -37,40 +37,20 @@ final class UploadedResourceViewHelper extends AbstractFormFieldViewHelper */ protected $tagName = 'input'; - /** - * @var HashService - */ - protected $hashService; + protected HashService $hashService; + protected PropertyMapper $propertyMapper; - /** - * @var \TYPO3\CMS\Extbase\Property\PropertyMapper - */ - protected $propertyMapper; - - /** - * @param HashService $hashService - * @internal - */ public function injectHashService(HashService $hashService) { $this->hashService = $hashService; } - /** - * @param \TYPO3\CMS\Extbase\Property\PropertyMapper $propertyMapper - * @internal - */ public function injectPropertyMapper(PropertyMapper $propertyMapper) { $this->propertyMapper = $propertyMapper; } - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { parent::initializeArguments(); $this->registerArgument('as', 'string', ''); @@ -81,10 +61,7 @@ final class UploadedResourceViewHelper extends AbstractFormFieldViewHelper $this->registerUniversalTagAttributes(); } - /** - * @return string - */ - public function render() + public function render(): string { $output = ''; @@ -135,10 +112,8 @@ final class UploadedResourceViewHelper extends AbstractFormFieldViewHelper /** * Return a previously uploaded resource. * Return NULL if errors occurred during property mapping for this property. - * - * @return FileReference|null */ - protected function getUploadedResource() + protected function getUploadedResource(): ?FileReference { if ($this->getMappingResultsForProperty()->hasErrors()) { return null; diff --git a/typo3/sysext/form/Classes/ViewHelpers/FormViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/FormViewHelper.php index 79951adbcad058824a836a8814b45a0da7f7958e..46e1f612805ad9e76d651f1c71c68d100b13eff0 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/FormViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/FormViewHelper.php @@ -33,14 +33,13 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder; */ final class FormViewHelper extends FluidFormViewHelper { - /** * Renders hidden form fields for referrer information about * the current request. * * @return string Hidden fields with referrer information */ - protected function renderHiddenReferrerFields() + protected function renderHiddenReferrerFields(): string { $formRuntime = $this->getFormRuntime(); $prefix = $this->prefixFieldName($this->getFormObjectName()); @@ -62,11 +61,6 @@ final class FormViewHelper extends FluidFormViewHelper return $markup; } - /** - * @param string $name - * @param string $value - * @return string - */ protected function createHiddenInputElement(string $name, string $value): string { $tagBuilder = GeneralUtility::makeInstance(TagBuilder::class, 'input'); @@ -79,10 +73,8 @@ final class FormViewHelper extends FluidFormViewHelper /** * We do NOT return NULL as in this case, the Form ViewHelpers do not enter $objectAccessorMode. * However, we return the form identifier. - * - * @return string */ - protected function getFormObjectName() + protected function getFormObjectName(): string { return $this->getFormRuntime()->getFormDefinition()->getIdentifier(); } diff --git a/typo3/sysext/form/Classes/ViewHelpers/GridColumnClassAutoConfigurationViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/GridColumnClassAutoConfigurationViewHelper.php index 7d7431dfbd310016f5fef1f2caedbccc49442887..e3cd2bb7ba278b2372fb816ad4b0b44690429892 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/GridColumnClassAutoConfigurationViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/GridColumnClassAutoConfigurationViewHelper.php @@ -34,27 +34,13 @@ final class GridColumnClassAutoConfigurationViewHelper extends AbstractViewHelpe */ protected $escapeOutput = false; - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('element', RootRenderableInterface::class, 'A RootRenderableInterface instance', true); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic( - array $arguments, - \Closure $renderChildrenClosure, - RenderingContextInterface $renderingContext - ) { + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string + { $formElement = $arguments['element']; $gridRowElement = $formElement->getParentRenderable(); diff --git a/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php index 92729aae0af1a8ff97742a9c9c171033fbeb8b9f..e58fabfbd01498781b497fce2f027b03556b36db 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/RenderAllFormValuesViewHelper.php @@ -41,12 +41,7 @@ final class RenderAllFormValuesViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('renderable', RootRenderableInterface::class, 'A RootRenderableInterface instance', true); $this->registerArgument('as', 'string', 'The name within the template', false, 'formValue'); @@ -54,13 +49,8 @@ final class RenderAllFormValuesViewHelper extends AbstractViewHelper /** * Return array element by key. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string the rendered form values */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $renderable = $arguments['renderable']; diff --git a/typo3/sysext/form/Classes/ViewHelpers/RenderFormValueViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/RenderFormValueViewHelper.php index 6ea03adad6030f81d0cc998e6b7bdde42d15c204..ab72270801b513f113a8f1122f12cd5301f754cd 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/RenderFormValueViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/RenderFormValueViewHelper.php @@ -44,12 +44,7 @@ final class RenderFormValueViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize the arguments - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('renderable', RenderableInterface::class, 'A renderable element', true); $this->registerArgument('as', 'string', 'The name within the template', false, 'formValue'); @@ -57,13 +52,8 @@ final class RenderFormValueViewHelper extends AbstractViewHelper /** * Return array element by key - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string the rendered form values */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $element = $arguments['renderable']; @@ -95,23 +85,22 @@ final class RenderFormValueViewHelper extends AbstractViewHelper $as = $arguments['as']; $renderingContext->getVariableProvider()->add($as, $data); - $output = $renderChildrenClosure(); + $output = (string)$renderChildrenClosure(); $renderingContext->getVariableProvider()->remove($as); return $output; } /** - * Converts the given value to a simple type (string or array) considering the underlying FormElement definition + * Converts the given value to a simple type (string or array) considering the underlying FormElement definition. * * @param FormElementInterface $element * @param mixed $value * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed - * @internal */ - public static function processElementValue( + protected static function processElementValue( FormElementInterface $element, $value, \Closure $renderChildrenClosure, @@ -119,7 +108,7 @@ final class RenderFormValueViewHelper extends AbstractViewHelper ) { $properties = $element->getProperties(); $options = $properties['options'] ?? null; - if ($options !== null && is_array($options)) { + if (is_array($options)) { $properties['options'] = TranslateElementPropertyViewHelper::renderStatic( ['element' => $element, 'property' => 'options'], $renderChildrenClosure, @@ -137,15 +126,11 @@ final class RenderFormValueViewHelper extends AbstractViewHelper } /** - * Replaces the given values (=keys) with the corresponding elements in $options - * @see mapValueToOption() + * Replaces the given values (=keys) with the corresponding elements in $options. * - * @param array $value - * @param array $options - * @return array - * @internal + * @see mapValueToOption() */ - public static function mapValuesToOptions(array $value, array $options): array + protected static function mapValuesToOptions(array $value, array $options): array { $result = []; foreach ($value as $key) { @@ -161,22 +146,20 @@ final class RenderFormValueViewHelper extends AbstractViewHelper * @param mixed $value * @param array $options * @return mixed - * @internal */ - public static function mapValueToOption($value, array $options) + protected static function mapValueToOption($value, array $options) { return $options[$value] ?? $value; } /** - * Converts the given $object to a string representation considering the $element FormElement definition + * Converts the given $object to a string representation considering the $element FormElement definition. * * @param FormElementInterface $element * @param object $object * @return string - * @internal */ - public static function processObject(FormElementInterface $element, $object): string + protected static function processObject(FormElementInterface $element, $object): string { if ($element instanceof StringableFormElementInterface) { return $element->valueToString($object); @@ -201,23 +184,16 @@ final class RenderFormValueViewHelper extends AbstractViewHelper return 'Object [' . get_class($object) . ']'; } - /** - * @param RenderableInterface $renderable - * @return bool - * @internal - */ - public static function isEnabled(RenderableInterface $renderable): bool + protected static function isEnabled(RenderableInterface $renderable): bool { if (!$renderable->isEnabled()) { return false; } - while ($renderable = $renderable->getParentRenderable()) { if ($renderable instanceof RenderableInterface && !$renderable->isEnabled()) { return false; } } - return true; } } diff --git a/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php index bf5a27f794ffaea59d6c932764d438878a274b46..a0e112f689b146bd227d4cd355f36380c1119796 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/RenderRenderableViewHelper.php @@ -46,26 +46,13 @@ final class RenderRenderableViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('renderable', RootRenderableInterface::class, 'A RenderableInterface instance', true); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - * @internal - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - /** @var FormRuntime $formRuntime */ $formRuntime = $renderingContext ->getViewHelperVariableContainer() diff --git a/typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php index 74e582396211e223daeb15f5b9c6659e5d516ba3..c1b6428d31939c156af6cb5d87094ba9e725ad34 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php @@ -54,26 +54,15 @@ final class RenderViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize the arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { - $this->registerArgument('persistenceIdentifier', 'string', 'The persistence identifier for the form.', false, null); + $this->registerArgument('persistenceIdentifier', 'string', 'The persistence identifier for the form.', false); $this->registerArgument('factoryClass', 'string', 'The fully qualified class name of the factory', false, ArrayFormFactory::class); - $this->registerArgument('prototypeName', 'string', 'Name of the prototype to use', false, null); + $this->registerArgument('prototypeName', 'string', 'Name of the prototype to use', false); $this->registerArgument('overrideConfiguration', 'array', 'factory specific configuration', false, []); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): ?string { $persistenceIdentifier = $arguments['persistenceIdentifier']; $factoryClass = $arguments['factoryClass']; diff --git a/typo3/sysext/form/Classes/ViewHelpers/TranslateElementErrorViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/TranslateElementErrorViewHelper.php index 1efbfd8b627200abf2e5864526bc00eb5c98b2f5..f78bb210aa45aeee778a8c03ee4fb43ae3ad8d9e 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/TranslateElementErrorViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/TranslateElementErrorViewHelper.php @@ -35,26 +35,13 @@ final class TranslateElementErrorViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('element', RootRenderableInterface::class, 'Form Element to translate', true); $this->registerArgument('error', Error::class, 'Error', true); } - /** - * Return array element by key. - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $element = $arguments['element']; $error = $arguments['error']; diff --git a/typo3/sysext/form/Classes/ViewHelpers/TranslateElementPropertyViewHelper.php b/typo3/sysext/form/Classes/ViewHelpers/TranslateElementPropertyViewHelper.php index 7f30f69f9f4d8ffc4f74b35e97f825da6e43022c..6bc08ca3112a250952cc5264f1203a497ac5a664 100644 --- a/typo3/sysext/form/Classes/ViewHelpers/TranslateElementPropertyViewHelper.php +++ b/typo3/sysext/form/Classes/ViewHelpers/TranslateElementPropertyViewHelper.php @@ -35,12 +35,7 @@ final class TranslateElementPropertyViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments. - * - * @internal - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('element', RootRenderableInterface::class, 'Form Element to translate', true); $this->registerArgument('property', 'mixed', 'Property to translate', false); @@ -57,7 +52,7 @@ final class TranslateElementPropertyViewHelper extends AbstractViewHelper */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { - static::assertArgumentTypes($arguments); + self::assertArgumentTypes($arguments); $element = $arguments['element']; @@ -84,9 +79,6 @@ final class TranslateElementPropertyViewHelper extends AbstractViewHelper return GeneralUtility::makeInstance(TranslationService::class)->translateFormElementValue($element, $propertyParts, $formRuntime); } - /** - * @param array $arguments - */ protected static function assertArgumentTypes(array $arguments) { foreach (['property', 'renderingOptionProperty'] as $argumentName) { diff --git a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/DateTimeViewHelper.php b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/DateTimeViewHelper.php index 04feb0e752c0aa42217b0467e945766c643248ad..29459ec80dae08fac40066623b26dfed348320a3 100644 --- a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/DateTimeViewHelper.php +++ b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/DateTimeViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -21,7 +23,6 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * DateTime viewhelper * @internal */ final class DateTimeViewHelper extends AbstractViewHelper @@ -37,16 +38,10 @@ final class DateTimeViewHelper extends AbstractViewHelper protected $escapeChildren = false; /** - * Render the given timestamp as date & time - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string + * Render the given timestamp as date & time. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - return BackendUtility::datetime($renderChildrenClosure()); + return BackendUtility::datetime((int)$renderChildrenClosure()); } } diff --git a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/FlagValueViewHelper.php b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/FlagValueViewHelper.php index 7234b7499dfee2b5ad4744bba0f5f6007390252c..730f3fd5645952b563a3b2e3a94268a5665ea1a4 100644 --- a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/FlagValueViewHelper.php +++ b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/FlagValueViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,31 +22,21 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * FlagValue viewhelper * @internal */ final class FlagValueViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Sets up the needed arguments for this ViewHelper. - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('flags', 'int', '', true); } /** * Render additional flag information - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $flags = (int)$arguments['flags']; diff --git a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/GroupListViewHelper.php b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/GroupListViewHelper.php index 3260d74f5568f3616b9e22c9fc9a40ab5597ec7f..b86d2e1a14ae8950e46e4be43bc3a4dfe4358702 100644 --- a/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/GroupListViewHelper.php +++ b/typo3/sysext/indexed_search/Classes/ViewHelpers/Format/GroupListViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,31 +22,21 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * Group list viewhelper * @internal */ final class GroupListViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('groups', 'array', '', false, []); } /** - * Render the given group information as string - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string + * Render the given group information as string. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $groups = $arguments['groups']; diff --git a/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingResultsViewHelper.php b/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingResultsViewHelper.php index 345cb16ea0ee1e9bbdbd4fc83efa6478624ffa96..834d35fffead872b7b861286d570f542a94b2ff7 100644 --- a/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingResultsViewHelper.php +++ b/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingResultsViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -21,7 +23,8 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * renders the header of the results page + * Renders the header of the results page. + * * @internal */ final class PageBrowsingResultsViewHelper extends AbstractViewHelper @@ -35,23 +38,14 @@ final class PageBrowsingResultsViewHelper extends AbstractViewHelper */ protected $escapeOutput = false; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('numberOfResults', 'int', '', true); $this->registerArgument('resultsPerPage', 'int', '', true); $this->registerArgument('currentPage', 'int', '', false, 1); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $numberOfResults = $arguments['numberOfResults']; $resultsPerPage = $arguments['resultsPerPage']; diff --git a/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingViewHelper.php b/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingViewHelper.php index 0f26598d5b67ed65773f8083a73339593ba4cb4b..e5825dcbabe64b55d0228ead20eb7445c50aff54 100644 --- a/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingViewHelper.php +++ b/typo3/sysext/indexed_search/Classes/ViewHelpers/PageBrowsingViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -21,10 +23,9 @@ use TYPO3\CMS\Extbase\Utility\LocalizationUtility; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper; /** - * Page browser for indexed search, and only useful here, as the - * regular pagebrowser - * so this is a cleaner "pi_browsebox" but not a real page browser - * functionality + * Page browser for indexed search, and only useful here, as the regular pagebrowser. + * This is a cleaner "pi_browsebox" but not a real page browser functionality. + * * @internal */ final class PageBrowsingViewHelper extends AbstractTagBasedViewHelper @@ -39,10 +40,7 @@ final class PageBrowsingViewHelper extends AbstractTagBasedViewHelper */ protected $tagName = 'ul'; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('maximumNumberOfResultPages', 'int', '', true); $this->registerArgument('numberOfResults', 'int', '', true); @@ -52,10 +50,7 @@ final class PageBrowsingViewHelper extends AbstractTagBasedViewHelper $this->registerUniversalTagAttributes(); } - /** - * @inheritDoc - */ - public function render() + public function render(): string { $maximumNumberOfResultPages = $this->arguments['maximumNumberOfResultPages']; $numberOfResults = $this->arguments['numberOfResults']; diff --git a/typo3/sysext/install/Classes/ViewHelpers/Format/NoSpaceViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/Format/NoSpaceViewHelper.php index f025d9a831caaefc900269ed7999453cb7da1117..9491430e0485cc60ae1007fcd032fbfffa69dccc 100644 --- a/typo3/sysext/install/Classes/ViewHelpers/Format/NoSpaceViewHelper.php +++ b/typo3/sysext/install/Classes/ViewHelpers/Format/NoSpaceViewHelper.php @@ -30,9 +30,6 @@ final class NoSpaceViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ public function initializeArguments(): void { parent::initializeArguments(); @@ -40,13 +37,7 @@ final class NoSpaceViewHelper extends AbstractViewHelper } /** - * Render a string with whitespaces stripped - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string + * Render a string with whitespaces stripped. */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { diff --git a/typo3/sysext/install/Classes/ViewHelpers/Format/PhpErrorCodeViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/Format/PhpErrorCodeViewHelper.php index a35a08103e6e1caf25bb09fc55163f39620619f8..b8b499260feb1c9c040c19bde2851149d7f0ed7a 100644 --- a/typo3/sysext/install/Classes/ViewHelpers/Format/PhpErrorCodeViewHelper.php +++ b/typo3/sysext/install/Classes/ViewHelpers/Format/PhpErrorCodeViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -28,10 +30,7 @@ final class PhpErrorCodeViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * @var array - */ - protected static $levelNames = [ + protected static array $levelNames = [ E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', @@ -49,24 +48,15 @@ final class PhpErrorCodeViewHelper extends AbstractViewHelper E_USER_DEPRECATED => 'E_USER_DEPRECATED', ]; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('phpErrorCode', 'int', '', true); } /** - * Render a readable string for PHP error code - * - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string + * Render a readable string for PHP error code. */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $phpErrorCode = (int)$arguments['phpErrorCode']; $levels = []; diff --git a/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php index 2940b9cd917cb73309b0432db1c9fd273895fac2..68609bd4bee1add5725b0c98c6a512cab0e0a519 100644 --- a/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php +++ b/typo3/sysext/install/Classes/ViewHelpers/PhpInfoViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -20,7 +22,8 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** - * Utility class for phpinfo() + * Utility ViewHelper for phpinfo() + * * @internal */ final class PhpInfoViewHelper extends AbstractViewHelper @@ -37,28 +40,15 @@ final class PhpInfoViewHelper extends AbstractViewHelper */ protected $escapeChildren = false; - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { - return self::removeAllHtmlOutsideBody( - self::changeHtmlToHtml5( - self::getPhpInfo() - ) - ); + return self::removeAllHtmlOutsideBody(self::changeHtmlToHtml5(self::getPhpInfo())); } /** - * Get information about PHP's configuration - * - * @return string HTML page with the configuration options + * Get information about PHP's configuration as HTML string */ - protected static function getPhpInfo() + protected static function getPhpInfo(): string { ob_start(); phpinfo(); @@ -66,31 +56,25 @@ final class PhpInfoViewHelper extends AbstractViewHelper } /** - * Remove all HTML outside the body tag from HTML string - * - * @param string $html Complete HTML markup for page - * @return string Content of the body tag + * Remove all HTML outside the body tag from HTML string. */ - protected static function removeAllHtmlOutsideBody($html) + protected static function removeAllHtmlOutsideBody(string $html): string { - // Delete anything outside of the body tag and the body tag itself + // Delete anything outside the body tag and the body tag itself $html = (string)preg_replace('/^.*?<body.*?>/is', '', $html); - $html = (string)preg_replace('/<\/body>.*?$/is', '', $html); - - return $html; + return (string)preg_replace('/<\/body>.*?$/is', '', $html); } /** - * Change HTML markup to HTML5 + * Change HTML markup to HTML5. * * @param string $html HTML markup to be cleaned * @return string */ - protected static function changeHtmlToHtml5($html) + protected static function changeHtmlToHtml5(string $html): string { // Delete obsolete attributes $html = (string)preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html); - // Replace font tag with span return str_replace(['<font', '</font>'], ['<span', '</span>'], $html); } diff --git a/typo3/sysext/install/Classes/ViewHelpers/Uri/ActionViewHelper.php b/typo3/sysext/install/Classes/ViewHelpers/Uri/ActionViewHelper.php index 32ed009ac664840fbae2001c82964b82d4c9bdad..79eb63a577d4454ba249641fe3eb39d0ece3802d 100644 --- a/typo3/sysext/install/Classes/ViewHelpers/Uri/ActionViewHelper.php +++ b/typo3/sysext/install/Classes/ViewHelpers/Uri/ActionViewHelper.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + /* * This file is part of the TYPO3 CMS project. * @@ -32,16 +34,14 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; * <output> * install.php?install[controller]=Maintenance&install[context]= * </output> + * * @internal */ final class ActionViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initialize arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('controller', 'string', 'Target controller.', false, 'maintenance'); $this->registerArgument('arguments', 'array', 'Arguments', false, []); @@ -49,13 +49,7 @@ final class ActionViewHelper extends AbstractViewHelper $this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []); } - /** - * @param array $arguments - * @param \Closure $renderChildrenClosure - * @param RenderingContextInterface $renderingContext - * @return string - */ - public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) + public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext): string { $section = $arguments['section']; $additionalParams = $arguments['additionalParams']; diff --git a/typo3/sysext/redirects/Classes/ViewHelpers/TargetPageIdViewHelper.php b/typo3/sysext/redirects/Classes/ViewHelpers/TargetPageIdViewHelper.php index 4687f36a14f01321a94d35b827ad313783809ee5..2f60f4f06dec97931a8a4a855b975705f3d0982d 100644 --- a/typo3/sysext/redirects/Classes/ViewHelpers/TargetPageIdViewHelper.php +++ b/typo3/sysext/redirects/Classes/ViewHelpers/TargetPageIdViewHelper.php @@ -28,16 +28,14 @@ use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; /** * The target of a redirect can contain a t3://page link. * This ViewHelper checks for such a case and returns the Page ID + * * @internal */ final class TargetPageIdViewHelper extends AbstractViewHelper { use CompileWithRenderStatic; - /** - * Initializes the arguments - */ - public function initializeArguments() + public function initializeArguments(): void { $this->registerArgument('target', 'string', 'The target of the redirect.', true); }