From dd6201e8e5c0ff00b921aa9331ab64ad4f76bf98 Mon Sep 17 00:00:00 2001 From: Simon Praetorius Date: Sun, 25 Aug 2024 12:59:01 +0200 Subject: [PATCH] [TASK] Deprecate CompileWithRenderStatic and renderStatic() (#990) Both the trait `CompileWithRenderStatic` and ViewHelpers implementing `renderStatic()` without using one of the deprecated traits will be deprecated with Fluid v4 and will no longer work with v5. ViewHelpers should use `render()` as their primary rendering method. Related: #983 --- Documentation/Changelog/2.x.rst | 7 +++++++ src/Core/ViewHelper/AbstractViewHelper.php | 4 ++++ .../Traits/CompileWithContentArgumentAndRenderStatic.php | 5 +++-- src/Core/ViewHelper/Traits/CompileWithRenderStatic.php | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Documentation/Changelog/2.x.rst b/Documentation/Changelog/2.x.rst index 7293081de..07a41c818 100644 --- a/Documentation/Changelog/2.x.rst +++ b/Documentation/Changelog/2.x.rst @@ -9,9 +9,16 @@ Changelog 2.x 2.15 ---- +* Deprecation: Trait :php:`TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic` + has been marked as deprecated. It will log a deprecation level error message when called in + Fluid v4. It will be removed in Fluid v5. * Deprecation: Trait :php:`TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic` has been marked as deprecated. It will log a deprecation level error message when called in Fluid v4. It will be removed in Fluid v5. +* Deprecation: Static method :php:`renderStatic()` on ViewHelpers that don't use :php:`TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic` + or :php:`TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithContentArgumentAndRenderStatic` + have been marked as deprecated. They will log a deprecation level error message when called in + Fluid v4. `renderStatic()` will no longer be called in Fluid v5. * Deprecation: Variable names `true`, `false` and `null` will log a deprecation level error message because these identifiers will become a Fluid language feature with v4. diff --git a/src/Core/ViewHelper/AbstractViewHelper.php b/src/Core/ViewHelper/AbstractViewHelper.php index 3d21a8285..c63386cbb 100644 --- a/src/Core/ViewHelper/AbstractViewHelper.php +++ b/src/Core/ViewHelper/AbstractViewHelper.php @@ -537,6 +537,10 @@ public function compile($argumentsName, $closureName, &$initializationPhpCode, V * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * @return mixed + * @deprecated renderStatic() on ViewHelpers will still be called in v4, but will log a + * deprecation level error message. It will no longer be called in v5. + * This concrete fallback implementation in AbstractViewHelper will be removed + * with v4. */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { diff --git a/src/Core/ViewHelper/Traits/CompileWithContentArgumentAndRenderStatic.php b/src/Core/ViewHelper/Traits/CompileWithContentArgumentAndRenderStatic.php index 311a20667..587dc95a9 100644 --- a/src/Core/ViewHelper/Traits/CompileWithContentArgumentAndRenderStatic.php +++ b/src/Core/ViewHelper/Traits/CompileWithContentArgumentAndRenderStatic.php @@ -20,8 +20,9 @@ * argument is specified and not empty. * * @deprecated Will be removed in v5. No longer necessary since getContentArgumentName() has been - * integrated into AbstractViewHelper with v2.15. Name has to be specified explicitly by overriding the - * method, implicit definition (= first optional argument) is no longer supported. + * integrated into AbstractViewHelper with v2.15. Name has to be specified explicitly + * by overriding the method, implicit definition (= first optional argument) is no + * longer supported. */ trait CompileWithContentArgumentAndRenderStatic { diff --git a/src/Core/ViewHelper/Traits/CompileWithRenderStatic.php b/src/Core/ViewHelper/Traits/CompileWithRenderStatic.php index bf86e4493..2efa5335e 100644 --- a/src/Core/ViewHelper/Traits/CompileWithRenderStatic.php +++ b/src/Core/ViewHelper/Traits/CompileWithRenderStatic.php @@ -13,6 +13,9 @@ * Provides default methods for rendering and compiling * any ViewHelper that conforms to the `renderStatic` * method pattern. + * + * @deprecated Will be removed in v5. The non-static render() method + * should be used instead */ trait CompileWithRenderStatic {