Deprecate namespace overloading within templates
Currently, it is possible to define a namespace globally and then "extend"/overload it in the template. This is confusing and unnecessary, since it could just be registered with a different namespace locally.
The following should not work and should be deprecated:
$renderingContext->getViewHelperResolver()->addNamespace('my', 'Vendor\Package\ViewHelpers');
{namespace my=Vendor\OtherPackage\ViewHelpers}
Instead, local namespaces should override global namespaces. This would mean that a TYPO3 setup that registers a global news: namespace and then installs the news extension would not accidentially (?) leak ViewHelpers into the extension's templates.
An intended consequence would be that this common use case would keep working (just re-defining the existing global namespace locally for clarity and code completion):
{namespace my=Vendor\Package\ViewHelpers}
To get to this point, we should trigger a deprecation in Fluid 4 if a local namespace is registered that intentionally or accidentally extends a global namespace. With Fluid 5, we would first check local namespaces and then fall back to global namespaces.
For local namespaces, we should apply the same rule: If a namespace is defined multiple times in a template, only the last occurrence would be considered. This should also trigger a deprecation in Fluid 4:
{namespace my=Vendor\Package\ViewHelpers}
{namespace my=Vendor\OtherPackage\ViewHelpers}
v4: combination of ViewHelpers in one namespace v5: only ViewHelpers of second namespace
To avoid more deprecations triggered by templates, we might also delay the deprecation to Fluid v5.