Commit 06b37b43 authored by Christian Kuhn's avatar Christian Kuhn Committed by Anja Leichsenring
Browse files

[TASK] Type hint ext:fluid RenderingContext

The ext:fluid RenderingContext extends standalone fluid
RenderingContextInterface by adding getRequest(). This
object is always carried around in TYPO3 fluid universe.

When calling getRequest() in ViewHelpers, IDE's and
static analyzers don't know about this inheritance.
Unfortunately, we can't change standalone fluid at the
moment since that would be breaking, and we can't
change VH's method signatures either since that would
violate contravariance.

For now, we add a series on @var hints within various
ViewHelpers to make phpstan and IDE's more happy.

Resolves: #98378
Releases: main
Change-Id: I2cd8fc5962b2b8af3ce3fefabbae4e41577bb141
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/75783


Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
parent 471d9178
......@@ -165,21 +165,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/View/BackendLayout/ContentFetcher.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/Link/EditRecordViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/Link/NewRecordViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/ModuleLinkViewHelper.php
-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FileInterface\\:\\:process\\(\\)\\.$#"
count: 1
......@@ -190,16 +175,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/ThumbnailViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/Uri/EditRecordViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/ViewHelpers/Uri/NewRecordViewHelper.php
-
message: "#^Constructor of class TYPO3\\\\CMS\\\\Backend\\\\Tests\\\\Unit\\\\Form\\\\Fixtures\\\\NodeFactory\\\\NodeElements\\\\BarElement has an unused parameter \\$data\\.$#"
count: 1
......@@ -2360,26 +2335,6 @@ parameters:
count: 1
path: ../../typo3/sysext/extensionmanager/Classes/Utility/InstallUtility.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/extensionmanager/Classes/ViewHelpers/ReloadSqlDataViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/extensionmanager/Classes/ViewHelpers/RemoveExtensionViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/extensionmanager/Classes/ViewHelpers/ToggleExtensionInstallationStateViewHelper.php
-
message: "#^Method PHPUnit\\\\Framework\\\\TestCase\\:\\:count\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
......@@ -2435,61 +2390,21 @@ parameters:
count: 1
path: ../../typo3/sysext/fluid/Classes/View/TemplatePaths.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 2
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuItemViewHelper.php
-
message: "#^Method TYPO3\\\\CMS\\\\Fluid\\\\ViewHelpers\\\\Be\\\\Menus\\\\ActionMenuViewHelper\\:\\:compile\\(\\) should return string but returns null\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Be/Menus/ActionMenuViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Be/PageRendererViewHelper.php
-
message: "#^Parameter \\#1 \\$namespace of method TYPO3\\\\CMS\\\\Core\\\\Page\\\\PageRenderer\\:\\:addInlineSettingArray\\(\\) expects string, null given\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Be/PageRendererViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/CObjectViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/FlashMessagesViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Form/AbstractFormFieldViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Form/ValidationResultsViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 4
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
-
message: "#^Call to function is_int\\(\\) with mixed will always evaluate to false\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Format/BytesViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Format/HtmlViewHelper.php
-
message: "#^Method TYPO3\\\\CMS\\\\Fluid\\\\ViewHelpers\\\\Format\\\\HtmlentitiesDecodeViewHelper\\:\\:renderStatic\\(\\) should return string but returns mixed\\.$#"
count: 1
......@@ -2500,21 +2415,6 @@ parameters:
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/ImageViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Link/ActionViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 2
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Link/EmailViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Link/PageViewHelper.php
-
message: "#^Parameter \\#2 \\$attributeValue of method TYPO3Fluid\\\\Fluid\\\\Core\\\\ViewHelper\\\\TagBuilder\\:\\:addAttribute\\(\\) expects array\\|string\\|Traversable\\|null, TYPO3\\\\CMS\\\\Core\\\\Imaging\\\\ImageManipulation\\\\Area given\\.$#"
count: 1
......@@ -2525,16 +2425,6 @@ parameters:
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Uri/ActionViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Uri/PageViewHelper.php
-
message: "#^Call to an undefined method Psr\\\\Container\\\\ContainerInterface\\:\\:set\\(\\)\\.$#"
count: 4
......@@ -2730,11 +2620,6 @@ parameters:
count: 1
path: ../../typo3/sysext/form/Classes/ViewHelpers/GridColumnClassAutoConfigurationViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/form/Classes/ViewHelpers/RenderViewHelper.php
-
message: "#^Parameter \\#1 \\$fileReference of method TYPO3\\\\CMS\\\\Core\\\\Localization\\\\LanguageStore\\:\\:flushData\\(\\) expects string, array\\<int, string\\> given\\.$#"
count: 37
......
......@@ -21,6 +21,7 @@ use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -85,7 +86,9 @@ final class EditRecordViewHelper extends AbstractTagBasedViewHelper
if ($this->arguments['uid'] < 1) {
throw new \InvalidArgumentException('Uid must be a positive integer, ' . $this->arguments['uid'] . ' given.', 1526127158);
}
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
if (empty($this->arguments['returnUrl'])
&& $request instanceof ServerRequestInterface
) {
......
......@@ -20,6 +20,7 @@ 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 TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -126,7 +127,10 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper
}
if (empty($this->arguments['returnUrl'])) {
$this->arguments['returnUrl'] = $this->renderingContext->getRequest()->getAttribute('normalizedParams')->getRequestUri();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
$this->arguments['returnUrl'] = $request->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -21,6 +21,7 @@ use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
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;
......@@ -65,6 +66,7 @@ final class ModuleLinkViewHelper extends AbstractViewHelper
if ($arguments['query'] !== null) {
ArrayUtility::mergeRecursiveWithOverrule($parameters, GeneralUtility::explodeUrl2Array($arguments['query']));
}
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
if (!empty($arguments['currentUrlParameterName'])
&& empty($arguments['arguments'][$arguments['currentUrlParameterName']])
......
......@@ -20,6 +20,7 @@ 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 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;
......@@ -69,7 +70,9 @@ final class EditRecordViewHelper extends AbstractViewHelper
throw new \InvalidArgumentException('Uid must be a positive integer, ' . $arguments['uid'] . ' given.', 1526128259);
}
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = $renderingContext->getRequest()->getAttribute('normalizedParams')->getRequestUri();
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
$arguments['returnUrl'] = $request->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -20,6 +20,7 @@ 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 TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
......@@ -97,7 +98,9 @@ final class NewRecordViewHelper extends AbstractTagBasedViewHelper
}
if (empty($arguments['returnUrl'])) {
$arguments['returnUrl'] = $renderingContext->getRequest()->getAttribute('normalizedParams')->getRequestUri();
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
$arguments['returnUrl'] = $request->getAttribute('normalizedParams')->getRequestUri();
}
$params = [
......
......@@ -22,9 +22,11 @@ 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\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Service\ExtensionService;
use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper;
/**
......@@ -74,7 +76,11 @@ final class DownloadExtensionViewHelper extends AbstractFormViewHelper
}
$pathSelector .= '</ul>';
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->setRequest($this->renderingContext->getRequest());
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$uriBuilder->setRequest($request);
$action = 'checkDependencies';
$uriBuilder->reset();
$uriBuilder->setFormat('json');
......
......@@ -23,7 +23,9 @@ 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\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -77,7 +79,11 @@ final class ReloadSqlDataViewHelper extends AbstractTagBasedViewHelper
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->setRequest($this->renderingContext->getRequest());
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$uriBuilder->setRequest($request);
$uriBuilder->reset();
$uri = $uriBuilder->uriFor(
'reloadExtensionData',
......
......@@ -22,8 +22,10 @@ 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\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extensionmanager\Domain\Model\Extension;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -59,7 +61,11 @@ final class RemoveExtensionViewHelper extends AbstractTagBasedViewHelper
return '<span class="btn btn-default disabled">' . $iconFactory->getIcon('empty-empty', Icon::SIZE_SMALL)->render() . '</span>';
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->setRequest($this->renderingContext->getRequest());
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$uriBuilder->setRequest($request);
$uriBuilder->reset();
$uriBuilder->setFormat('json');
$uri = $uriBuilder->uriFor(
......
......@@ -23,7 +23,9 @@ 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\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -63,7 +65,11 @@ final class ToggleExtensionInstallationStateViewHelper extends AbstractTagBasedV
}
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->setRequest($this->renderingContext->getRequest());
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$uriBuilder->setRequest($request);
$uri = $uriBuilder->reset()->uriFor(
'toggleExtensionInstallationState',
['extensionKey' => $extension['key']],
......
......@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -77,7 +78,9 @@ final class ActionMenuItemViewHelper extends AbstractTagBasedViewHelper
$arguments = $this->arguments['arguments'];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
// Throw if not an extbase request
throw new \RuntimeException(
......@@ -100,7 +103,10 @@ final class ActionMenuItemViewHelper extends AbstractTagBasedViewHelper
protected function evaluateSelectItemState(string $controller, string $action, array $arguments): void
{
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$flatRequestArguments = ArrayUtility::flattenPlain(
array_merge([
'controller' => $request->getControllerName(),
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
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;
......@@ -105,6 +106,7 @@ final class PageRendererViewHelper extends AbstractViewHelper
// Add inline language labels
if (is_array($addJsInlineLabels) && count($addJsInlineLabels) > 0) {
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
if ($request instanceof RequestInterface) {
// Extbase request resolves extension key and allows overriding labels using TypoScript configuration.
......
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\TimeTracker\TimeTracker;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
......@@ -124,6 +125,7 @@ final class CObjectViewHelper extends AbstractViewHelper
$typoscriptObjectPath = (string)$arguments['typoscriptObjectPath'];
$currentValueKey = $arguments['currentValueKey'];
$table = $arguments['table'];
/** @var RenderingContext $renderingContext */
$contentObjectRenderer = self::getContentObjectRenderer($renderingContext->getRequest());
$tsfeBackup = null;
if (!isset($GLOBALS['TSFE']) || !($GLOBALS['TSFE'] instanceof TypoScriptFrontendController)) {
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Messaging\FlashMessageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Service\ExtensionService;
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;
......@@ -134,6 +135,7 @@ final class FlashMessagesViewHelper extends AbstractViewHelper
$queueIdentifier = $arguments['queueIdentifier'];
if ($queueIdentifier === null) {
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
// Throw if not an extbase request
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Extbase\Error\Result;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper;
/**
......@@ -88,7 +89,16 @@ abstract class AbstractFormFieldViewHelper extends AbstractFormViewHelper
*/
protected function getRequest(): RequestInterface
{
return $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
throw new \RuntimeException(
'Form ViewHelpers are Extbase specific and need an Extbase Request to work',
1663617170
);
}
return $request;
}
/**
......
......@@ -18,6 +18,7 @@ declare(strict_types=1);
namespace TYPO3\CMS\Fluid\ViewHelpers\Form;
use TYPO3\CMS\Extbase\Mvc\ExtbaseRequestParameters;
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;
......@@ -96,6 +97,7 @@ final class ValidationResultsViewHelper extends AbstractViewHelper
$for = $arguments['for'];
$as = $arguments['as'];
/** @var RenderingContext $renderingContext */
/** @var ExtbaseRequestParameters $extbaseRequestParameters */
$extbaseRequestParameters = $renderingContext->getRequest()->getAttribute('extbase');
$validationResults = $extbaseRequestParameters->getOriginalRequestMappingResults();
......
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Extbase\Security\Cryptography\HashService;
use TYPO3\CMS\Extbase\Service\ExtensionService;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper;
use TYPO3\CMS\Fluid\ViewHelpers\Form\CheckboxViewHelper;
......@@ -135,7 +136,9 @@ class FormViewHelper extends AbstractFormViewHelper
public function render(): string
{
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
throw new \RuntimeException(
'ViewHelper f:form can be used only in extbase context and needs a request implementing extbase RequestInterface.',
......@@ -192,10 +195,14 @@ class FormViewHelper extends AbstractFormViewHelper
if ($this->hasArgument('actionUri')) {
$formActionUri = $this->arguments['actionUri'];
} else {
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder
->reset()
->setRequest($this->renderingContext->getRequest())
->setRequest($request)
->setTargetPageType($this->arguments['pageType'] ?? 0)
->setNoCache($this->arguments['noCache'] ?? false)
->setSection($this->arguments['section'] ?? '')
......@@ -252,8 +259,10 @@ class FormViewHelper extends AbstractFormViewHelper
*/
protected function renderHiddenReferrerFields(): string
{
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $this->renderingContext->getRequest();
$request = $renderingContext->getRequest();
$extensionName = $request->getControllerExtensionName();
$controllerName = $request->getControllerName();
$actionName = $request->getControllerActionName();
......@@ -387,7 +396,10 @@ class FormViewHelper extends AbstractFormViewHelper
*/
protected function getDefaultFieldNamePrefix(): string
{
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
/** @var RequestInterface $request */
$request = $renderingContext->getRequest();
// New Backend URLs doe not have a prefix anymore
if (!$this->configurationManager->isFeatureEnabled('enableNamespacedArgumentsForBackend')
&& $request instanceof ServerRequestInterface
......
......@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
......@@ -148,6 +149,7 @@ final class HtmlViewHelper extends AbstractViewHelper
$currentValueKey = $arguments['currentValueKey'];
$table = $arguments['table'];
/** @var RenderingContext $renderingContext */
$request = $renderingContext->getRequest();
$isBackendRequest = $request instanceof ServerRequestInterface
&& $request->getAttribute('applicationType')
......
......@@ -21,6 +21,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
/**
......@@ -73,7 +74,9 @@ final class ActionViewHelper extends AbstractTagBasedViewHelper
public function render(): string
{
$request = $this->renderingContext->getRequest();
/** @var RenderingContext $renderingContext */
$renderingContext = $this->renderingContext;
$request = $renderingContext->getRequest();
if (!$request instanceof RequestInterface) {
throw new \RuntimeException(
'ViewHelper f:link.action can be used only in extbase context and needs a request implementing extbase RequestInterface.',
......
......@@ -20,6 +20,7 @@ namespace TYPO3\CMS\Fluid\ViewHelpers\Link;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Http\ApplicationType;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Typolink\LinkFactory;
use TYPO3\CMS\Frontend\Typolink\UnableToLinkException;
......@@ -84,10 +85,10 @@ final class EmailViewHelper extends AbstractTagBasedViewHelper
$linkHref = 'mailto:' . $email;
$attributes = [];
$linkText = htmlspecialchars($email);
$request = $this->renderingContext->getRequest();