[TASK] Use render() as primary ViewHelper method #983
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Until now it was best practice to differentiate between object-based
ViewHelpers, using the object method
render()
as their primary rendermethod, and static ViewHelpers, using the static method
renderStatic()
.This distinction has been introduced to Fluid mainly for performance reasons:
With earlier PHP versions it was quite expensive performance-wise to create a
new ViewHelper object for each ViewHelper call. However, PHP's performance
characteristics for objects have changed quite a bit with newer versions,
which questions the usefulness of this performance optimization nowadays.
Our performance tests have shown that the performance gains are still existent
today if you compare
renderStatic()
torender()
ViewHelpers, especiallyif no further optimizations are applied to Fluid's core implementation.
However, the impact is quite small and almost not measurable in real-world
scenarios.
In contrast to that, we see meaningful opportunities for the further development
and optimization for Fluid if we streamline and simplify Fluid's APIs. It
improves the developer experience if there's only one correct way to
implement ViewHelpers and if all ViewHelpers use the same API. For Fluid
internally, this opens up new opportunities of optimization and refactoring,
which are currently not feasible to tackle.
Ultimately, we have taken the decision to deprecate
renderStatic()
with Fluid v4.ViewHelpers should use
render()
as their primary render method from now on.This patch deprecates both the trait
CompileWithRenderStatic
and the usageof
renderStatic()
without any trait applied to the ViewHelper (which is probablyonly an edge case). Instead, the
ViewHelperInvoker
is called both for uncachedand cached templates to initiate and perform each ViewHelper call.
We will backport the
@deprecated
annotation onCompileWithRenderStatic
toFluid v2.15 to let users know in advance of this change.
AbstractConditionViewHelper
will be adjusted to this change in a follow-up patch.There will probably also be further code optimization patches that are made possible
because of this decision, either still in Fluid v4 or later in Fluid v5, when
renderStatic()
will be removed completely.